1
1
package enclave
2
2
3
3
import (
4
- "bytes"
5
4
"context"
6
5
"errors"
7
6
"fmt"
@@ -26,7 +25,7 @@ func ExecuteStateless(
26
25
l1Receipts types.Receipts ,
27
26
previousBlockTxs []hexutil.Bytes ,
28
27
blockHeader * types.Header ,
29
- blockTxs []hexutil.Bytes ,
28
+ sequencedTxs []hexutil.Bytes ,
30
29
witness * stateless.Witness ,
31
30
messageAccount * eth.AccountResult ,
32
31
) error {
@@ -42,6 +41,11 @@ func ExecuteStateless(
42
41
return errors .New ("invalid parent hash" )
43
42
}
44
43
44
+ // block must only contain deposit transactions if it is outside the sequencer drift
45
+ if len (sequencedTxs ) > 0 && blockHeader .Time > l1Origin .Time + maxSequencerDriftFjord {
46
+ return errors .New ("l1 origin is too old" )
47
+ }
48
+
45
49
unmarshalTxs := func (rlp []hexutil.Bytes ) (types.Transactions , error ) {
46
50
txs := make (types.Transactions , len (rlp ))
47
51
for i , tx := range rlp {
@@ -56,10 +60,6 @@ func ExecuteStateless(
56
60
if err != nil {
57
61
return err
58
62
}
59
- txs , err := unmarshalTxs (blockTxs )
60
- if err != nil {
61
- return err
62
- }
63
63
64
64
previousTxHash := types .DeriveSha (previousTxs , trie .NewStackTrie (nil ))
65
65
if previousTxHash != previousBlockHeader .TxHash {
@@ -90,25 +90,23 @@ func ExecuteStateless(
90
90
return fmt .Errorf ("failed to prepare payload attributes: %w" , err )
91
91
}
92
92
93
- if txs .Len () < len (payload .Transactions ) {
94
- return errors .New ("invalid transaction count" )
93
+ // sequencer cannot include manual deposit transactions; otherwise it could mint funds arbitrarily
94
+ txs , err := unmarshalTxs (sequencedTxs )
95
+ if err != nil {
96
+ return err
95
97
}
96
-
97
- for i , payloadTx := range payload .Transactions {
98
- tx := txs [i ]
99
- if ! tx .IsDepositTx () {
100
- return errors .New ("invalid transaction type" )
101
- }
102
- if ! bytes .Equal (blockTxs [i ], payloadTx ) {
103
- return errors .New ("invalid deposit transaction" )
98
+ for _ , tx := range txs {
99
+ if tx .IsDepositTx () {
100
+ return errors .New ("sequenced txs cannot include deposits" )
104
101
}
105
102
}
106
103
107
- // block must only contain deposit transactions if it is outside the sequencer drift
108
- if txs . Len () > len (payload .Transactions ) &&
109
- blockHeader . Time > l1Origin . Time + maxSequencerDriftFjord {
110
- return errors . New ( "L1 origin is too old" )
104
+ // now add the deposits from L1 (and any from fork upgrades)
105
+ payloadTxs , err := unmarshalTxs (payload .Transactions )
106
+ if err != nil {
107
+ return fmt . Errorf ( "failed to parse payload transactions: %w" , err )
111
108
}
109
+ txs = append (payloadTxs , txs ... )
112
110
113
111
expectedRoot := blockHeader .Root
114
112
expectedReceiptHash := blockHeader .ReceiptHash
0 commit comments