Skip to content

Commit

Permalink
moving backfilled oracle blocking start work to background thread (#1201
Browse files Browse the repository at this point in the history
)

## Motivation
[Old
impl](https://github.com/smartcontractkit/ccip/blob/7d2cae3660bac29ba9dd48b03d88a761c154d6ae/core/services/ocr2/plugins/ccip/internal/oraclelib/backfilled_oracle.go#L41)
of backfilled oracle would run log poller in a non-blocking fashion on
job creation. The new implementation has it blocking on job creation,
which is impacting load testing.

## Solution
Move back to the old background thread pattern.
  • Loading branch information
patrickhuie19 authored Jul 24, 2024
1 parent 054de17 commit 5ef031c
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ type ChainAgnosticBackFilledOracle struct {
}

func (r *ChainAgnosticBackFilledOracle) Start(ctx context.Context) error {
ctx, cancelFn := context.WithCancel(context.Background())
go r.run(ctx)
return nil
}

func (r *ChainAgnosticBackFilledOracle) run(ctx context.Context) {
ctx, cancelFn := context.WithCancel(ctx)
r.cancelFn = cancelFn
var err error
var errMu sync.Mutex
Expand Down Expand Up @@ -175,7 +180,6 @@ func (r *ChainAgnosticBackFilledOracle) Start(ctx context.Context) error {
}
if err := ctx.Err(); err != nil {
r.lggr.Errorw("context already cancelled", "err", err)
return nil
}
// Start oracle with all logs present from dstStartBlock on dst and
// all logs from srcStartBlock on src.
Expand All @@ -185,7 +189,6 @@ func (r *ChainAgnosticBackFilledOracle) Start(ctx context.Context) error {
} else {
r.oracleStarted.Store(true)
}
return nil
}

func (r *ChainAgnosticBackFilledOracle) Close() error {
Expand Down

0 comments on commit 5ef031c

Please sign in to comment.