cmd/evm: use correct parent number for t8n base fee calculation (#27032)

Currently the t8n tool uses the same block number for the current block and its parent while calculating the base fee. This causes incorrect base fee calculation for the london fork block. This commit sets the parent block number to be one less than the current block number
This commit is contained in:
Guruprasad Kamath 2023-04-03 09:33:17 +02:00 committed by GitHub
parent 00a73fbcce
commit bed07cd590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,9 +250,9 @@ func Transition(ctx *cli.Context) error {
if chainConfig.IsLondon(big.NewInt(int64(prestate.Env.Number))) { if chainConfig.IsLondon(big.NewInt(int64(prestate.Env.Number))) {
if prestate.Env.BaseFee != nil { if prestate.Env.BaseFee != nil {
// Already set, base fee has precedent over parent base fee. // Already set, base fee has precedent over parent base fee.
} else if prestate.Env.ParentBaseFee != nil { } else if prestate.Env.ParentBaseFee != nil && prestate.Env.Number != 0 {
parent := &types.Header{ parent := &types.Header{
Number: new(big.Int).SetUint64(prestate.Env.Number), Number: new(big.Int).SetUint64(prestate.Env.Number - 1),
BaseFee: prestate.Env.ParentBaseFee, BaseFee: prestate.Env.ParentBaseFee,
GasUsed: prestate.Env.ParentGasUsed, GasUsed: prestate.Env.ParentGasUsed,
GasLimit: prestate.Env.ParentGasLimit, GasLimit: prestate.Env.ParentGasLimit,