4
4
"context"
5
5
"time"
6
6
7
- "github.com/ethereum/go-ethereum/common"
8
7
"github.com/ethereum/go-ethereum/ethclient"
9
8
gethLog "github.com/ethereum/go-ethereum/log"
10
9
"github.com/jackc/pgx/v4/pgxpool"
@@ -14,7 +13,6 @@ import (
14
13
validatorRegistryBindings "github.com/shutter-network/gnosh-contracts/gnoshcontracts/validatorregistry"
15
14
"golang.org/x/exp/slog"
16
15
17
- obskeyper "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
18
16
"github.com/shutter-network/rolling-shutter/rolling-shutter/eonkeypublisher"
19
17
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper"
20
18
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/epochkghandler"
@@ -174,67 +172,24 @@ func (kpr *Keyper) Start(ctx context.Context, runner service.Runner) error {
174
172
// keyper set. Otherwise, the syncer will only be initialized once such a keyper set is observed to
175
173
// be added, as only then we will know which eon(s) we are responsible for.
176
174
func (kpr * Keyper ) initSequencerSyncer (ctx context.Context ) error {
177
- obskeyperdb := obskeyper .New (kpr .dbpool )
178
- keyperSets , err := obskeyperdb .GetKeyperSets (ctx )
179
- if err != nil {
180
- return errors .Wrap (err , "failed to query keyper sets from db" )
181
- }
182
-
183
- keyperSetFound := false
184
- minEon := uint64 (0 )
185
- for _ , keyperSet := range keyperSets {
186
- for _ , m := range keyperSet .Keypers {
187
- mAddress := common .HexToAddress (m )
188
- if mAddress .Cmp (kpr .config .GetAddress ()) == 0 {
189
- keyperSetFound = true
190
- if minEon > uint64 (keyperSet .KeyperConfigIndex ) {
191
- minEon = uint64 (keyperSet .KeyperConfigIndex )
192
- }
193
- break
194
- }
195
- }
196
- }
197
-
198
- if keyperSetFound {
199
- err := kpr .ensureSequencerSyncing (ctx , minEon )
200
- if err != nil {
201
- return err
202
- }
203
- }
204
- return nil
205
- }
206
-
207
- func (kpr * Keyper ) ensureSequencerSyncing (ctx context.Context , eon uint64 ) error {
208
175
client , err := ethclient .DialContext (ctx , kpr .config .Gnosis .Node .ContractsURL )
209
176
if err != nil {
210
177
return errors .Wrap (err , "failed to dial Ethereum execution node" )
211
178
}
212
179
213
- if kpr .sequencerSyncer == nil {
214
- log .Info ().
215
- Uint64 ("eon" , eon ).
216
- Str ("contract-address" , kpr .config .Gnosis .Contracts .KeyperSetManager .Hex ()).
217
- Msg ("initializing sequencer syncer" )
218
- contract , err := sequencerBindings .NewSequencer (kpr .config .Gnosis .Contracts .Sequencer , client )
219
- if err != nil {
220
- return err
221
- }
222
- kpr .sequencerSyncer = & SequencerSyncer {
223
- Contract : contract ,
224
- DBPool : kpr .dbpool ,
225
- ExecutionClient : client ,
226
- StartEon : eon ,
227
- GenesisSlotTimestamp : kpr .config .Gnosis .GenesisSlotTimestamp ,
228
- SecondsPerSlot : kpr .config .Gnosis .SecondsPerSlot ,
229
- }
180
+ log .Info ().
181
+ Str ("contract-address" , kpr .config .Gnosis .Contracts .KeyperSetManager .Hex ()).
182
+ Msg ("initializing sequencer syncer" )
183
+ contract , err := sequencerBindings .NewSequencer (kpr .config .Gnosis .Contracts .Sequencer , client )
184
+ if err != nil {
185
+ return err
230
186
}
231
-
232
- if eon < kpr .sequencerSyncer .StartEon {
233
- log .Info ().
234
- Uint64 ("old-start-eon" , kpr .sequencerSyncer .StartEon ).
235
- Uint64 ("new-start-eon" , eon ).
236
- Msg ("decreasing sequencer syncing start eon" )
237
- kpr .sequencerSyncer .StartEon = eon
187
+ kpr .sequencerSyncer = & SequencerSyncer {
188
+ Contract : contract ,
189
+ DBPool : kpr .dbpool ,
190
+ ExecutionClient : client ,
191
+ GenesisSlotTimestamp : kpr .config .Gnosis .GenesisSlotTimestamp ,
192
+ SecondsPerSlot : kpr .config .Gnosis .SecondsPerSlot ,
238
193
}
239
194
240
195
// Perform an initial sync now because it might take some time and doing so during regular
0 commit comments