From b714e22893d0847404fcedf9566c409101b05a2d Mon Sep 17 00:00:00 2001 From: maskpp Date: Fri, 1 Apr 2022 20:40:34 +0800 Subject: [PATCH] fix bug of null baseFee (#73) * fix bug of null baseFee * Update l2trace_block.go * Update l2trace_block.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- core/types/l2trace_block.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/types/l2trace_block.go b/core/types/l2trace_block.go index ab5755863d..1d0a27fa98 100644 --- a/core/types/l2trace_block.go +++ b/core/types/l2trace_block.go @@ -41,12 +41,20 @@ func NewTraceBlock(config *params.ChainConfig, block *Block, coinbase *AccountPr for i, tx := range block.Transactions() { txs[i] = newTraceTransaction(tx, block.NumberU64(), config) } + + baseFee := block.BaseFee() + // due to the special logic of `baseFee`, if `baseFee` is a nil + // we would like to use new(big.Int) to replace it so that `baseFee.String()` would return "0" + if baseFee == nil { + baseFee = new(big.Int) + } + return &BlockTrace{ Number: block.Number().String(), Hash: block.Hash(), GasLimit: block.GasLimit(), Difficulty: block.Difficulty().String(), - BaseFee: block.BaseFee().String(), + BaseFee: baseFee.String(), Coinbase: coinbase, Time: block.Time(), Transactions: txs,