diff --git a/app/app.go b/app/app.go index 9b0dd422e6..df279767bf 100644 --- a/app/app.go +++ b/app/app.go @@ -29,6 +29,7 @@ import ( authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" @@ -536,14 +537,19 @@ func NewWasmApp( slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, - ibchost.ModuleName, - ) - app.mm.SetOrderEndBlockers( - crisistypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, govtypes.ModuleName, - stakingtypes.ModuleName, - feegrant.ModuleName, + crisistypes.ModuleName, + genutiltypes.ModuleName, authz.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + vestingtypes.ModuleName, + // additional non simd modules + ibchost.ModuleName, + ibctransfertypes.ModuleName, + wasm.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -551,7 +557,7 @@ func NewWasmApp( // NOTE: Capability module must occur first so that it can initialize any capabilities // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. - // wasm module should be at the end as it can call other modules functionality direct or via message dispatching during + // NOTE: wasm module should be at the end as it can call other module functionality direct or via message dispatching during // genesis phase. For example bank transfer, auth account check, staking, ... app.mm.SetOrderInitGenesis( capabilitytypes.ModuleName, @@ -563,16 +569,23 @@ func NewWasmApp( govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, - ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, - ibctransfertypes.ModuleName, - feegrant.ModuleName, authz.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + upgradetypes.ModuleName, + vestingtypes.ModuleName, + // additional non simd modules + ibchost.ModuleName, + ibctransfertypes.ModuleName, // wasm after ibc transfer wasm.ModuleName, ) + // Uncomment if you want to set a custom migration order here. + // app.mm.SetOrderMigrations(custom order) + app.mm.RegisterInvariants(&app.crisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) diff --git a/contrib/local/01-accounts.sh b/contrib/local/01-accounts.sh index 0c27541023..1cb4b0e515 100755 --- a/contrib/local/01-accounts.sh +++ b/contrib/local/01-accounts.sh @@ -12,7 +12,7 @@ NEW_ACCOUNT=$(wasmd keys show fred -a) wasmd q bank balances "$NEW_ACCOUNT" -o json || true echo "## Transfer tokens" -wasmd tx send validator "$NEW_ACCOUNT" 1ustake --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block | jq +wasmd tx bank send validator "$NEW_ACCOUNT" 1ustake --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block -o json | jq echo "## Check balance again" wasmd q bank balances "$NEW_ACCOUNT" -o json | jq diff --git a/contrib/local/02-contracts.sh b/contrib/local/02-contracts.sh index 4df4cc5a2e..ecbadf31eb 100755 --- a/contrib/local/02-contracts.sh +++ b/contrib/local/02-contracts.sh @@ -6,7 +6,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" echo "-----------------------" echo "## Add new CosmWasm contract" RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/hackatom.wasm" \ - --from validator --gas 1500000 -y --chain-id=testing --node=http://localhost:26657 -b block) + --from validator --gas 1500000 -y --chain-id=testing --node=http://localhost:26657 -b block -o json) CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-1].value') echo "* Code id: $CODE_ID" @@ -23,7 +23,7 @@ echo "## Create new contract instance" INIT="{\"verifier\":\"$(wasmd keys show validator -a)\", \"beneficiary\":\"$(wasmd keys show fred -a)\"}" wasmd tx wasm instantiate "$CODE_ID" "$INIT" --admin="$(wasmd keys show validator -a)" \ --from validator --amount="100ustake" --label "local0.1.0" \ - --gas 1000000 -y --chain-id=testing -b block | jq + --gas 1000000 -y --chain-id=testing -b block -o json | jq CONTRACT=$(wasmd query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.contracts[-1]') echo "* Contract address: $CONTRACT" @@ -41,28 +41,28 @@ echo "## Execute contract $CONTRACT" MSG='{"release":{}}' wasmd tx wasm execute "$CONTRACT" "$MSG" \ --from validator \ - --gas 1000000 -y --chain-id=testing -b block | jq + --gas 1000000 -y --chain-id=testing -b block -o json | jq echo "-----------------------" echo "## Set new admin" echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" echo "### Update contract" wasmd tx wasm set-contract-admin "$CONTRACT" "$(wasmd keys show fred -a)" \ - --from validator -y --chain-id=testing -b block | jq -echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.admin')" + --from validator -y --chain-id=testing -b block -o json | jq +echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" echo "-----------------------" echo "## Migrate contract" echo "### Upload new code" RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/burner.wasm" \ - --from validator --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block) + --from validator --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block -o json) BURNER_CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[1].attributes[-1].value') echo "### Migrate to code id: $BURNER_CODE_ID" DEST_ACCOUNT=$(wasmd keys show fred -a) wasmd tx wasm migrate "$CONTRACT" "$BURNER_CODE_ID" "{\"payout\": \"$DEST_ACCOUNT\"}" --from fred \ - --chain-id=testing -b block -y | jq + --chain-id=testing -b block -y -o json | jq echo "### Query destination account: $BURNER_CODE_ID" wasmd q bank balances "$DEST_ACCOUNT" -o json | jq @@ -74,8 +74,8 @@ wasmd q wasm contract-history "$CONTRACT" -o json | jq echo "-----------------------" echo "## Clear contract admin" -echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.admin')" +echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" echo "### Update contract" wasmd tx wasm clear-contract-admin "$CONTRACT" \ - --from fred -y --chain-id=testing -b block | jq -echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.admin')" + --from fred -y --chain-id=testing -b block -o json | jq +echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')" diff --git a/go.mod b/go.mod index 6d78bbfd28..6277cc29e3 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/CosmWasm/wasmvm v1.0.0-beta5 - github.com/cosmos/cosmos-sdk v0.44.5 + github.com/cosmos/cosmos-sdk v0.45.0 github.com/cosmos/iavl v0.17.3 github.com/cosmos/ibc-go/v2 v2.0.2 github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b @@ -43,7 +43,7 @@ require ( github.com/btcsuite/btcd v0.22.0-beta // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/coinbase/rosetta-sdk-go v0.6.10 // indirect + github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect github.com/confio/ics23/go v0.6.6 // indirect github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect @@ -123,7 +123,7 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 github.com/confio/ics23/go => github.com/confio/ics23/go v0.6.6 - github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.44.5 + github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.0-rc1 github.com/cosmos/go-bip39 => github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl => github.com/cosmos/iavl v0.17.3 // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. diff --git a/go.sum b/go.sum index 07ca125f02..c154c5e782 100644 --- a/go.sum +++ b/go.sum @@ -185,8 +185,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go v0.6.10 h1:rgHD/nHjxLh0lMEdfGDqpTtlvtSBwULqrrZ2qPdNaCM= -github.com/coinbase/rosetta-sdk-go v0.6.10/go.mod h1:J/JFMsfcePrjJZkwQFLh+hJErkAmdm9Iyy3D5Y0LfXo= +github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= +github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= github.com/confio/ics23/go v0.6.6 h1:pkOy18YxxJ/r0XFDCnrl4Bjv6h4LkBSpLS6F38mrKL8= github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= @@ -204,8 +204,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -github.com/cosmos/cosmos-sdk v0.44.5 h1:t5h+KPzZb0Zsag1RP1DCMQlyJyIQqJcqSPJrbUCDGHY= -github.com/cosmos/cosmos-sdk v0.44.5/go.mod h1:maUA6m2TBxOJZkbwl0eRtEBgTX37kcaiOWU5t1HEGaY= +github.com/cosmos/cosmos-sdk v0.45.0-rc1 h1:94EoI38gvnkYVUO+w4vBunEFPX8/5S0kwc6QEdkP0mo= +github.com/cosmos/cosmos-sdk v0.45.0-rc1/go.mod h1:XXS/asyCqWNWkx2rW6pSuen+EVcpAFxq6khrhnZgHaQ= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 1436f1a020..d7443f663d 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -313,7 +313,7 @@ func TestInstantiate(t *testing.T) { gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x170e3), gasAfter-gasBefore) + require.Equal(t, uint64(0x18dab), gasAfter-gasBefore) } // ensure it is stored properly @@ -546,7 +546,7 @@ func TestExecute(t *testing.T) { // make sure gas is properly deducted from ctx gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x16c73), gasAfter-gasBefore) + require.Equal(t, uint64(0x17cd2), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) @@ -1630,7 +1630,7 @@ func TestReply(t *testing.T) { Bank: &wasmvmtypes.BankQuery{ Balance: &wasmvmtypes.BalanceQuery{Address: env.Contract.Address, Denom: "stake"}, }, - }, 1000*DefaultGasMultiplier) + }, 10_000*DefaultGasMultiplier) require.NoError(t, err) var gotBankRsp wasmvmtypes.BalanceResponse require.NoError(t, json.Unmarshal(bzRsp, &gotBankRsp)) diff --git a/x/wasm/keeper/recurse_test.go b/x/wasm/keeper/recurse_test.go index 8564e32787..2d6052075a 100644 --- a/x/wasm/keeper/recurse_test.go +++ b/x/wasm/keeper/recurse_test.go @@ -53,9 +53,9 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.Acc func TestGasCostOnQuery(t *testing.T) { const ( - GasNoWork uint64 = 63_832 + GasNoWork uint64 = 63_958 // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 - GasWork50 uint64 = 64_275 // this is a little shy of 50k gas - to keep an eye on the limit + GasWork50 uint64 = 64_401 // this is a little shy of 50k gas - to keep an eye on the limit GasReturnUnhashed uint64 = 33 GasReturnHashed uint64 = 25 @@ -216,7 +216,7 @@ func TestLimitRecursiveQueryGas(t *testing.T) { const ( // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 - GasWork2k uint64 = 84_110 // = NewContractInstanceCosts + x // we have 6x gas used in cpu than in the instance + GasWork2k uint64 = 84_236 // = NewContractInstanceCosts + x // we have 6x gas used in cpu than in the instance // This is overhead for calling into a sub-contract GasReturnHashed uint64 = 26 ) diff --git a/x/wasm/keeper/relay_test.go b/x/wasm/keeper/relay_test.go index ca7b696b12..11bf273439 100644 --- a/x/wasm/keeper/relay_test.go +++ b/x/wasm/keeper/relay_test.go @@ -80,7 +80,7 @@ func TestOnOpenChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2777) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expGas, ctx.GasMeter().GasConsumed()-before-storageCosts) }) } @@ -185,7 +185,7 @@ func TestOnConnectChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2777) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -295,7 +295,7 @@ func TestOnCloseChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2777) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -314,6 +314,7 @@ func TestOnRecvPacket(t *testing.T) { parentCtx, keepers := CreateTestInput(t, false, SupportedFeatures, WithMessageHandler(messenger)) example := SeedNewContractInstance(t, parentCtx, keepers, &m) const myContractGas = 40 + const storageCosts = sdk.Gas(2903) specs := map[string]struct { contractAddr sdk.AccAddress @@ -400,7 +401,7 @@ func TestOnRecvPacket(t *testing.T) { }, "submessage reply can overwrite ack data": { contractAddr: example.Contract, - expContractGas: myContractGas + 2777, + expContractGas: myContractGas + storageCosts, contractResp: &wasmvmtypes.IBCReceiveResponse{ Acknowledgement: []byte("myAck"), Messages: []wasmvmtypes.SubMsg{{ReplyOn: wasmvmtypes.ReplyAlways, Msg: wasmvmtypes.CosmosMsg{Bank: &wasmvmtypes.BankMsg{}}}}, @@ -456,7 +457,7 @@ func TestOnRecvPacket(t *testing.T) { require.Equal(t, spec.expAck, gotAck) // verify gas consumed - const storageCosts = sdk.Gas(2777) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -562,7 +563,7 @@ func TestOnAckPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2777) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) @@ -682,7 +683,7 @@ func TestOnTimeoutPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(2777) + const storageCosts = sdk.Gas(2903) assert.Equal(t, spec.expContractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched require.Len(t, *capturedMsgs, len(spec.contractResp.Messages)) diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index e41b1c2f99..2fdb17eb3b 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -247,7 +247,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { "send tokens": { submsgID: 5, msg: validBankSend, - resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(96000, 107367)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(112000, 112900)}, }, "not enough tokens": { submsgID: 6, @@ -267,7 +267,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { msg: validBankSend, gasLimit: &subGasLimit, // uses same gas as call without limit (note we do not charge the 40k on reply) - resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(96000, 107469)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(112000, 113000)}, }, "not enough tokens with limit": { submsgID: 16, @@ -275,7 +275,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { subMsgError: true, gasLimit: &subGasLimit, // uses same gas as call without limit (note we do not charge the 40k on reply) - resultAssertions: []assertion{assertGasUsed(76000, 79000), assertErrorString("insufficient funds")}, + resultAssertions: []assertion{assertGasUsed(79000, 79040), assertErrorString("insufficient funds")}, }, "out of gas caught with gas limit": { submsgID: 17, @@ -283,7 +283,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { subMsgError: true, gasLimit: &subGasLimit, // uses all the subGasLimit, plus the 52k or so for the main contract - resultAssertions: []assertion{assertGasUsed(subGasLimit+71000, subGasLimit+74000), assertErrorString("out of gas")}, + resultAssertions: []assertion{assertGasUsed(subGasLimit+73000, subGasLimit+80000), assertErrorString("out of gas")}, }, "instantiate contract gets address in data and events": { submsgID: 21,