Skip to content

Commit d2e22b4

Browse files
authored
Merge pull request #216 from CosmWasm/upgrade-to-rc1
Update to cosmwasm v0.14.0-rc1
2 parents 5e02dd7 + 6f83e32 commit d2e22b4

16 files changed

+221
-89
lines changed

Cargo.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ default = []
2626
backtraces = []
2727

2828
[dependencies]
29-
cosmwasm-std = { git = "https://github.com/CosmWasm/cosmwasm", rev = "v0.14.0-beta5", features = ["iterator", "staking", "stargate"] }
30-
cosmwasm-vm = { git = "https://github.com/CosmWasm/cosmwasm", rev = "v0.14.0-beta5", features = ["iterator", "staking", "stargate"] }
29+
cosmwasm-std = { git = "https://github.com/CosmWasm/cosmwasm", rev = "v0.14.0-rc1", features = ["iterator", "staking", "stargate"] }
30+
cosmwasm-vm = { git = "https://github.com/CosmWasm/cosmwasm", rev = "v0.14.0-rc1", features = ["iterator", "staking", "stargate"] }
3131
errno = "0.2"
3232
serde_json = "1.0"
3333
thiserror = "1.0"

api/lib_test.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func TestGetMetrics(t *testing.T) {
208208
assert.Equal(t, &types.Metrics{
209209
HitsFsCache: 1,
210210
ElementsMemoryCache: 1,
211-
SizeMemoryCache: 3428923,
211+
SizeMemoryCache: 3432787,
212212
}, metrics)
213213

214214
// Instantiate 2
@@ -223,7 +223,7 @@ func TestGetMetrics(t *testing.T) {
223223
HitsMemoryCache: 1,
224224
HitsFsCache: 1,
225225
ElementsMemoryCache: 1,
226-
SizeMemoryCache: 3428923,
226+
SizeMemoryCache: 3432787,
227227
}, metrics)
228228

229229
// Pin
@@ -238,8 +238,8 @@ func TestGetMetrics(t *testing.T) {
238238
HitsFsCache: 1,
239239
ElementsPinnedMemoryCache: 1,
240240
ElementsMemoryCache: 1,
241-
SizePinnedMemoryCache: 3428923,
242-
SizeMemoryCache: 3428923,
241+
SizePinnedMemoryCache: 3432787,
242+
SizeMemoryCache: 3432787,
243243
}, metrics)
244244

245245
// Instantiate 3
@@ -256,8 +256,8 @@ func TestGetMetrics(t *testing.T) {
256256
HitsFsCache: 1,
257257
ElementsPinnedMemoryCache: 1,
258258
ElementsMemoryCache: 1,
259-
SizePinnedMemoryCache: 3428923,
260-
SizeMemoryCache: 3428923,
259+
SizePinnedMemoryCache: 3432787,
260+
SizeMemoryCache: 3432787,
261261
}, metrics)
262262

263263
// Unpin
@@ -274,7 +274,7 @@ func TestGetMetrics(t *testing.T) {
274274
ElementsPinnedMemoryCache: 0,
275275
ElementsMemoryCache: 1,
276276
SizePinnedMemoryCache: 0,
277-
SizeMemoryCache: 3428923,
277+
SizeMemoryCache: 3432787,
278278
}, metrics)
279279

280280
// Instantiate 4
@@ -292,7 +292,7 @@ func TestGetMetrics(t *testing.T) {
292292
ElementsPinnedMemoryCache: 0,
293293
ElementsMemoryCache: 1,
294294
SizePinnedMemoryCache: 0,
295-
SizeMemoryCache: 3428923,
295+
SizeMemoryCache: 3432787,
296296
}, metrics)
297297
}
298298

