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

Commit

Permalink
Problem: web3 rpc api returns wrong block gas limit
Browse files Browse the repository at this point in the history
Closes: #777

Solution:
- pass in specific block height to the query
  • Loading branch information
yihuang committed Nov 25, 2021
1 parent afe15fe commit 7ed3f47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rpc/ethereum/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (e *EVMBackend) EthBlockFromTendermint(

validatorAddr := common.BytesToAddress(addr)

gasLimit, err := types.BlockMaxGasFromConsensusParams(ctx, e.clientCtx)
gasLimit, err := types.BlockMaxGasFromConsensusParams(ctx, e.clientCtx, block.Height)
if err != nil {
e.logger.Error("failed to query consensus params", "error", err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions rpc/ethereum/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func EthHeaderFromTendermint(header tmtypes.Header, bloom ethtypes.Bloom, baseFe
}

// BlockMaxGasFromConsensusParams returns the gas limit for the latest block from the chain consensus params.
func BlockMaxGasFromConsensusParams(ctx context.Context, clientCtx client.Context) (int64, error) {
resConsParams, err := clientCtx.Client.ConsensusParams(ctx, nil)
func BlockMaxGasFromConsensusParams(goCtx context.Context, clientCtx client.Context, blockHeight int64) (int64, error) {
resConsParams, err := clientCtx.Client.ConsensusParams(goCtx, &blockHeight)
if err != nil {
return int64(^uint32(0)), err
}
Expand Down

0 comments on commit 7ed3f47

Please sign in to comment.