From c637add01c703cebbd978c6bc5e673293b81ab3a Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Mon, 7 Jun 2021 10:46:26 +0200 Subject: [PATCH] Remove max gas limit --- x/wasm/alias.go | 1 - x/wasm/keeper/keeper.go | 8 -------- x/wasm/keeper/relay_test.go | 3 ++- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/x/wasm/alias.go b/x/wasm/alias.go index 82573fa2fa..bea70fa318 100644 --- a/x/wasm/alias.go +++ b/x/wasm/alias.go @@ -30,7 +30,6 @@ const ( ProposalTypeUpdateAdmin = types.ProposalTypeUpdateAdmin ProposalTypeClearAdmin = types.ProposalTypeClearAdmin GasMultiplier = keeper.GasMultiplier - MaxGas = keeper.MaxGas QueryListContractByCode = keeper.QueryListContractByCode QueryGetContract = keeper.QueryGetContract QueryGetContractState = keeper.QueryGetContractState diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index f88a739fd5..6ebe887718 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -28,11 +28,6 @@ import ( // Please note that all gas prices returned to the wasmer engine should have this multiplied const GasMultiplier uint64 = 100 -// MaxGas for a contract is 10 billion wasmer gas (enforced in rust to prevent overflow) -// The limit for v0.9.3 is defined here: https://github.com/CosmWasm/cosmwasm/blob/v0.9.3/packages/vm/src/backends/singlepass.rs#L15-L23 -// (this will be increased in future releases) -const MaxGas = 10_000_000_000 - // InstanceCost is how much SDK gas we charge each time we load a WASM instance. // Creating a new instance is costly, and this helps put a recursion limit to contracts calling contracts. const InstanceCost uint64 = 40_000 @@ -823,9 +818,6 @@ func gasForContract(ctx sdk.Context) uint64 { return 0 } remaining := (meter.Limit() - meter.GasConsumedToLimit()) * GasMultiplier - if remaining > MaxGas { - return MaxGas - } return remaining } diff --git a/x/wasm/keeper/relay_test.go b/x/wasm/keeper/relay_test.go index f8e57d4ccf..5c929596b4 100644 --- a/x/wasm/keeper/relay_test.go +++ b/x/wasm/keeper/relay_test.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "math" "testing" ) @@ -31,7 +32,7 @@ func TestOnOpenChannel(t *testing.T) { }, "consume max gas": { contractAddr: example.Contract, - contractGas: MaxGas, + contractGas: math.MaxUint64 / GasMultiplier, }, "consume gas on error": { contractAddr: example.Contract,