Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

fix: raise error when get invalid consensus params #1790

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (app) [#1739](https://github.com/evmos/ethermint/pull/1739) Remove distribution module perms
- (ante) [#1741](https://github.com/evmos/ethermint/pull/1741) Add authz ante handler
- (eip712) [#1746](https://github.com/evmos/ethermint/pull/1746) Add EIP712 support for multiple messages and schemas
- (feemarket) [#1790](https://github.com/evmos/ethermint/pull/1790) Raise error when get invalid consensus params

### Bug Fixes

Expand Down
4 changes: 2 additions & 2 deletions app/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import (
// EthermintApp testing.
var DefaultConsensusParams = &abci.ConsensusParams{
Block: &abci.BlockParams{
MaxBytes: 200000,
MaxGas: -1, // no limit
MaxBytes: 1048576,
MaxGas: 81500000, // default limit
},
Evidence: &tmproto.EvidenceParams{
MaxAgeNumBlocks: 302400,
Expand Down
20 changes: 10 additions & 10 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ schema = 3
version = "v0.9.1"
hash = "sha256-YLGNrHHM+mN4ElW/XWuylOnFrA/VjSY+eBuC4LN//5c="
[mod."github.com/rs/cors"]
version = "v1.8.3"
hash = "sha256-VgVB4HKAhPSjNg96mIEUN1bt5ZQng8Fi3ZABy3CDWQE="
version = "v1.9.0"
hash = "sha256-CNBCGXOydU6MIEZ0B5eXBjBm3smH2ryYHvgRJA2udBM="
[mod."github.com/rs/zerolog"]
version = "v1.27.0"
hash = "sha256-BxQtP2TROeSSpj9l1irocuSfxn55UL4ugzB/og7r8eE="
Expand Down Expand Up @@ -512,23 +512,23 @@ schema = 3
version = "v0.0.0-20230131160201-f062dba9d201"
hash = "sha256-sxLT/VOe93v0h3miChJSHS9gscTZS/B71+390ju/e20="
[mod."golang.org/x/net"]
version = "v0.8.0"
hash = "sha256-2cOtqa7aJ5mn64kZ+8+PVjJ4uGbhpXTpC1vm/+iaZzM="
version = "v0.9.0"
hash = "sha256-EG5GRDq282twyce8uugsDTjMz1pNn6zPcyVTZmSiJ14="
[mod."golang.org/x/oauth2"]
version = "v0.4.0"
hash = "sha256-Dj9wHbSbs0Ghr9Hef0hSfanaR8L0GShI18jGBT3yNn8="
[mod."golang.org/x/sync"]
version = "v0.1.0"
hash = "sha256-Hygjq9euZ0qz6TvHYQwOZEjNiTbTh1nSLRAWZ6KFGR8="
[mod."golang.org/x/sys"]
version = "v0.6.0"
hash = "sha256-zAgxiTuL24sGhbXrna9R1UYqLQh46ldztpumOScmduY="
version = "v0.7.0"
hash = "sha256-GotRHJaas/q3L+tFam0q3oQ1rc8GDStt7wnz9h8MTEU="
[mod."golang.org/x/term"]
version = "v0.6.0"
hash = "sha256-Ao0yXpwY8GyG+/23dVfJUYrfEfNUTES3RF45v1VhUAk="
version = "v0.7.0"
hash = "sha256-VYnXZ50OXTsylzncIMceVC2ZBKdbyp+V367Qbq3Vlqk="
[mod."golang.org/x/text"]
version = "v0.8.0"
hash = "sha256-hgWFnT01DRmywBEXKYEVaOee7i6z8Ydz7zGbjcWwOgI="
version = "v0.9.0"
hash = "sha256-tkhDeMsSQZr3jo7vmKehWs3DvWetwXR0IB+DCLbQ4nk="
[mod."golang.org/x/tools"]
version = "v0.7.0"
hash = "sha256-ZEjfFulQd6U9r4mEJ5RZOnW49NZnQnrCFLMKCgLg7go="
Expand Down
9 changes: 4 additions & 5 deletions x/feemarket/keeper/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package keeper

import (
"fmt"
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -56,13 +57,11 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {

parentGasUsed := k.GetBlockGasWanted(ctx)

gasLimit := new(big.Int).SetUint64(math.MaxUint64)

// NOTE: a MaxGas equal to -1 means that block gas is unlimited
if consParams != nil && consParams.Block.MaxGas > -1 {
gasLimit = big.NewInt(consParams.Block.MaxGas)
if consParams == nil || consParams.Block == nil || consParams.Block.MaxGas <= -1 {
panic(fmt.Sprintf("get invalid consensus params: %s", consParams))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}

gasLimit := big.NewInt(consParams.Block.MaxGas)
// CONTRACT: ElasticityMultiplier cannot be 0 as it's checked in the params
// validation
parentGasTargetBig := new(big.Int).Div(gasLimit, new(big.Int).SetUint64(uint64(params.ElasticityMultiplier)))
Expand Down