@@ -372,10 +372,14 @@ func (s *ExecutionEngine) NextDelayedMessageNumber() (uint64, error) {
372372 return currentHeader .Nonce .Uint64 (), nil
373373}
374374
375- func MessageFromTxes (header * arbostypes.L1IncomingMessageHeader , txes types. Transactions , txErrors [] error ) (* arbostypes.L1IncomingMessage , error ) {
375+ func MessageFromTxes (header * arbostypes.L1IncomingMessageHeader , hooks * arbos. SequencingHooks ) (* arbostypes.L1IncomingMessage , error ) {
376376 var l2Message []byte
377- if len (txes ) == 1 && txErrors [0 ] == nil {
378- txBytes , err := txes [0 ].MarshalBinary ()
377+ if len (hooks .TxErrors ) == 1 && hooks .TxErrors [0 ] == nil {
378+ tx , err := hooks .SequencedTx (0 )
379+ if err != nil {
380+ return nil , err
381+ }
382+ txBytes , err := tx .MarshalBinary ()
379383 if err != nil {
380384 return nil , err
381385 }
@@ -384,10 +388,14 @@ func MessageFromTxes(header *arbostypes.L1IncomingMessageHeader, txes types.Tran
384388 } else {
385389 l2Message = append (l2Message , arbos .L2MessageKind_Batch )
386390 sizeBuf := make ([]byte , 8 )
387- for i , tx := range txes {
388- if txErrors [i ] != nil {
391+ for i := 0 ; i < len ( hooks . TxErrors ); i ++ {
392+ if hooks . TxErrors [i ] != nil {
389393 continue
390394 }
395+ tx , err := hooks .SequencedTx (i )
396+ if err != nil {
397+ return nil , err
398+ }
391399 txBytes , err := tx .MarshalBinary ()
392400 if err != nil {
393401 return nil , err
@@ -451,9 +459,9 @@ func (s *ExecutionEngine) resequenceReorgedMessages(messages []*arbostypes.Messa
451459 log .Warn ("failed to parse sequencer message found from reorg" , "err" , err )
452460 continue
453461 }
454- hooks := arbos .NoopSequencingHooks ()
462+ hooks := arbos .NoopSequencingHooks (txes )
455463 hooks .DiscardInvalidTxsEarly = true
456- _ , err = s .sequenceTransactionsWithBlockMutex (msg .Message .Header , txes , hooks , nil )
464+ _ , err = s .sequenceTransactionsWithBlockMutex (msg .Message .Header , hooks , nil )
457465 if err != nil {
458466 log .Error ("failed to re-sequence old user message removed by reorg" , "err" , err )
459467 return
@@ -490,17 +498,17 @@ func (s *ExecutionEngine) sequencerWrapper(sequencerFunc func() (*types.Block, e
490498 }
491499}
492500
493- func (s * ExecutionEngine ) SequenceTransactions (header * arbostypes.L1IncomingMessageHeader , txes types. Transactions , hooks * arbos.SequencingHooks , timeboostedTxs map [common.Hash ]struct {}) (* types.Block , error ) {
501+ func (s * ExecutionEngine ) SequenceTransactions (header * arbostypes.L1IncomingMessageHeader , hooks * arbos.SequencingHooks , timeboostedTxs map [common.Hash ]struct {}) (* types.Block , error ) {
494502 return s .sequencerWrapper (func () (* types.Block , error ) {
495503 hooks .TxErrors = nil
496- return s .sequenceTransactionsWithBlockMutex (header , txes , hooks , timeboostedTxs )
504+ return s .sequenceTransactionsWithBlockMutex (header , hooks , timeboostedTxs )
497505 })
498506}
499507
500508// SequenceTransactionsWithProfiling runs SequenceTransactions with tracing and
501509// CPU profiling enabled. If the block creation takes longer than 2 seconds, it
502510// keeps both and prints out filenames in an error log line.
503- func (s * ExecutionEngine ) SequenceTransactionsWithProfiling (header * arbostypes.L1IncomingMessageHeader , txes types. Transactions , hooks * arbos.SequencingHooks , timeboostedTxs map [common.Hash ]struct {}) (* types.Block , error ) {
511+ func (s * ExecutionEngine ) SequenceTransactionsWithProfiling (header * arbostypes.L1IncomingMessageHeader , hooks * arbos.SequencingHooks , timeboostedTxs map [common.Hash ]struct {}) (* types.Block , error ) {
504512 pprofBuf , traceBuf := bytes .NewBuffer (nil ), bytes .NewBuffer (nil )
505513 if err := pprof .StartCPUProfile (pprofBuf ); err != nil {
506514 log .Error ("Starting CPU profiling" , "error" , err )
@@ -509,7 +517,7 @@ func (s *ExecutionEngine) SequenceTransactionsWithProfiling(header *arbostypes.L
509517 log .Error ("Starting tracing" , "error" , err )
510518 }
511519 start := time .Now ()
512- res , err := s .SequenceTransactions (header , txes , hooks , timeboostedTxs )
520+ res , err := s .SequenceTransactions (header , hooks , timeboostedTxs )
513521 elapsed := time .Since (start )
514522 pprof .StopCPUProfile ()
515523 trace .Stop ()
@@ -535,7 +543,7 @@ func writeAndLog(pprof, trace *bytes.Buffer) {
535543 log .Info ("Transactions sequencing took longer than 2 seconds, created pprof and trace files" , "pprof" , pprofFile , "traceFile" , traceFile )
536544}
537545
538- func (s * ExecutionEngine ) sequenceTransactionsWithBlockMutex (header * arbostypes.L1IncomingMessageHeader , txes types. Transactions , hooks * arbos.SequencingHooks , timeboostedTxs map [common.Hash ]struct {}) (* types.Block , error ) {
546+ func (s * ExecutionEngine ) sequenceTransactionsWithBlockMutex (header * arbostypes.L1IncomingMessageHeader , hooks * arbos.SequencingHooks , timeboostedTxs map [common.Hash ]struct {}) (* types.Block , error ) {
539547 lastBlockHeader , err := s .getCurrentHeader ()
540548 if err != nil {
541549 return nil , err
@@ -563,7 +571,6 @@ func (s *ExecutionEngine) sequenceTransactionsWithBlockMutex(header *arbostypes.
563571 startTime := time .Now ()
564572 block , receipts , err := arbos .ProduceBlockAdvanced (
565573 header ,
566- txes ,
567574 delayedMessagesRead ,
568575 lastBlockHeader ,
569576 statedb ,
@@ -577,9 +584,6 @@ func (s *ExecutionEngine) sequenceTransactionsWithBlockMutex(header *arbostypes.
577584 }
578585 blockCalcTime := time .Since (startTime )
579586 blockExecutionTimer .Update (blockCalcTime .Nanoseconds ())
580- if len (hooks .TxErrors ) != len (txes ) {
581- return nil , fmt .Errorf ("unexpected number of error results: %v vs number of txes %v" , len (hooks .TxErrors ), len (txes ))
582- }
583587
584588 if len (receipts ) == 0 {
585589 return nil , nil
@@ -596,7 +600,7 @@ func (s *ExecutionEngine) sequenceTransactionsWithBlockMutex(header *arbostypes.
596600 return nil , nil
597601 }
598602
599- msg , err := MessageFromTxes (header , txes , hooks . TxErrors )
603+ msg , err := MessageFromTxes (header , hooks )
600604 if err != nil {
601605 return nil , err
602606 }
0 commit comments