From acc87bfbba732908dc011d8b514c5d4097206079 Mon Sep 17 00:00:00 2001 From: Loredana Cirstea Date: Sun, 6 Mar 2022 15:39:48 +0200 Subject: [PATCH] Quick fix for eth_feeHistory when reward is nil (#975) * Quick fix for eth_feeHistory when reward is nil `RPC method eth_feeHistory crashed: runtime error: invalid memory address or nil pointer dereference` from https://github.com/tharsis/ethermint/blob/caa1c5a6c6b7ed8ba4aaf6e0b0848f6be5ba6668/rpc/ethereum/backend/feebackend.go#L29 * Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ rpc/ethereum/backend/feebackend.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5099649b1f..aac6031197 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased +### Bug Fixes + +* (rpc) [#970] (https://github.com/tharsis/ethermint/pull/970) Fix unexpected nil reward values on `eth_feeHistory` response + ### API Breaking * (ante) [\#866](https://github.com/tharsis/ethermint/pull/866) `NewAnteHandler` constructor now receives a `HandlerOptions` field. diff --git a/rpc/ethereum/backend/feebackend.go b/rpc/ethereum/backend/feebackend.go index b09b5d421b..ed44833aca 100644 --- a/rpc/ethereum/backend/feebackend.go +++ b/rpc/ethereum/backend/feebackend.go @@ -87,6 +87,9 @@ func (e *EVMBackend) processBlock( } tx := ethMsg.AsTransaction() reward := tx.EffectiveGasTipValue(blockBaseFee) + if reward == nil { + reward = big.NewInt(0) + } sorter[i] = txGasAndReward{gasUsed: txGasUsed, reward: reward} break }