-
Notifications
You must be signed in to change notification settings - Fork 418
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 0.14.0 beta3 #487
Changes from 6 commits
2536242
39856bf
6189e17
84a6c4d
1bec925
42ca87d
1a355dc
9ec97b5
39eed79
7029368
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQ | |
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= | ||
github.com/CosmWasm/wasmvm v0.14.0-beta1 h1:ASqXB/2D8CEBmAI/uljRw6eEMbeKXPQtL/wZzKXZGGA= | ||
github.com/CosmWasm/wasmvm v0.14.0-beta1/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A= | ||
github.com/CosmWasm/wasmvm v0.14.0-beta2 h1:8bLLNaxj796qUwu6UuQDbqpMV9zPpxG3lNZZbswNdOo= | ||
github.com/CosmWasm/wasmvm v0.14.0-beta2/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. next |
||
github.com/CosmWasm/wasmvm v0.14.0-beta3 h1:HN1+HrC2kgO/V4voGdOWrN1sdUoTnSoLuSrBXbDVnbY= | ||
github.com/CosmWasm/wasmvm v0.14.0-beta3/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A= | ||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= | ||
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= | ||
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,9 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) { | |
reflectSend := ReflectHandleMsg{ | ||
ReflectSubCall: &reflectSubPayload{ | ||
Msgs: []wasmvmtypes.SubMsg{{ | ||
ID: 7, | ||
Msg: msg, | ||
ID: 7, | ||
Msg: msg, | ||
ReplyOn: wasmvmtypes.ReplyAlways, | ||
}}, | ||
}, | ||
} | ||
|
@@ -322,6 +323,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { | |
ID: tc.submsgID, | ||
Msg: msg, | ||
GasLimit: tc.gasLimit, | ||
ReplyOn: wasmvmtypes.ReplyAlways, | ||
}}, | ||
}, | ||
} | ||
|
@@ -421,8 +423,9 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { | |
reflectSend := ReflectHandleMsg{ | ||
ReflectSubCall: &reflectSubPayload{ | ||
Msgs: []wasmvmtypes.SubMsg{{ | ||
ID: 7, | ||
Msg: msg, | ||
ID: 7, | ||
Msg: msg, | ||
ReplyOn: wasmvmtypes.ReplyAlways, | ||
}}, | ||
}, | ||
} | ||
|
@@ -450,3 +453,132 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { | |
assert.Empty(t, sub.Data) | ||
require.Len(t, sub.Events, 0) | ||
} | ||
|
||
// Try a simple send, no gas limit to for a sanity check before trying table tests | ||
func TestDispatchSubMsgConditionalReplyOn(t *testing.T) { | ||
ctx, keepers := CreateTestInput(t, false, ReflectFeatures) | ||
accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper | ||
|
||
deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) | ||
contractStart := sdk.NewCoins(sdk.NewInt64Coin("denom", 40000)) | ||
|
||
creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit) | ||
_, _, fred := keyPubAddr() | ||
|
||
// upload code | ||
reflectCode, err := ioutil.ReadFile("./testdata/reflect.wasm") | ||
require.NoError(t, err) | ||
codeID, err := keepers.ContractKeeper.Create(ctx, creator, reflectCode, "", "", nil) | ||
require.NoError(t, err) | ||
|
||
// creator instantiates a contract and gives it tokens | ||
contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, codeID, creator, nil, []byte("{}"), "reflect contract 1", contractStart) | ||
require.NoError(t, err) | ||
|
||
goodSend := wasmvmtypes.CosmosMsg{ | ||
Bank: &wasmvmtypes.BankMsg{ | ||
Send: &wasmvmtypes.SendMsg{ | ||
ToAddress: fred.String(), | ||
Amount: []wasmvmtypes.Coin{{ | ||
Denom: "denom", | ||
Amount: "1000", | ||
}}, | ||
}, | ||
}, | ||
} | ||
failSend := wasmvmtypes.CosmosMsg{ | ||
Bank: &wasmvmtypes.BankMsg{ | ||
Send: &wasmvmtypes.SendMsg{ | ||
ToAddress: fred.String(), | ||
Amount: []wasmvmtypes.Coin{{ | ||
Denom: "no-such-token", | ||
Amount: "777777", | ||
}}, | ||
}, | ||
}, | ||
} | ||
|
||
cases := map[string]struct { | ||
ethanfrey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// true for wasmvmtypes.ReplySuccess, false for wasmvmtypes.ReplyError | ||
replyOnSuccess bool | ||
msg wasmvmtypes.CosmosMsg | ||
// true if the call should return an error (it wasn't handled) | ||
expectError bool | ||
// true if the reflect contract wrote the response (success or error) - it was captured | ||
writeResult bool | ||
}{ | ||
"all good, reply success": { | ||
replyOnSuccess: true, | ||
msg: goodSend, | ||
expectError: false, | ||
writeResult: true, | ||
}, | ||
"all good, reply error": { | ||
replyOnSuccess: false, | ||
msg: goodSend, | ||
expectError: false, | ||
writeResult: false, | ||
}, | ||
"bad msg, reply success": { | ||
replyOnSuccess: true, | ||
msg: failSend, | ||
expectError: true, | ||
writeResult: false, | ||
}, | ||
"bad msg, reply error": { | ||
replyOnSuccess: false, | ||
msg: failSend, | ||
expectError: false, | ||
writeResult: true, | ||
}, | ||
} | ||
|
||
var id uint64 = 0 | ||
for name, tc := range cases { | ||
id++ | ||
t.Run(name, func(t *testing.T) { | ||
subMsg := wasmvmtypes.SubMsg{ | ||
ID: id, | ||
Msg: tc.msg, | ||
ReplyOn: wasmvmtypes.ReplySuccess, | ||
} | ||
if !tc.replyOnSuccess { | ||
subMsg.ReplyOn = wasmvmtypes.ReplyError | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice to have: you can avoid the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to, but it requires me to use a private type in the struct... hmmmm I made the type private to keep it a closed enum (there are only 3 public instances of it), rather than allow anyone to create new |
||
} | ||
|
||
reflectSend := ReflectHandleMsg{ | ||
ReflectSubCall: &reflectSubPayload{ | ||
Msgs: []wasmvmtypes.SubMsg{subMsg}, | ||
}, | ||
} | ||
reflectSendBz, err := json.Marshal(reflectSend) | ||
require.NoError(t, err) | ||
_, err = keepers.ContractKeeper.Execute(ctx, contractAddr, creator, reflectSendBz, nil) | ||
|
||
if tc.expectError { | ||
require.Error(t, err) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
|
||
// query the reflect state to check if the result was stored | ||
query := ReflectQueryMsg{ | ||
SubCallResult: &SubCall{ID: id}, | ||
} | ||
queryBz, err := json.Marshal(query) | ||
require.NoError(t, err) | ||
queryRes, err := keeper.QuerySmart(ctx, contractAddr, queryBz) | ||
if tc.writeResult { | ||
// we got some data for this call | ||
require.NoError(t, err) | ||
var res wasmvmtypes.Reply | ||
err = json.Unmarshal(queryRes, &res) | ||
require.NoError(t, err) | ||
require.Equal(t, id, res.ID) | ||
} else { | ||
// nothing should be there -> error | ||
require.Error(t, err) | ||
} | ||
}) | ||
} | ||
} |
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.
There is a reference in the Dockerfile that we need to update. 🕵️
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.
Will do that and
go mod tidy