@@ -319,7 +319,7 @@ func TestInstantiate(t *testing.T) {
319319
res, cost, err := Instantiate(cache, checksum, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
320320
require.NoError(t, err)
321321
requireOkResponse(t, res, 0)
322-
assert.Equal(t, uint64(0x92d1), cost)
322+
assert.Equal(t, uint64(0x8e99), cost)
323323

324324
var result types.ContractResult
325325
err = json.Unmarshal(res, &result)
@@ -350,7 +350,7 @@ func TestExecute(t *testing.T) {
350350
diff := time.Now().Sub(start)
351351
require.NoError(t, err)
352352
requireOkResponse(t, res, 0)
353-
assert.Equal(t, uint64(0x92d1), cost)
353+
assert.Equal(t, uint64(0x8e99), cost)
354354
t.Logf("Time (%d gas): %s\n", cost, diff)
355355

356356
// execute with the same store
@@ -363,7 +363,7 @@ func TestExecute(t *testing.T) {
363363
res, cost, err = Execute(cache, checksum, env, info, []byte(`{"release":{}}`), &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
364364
diff = time.Now().Sub(start)
365365
require.NoError(t, err)
366-
assert.Equal(t, uint64(0xf364), cost)
366+
assert.Equal(t, uint64(0xef2c), cost)
367367
t.Logf("Time (%d gas): %s\n", cost, diff)
368368

369369
// make sure it read the balance properly and we got 250 atoms
@@ -405,7 +405,7 @@ func TestExecuteCpuLoop(t *testing.T) {
405405
diff := time.Now().Sub(start)
406406
require.NoError(t, err)
407407
requireOkResponse(t, res, 0)
408-
assert.Equal(t, uint64(0x92d1), cost)
408+
assert.Equal(t, uint64(0x8e99), cost)
409409
t.Logf("Time (%d gas): %s\n", cost, diff)
410410

411411
// execute a cpu loop
@@ -556,7 +556,7 @@ func TestMultipleInstances(t *testing.T) {
556556
require.NoError(t, err)
557557
requireOkResponse(t, res, 0)
558558
// we now count wasm gas charges and db writes
559-
assert.Equal(t, uint64(0x91b0), cost)
559+
assert.Equal(t, uint64(0x8d78), cost)
560560

561561
// instance2 controlled by mary
562562
gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
@@ -567,14 +567,14 @@ func TestMultipleInstances(t *testing.T) {
567567
res, cost, err = Instantiate(cache, checksum, env, info, msg, &igasMeter2, store2, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
568568
require.NoError(t, err)
569569
requireOkResponse(t, res, 0)
570-
assert.Equal(t, uint64(0x9255), cost)
570+
assert.Equal(t, uint64(0x8e1d), cost)
571571

572572
// fail to execute store1 with mary
573-
resp := exec(t, cache, checksum, "mary", store1, api, querier, 0x7e26)
573+
resp := exec(t, cache, checksum, "mary", store1, api, querier, 0x79ee)
574574
require.Equal(t, "Unauthorized", resp.Err)
575575

576576
// succeed to execute store1 with fred
577-
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0xf2f0)
577+
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0xeeb8)
578578
require.Equal(t, "", resp.Err)
579579
require.Equal(t, 1, len(resp.Ok.Messages))
580580
attributes := resp.Ok.Attributes
@@ -583,7 +583,7 @@ func TestMultipleInstances(t *testing.T) {
583583
require.Equal(t, "bob", attributes[1].Value)
584584

585585
// succeed to execute store2 with mary
586-
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0xf32a)
586+
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0xeef2)
587587
require.Equal(t, "", resp.Err)
588588
require.Equal(t, 1, len(resp.Ok.Messages))
589589
attributes = resp.Ok.Attributes

api/mocks.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ const MOCK_CONTRACT_ADDR = "contract"
2222
func MockEnv() types.Env {
2323
return types.Env{
2424
Block: types.BlockInfo{
25-
Height: 123,
26-
Time: 1578939743,
27-
TimeNanos: 987654321,
28-
ChainID: "foobar",
25+
Height: 123,
26+
Time: 1578939743_987654321,
27+
ChainID: "foobar",
2928
},
3029
Contract: types.ContractInfo{
3130
Address: MOCK_CONTRACT_ADDR,

api/testdata/hackatom.wasm

237 Bytes
Binary file not shown.

api/testdata/ibc_reflect.wasm

9.19 KB
Binary file not shown.

api/testdata/queue.wasm

233 Bytes
Binary file not shown.

api/testdata/reflect.wasm

-1.21 KB
Binary file not shown.

ibc_test.go

+27-9
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ func TestIBCHandshake(t *testing.T) {
126126
channel = api.MockIBCChannel(CHANNEL_ID, types.Ordered, IBC_VERSION)
127127
res, _, err := vm.IBCChannelConnect(checksum, env, channel, store, *goapi, querier, gasMeter2, TESTING_GAS_LIMIT)
128128
require.NoError(t, err)
129-
require.Equal(t, 1, len(res.Messages))
129+
require.Equal(t, 0, len(res.Messages))
130+
require.Equal(t, 1, len(res.Submessages))
130131

131132
// make sure it read the balance properly and we got 250 atoms
132-
dispatch := res.Messages[0]
133+
dispatch := res.Submessages[0].Msg
133134
require.NotNil(t, dispatch.Wasm, "%#v", dispatch)
134135
require.NotNil(t, dispatch.Wasm.Instantiate, "%#v", dispatch)
135136
init := dispatch.Wasm.Instantiate
@@ -177,20 +178,37 @@ func TestIBCPacketDispatch(t *testing.T) {
177178
store.SetGasMeter(gasMeter3)
178179
// completes and dispatches message to create reflect contract
179180
channel = api.MockIBCChannel(CHANNEL_ID, types.Ordered, IBC_VERSION)
180-
_, _, err = vm.IBCChannelConnect(checksum, env, channel, store, *goapi, querier, gasMeter3, TESTING_GAS_LIMIT)
181+
res, _, err := vm.IBCChannelConnect(checksum, env, channel, store, *goapi, querier, gasMeter3, TESTING_GAS_LIMIT)
181182
require.NoError(t, err)
183+
require.Equal(t, 0, len(res.Messages))
184+
require.Equal(t, 1, len(res.Submessages))
185+
id := res.Submessages[0].ID
182186

183187
// mock reflect init callback (to store address)
184188
gasMeter4 := api.NewMockGasMeter(TESTING_GAS_LIMIT)
185189
store.SetGasMeter(gasMeter4)
186-
handleMsg := IBCExecuteMsg{
187-
InitCallback: InitCallback{
188-
ID: CHANNEL_ID,
189-
ContractAddr: REFLECT_ADDR,
190+
reply := types.Reply{
191+
ID: id,
192+
Result: types.SubcallResult{
193+
Ok: &types.SubcallResponse{
194+
Events: types.Events{{
195+
Type: "message",
196+
Attributes: types.EventAttributes{
197+
{
198+
Key: "module",
199+
Value: "wasm",
200+
},
201+
{
202+
Key: "contract_address",
203+
Value: REFLECT_ADDR,
204+
},
205+
},
206+
}},
207+
Data: nil,
208+
},
190209
},
191210
}
192-
info = api.MockInfo(REFLECT_ADDR, nil)
193-
_, _, err = vm.Execute(checksum, env, info, toBytes(t, handleMsg), store, *goapi, querier, gasMeter4, TESTING_GAS_LIMIT)
211+
_, _, err = vm.Reply(checksum, env, reply, store, *goapi, querier, gasMeter4, TESTING_GAS_LIMIT)
194212
require.NoError(t, err)
195213

196214
// ensure the channel is registered

lib_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestGetMetrics(t *testing.T) {
130130
assert.Equal(t, &types.Metrics{
131131
HitsFsCache: 1,
132132
ElementsMemoryCache: 1,
133-
SizeMemoryCache: 3428923,
133+
SizeMemoryCache: 3432787,
134134
}, metrics)
135135

136136
// Instantiate 2
@@ -146,7 +146,7 @@ func TestGetMetrics(t *testing.T) {
146146
HitsMemoryCache: 1,
147147
HitsFsCache: 1,
148148
ElementsMemoryCache: 1,
149-
SizeMemoryCache: 3428923,
149+
SizeMemoryCache: 3432787,
150150
}, metrics)
151151

152152
// Pin
@@ -161,8 +161,8 @@ func TestGetMetrics(t *testing.T) {
161161
HitsFsCache: 1,
162162
ElementsPinnedMemoryCache: 1,
163163
ElementsMemoryCache: 1,
164-
SizePinnedMemoryCache: 3428923,
165-
SizeMemoryCache: 3428923,
164+
SizePinnedMemoryCache: 3432787,
165+
SizeMemoryCache: 3432787,
166166
}, metrics)
167167

168168
// Instantiate 3
@@ -180,8 +180,8 @@ func TestGetMetrics(t *testing.T) {
180180
HitsFsCache: 1,
181181
ElementsPinnedMemoryCache: 1,
182182
ElementsMemoryCache: 1,
183-
SizePinnedMemoryCache: 3428923,
184-
SizeMemoryCache: 3428923,
183+
SizePinnedMemoryCache: 3432787,
184+
SizeMemoryCache: 3432787,
185185
}, metrics)
186186

187187
// Unpin
@@ -198,7 +198,7 @@ func TestGetMetrics(t *testing.T) {
198198
ElementsPinnedMemoryCache: 0,
199199
ElementsMemoryCache: 1,
200200
SizePinnedMemoryCache: 0,
201-
SizeMemoryCache: 3428923,
201+
SizeMemoryCache: 3432787,
202202
}, metrics)
203203

204204
// Instantiate 4
@@ -217,6 +217,6 @@ func TestGetMetrics(t *testing.T) {
217217
ElementsPinnedMemoryCache: 0,
218218
ElementsMemoryCache: 1,
219219
SizePinnedMemoryCache: 0,
220-
SizeMemoryCache: 3428923,
220+
SizeMemoryCache: 3432787,
221221
}, metrics)
222222
}

0 commit comments

Comments
 (0)