Skip to content

Commit

Permalink
chore: remove nil check of consensusparam.abci, fix eip1559 base fee …
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
dudong2 committed Jan 22, 2024
1 parent 9395e7d commit c4ccd6c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func BlockGasLimit(ctx sdk.Context) uint64 {

// Otherwise get from the consensus parameters
cp := ctx.ConsensusParams()
if cp.Abci == nil || cp.Block == nil {
if cp.Block == nil {
return 0
}

Expand Down
2 changes: 1 addition & 1 deletion x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type
} else {
// Query block gas limit
params := ctx.ConsensusParams()
if params.Abci != nil && params.Block != nil && params.Block.MaxGas > 0 {
if params.Block != nil && params.Block.MaxGas > 0 {
hi = uint64(params.Block.MaxGas)
} else {
hi = req.GasCap
Expand Down
2 changes: 1 addition & 1 deletion x/feemarket/keeper/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {
gasLimit := new(big.Int).SetUint64(math.MaxUint64)

// NOTE: a MaxGas equal to -1 means that block gas is unlimited
if consParams.Abci != nil && consParams.Block.MaxGas > -1 {
if consParams.Block.MaxGas > -1 {
gasLimit = big.NewInt(consParams.Block.MaxGas)
}

Expand Down
10 changes: 5 additions & 5 deletions x/feemarket/keeper/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,39 +39,39 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() {
1,
50,
sdkmath.LegacyZeroDec(),
big.NewInt(875000001),
suite.app.FeeMarketKeeper.GetParams(suite.ctx).BaseFee.BigInt(),
},
{
"with BaseFee - parent block wanted the same gas as its target, with higher min gas price (ElasticityMultiplier = 2)",
false,
1,
50,
sdkmath.LegacyNewDec(1500000000),
big.NewInt(1500000000),
suite.app.FeeMarketKeeper.GetParams(suite.ctx).BaseFee.BigInt(),
},
{
"with BaseFee - parent block wanted more gas than its target (ElasticityMultiplier = 2)",
false,
1,
100,
sdkmath.LegacyZeroDec(),
big.NewInt(875000001),
big.NewInt(1125000000),
},
{
"with BaseFee - parent block wanted more gas than its target, with higher min gas price (ElasticityMultiplier = 2)",
false,
1,
100,
sdkmath.LegacyNewDec(1500000000),
big.NewInt(1500000000),
big.NewInt(1125000000),
},
{
"with BaseFee - Parent gas wanted smaller than parent gas target (ElasticityMultiplier = 2)",
false,
1,
25,
sdkmath.LegacyZeroDec(),
big.NewInt(875000001),
big.NewInt(937500000),
},
{
"with BaseFee - Parent gas wanted smaller than parent gas target, with higher min gas price (ElasticityMultiplier = 2)",
Expand Down

0 comments on commit c4ccd6c

Please sign in to comment.