Skip to content

Commit

Permalink
fix: calc wrong block reward if has dynamic fee tx
Browse files Browse the repository at this point in the history
  • Loading branch information
fanbsb committed Dec 6, 2022
1 parent cbc37f1 commit edd3877
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/ethapi/api_fsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,14 @@ func (s *PublicFusionAPI) GetBlockReward(ctx context.Context, blockNr rpc.BlockN
}
for _, tx := range block.Transactions() {
if gasUsed, ok := gasUses[tx.Hash()]; ok {
gasReward := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(gasUsed))
var gasPrice *big.Int
if tx.Type() == types.DynamicFeeTxType {
baseFee := block.BaseFee()
gasPrice = new(big.Int).Add(baseFee, tx.EffectiveGasTipValue(baseFee))
} else {
gasPrice = tx.GasPrice()
}
gasReward := new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gasUsed))
if gasReward.Sign() > 0 {
// transaction gas reward
reward.Add(reward, gasReward)
Expand Down

0 comments on commit edd3877

Please sign in to comment.