-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to WasmVM v0.15.1 #548
Conversation
Codecov Report
@@ Coverage Diff @@
## master #548 +/- ##
==========================================
+ Coverage 59.26% 59.61% +0.35%
==========================================
Files 44 45 +1
Lines 5165 5220 +55
==========================================
+ Hits 3061 3112 +51
- Misses 1881 1884 +3
- Partials 223 224 +1
|
A patched wasmvm 0.15.1 is released that should solve the two blocker tickets as well as the missing pointer in GovMsg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff. Will merge.
Left some minor comments that may be worth addressing in the future
return sdk.Events{sdk.NewEvent(types.WasmModuleEventType, attrs...)} | ||
} | ||
|
||
// returns true when a wasm module event was emitted for this contract already |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice to avoid duplicates with reply, etc
func newCustomEvents(evts wasmvmtypes.Events, contractAddr sdk.AccAddress) sdk.Events { | ||
events := make(sdk.Events, 0, len(evts)) | ||
for _, e := range evts { | ||
if len(e.Type) <= eventTypeMinLength { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like silent failures/filters. I would prefer returning an error (even panic-ing in Go), Devs learn quick when things panic. They ignore errors for months if they are silently ignored
func (g WasmGasRegister) EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas { | ||
gas, remainingFreeTier := g.eventAttributeCosts(attrs, g.c.EventAttributeDataFreeTier) | ||
for _, e := range events { | ||
gas += g.c.CustomEventCost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we really need some overview docs on gas pricing (including from the sdk and wasmer) so devs understand this all
|
||
func EncodeGovMsg(sender sdk.AccAddress, msg *wasmvmtypes.GovMsg) ([]sdk.Msg, error) { | ||
var option govtypes.VoteOption | ||
switch msg.Vote.Vote { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would pull this switch out into a function. But if it is only used here, I guess no need
events := types.ParseEvents(attrs, contractAddr) | ||
ctx.EventManager().EmitEvents(events) | ||
return k.wasmVMResponseHandler.Handle(ctx, contractAddr, ibcPort, subMsg, msgs, data) | ||
if len(attrs) != 0 || !hasWasmModuleEvent(ctx, contractAddr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice check. If we don't add any info, and they already emitted some event in this tx (recursive calls, reply), then no need to emit one 👍
replyer: &mockReplyer{}, | ||
msgHandler: &wasmtesting.MockMessageHandler{ | ||
DispatchMsgFn: func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error) { | ||
return nil, [][]byte{{}}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nil vs empty is an odd test. What is being tested here anyway?
require.NoError(t, err) | ||
//coordinator.CommitBlock(chainA, chainB) | ||
err = coordinator.UpdateClient(chainA, chainB, clientA, ibcexported.Tendermint) | ||
err := coordinator.RelayAndAckPendingPackets(chainA, chainB, clientA, clientB) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did that just get 90% smaller? 😄
@@ -297,23 +297,6 @@ func NewWasmCoins(cosmosCoins sdk.Coins) (wasmCoins []wasmvmtypes.Coin) { | |||
return wasmCoins | |||
} | |||
|
|||
// ParseEvents converts wasm LogAttributes into an sdk.Events. Returns events and number of bytes for custom attributes | |||
func ParseEvents(wasmOutputAttrs []wasmvmtypes.EventAttribute, contractAddr sdk.AccAddress) sdk.Events { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I prefer your more complex functions now
) (*wasmvmtypes.IBCBasicResponse, uint64, error) | ||
|
||
// IBCPacketTimeout is available on IBC-enabled contracts and is called when an | ||
// outgoing packet (previously sent by this contract) will provably never be executed. | ||
// Usually handled like ack returning an error | ||
IBCPacketTimeout( | ||
codeID wasmvm.Checksum, | ||
checksum wasmvm.Checksum, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice typo to fix
Closes #532
replyOn
type now got a new "never" case for the fire and forget messagesreplyOn
is not an integer but supports the Stringer interface (i.e..String()
)vm.Execute
and friends. We messed up storing the value in thevm
instance, such that it needs to be passed to every call. Sorry for that! The deserialization cost is in gas per byte. It is a fraction, so you can use 20/1, 10/1, 1/1, 1/2, 1/30, ... in there.Attributes
should go into a mainwasm
event as before. All other events should be added with awasm-
prefix on the event type.go.mod
Blocker
CosmWasm/wasmvm#235CosmWasm/wasmvm#236Inconsistent
#552
#553
Improvements:
CosmWasm/wasmvm#239
CosmWasm/wasmvm#238