Skip to content

Commit

Permalink
Merge pull request #617 from CosmWasm/cosmwasm-1.0-soon
Browse files Browse the repository at this point in the history
Update to Cosmwasm v1.0.0-soon
  • Loading branch information
ethanfrey authored Sep 22, 2021
2 parents 2900e6c + 5c42c10 commit 6bd9172
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ WORKDIR /code
COPY . /code/

# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v0.16.1/libwasmvm_muslc.a /lib/libwasmvm_muslc.a
RUN sha256sum /lib/libwasmvm_muslc.a | grep 0e62296b9f24cf3a05f8513f99cee536c7087079855ea6ffb4f89b35eccdaa66
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0-soon/libwasmvm_muslc.a /lib/libwasmvm_muslc.a
RUN sha256sum /lib/libwasmvm_muslc.a | grep 6e82693aa64e4373ae303e82988c2f3a7216e83ee0021e9be80acbf18676ca9b

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc make build
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "staking,stargate"
supportedFeatures := "iterator,staking,stargate"
app.wasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/CosmWasm/wasmd
go 1.16

require (
github.com/CosmWasm/wasmvm v0.16.1
github.com/CosmWasm/wasmvm v1.0.0-soon
github.com/cosmos/cosmos-sdk v0.42.9
github.com/cosmos/iavl v0.16.0
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ 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.16.1 h1:o14Y9xnxaLaLnYiFG9rIna2ZtmB/F8BAIOLboVzXguQ=
github.com/CosmWasm/wasmvm v0.16.1/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A=
github.com/CosmWasm/wasmvm v1.0.0-soon h1:AUN0RDNgJ85hAv8LClUuhmm9OZOWYw3JhINiLa9NEeQ=
github.com/CosmWasm/wasmvm v1.0.0-soon/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=
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 @@ -35,7 +35,7 @@ func init() {

var hackatomWasm []byte

const SupportedFeatures = "staking,stargate"
const SupportedFeatures = "iterator,staking,stargate"

func TestNewKeeper(t *testing.T) {
_, keepers := CreateTestInput(t, false, SupportedFeatures)
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestInstantiate(t *testing.T) {

gasAfter := ctx.GasMeter().GasConsumed()
if types.EnableGasVerification {
require.Equal(t, uint64(0x12206), gasAfter-gasBefore)
require.Equal(t, uint64(0x12215), gasAfter-gasBefore)
}

// ensure it is stored properly
Expand Down Expand Up @@ -541,7 +541,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(0x12af1), gasAfter-gasBefore)
require.Equal(t, uint64(0x12af8), gasAfter-gasBefore)
}
// ensure bob now exists and got both payments released
bobAcct = accKeeper.GetAccount(ctx, bob)
Expand Down
19 changes: 9 additions & 10 deletions x/wasm/keeper/recurse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.Acc

func TestGasCostOnQuery(t *testing.T) {
const (
GasNoWork uint64 = 44_149
GasNoWork uint64 = 44_162
// Note: about 100 SDK gas (10k wasmer gas) for each round of sha256
GasWork50 uint64 = 49_809 // this is a little shy of 50k gas - to keep an eye on the limit
GasWork50 uint64 = 48_846 // this is a little shy of 50k gas - to keep an eye on the limit

GasReturnUnhashed uint64 = 256
GasReturnHashed uint64 = 232
GasReturnUnhashed uint64 = 253
GasReturnHashed uint64 = 228
)

cases := map[string]struct {
Expand Down Expand Up @@ -216,9 +216,9 @@ func TestLimitRecursiveQueryGas(t *testing.T) {

const (
// Note: about 100 SDK gas (10k wasmer gas) for each round of sha256
GasWork2k uint64 = 273_076 // = NewContractInstanceCosts + x // we have 6x gas used in cpu than in the instance
GasWork2k uint64 = 233_971 // = NewContractInstanceCosts + x // we have 6x gas used in cpu than in the instance
// This is overhead for calling into a sub-contract
GasReturnHashed uint64 = 236
GasReturnHashed uint64 = 231
)

cases := map[string]struct {
Expand All @@ -244,15 +244,14 @@ func TestLimitRecursiveQueryGas(t *testing.T) {
Work: 2000,
},
expectQueriesFromContract: 5,
// FIXME: why -3 ... confused a bit by calculations, seems like rounding issues
expectedGas: GasWork2k + 5*(GasWork2k+GasReturnHashed) - 3,
// FIXME: why +2 ... confused a bit by calculations, seems like rounding issues
expectedGas: GasWork2k + 5*(GasWork2k+GasReturnHashed) + 2,
},
// this is where we expect an error...
// it has enough gas to run 4 times and die on the 5th (4th time dispatching to sub-contract)
// however, if we don't charge the cpu gas before sub-dispatching, we can recurse over 20 times
// TODO: figure out how to asset how deep it went
"deep recursion, should die on 5th level": {
gasLimit: 1_200_000,
gasLimit: 1_000_000,
msg: Recurse{
Depth: 50,
Work: 2000,
Expand Down
Binary file modified x/wasm/keeper/testdata/burner.wasm
Binary file not shown.
Binary file modified x/wasm/keeper/testdata/hackatom.wasm
Binary file not shown.
Binary file modified x/wasm/keeper/testdata/hackatom.wasm.gzip
Binary file not shown.
Binary file modified x/wasm/keeper/testdata/ibc_reflect.wasm
Binary file not shown.
Binary file modified x/wasm/keeper/testdata/ibc_reflect_send.wasm
Binary file not shown.
Binary file modified x/wasm/keeper/testdata/reflect.wasm
Binary file not shown.
Binary file modified x/wasm/keeper/testdata/staking.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion x/wasm/keeper/testdata/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.16.0+contracts
v1.0.0-soon
2 changes: 1 addition & 1 deletion x/wasm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type testData struct {
}

func setupTest(t *testing.T) testData {
ctx, keepers := CreateTestInput(t, false, "staking,stargate")
ctx, keepers := CreateTestInput(t, false, "iterator,staking,stargate")
cdc := keeper.MakeTestCodec(t)
data := testData{
module: NewAppModule(cdc, keepers.WasmKeeper, keepers.StakingKeeper),
Expand Down

0 comments on commit 6bd9172

Please sign in to comment.