Skip to content
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 SDK v0.45.0-rc1 #721

Merged
merged 3 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -536,22 +537,27 @@ func NewWasmApp(
slashingtypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
ibchost.ModuleName,
)
app.mm.SetOrderEndBlockers(
alpe marked this conversation as resolved.
Show resolved Hide resolved
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
// properly initialized with tokens from genesis accounts.
// 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,
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion contrib/local/01-accounts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 10 additions & 10 deletions contrib/local/02-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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')"
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-rc1
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions x/wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions x/wasm/keeper/recurse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
15 changes: 8 additions & 7 deletions x/wasm/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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{}}}},
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions x/wasm/keeper/submsg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -267,23 +267,23 @@ 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,
msg: invalidBankSend,
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,
msg: infiniteLoop,
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,
Expand Down