From 5c42c10b713d321f00f9034a226ebf668522d7ba Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 22 Sep 2021 19:19:58 +0200 Subject: [PATCH] Adjust gas prices for new contracts --- x/wasm/keeper/keeper_test.go | 4 ++-- x/wasm/keeper/recurse_test.go | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 5c361531..4c415dce 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -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 @@ -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) diff --git a/x/wasm/keeper/recurse_test.go b/x/wasm/keeper/recurse_test.go index 106e9cab..57b29dde 100644 --- a/x/wasm/keeper/recurse_test.go +++ b/x/wasm/keeper/recurse_test.go @@ -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 { @@ -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 { @@ -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,