Skip to content

Commit 3d9d92c

Browse files
authored
Wasmvm 1.4 upgrade (#1590)
* Start wasmvm 1.4 upgrade * Checksum lowercase * Start distribution query tests * Use wasmvm 1.4.0 * Implement remaining distribution queries * Update test * Update to burner v1.4; minor updates * Add dec coin test * Fix merge conflict
1 parent 87dce54 commit 3d9d92c

29 files changed

+877
-593
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ RUN apk add git
1515
WORKDIR /code
1616
COPY . /code/
1717
# See https://github.com/CosmWasm/wasmvm/releases
18-
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.3.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
19-
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.3.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
20-
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep b1610f9c8ad8bdebf5b8f819f71d238466f83521c74a2deb799078932e862722
21-
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep b4aad4480f9b4c46635b4943beedbb72c929eab1d1b9467fe3b43e6dbf617e32
18+
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.4.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
19+
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.4.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
20+
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 2a72c7062e3c791792b3dab781c815c9a76083a7997ce6f9f2799aaf577f3c25
21+
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 8ea2e3b5fae83e671da2bb51115adc88591045953f509955ec38dc02ea5a7b94
2222

2323
# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc`
2424
RUN cp /lib/libwasmvm_muslc.${arch}.a /lib/libwasmvm_muslc.a

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ compatibility list:
2727

2828
| wasmd | wasmvm | cosmwasm-vm | cosmwasm-std |
2929
|-------|--------------|-------------|--------------|
30+
| 0.42 | v1.4.0 | | 1.0-1.4 |
3031
| 0.41 | v1.3.0 | | 1.0-1.3 |
3132
| 0.40 | v1.2.3 | | 1.0-1.2 |
3233
| 0.31 | v1.2.0 | | 1.0-1.2 |

app/wasm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ func AllCapabilities() []string {
1111
"cosmwasm_1_1",
1212
"cosmwasm_1_2",
1313
"cosmwasm_1_3",
14+
"cosmwasm_1_4",
1415
}
1516
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/CosmWasm/wasmd
33
go 1.20
44

55
require (
6-
github.com/CosmWasm/wasmvm v1.3.0
6+
github.com/CosmWasm/wasmvm v1.4.0
77
github.com/cosmos/cosmos-proto v1.0.0-beta.2
88
github.com/cosmos/cosmos-sdk v0.47.5
99
github.com/cosmos/gogogateway v1.2.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
211211
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
212212
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
213213
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
214-
github.com/CosmWasm/wasmvm v1.3.0 h1:x12X4bKlUPS7TT9QQP45+fJo2sp30GEbiSSgb9jsec8=
215-
github.com/CosmWasm/wasmvm v1.3.0/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc=
214+
github.com/CosmWasm/wasmvm v1.4.0 h1:84I3MlvvzcOo2z+ed0ztPi7eeDNk6/sYuK76uyXP1nI=
215+
github.com/CosmWasm/wasmvm v1.4.0/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc=
216216
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
217217
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
218218
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=

x/wasm/client/cli/gov_tx_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ package cli
22

33
import (
44
"os"
5+
"strings"
56
"testing"
67

8+
"github.com/CosmWasm/wasmd/x/wasm/keeper/testdata"
9+
710
"github.com/stretchr/testify/assert"
811
"github.com/stretchr/testify/require"
912

@@ -104,7 +107,7 @@ func TestParseCodeInfoFlags(t *testing.T) {
104107
wasmBin, err := os.ReadFile("../../keeper/testdata/hackatom.wasm.gzip")
105108
require.NoError(t, err)
106109

107-
checksumStr := "5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2"
110+
checksumStr := strings.ToUpper(testdata.ChecksumHackatom)
108111

109112
specs := map[string]struct {
110113
args []string

x/wasm/client/cli/tx_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"encoding/hex"
55
"testing"
66

7+
"github.com/CosmWasm/wasmd/x/wasm/keeper/testdata"
8+
79
"github.com/stretchr/testify/assert"
810
"github.com/stretchr/testify/require"
911

@@ -27,22 +29,22 @@ func TestParseVerificationFlags(t *testing.T) {
2729
"gov store zipped": {
2830
srcPath: "../../keeper/testdata/hackatom.wasm.gzip",
2931
args: []string{
30-
"--instantiate-everybody=true", "--code-hash=5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2",
32+
"--instantiate-everybody=true", "--code-hash=" + testdata.ChecksumHackatom,
3133
"--code-source-url=https://example.com", "--builder=cosmwasm/workspace-optimizer:0.12.11",
3234
},
3335
expBuilder: "cosmwasm/workspace-optimizer:0.12.11",
3436
expSource: "https://example.com",
35-
expCodeHash: "5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2",
37+
expCodeHash: testdata.ChecksumHackatom,
3638
},
3739
"gov store raw": {
3840
srcPath: "../../keeper/testdata/hackatom.wasm",
3941
args: []string{
40-
"--instantiate-everybody=true", "--code-hash=5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2",
42+
"--instantiate-everybody=true", "--code-hash=" + testdata.ChecksumHackatom,
4143
"--code-source-url=https://example.com", "--builder=cosmwasm/workspace-optimizer:0.12.11",
4244
},
4345
expBuilder: "cosmwasm/workspace-optimizer:0.12.11",
4446
expSource: "https://example.com",
45-
expCodeHash: "5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2",
47+
expCodeHash: testdata.ChecksumHackatom,
4648
},
4749
"gov store checksum mismatch": {
4850
srcPath: "../../keeper/testdata/hackatom.wasm",

x/wasm/ibc_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func TestOnIBCPacketReceive(t *testing.T) {
208208

209209
// then
210210
if spec.expPacketNotHandled {
211-
const contractPanicToErrMsg = `recovered: Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: Aborted: panicked at 'This page intentionally faulted', src/contract.rs:316:5`
211+
const contractPanicToErrMsg = `recovered: Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: Aborted: panicked at 'This page intentionally faulted'`
212212
assert.ErrorContains(t, err, contractPanicToErrMsg)
213213
require.Nil(t, *capturedAck)
214214
return

x/wasm/keeper/keeper_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88
"fmt"
99
stdrand "math/rand"
1010
"os"
11-
"strings"
1211
"testing"
1312
"time"
1413

14+
"github.com/CosmWasm/wasmd/x/wasm/keeper/testdata"
15+
1516
wasmvm "github.com/CosmWasm/wasmvm"
1617
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
1718
abci "github.com/cometbft/cometbft/abci/types"
@@ -42,7 +43,7 @@ import (
4243
//go:embed testdata/hackatom.wasm
4344
var hackatomWasm []byte
4445

45-
const AvailableCapabilities = "iterator,staking,stargate,cosmwasm_1_1"
46+
const AvailableCapabilities = "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4"
4647

4748
func TestNewKeeper(t *testing.T) {
4849
_, keepers := CreateTestInput(t, false, AvailableCapabilities)
@@ -65,7 +66,7 @@ func TestCreateSuccess(t *testing.T) {
6566
require.NoError(t, err)
6667
require.Equal(t, hackatomWasm, storedCode)
6768
// and events emitted
68-
codeHash := strings.ToLower("5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2")
69+
codeHash := testdata.ChecksumHackatom
6970
exp := sdk.Events{sdk.NewEvent("store_code", sdk.NewAttribute("code_checksum", codeHash), sdk.NewAttribute("code_id", "1"))}
7071
assert.Equal(t, exp, em.Events())
7172
}
@@ -861,7 +862,7 @@ func TestExecute(t *testing.T) {
861862
// make sure gas is properly deducted from ctx
862863
gasAfter := ctx.GasMeter().GasConsumed()
863864
if types.EnableGasVerification {
864-
require.Equal(t, uint64(0x1a154), gasAfter-gasBefore)
865+
require.Equal(t, uint64(0x1a155), gasAfter-gasBefore)
865866
}
866867
// ensure bob now exists and got both payments released
867868
bobAcct = accKeeper.GetAccount(ctx, bob)
@@ -1367,11 +1368,10 @@ func TestMigrateWithDispatchedMessage(t *testing.T) {
13671368
contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, originalContractID, creator, fred, initMsgBz, "demo contract", deposit)
13681369
require.NoError(t, err)
13691370

1370-
migMsgBz := BurnerExampleInitMsg{Payout: myPayoutAddr}.GetBytes(t)
1371+
migMsgBz := BurnerExampleInitMsg{Payout: myPayoutAddr, Delete: 100}.GetBytes(t)
13711372
ctx = ctx.WithEventManager(sdk.NewEventManager()).WithBlockHeight(ctx.BlockHeight() + 1)
1372-
data, err := keeper.Migrate(ctx, contractAddr, fred, burnerContractID, migMsgBz)
1373+
_, err = keeper.Migrate(ctx, contractAddr, fred, burnerContractID, migMsgBz)
13731374
require.NoError(t, err)
1374-
assert.Equal(t, "burnt 1 keys", string(data))
13751375
type dict map[string]interface{}
13761376
expEvents := []dict{
13771377
{
@@ -1385,8 +1385,9 @@ func TestMigrateWithDispatchedMessage(t *testing.T) {
13851385
"Type": "wasm",
13861386
"Attr": []dict{
13871387
{"_contract_address": contractAddr},
1388-
{"action": "burn"},
1388+
{"action": "migrate"},
13891389
{"payout": myPayoutAddr},
1390+
{"deleted_entries": "1"},
13901391
},
13911392
},
13921393
{

x/wasm/keeper/proposal_integration_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"os"
99
"testing"
1010

11+
"github.com/CosmWasm/wasmd/x/wasm/keeper/testdata"
12+
1113
wasmvm "github.com/CosmWasm/wasmvm"
1214
"github.com/stretchr/testify/assert"
1315
"github.com/stretchr/testify/require"
@@ -36,7 +38,7 @@ func TestStoreCodeProposal(t *testing.T) {
3638
require.NoError(t, err)
3739
gzippedWasmCode, err := os.ReadFile("./testdata/hackatom.wasm.gzip")
3840
require.NoError(t, err)
39-
checksum, err := hex.DecodeString("5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2")
41+
checksum, err := hex.DecodeString(testdata.ChecksumHackatom)
4042
require.NoError(t, err)
4143

4244
specs := map[string]struct {
@@ -331,7 +333,7 @@ func TestStoreAndInstantiateContractProposal(t *testing.T) {
331333
wasmCode, err := os.ReadFile("./testdata/hackatom.wasm")
332334
require.NoError(t, err)
333335

334-
checksum, err := hex.DecodeString("5ca46abb8e9b1b754a5c906f9c0f4eec9121ee09e3cee55ea0faba54763706e2")
336+
checksum, err := hex.DecodeString(testdata.ChecksumHackatom)
335337
require.NoError(t, err)
336338

337339
var (

0 commit comments

Comments
 (0)