Skip to content

Commit b5b7003

Browse files
authored
tests: add currentExcessBlobGas to state tests (#28735)
1 parent d2e3cb8 commit b5b7003

File tree

2 files changed

+40
-28
lines changed

2 files changed

+40
-28
lines changed

tests/gen_stenv.go

Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/state_test_util.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/ethereum/go-ethereum/common"
2929
"github.com/ethereum/go-ethereum/common/hexutil"
3030
"github.com/ethereum/go-ethereum/common/math"
31+
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
3132
"github.com/ethereum/go-ethereum/core"
3233
"github.com/ethereum/go-ethereum/core/rawdb"
3334
"github.com/ethereum/go-ethereum/core/state"
@@ -83,23 +84,25 @@ type stPostState struct {
8384
//go:generate go run github.com/fjl/gencodec -type stEnv -field-override stEnvMarshaling -out gen_stenv.go
8485

8586
type stEnv struct {
86-
Coinbase common.Address `json:"currentCoinbase" gencodec:"required"`
87-
Difficulty *big.Int `json:"currentDifficulty" gencodec:"optional"`
88-
Random *big.Int `json:"currentRandom" gencodec:"optional"`
89-
GasLimit uint64 `json:"currentGasLimit" gencodec:"required"`
90-
Number uint64 `json:"currentNumber" gencodec:"required"`
91-
Timestamp uint64 `json:"currentTimestamp" gencodec:"required"`
92-
BaseFee *big.Int `json:"currentBaseFee" gencodec:"optional"`
87+
Coinbase common.Address `json:"currentCoinbase" gencodec:"required"`
88+
Difficulty *big.Int `json:"currentDifficulty" gencodec:"optional"`
89+
Random *big.Int `json:"currentRandom" gencodec:"optional"`
90+
GasLimit uint64 `json:"currentGasLimit" gencodec:"required"`
91+
Number uint64 `json:"currentNumber" gencodec:"required"`
92+
Timestamp uint64 `json:"currentTimestamp" gencodec:"required"`
93+
BaseFee *big.Int `json:"currentBaseFee" gencodec:"optional"`
94+
ExcessBlobGas *uint64 `json:"currentExcessBlobGas" gencodec:"optional"`
9395
}
9496

9597
type stEnvMarshaling struct {
96-
Coinbase common.UnprefixedAddress
97-
Difficulty *math.HexOrDecimal256
98-
Random *math.HexOrDecimal256
99-
GasLimit math.HexOrDecimal64
100-
Number math.HexOrDecimal64
101-
Timestamp math.HexOrDecimal64
102-
BaseFee *math.HexOrDecimal256
98+
Coinbase common.UnprefixedAddress
99+
Difficulty *math.HexOrDecimal256
100+
Random *math.HexOrDecimal256
101+
GasLimit math.HexOrDecimal64
102+
Number math.HexOrDecimal64
103+
Timestamp math.HexOrDecimal64
104+
BaseFee *math.HexOrDecimal256
105+
ExcessBlobGas *math.HexOrDecimal64
103106
}
104107

105108
//go:generate go run github.com/fjl/gencodec -type stTransaction -field-override stTransactionMarshaling -out gen_sttransaction.go
@@ -283,6 +286,9 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
283286
context.Random = &rnd
284287
context.Difficulty = big.NewInt(0)
285288
}
289+
if config.IsCancun(new(big.Int), block.Time()) && t.json.Env.ExcessBlobGas != nil {
290+
context.BlobBaseFee = eip4844.CalcBlobFee(*t.json.Env.ExcessBlobGas)
291+
}
286292
evm := vm.NewEVM(context, txContext, statedb, config, vmconfig)
287293

288294
// Execute the message.

0 commit comments

Comments
 (0)