Skip to content

Commit

Permalink
Fix gas
Browse files Browse the repository at this point in the history
  • Loading branch information
pinosu committed Aug 9, 2024
1 parent 845a69f commit d9238c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions x/wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func TestInstantiate(t *testing.T) {

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

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

func TestGasCostOnQuery(t *testing.T) {
const (
GasNoWork uint64 = 63_956
GasNoWork uint64 = 63_983
// Note: about 100 SDK gas (10k CosmWasm gas) for each round of sha256
GasWork50 uint64 = 64_268 // this is a little shy of 50k gas - to keep an eye on the limit
GasWork50 uint64 = 64_222 // this is a little shy of 50k gas - to keep an eye on the limit

GasReturnUnhashed uint64 = 36
GasReturnHashed uint64 = 29
GasReturnUnhashed uint64 = 55
GasReturnHashed uint64 = 46
)

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

const (
// Note: about 100 SDK gas (10k CosmWasm gas) for each round of sha256
GasWork2k uint64 = 78_937 // = SetupContractCost + x // we have 6x gas used in cpu than in the instance
GasWork2k uint64 = 76_279 // = SetupContractCost + x // we have 6x gas used in cpu than in the instance
// This is overhead for calling into a sub-contract
GasReturnHashed uint64 = 30
GasReturnHashed uint64 = 48
)

cases := map[string]struct {
Expand Down Expand Up @@ -263,7 +263,7 @@ func TestLimitRecursiveQueryGas(t *testing.T) {
expectQueriesFromContract: 10,
expectOutOfGas: false,
expectError: "query wasm contract failed", // Error we get from the contract instance doing the failing query, not wasmd
expectedGas: 10*(GasWork2k+GasReturnHashed) + 3152, // lots of additional gas for long error message
expectedGas: 10*(GasWork2k+GasReturnHashed) + 3279, // lots of additional gas for long error message
},
}

Expand Down
2 changes: 1 addition & 1 deletion x/wasm/keeper/submsg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
"send tokens": {
submsgID: 5,
msg: validBankSend,
resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(110_000, 111_000)},
resultAssertions: []assertion{assertReturnedEvents(0), assertGasUsed(110_000, 112_000)},
},
"not enough tokens": {
submsgID: 6,
Expand Down

0 comments on commit d9238c8

Please sign in to comment.