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>
This commit is contained in:
maskpp 2022-04-01 20:40:34 +08:00 committed by GitHub
parent 33fcd2bf6d
commit b714e22893
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,