From 5ab4c47bfabd236869f62dd013b75ab78876df8e Mon Sep 17 00:00:00 2001 From: Mikhail Wall Date: Fri, 21 Jun 2024 15:31:40 +0200 Subject: [PATCH] fix: changed to not start from 0 (#166) * fix: changed to not start from 0 * fix: increased timeout --- oracle/pkg/l1Listener/l1Listener.go | 9 +++++++-- oracle/pkg/l1Listener/l1Listener_test.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/oracle/pkg/l1Listener/l1Listener.go b/oracle/pkg/l1Listener/l1Listener.go index 90065a7e7..b8f3d0e71 100644 --- a/oracle/pkg/l1Listener/l1Listener.go +++ b/oracle/pkg/l1Listener/l1Listener.go @@ -130,7 +130,12 @@ func (l *L1Listener) watchL1Block(ctx context.Context) error { ticker := time.NewTicker(checkInterval) defer ticker.Stop() - currentBlockNo := 0 + // TODO: change it to the store to not miss blocks, if oracle is down + currentBlockNo, err := l.l1Client.BlockNumber(ctx) + if err != nil { + l.logger.Error("failed to get block number", "error", err) + return err + } for { select { case <-ctx.Done(): @@ -181,7 +186,7 @@ func (l *L1Listener) watchL1Block(ctx context.Context) error { ) } - currentBlockNo = int(blockNum) + currentBlockNo = blockNum } } } diff --git a/oracle/pkg/l1Listener/l1Listener_test.go b/oracle/pkg/l1Listener/l1Listener_test.go index 808de38a0..48da63cd2 100644 --- a/oracle/pkg/l1Listener/l1Listener_test.go +++ b/oracle/pkg/l1Listener/l1Listener_test.go @@ -93,7 +93,7 @@ func TestL1Listener(t *testing.T) { // ensure no winner is sent for the previous block select { - case <-time.After(5 * time.Second): + case <-time.After(10 * time.Second): t.Fatal("timeout waiting for winner") case update := <-rec.updates: if update.blockNum.Int64() != 11 {