@@ -23,6 +23,7 @@ import (
23
23
"math/big"
24
24
25
25
"github.com/ethereum/go-ethereum/common"
26
+ "github.com/ethereum/go-ethereum/common/hexutil"
26
27
"github.com/ethereum/go-ethereum/common/math"
27
28
"github.com/ethereum/go-ethereum/consensus/ethash"
28
29
"github.com/ethereum/go-ethereum/consensus/misc"
@@ -50,6 +51,8 @@ type Prestate struct {
50
51
Pre types.GenesisAlloc `json:"pre"`
51
52
}
52
53
54
+ //go:generate go run github.com/fjl/gencodec -type ExecutionResult -field-override executionResultMarshaling -out gen_execresult.go
55
+
53
56
// ExecutionResult contains the execution status after running a state test, any
54
57
// error that might have occurred and a dump of the final state if requested.
55
58
type ExecutionResult struct {
@@ -70,6 +73,10 @@ type ExecutionResult struct {
70
73
Requests [][]byte `json:"requests,omitempty"`
71
74
}
72
75
76
+ type executionResultMarshaling struct {
77
+ Requests []hexutil.Bytes `json:"requests,omitempty"`
78
+ }
79
+
73
80
type ommer struct {
74
81
Delta uint64 `json:"delta"`
75
82
Address common.Address `json:"address"`
@@ -354,6 +361,28 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
354
361
amount := new (big.Int ).Mul (new (big.Int ).SetUint64 (w .Amount ), big .NewInt (params .GWei ))
355
362
statedb .AddBalance (w .Address , uint256 .MustFromBig (amount ), tracing .BalanceIncreaseWithdrawal )
356
363
}
364
+
365
+ // Gather the execution-layer triggered requests.
366
+ var requests [][]byte
367
+ if chainConfig .IsPrague (vmContext .BlockNumber , vmContext .Time ) {
368
+ // EIP-6110 deposits
369
+ var allLogs []* types.Log
370
+ for _ , receipt := range receipts {
371
+ allLogs = append (allLogs , receipt .Logs ... )
372
+ }
373
+ depositRequests , err := core .ParseDepositLogs (allLogs , chainConfig )
374
+ if err != nil {
375
+ return nil , nil , nil , NewError (ErrorEVM , fmt .Errorf ("could not parse requests logs: %v" , err ))
376
+ }
377
+ requests = append (requests , depositRequests )
378
+ // create EVM for system calls
379
+ vmenv := vm .NewEVM (vmContext , vm.TxContext {}, statedb , chainConfig , vm.Config {})
380
+ // EIP-7002 withdrawals
381
+ requests = append (requests , core .ProcessWithdrawalQueue (vmenv , statedb ))
382
+ // EIP-7251 consolidations
383
+ requests = append (requests , core .ProcessConsolidationQueue (vmenv , statedb ))
384
+ }
385
+
357
386
// Commit block
358
387
root , err := statedb .Commit (vmContext .BlockNumber .Uint64 (), chainConfig .IsEIP158 (vmContext .BlockNumber ))
359
388
if err != nil {
@@ -379,32 +408,14 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
379
408
execRs .CurrentExcessBlobGas = (* math .HexOrDecimal64 )(& excessBlobGas )
380
409
execRs .CurrentBlobGasUsed = (* math .HexOrDecimal64 )(& blobGasUsed )
381
410
}
382
-
383
- var requests [][]byte
384
- if chainConfig .IsPrague (vmContext .BlockNumber , vmContext .Time ) {
385
- // EIP-6110 deposits
386
- var allLogs []* types.Log
387
- for _ , receipt := range receipts {
388
- allLogs = append (allLogs , receipt .Logs ... )
389
- }
390
- depositRequests , err := core .ParseDepositLogs (allLogs , chainConfig )
391
- if err != nil {
392
- return nil , nil , nil , NewError (ErrorEVM , fmt .Errorf ("could not parse requests logs: %v" , err ))
393
- }
394
- requests = append (requests , depositRequests )
395
- // create EVM for system calls
396
- vmenv := vm .NewEVM (vmContext , vm.TxContext {}, statedb , chainConfig , vm.Config {})
397
- // EIP-7002 withdrawals
398
- withdrawalRequests := core .ProcessWithdrawalQueue (vmenv , statedb )
399
- requests = append (requests , withdrawalRequests )
400
- // EIP-7251 consolidations
401
- consolidationRequests := core .ProcessConsolidationQueue (vmenv , statedb )
402
- requests = append (requests , consolidationRequests )
403
- }
404
411
if requests != nil {
405
412
// Set requestsHash on block.
406
413
h := types .CalcRequestsHash (requests )
407
414
execRs .RequestsHash = & h
415
+ for i := range requests {
416
+ // remove prefix
417
+ requests [i ] = requests [i ][1 :]
418
+ }
408
419
execRs .Requests = requests
409
420
}
410
421
0 commit comments