Skip to content

Commit

Permalink
Problem: trace block not accurate for dynamic fee transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Sep 23, 2024
1 parent b98aaf7 commit 3429b26
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,14 @@ func (k *Keeper) ApplyMessageWithConfig(
if vmCfg.Tracer != nil {
if cfg.DebugTrace {
// msg.GasPrice should have been set to effective gas price
stateDB.SubBalance(sender.Address(), new(big.Int).Mul(msg.GasPrice, new(big.Int).SetUint64(msg.GasLimit)))
var gasPrice *big.Int
if cfg.BaseFee == nil {
gasPrice = msg.GasPrice
} else {
// for legacy tx, the GasFeeCap/GasTipCap defaults to GasPrice, so it's compatible.
gasPrice = types.EffectiveGasPrice(cfg.BaseFee, msg.GasFeeCap, msg.GasTipCap)
}
stateDB.SubBalance(sender.Address(), new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(msg.GasLimit)))
stateDB.SetNonce(sender.Address(), stateDB.GetNonce(sender.Address())+1)
}
vmCfg.Tracer.CaptureTxStart(leftoverGas)
Expand Down

0 comments on commit 3429b26

Please sign in to comment.