@@ -17,7 +17,6 @@ import (
1717 "time"
1818
1919 hotshotClient "github.com/EspressoSystems/espresso-network/sdks/go/client"
20- lightclient "github.com/EspressoSystems/espresso-network/sdks/go/light-client"
2120 "github.com/andybalholm/brotli"
2221 "github.com/spf13/pflag"
2322
@@ -287,7 +286,6 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) {
287286 f .Uint64 (prefix + ".hotshot-block" , DefaultBatchPosterConfig .HotShotBlock , "specifies the hotshot block number to start the espresso streamer on" )
288287 f .Uint64 (prefix + ".hotshot-first-posting-block" , DefaultBatchPosterConfig .HotShotFirstPostingBlock , "specifies the l1 block number when this rollup started posting to hotshot" )
289288 f .Uint64 (prefix + ".espresso-event-polling-step" , DefaultBatchPosterConfig .EspressoEventPollingStep , "specifies the number of blocks at a time to query when searching for logs emitted by batch posting." )
290- f .String (prefix + ".light-client-address" , DefaultBatchPosterConfig .LightClientAddress , "specifies the hotshot light client address if we are batching in espresso mode" )
291289 f .Uint64 (prefix + ".gas-estimate-base-fee-multiple-bips" , uint64 (DefaultBatchPosterConfig .GasEstimateBaseFeeMultipleBips ), "for gas estimation, use this multiple of the basefee (measured in basis points) as the max fee per gas" )
292290 f .Duration (prefix + ".reorg-resistance-margin" , DefaultBatchPosterConfig .ReorgResistanceMargin , "do not post batch if its within this duration from layer 1 minimum bounds. Requires l1-block-bound option not be set to \" ignore\" " )
293291 f .Bool (prefix + ".check-batch-correctness" , DefaultBatchPosterConfig .CheckBatchCorrectness , "setting this to true will run the batch against an inbox multiplexer and verifies that it produces the correct set of messages" )
@@ -353,7 +351,6 @@ var DefaultBatchPosterConfig = BatchPosterConfig{
353351 EspressoTxnsSendingInterval : 125 * time .Millisecond ,
354352 EspressoTxnsResubmissionInterval : 2 * time .Second ,
355353 ResubmitEspressoTxDeadline : 10 * time .Minute ,
356- LightClientAddress : "" ,
357354 HotShotUrls : []string {},
358355 EspressoTeeType : "SGX" ,
359356 EspressoRegisterSignerConfig : espressotee .DefaultEspressoRegisterSignerConfig ,
@@ -404,7 +401,6 @@ var TestBatchPosterConfig = BatchPosterConfig{
404401 EspressoTxnsPollingInterval : time .Second ,
405402 EspressoTxnsSendingInterval : time .Second ,
406403 EspressoTxnsResubmissionInterval : 2 * time .Second ,
407- LightClientAddress : "" ,
408404 ResubmitEspressoTxDeadline : 10 * time .Second ,
409405 HotShotUrls : []string {},
410406 EspressoTeeType : "SGX" ,
@@ -562,170 +558,161 @@ func NewBatchPoster(ctx context.Context, opts *BatchPosterOpts) (*BatchPoster, e
562558 }
563559
564560 // Espresso Config Round 2
565- {
566- hotShotUrls := opts .Config ().HotShotUrls
561+ hotShotUrls := opts .Config ().HotShotUrls
567562
568- lightClientAddr := opts .Config ().LightClientAddress
569- hotShotUrlsLen := len (hotShotUrls )
563+ hotShotUrlsLen := len (hotShotUrls )
570564
571- submitterOptions = append (submitterOptions , WithTransactionStreamer (opts .Streamer ))
565+ submitterOptions = append (submitterOptions , WithTransactionStreamer (opts .Streamer ))
572566
573- // If the length of the hotshot urls is greater than zero, and it's not length 1 with an empty string, create the espresso multiple nodes client.
574- if hotShotUrlsLen != 0 && ! (hotShotUrls [0 ] == "" && hotShotUrlsLen == 1 ) {
575- hotShotClient , err := hotshotClient .NewMultipleNodesClient (hotShotUrls )
576- if err != nil {
577- log .Crit ("Failed to create hotshot client" , "err" , err )
578- }
579- submitterOptions = append (submitterOptions , submitter .WithEspressoClient (hotShotClient ))
567+ // If the length of the hotshot urls is greater than zero, and it's not length 1 with an empty string, create the espresso multiple nodes client.
568+ if hotShotUrlsLen != 0 && ! (hotShotUrls [0 ] == "" && hotShotUrlsLen == 1 ) {
569+ hotShotClient , err := hotshotClient .NewMultipleNodesClient (hotShotUrls )
570+ if err != nil {
571+ log .Crit ("Failed to create hotshot client" , "err" , err )
572+ }
573+ submitterOptions = append (submitterOptions , submitter .WithEspressoClient (hotShotClient ))
580574
581- if err != nil {
582- return nil , fmt .Errorf ("failed to create espresso original submitter: %w" , err )
583- }
575+ if err != nil {
576+ return nil , fmt .Errorf ("failed to create espresso original submitter: %w" , err )
577+ }
584578
585- // If hotshot url is set, also set the sequencer inbox
586- if seqInbox == nil {
587- log .Error ("espresso mode enabled without a sequencer inbox address" )
588- return nil , fmt .Errorf ("espresso mode enabled without a sequencer inbox address" )
589- }
590- bridgeAddress , err := seqInbox .Bridge (& bind.CallOpts {Context : context .Background ()})
591- if err != nil {
592- return nil , fmt .Errorf ("espresso mode enabled bridge" )
593- }
594- bridge , err := bridgegen .NewBridge (bridgeAddress , opts .L1Reader .Client ())
595- if err != nil {
596- return nil , fmt .Errorf ("espresso mode enabled without bridge" )
597- }
579+ // If hotshot url is set, also set the sequencer inbox
580+ if seqInbox == nil {
581+ log .Error ("espresso mode enabled without a sequencer inbox address" )
582+ return nil , fmt .Errorf ("espresso mode enabled without a sequencer inbox address" )
583+ }
584+ bridgeAddress , err := seqInbox .Bridge (& bind.CallOpts {Context : context .Background ()})
585+ if err != nil {
586+ return nil , fmt .Errorf ("espresso mode enabled bridge" )
587+ }
588+ bridge , err := bridgegen .NewBridge (bridgeAddress , opts .L1Reader .Client ())
589+ if err != nil {
590+ return nil , fmt .Errorf ("espresso mode enabled without bridge" )
591+ }
598592
599- // check if the pos is already finalized on L1
600- // and get the current finalized block number from L1
601- blockNumber , err := opts .L1Reader .LatestFinalizedBlockNr (context .Background ())
602- if err != nil {
603- return nil , fmt .Errorf ("failed to get finalized block number: %w" , err )
604- }
593+ // check if the pos is already finalized on L1
594+ // and get the current finalized block number from L1
595+ blockNumber , err := opts .L1Reader .LatestFinalizedBlockNr (context .Background ())
596+ if err != nil {
597+ return nil , fmt .Errorf ("failed to get finalized block number: %w" , err )
598+ }
605599
606- // Edge case: its possible that batch poster is started even before the `DeployedAt` block is finalized
607- // in that case we should use the `DeployedAt` block number because no message would have been posted before that
608- if blockNumber < opts .DeployInfo .DeployedAt {
609- blockNumber = opts .DeployInfo .DeployedAt
610- }
600+ // Edge case: its possible that batch poster is started even before the `DeployedAt` block is finalized
601+ // in that case we should use the `DeployedAt` block number because no message would have been posted before that
602+ if blockNumber < opts .DeployInfo .DeployedAt {
603+ blockNumber = opts .DeployInfo .DeployedAt
604+ }
611605
612- sequencerMessageCount , err := bridge .SequencerReportedSubMessageCount (& bind.CallOpts {
613- BlockNumber : new (big.Int ).SetUint64 (blockNumber ),
614- })
615- if err != nil {
616- return nil , fmt .Errorf ("failed to get sequencerMessageCount: %w" , err )
617- }
606+ sequencerMessageCount , err := bridge .SequencerReportedSubMessageCount (& bind.CallOpts {
607+ BlockNumber : new (big.Int ).SetUint64 (blockNumber ),
608+ })
609+ if err != nil {
610+ return nil , fmt .Errorf ("failed to get sequencerMessageCount: %w" , err )
611+ }
618612
619- submitterOptions = append (submitterOptions , submitter .WithInitialFinalizedSequencerMessageCount (sequencerMessageCount ))
613+ submitterOptions = append (submitterOptions , submitter .WithInitialFinalizedSequencerMessageCount (sequencerMessageCount ))
620614
621- initStringAddresses := opts .Config ().InitBatcherAddresses
622- // Convert the init addresses to common.Address
623- initAddresses := []common.Address {}
624- for _ , addr := range initStringAddresses {
625- initAddresses = append (initAddresses , common .HexToAddress (addr ))
615+ initStringAddresses := opts .Config ().InitBatcherAddresses
616+ // Convert the init addresses to common.Address
617+ initAddresses := []common.Address {}
618+ for _ , addr := range initStringAddresses {
619+ initAddresses = append (initAddresses , common .HexToAddress (addr ))
620+ }
621+ if len (initAddresses ) == 0 {
622+ addr , err := recoverAddressFromSigner (opts .DataSigner )
623+ if err != nil {
624+ return nil , fmt .Errorf ("failed to recover address from signer: %w" , err )
626625 }
627- if len (initAddresses ) == 0 {
628- addr , err := recoverAddressFromSigner (opts .DataSigner )
629- if err != nil {
630- return nil , fmt .Errorf ("failed to recover address from signer: %w" , err )
631- }
632626
633- initAddresses = []common.Address {addr }
634- }
627+ initAddresses = []common.Address {addr }
628+ }
635629
636- monitor := NewBatcherAddrMonitor (
637- initAddresses ,
638- opts .DataPosterDB ,
639- opts .L1Reader ,
640- opts .DeployInfo .SequencerInbox ,
641- opts .DeployInfo .DeployedAt ,
642- opts .Config ().AddressMonitorStartL1 ,
643- opts .Config ().AddressMonitorStep ,
644- )
630+ monitor := NewBatcherAddrMonitor (
631+ initAddresses ,
632+ opts .DataPosterDB ,
633+ opts .L1Reader ,
634+ opts .DeployInfo .SequencerInbox ,
635+ opts .DeployInfo .DeployedAt ,
636+ opts .Config ().AddressMonitorStartL1 ,
637+ opts .Config ().AddressMonitorStep ,
638+ )
645639
646- espressoStreamer := espressostreamer .NewEspressoStreamer (
647- opts .ChainID ,
648- opts .Config ().HotShotBlock ,
649- nil ,
650- hotShotClient ,
651- false ,
652- monitor .GetValidAddresses ,
653- opts .Config ().EspressoTxnsPollingInterval ,
654- opts .Config ().Dangerous .MinimumHotshotBlockNum ,
655- )
640+ espressoStreamer := espressostreamer .NewEspressoStreamer (
641+ opts .ChainID ,
642+ opts .Config ().HotShotBlock ,
643+ nil ,
644+ hotShotClient ,
645+ false ,
646+ monitor .GetValidAddresses ,
647+ opts .Config ().EspressoTxnsPollingInterval ,
648+ opts .Config ().Dangerous .MinimumHotshotBlockNum ,
649+ )
656650
657- b .espressoBatcherAddrMonitor = monitor
658- b .espressoStreamer = espressoStreamer
659- }
651+ b .espressoBatcherAddrMonitor = monitor
652+ b .espressoStreamer = espressoStreamer
653+ }
660654
661- if lightClientAddr != "" {
662- lightClientReader , err := lightclient .NewLightClientReader (common .HexToAddress (lightClientAddr ), opts .L1Reader .Client ())
663- if err != nil {
664- return nil , err
665- }
655+ if b .espressoStreamer != nil {
656+ cfg := opts .Config ()
657+
658+ submitterOptions = append (
659+ submitterOptions ,
660+ submitter .WithTxnsPollingInterval (cfg .EspressoTxnsPollingInterval ),
661+ submitter .WithTxnsSendingInterval (cfg .EspressoTxnsSendingInterval ),
662+ submitter .WithTxnsResubmissionInterval (cfg .EspressoTxnsResubmissionInterval ),
663+ submitter .WithResubmitEspressoTxDeadline (cfg .ResubmitEspressoTxDeadline ),
664+ submitter .WithMaxTransactionSize (cfg .EspressoTxSizeLimit ),
665+ )
666666
667- cfg := opts .Config ()
667+ // Get the espressoTEEVerifier address for the sequencer inbox contract
668+ espresssoTEEVerifierAddress , err := seqInbox .EspressoTEEVerifier (& bind.CallOpts {})
669+ if err != nil {
670+ return nil , err
671+ }
668672
669- submitterOptions = append (
670- submitterOptions ,
671- submitter .WithLightClientReader (lightClientReader ),
672- submitter .WithTxnsPollingInterval (cfg .EspressoTxnsPollingInterval ),
673- submitter .WithTxnsSendingInterval (cfg .EspressoTxnsSendingInterval ),
674- submitter .WithTxnsResubmissionInterval (cfg .EspressoTxnsResubmissionInterval ),
675- submitter .WithResubmitEspressoTxDeadline (cfg .ResubmitEspressoTxDeadline ),
676- submitter .WithMaxTransactionSize (cfg .EspressoTxSizeLimit ),
677- )
673+ teeVerifier , err := espressogen .NewIEspressoTEEVerifier (
674+ espresssoTEEVerifierAddress ,
675+ opts .L1Reader .Client ())
676+ if err != nil {
677+ return nil , err
678+ }
679+ verifier := espressotee .NewEspressoTEEVerifier (teeVerifier , opts .L1Reader .Client (), espresssoTEEVerifierAddress )
678680
679- // Get the espressoTEEVerifier address for the sequencer inbox contract
680- espresssoTEEVerifierAddress , err := seqInbox .EspressoTEEVerifier (& bind.CallOpts {})
681- if err != nil {
682- return nil , err
683- }
681+ var teeType espressotee.TEE
682+ configTee := cfg .EspressoTeeType
683+ teeType , err = teeType .FromString (configTee )
684+ if err != nil {
685+ return nil , fmt .Errorf ("unsupported tee type in config: %s" , configTee )
686+ }
684687
685- teeVerifier , err := espressogen .NewIEspressoTEEVerifier (
686- espresssoTEEVerifierAddress ,
687- opts .L1Reader .Client ())
688+ var nitroVerifier espressotee.EspressoNitroTEEVerifierInterface
689+ if teeType == espresso_key_manager .NITRO {
690+ log .Info ("setting up nitro verifier" , "tee type" , teeType )
691+ nitroVerifier , err = setupNitroVerifier (teeVerifier , opts .L1Reader .Client ())
688692 if err != nil {
689693 return nil , err
690694 }
691- verifier := espressotee .NewEspressoTEEVerifier (teeVerifier , opts .L1Reader .Client (), espresssoTEEVerifierAddress )
692-
693- var teeType espressotee.TEE
694- configTee := cfg .EspressoTeeType
695- teeType , err = teeType .FromString (configTee )
696- if err != nil {
697- return nil , fmt .Errorf ("unsupported tee type in config: %s" , configTee )
698- }
699-
700- var nitroVerifier espressotee.EspressoNitroTEEVerifierInterface
701- if teeType == espresso_key_manager .NITRO {
702- log .Info ("setting up nitro verifier" , "tee type" , teeType )
703- nitroVerifier , err = setupNitroVerifier (teeVerifier , opts .L1Reader .Client ())
704- if err != nil {
705- return nil , err
706- }
707- }
708-
709- if b .dataPoster .Auth () == nil {
710- panic ("TransactOpts is nil" )
711- }
712- submitterOptions = append (
713- submitterOptions ,
714- submitter .WithKeyManager (
715- espresso_key_manager .NewEspressoKeyManager (verifier , nitroVerifier , b .dataPoster , opts .DataSigner , teeType , cfg .EspressoRegisterSignerConfig ),
716- ),
717- )
695+ }
718696
719- submitter , err := submitter .NewPollingEspressoSubmitter (
720- submitterOptions ... ,
721- )
697+ if b .dataPoster .Auth () == nil {
698+ panic ("TransactOpts is nil" )
699+ }
700+ submitterOptions = append (
701+ submitterOptions ,
702+ submitter .WithKeyManager (
703+ espresso_key_manager .NewEspressoKeyManager (verifier , nitroVerifier , b .dataPoster , opts .DataSigner , teeType , cfg .EspressoRegisterSignerConfig ),
704+ ),
705+ )
722706
723- if err != nil {
724- return nil , fmt . Errorf ( "failed to create espresso original submitter: %w" , err )
725- }
707+ submitter , err := submitter . NewPollingEspressoSubmitter (
708+ submitterOptions ... ,
709+ )
726710
727- opts .Streamer .espressoSubmitter = submitter
711+ if err != nil {
712+ return nil , fmt .Errorf ("failed to create espresso original submitter: %w" , err )
728713 }
714+
715+ opts .Streamer .espressoSubmitter = submitter
729716 }
730717
731718 return b , nil
0 commit comments