@@ -80,7 +80,8 @@ type stPostState struct {
8080
8181type stEnv struct {
8282 Coinbase common.Address `json:"currentCoinbase" gencodec:"required"`
83- Difficulty * big.Int `json:"currentDifficulty" gencodec:"required"`
83+ Difficulty * big.Int `json:"currentDifficulty" gencodec:"optional"`
84+ Random * big.Int `json:"currentRandom" gencodec:"optional"`
8485 GasLimit uint64 `json:"currentGasLimit" gencodec:"required"`
8586 Number uint64 `json:"currentNumber" gencodec:"required"`
8687 Timestamp uint64 `json:"currentTimestamp" gencodec:"required"`
@@ -90,6 +91,7 @@ type stEnv struct {
9091type stEnvMarshaling struct {
9192 Coinbase common.UnprefixedAddress
9293 Difficulty * math.HexOrDecimal256
94+ Random * math.HexOrDecimal256
9395 GasLimit math.HexOrDecimal64
9496 Number math.HexOrDecimal64
9597 Timestamp math.HexOrDecimal64
@@ -218,8 +220,11 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
218220 context := core .NewEVMBlockContext (block .Header (), nil , & t .json .Env .Coinbase )
219221 context .GetHash = vmTestBlockHash
220222 context .BaseFee = baseFee
223+ if t .json .Env .Random != nil {
224+ context .Random = common .BigToHash (t .json .Env .Random )
225+ context .Difficulty = nil
226+ }
221227 evm := vm .NewEVM (context , txContext , statedb , config , vmconfig )
222-
223228 // Execute the message.
224229 snapshot := statedb .Snapshot ()
225230 gaspool := new (core.GasPool )
@@ -268,7 +273,7 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter boo
268273}
269274
270275func (t * StateTest ) genesis (config * params.ChainConfig ) * core.Genesis {
271- return & core.Genesis {
276+ genesis := & core.Genesis {
272277 Config : config ,
273278 Coinbase : t .json .Env .Coinbase ,
274279 Difficulty : t .json .Env .Difficulty ,
@@ -277,6 +282,12 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
277282 Timestamp : t .json .Env .Timestamp ,
278283 Alloc : t .json .Pre ,
279284 }
285+ if t .json .Env .Random != nil {
286+ // Post-Merge
287+ genesis .Mixhash = common .BigToHash (t .json .Env .Random )
288+ genesis .Difficulty = nil
289+ }
290+ return genesis
280291}
281292
282293func (tx * stTransaction ) toMessage (ps stPostState , baseFee * big.Int ) (core.Message , error ) {
0 commit comments