@@ -69,11 +69,6 @@ func main() {
69
69
}
70
70
periodStore := store .NewPeriodStore (db )
71
71
72
- domains := make ([]uint8 , 0 )
73
- for domain := range cfg .Domains {
74
- domains = append (domains , domain )
75
- }
76
-
77
72
proverClient := jsonrpc .NewClient (cfg .Prover .URL )
78
73
79
74
msgChan := make (chan []* message.Message )
@@ -106,33 +101,41 @@ func main() {
106
101
t := monitored .NewMonitoredTransactor (transaction .NewTransaction , gasPricer , client , big .NewInt (config .MaxGasPrice ), big .NewInt (config .GasIncreasePercentage ))
107
102
go t .Monitor (ctx , time .Minute * 3 , time .Minute * 10 , time .Minute )
108
103
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 )
122
138
}
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 )
136
139
137
140
messageHandler := message .NewMessageHandler ()
138
141
rotateMessageHandler := evmMessage.EvmRotateHandler {}
@@ -143,7 +146,7 @@ func main() {
143
146
spectre := contracts .NewSpectreContract (common .HexToAddress (config .Spectre ), t )
144
147
executor := executor .NewEVMExecutor (id , spectre )
145
148
146
- chain := evm .NewEVMChain (listener , messageHandler , executor , id , nil )
149
+ chain := evm .NewEVMChain (evmListener , messageHandler , executor , id , nil )
147
150
chains [id ] = chain
148
151
}
149
152
default :
0 commit comments