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 7e30762 commit d91f5a9
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

Check warning on line 342 in x/evm/keeper/state_transition.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/state_transition.go#L342

Added line #L342 was not covered by tests
} 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 d91f5a9

Please sign in to comment.