Skip to content

Commit ee9d7a6

Browse files
committed
Do not consider eon in sequencer syncer
This removes some unnecessary complexity. In particular, it means we can perform an initial sequencer sync at startup, instead of only when we receive a keyper set.
1 parent 912e468 commit ee9d7a6

File tree

3 files changed

+14
-67
lines changed

3 files changed

+14
-67
lines changed

rolling-shutter/keyperimpl/gnosis/keyper.go

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"time"
66

7-
"github.com/ethereum/go-ethereum/common"
87
"github.com/ethereum/go-ethereum/ethclient"
98
gethLog "github.com/ethereum/go-ethereum/log"
109
"github.com/jackc/pgx/v4/pgxpool"
@@ -14,7 +13,6 @@ import (
1413
validatorRegistryBindings "github.com/shutter-network/gnosh-contracts/gnoshcontracts/validatorregistry"
1514
"golang.org/x/exp/slog"
1615

17-
obskeyper "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
1816
"github.com/shutter-network/rolling-shutter/rolling-shutter/eonkeypublisher"
1917
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper"
2018
"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 {
174172
// keyper set. Otherwise, the syncer will only be initialized once such a keyper set is observed to
175173
// be added, as only then we will know which eon(s) we are responsible for.
176174
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 {
208175
client, err := ethclient.DialContext(ctx, kpr.config.Gnosis.Node.ContractsURL)
209176
if err != nil {
210177
return errors.Wrap(err, "failed to dial Ethereum execution node")
211178
}
212179

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
230186
}
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,
238193
}
239194

240195
// Perform an initial sync now because it might take some time and doing so during regular

rolling-shutter/keyperimpl/gnosis/newkeyperset.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ func (kpr *Keyper) processNewKeyperSet(ctx context.Context, ev *syncevent.Keyper
2929
Bool("is-member", isMember).
3030
Msg("new keyper set added")
3131

32-
if isMember {
33-
if err := kpr.ensureSequencerSyncing(ctx, ev.Eon); err != nil {
34-
return err
35-
}
36-
}
37-
3832
return kpr.dbpool.BeginFunc(ctx, func(tx pgx.Tx) error {
3933
obskeyperdb := obskeyper.New(tx)
4034

rolling-shutter/keyperimpl/gnosis/sequencersyncer.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type SequencerSyncer struct {
2424
Contract *sequencerBindings.Sequencer
2525
DBPool *pgxpool.Pool
2626
ExecutionClient *ethclient.Client
27-
StartEon uint64
2827
GenesisSlotTimestamp uint64
2928
SecondsPerSlot uint64
3029
}
@@ -126,16 +125,15 @@ func (s *SequencerSyncer) filterEvents(
126125
) []*sequencerBindings.SequencerTransactionSubmitted {
127126
filteredEvents := []*sequencerBindings.SequencerTransactionSubmitted{}
128127
for _, event := range events {
129-
if event.Eon < s.StartEon ||
130-
event.Eon > math.MaxInt64 ||
128+
if event.Eon > math.MaxInt64 ||
131129
!event.GasLimit.IsInt64() {
132130
log.Debug().
133131
Uint64("eon", event.Eon).
134132
Uint64("block-number", event.Raw.BlockNumber).
135133
Str("block-hash", event.Raw.BlockHash.Hex()).
136134
Uint("tx-index", event.Raw.TxIndex).
137135
Uint("log-index", event.Raw.Index).
138-
Msg("ignoring transaction submitted event")
136+
Msg("ignoring transaction submitted event with high eon")
139137
continue
140138
}
141139
filteredEvents = append(filteredEvents, event)

0 commit comments

Comments
 (0)