Skip to content

Commit

Permalink
Ready replaced with Healthy
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Mar 7, 2024
1 parent 104eaa1 commit 48d2284
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions core/chains/evm/logpoller/disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func (disabled) Name() string { return "disabledLogPoller" }

func (disabled) Start(ctx context.Context) error { return ErrDisabled }

func (disabled) Healthy() error {
return ErrDisabled
}

func (disabled) Close() error { return ErrDisabled }

func (disabled) Ready() error { return ErrDisabled }
Expand Down
3 changes: 2 additions & 1 deletion core/chains/evm/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
//go:generate mockery --quiet --name LogPoller --output ./mocks/ --case=underscore --structname LogPoller --filename log_poller.go
type LogPoller interface {
services.Service
Healthy() error
Replay(ctx context.Context, fromBlock int64) error
ReplayAsync(fromBlock int64)
RegisterFilter(filter Filter, qopts ...pg.QOpt) error
Expand Down Expand Up @@ -213,7 +214,7 @@ func (filter *Filter) Contains(other *Filter) bool {
return true
}

func (lp *logPoller) Ready() error {
func (lp *logPoller) Healthy() error {
if lp.finalityViolated.Load() {
return ErrFinalityViolated
}
Expand Down
10 changes: 5 additions & 5 deletions core/chains/evm/logpoller/log_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ func TestLogPoller_ReorgDeeperThanFinality(t *testing.T) {
// Polling should get us the L1 log.
firstPoll := th.PollAndSaveLogs(testutils.Context(t), 1)
assert.Equal(t, int64(5), firstPoll)
assert.NoError(t, th.LogPoller.Ready())
assert.NoError(t, th.LogPoller.Healthy())

// Fork deeper than finality depth
// Chain gen <- 1 <- 2 <- 3 (finalized) <- 4 (L1_1)
Expand All @@ -1049,7 +1049,7 @@ func TestLogPoller_ReorgDeeperThanFinality(t *testing.T) {

secondPoll := th.PollAndSaveLogs(testutils.Context(t), firstPoll)
assert.Equal(t, firstPoll, secondPoll)
assert.Equal(t, logpoller.ErrFinalityViolated, th.LogPoller.Ready())
assert.Equal(t, logpoller.ErrFinalityViolated, th.LogPoller.Healthy())

// Manually remove latest block from the log poller to bring it back to life
// LogPoller should be healthy again after first poll
Expand All @@ -1059,7 +1059,7 @@ func TestLogPoller_ReorgDeeperThanFinality(t *testing.T) {
// Poll from latest
recoveryPoll := th.PollAndSaveLogs(testutils.Context(t), 1)
assert.Equal(t, int64(10), recoveryPoll)
assert.NoError(t, th.LogPoller.Ready())
assert.NoError(t, th.LogPoller.Healthy())
})
}
}
Expand Down Expand Up @@ -1107,7 +1107,7 @@ func TestLogPoller_PollAndSaveLogsDeepReorg(t *testing.T) {
// Polling should get us the L1 log.
newStart := th.PollAndSaveLogs(testutils.Context(t), 1)
assert.Equal(t, int64(3), newStart)
assert.NoError(t, th.LogPoller.Ready())
assert.NoError(t, th.LogPoller.Healthy())
// Check that L1_1 has a proper data payload
lgs, err := th.ORM.SelectLogsByBlockRange(2, 2)
require.NoError(t, err)
Expand All @@ -1133,7 +1133,7 @@ func TestLogPoller_PollAndSaveLogsDeepReorg(t *testing.T) {

newStart = th.PollAndSaveLogs(testutils.Context(t), newStart)
assert.Equal(t, int64(10), newStart)
assert.NoError(t, th.LogPoller.Ready())
assert.NoError(t, th.LogPoller.Healthy())

// Expect L1_2 to be properly updated
lgs, err = th.ORM.SelectLogsByBlockRange(2, 2)
Expand Down
18 changes: 18 additions & 0 deletions core/chains/evm/logpoller/mocks/log_poller.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 48d2284

Please sign in to comment.