Skip to content

Commit

Permalink
Remove max gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Jun 7, 2021
1 parent bbb1669 commit c637add
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
1 change: 0 additions & 1 deletion x/wasm/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion x/wasm/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"math"
"testing"
)

Expand All @@ -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,
Expand Down

0 comments on commit c637add

Please sign in to comment.