@@ -69,11 +69,6 @@ func main() {
6969 }
7070 periodStore := store .NewPeriodStore (db )
7171
72- domains := make ([]uint8 , 0 )
73- for domain := range cfg .Domains {
74- domains = append (domains , domain )
75- }
76-
7772 proverClient := jsonrpc .NewClient (cfg .Prover .URL )
7873
7974 msgChan := make (chan []* message.Message )
@@ -106,33 +101,41 @@ func main() {
106101 t := monitored .NewMonitoredTransactor (transaction .NewTransaction , gasPricer , client , big .NewInt (config .MaxGasPrice ), big .NewInt (config .GasIncreasePercentage ))
107102 go t .Monitor (ctx , time .Minute * 3 , time .Minute * 10 , time .Minute )
108103
109- beaconClient , err := http .New (ctx ,
110- http .WithAddress (config .BeaconEndpoint ),
111- http .WithLogLevel (logLevel ),
112- http .WithTimeout (time .Second * 30 ),
113- )
114- if err != nil {
115- panic (err )
116- }
117- beaconProvider := beaconClient .(* http.Service )
118-
119- storedPeriod , err := periodStore .Period (id )
120- if err != nil {
121- panic (err )
104+ var evmListener * listener.EVMListener
105+ if len (config .TargetDomains ) > 0 {
106+ beaconClient , err := http .New (ctx ,
107+ http .WithAddress (config .BeaconEndpoint ),
108+ http .WithLogLevel (logLevel ),
109+ http .WithTimeout (time .Second * 30 ),
110+ )
111+ if err != nil {
112+ panic (err )
113+ }
114+ beaconProvider := beaconClient .(* http.Service )
115+
116+ storedPeriod , err := periodStore .Period (id )
117+ if err != nil {
118+ panic (err )
119+ }
120+ var latestPeriod * big.Int
121+ if (storedPeriod .Uint64 () >= config .StartingPeriod ) && ! config .ForcePeriod {
122+ latestPeriod = storedPeriod
123+ } else {
124+ latestPeriod = big .NewInt (int64 (config .StartingPeriod ))
125+ }
126+
127+ targetDomains := make ([]uint8 , len (config .TargetDomains ))
128+ for i , d := range config .TargetDomains {
129+ targetDomains [i ] = uint8 (d )
130+ }
131+
132+ lightClient := lightclient .NewLightClient (config .BeaconEndpoint )
133+ p := prover .NewProver (proverClient , beaconProvider , lightClient , prover .Spec (config .Spec ), config .FinalityThreshold , config .SlotsPerEpoch )
134+ routerAddress := common .HexToAddress (config .Router )
135+ stepHandler := handlers .NewStepEventHandler (msgChan , client , beaconProvider , p , routerAddress , id , targetDomains )
136+ rotateHandler := handlers .NewRotateHandler (msgChan , periodStore , p , id , targetDomains , config .CommitteePeriodLength , latestPeriod )
137+ evmListener = listener .NewEVMListener (beaconProvider , []listener.EventHandler {rotateHandler , stepHandler }, id , time .Duration (config .RetryInterval )* time .Second )
122138 }
123- var latestPeriod * big.Int
124- if (storedPeriod .Uint64 () >= config .StartingPeriod ) && ! config .ForcePeriod {
125- latestPeriod = storedPeriod
126- } else {
127- latestPeriod = big .NewInt (int64 (config .StartingPeriod ))
128- }
129-
130- lightClient := lightclient .NewLightClient (config .BeaconEndpoint )
131- p := prover .NewProver (proverClient , beaconProvider , lightClient , prover .Spec (config .Spec ), config .FinalityThreshold , config .SlotsPerEpoch )
132- routerAddress := common .HexToAddress (config .Router )
133- stepHandler := handlers .NewStepEventHandler (msgChan , client , beaconProvider , p , routerAddress , id , domains )
134- rotateHandler := handlers .NewRotateHandler (msgChan , periodStore , p , id , domains , config .CommitteePeriodLength , latestPeriod )
135- listener := listener .NewEVMListener (beaconProvider , []listener.EventHandler {rotateHandler , stepHandler }, id , time .Duration (config .RetryInterval )* time .Second )
136139
137140 messageHandler := message .NewMessageHandler ()
138141 rotateMessageHandler := evmMessage.EvmRotateHandler {}
@@ -143,7 +146,7 @@ func main() {
143146 spectre := contracts .NewSpectreContract (common .HexToAddress (config .Spectre ), t )
144147 executor := executor .NewEVMExecutor (id , spectre )
145148
146- chain := evm .NewEVMChain (listener , messageHandler , executor , id , nil )
149+ chain := evm .NewEVMChain (evmListener , messageHandler , executor , id , nil )
147150 chains [id ] = chain
148151 }
149152 default :
0 commit comments