evm, rpc: fix parameters and block gas limit in getBlockByHeight and getBlockByHash (#312)

* fix evm set parameters

* recompute header hash only if its not set

* Update x/evm/keeper/state_transition.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
Thomas Nguy
2021-07-19 01:52:44 +00:00
committed by GitHub
co-authored by Federico Kunze Küllmer
parent 0a8f02e067
commit c8b88a3a8b
7 changed files with 33 additions and 5 deletions
+6 -1
View File
@@ -229,7 +229,12 @@ func (e *EVMBackend) EthBlockFromTendermint(
validatorAddr := common.BytesToAddress(addr)
bloom := ethtypes.BytesToBloom(blockBloomResp.Bloom)
formattedBlock := types.FormatBlock(block.Header, block.Size(), ethermint.DefaultRPCGasLimit, new(big.Int).SetUint64(gasUsed), ethRPCTxs, bloom, validatorAddr)
gasLimit, err := types.BlockMaxGasFromConsensusParams(types.ContextWithHeight(block.Height), e.clientCtx)
if err != nil {
e.logger.Error("failed to query consensus params", "error", err.Error())
}
formattedBlock := types.FormatBlock(block.Header, block.Size(), gasLimit, new(big.Int).SetUint64(gasUsed), ethRPCTxs, bloom, validatorAddr)
return formattedBlock, nil
}
+1 -1
View File
@@ -132,7 +132,7 @@ func EthTransactionsFromTendermint(clientCtx client.Context, txs []tmtypes.Tx) (
func BlockMaxGasFromConsensusParams(ctx context.Context, clientCtx client.Context) (int64, error) {
resConsParams, err := clientCtx.Client.ConsensusParams(ctx, nil)
if err != nil {
return 0, err
return int64(^uint32(0)), err
}
gasLimit := resConsParams.ConsensusParams.Block.MaxGas