From c337d1f31a0e16fd3d123f4c02bf4ffbcd7751d7 Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 18 Oct 2023 16:18:16 +0300 Subject: [PATCH] offchain - explicit initialisations (#219) --- core/services/ocr2/plugins/ccip/commit_reporting_plugin.go | 4 ++++ .../ocr2/plugins/ccip/execution_reporting_plugin.go | 4 ++++ .../plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go | 5 +++++ .../plugins/ccip/internal/ccipdata/commit_store_v1_2_0.go | 5 +++++ .../ocr2/plugins/ccip/internal/ccipdata/logpoller.go | 7 ++++--- .../ocr2/plugins/ccip/internal/ccipdata/offramp_v1_0_0.go | 6 ++++++ .../ocr2/plugins/ccip/internal/ccipdata/offramp_v1_2_0.go | 6 ++++++ 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/commit_reporting_plugin.go b/core/services/ocr2/plugins/ccip/commit_reporting_plugin.go index a5cd9a6f9d..7ed100a341 100644 --- a/core/services/ocr2/plugins/ccip/commit_reporting_plugin.go +++ b/core/services/ocr2/plugins/ccip/commit_reporting_plugin.go @@ -100,6 +100,10 @@ func NewCommitReportingPluginFactory(config CommitPluginStaticConfig) *CommitRep return &CommitReportingPluginFactory{ config: config, readersMu: &sync.Mutex{}, + + // the fields below are initially empty and populated on demand + destPriceRegReader: nil, + destPriceRegAddr: common.Address{}, } } diff --git a/core/services/ocr2/plugins/ccip/execution_reporting_plugin.go b/core/services/ocr2/plugins/ccip/execution_reporting_plugin.go index 41e0458340..e09400551b 100644 --- a/core/services/ocr2/plugins/ccip/execution_reporting_plugin.go +++ b/core/services/ocr2/plugins/ccip/execution_reporting_plugin.go @@ -95,6 +95,10 @@ func NewExecutionReportingPluginFactory(config ExecutionPluginStaticConfig) *Exe return &ExecutionReportingPluginFactory{ config: config, readersMu: &sync.Mutex{}, + + // the fields below are initially empty and populated on demand + destPriceRegReader: nil, + destPriceRegAddr: common.Address{}, } } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go index 4b94ff48f9..6083e9f0c4 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go @@ -352,5 +352,10 @@ func NewCommitStoreV1_0_0(lggr logger.Logger, addr common.Address, ec client.Cli reportAcceptedSig: eventSig, // offset || priceUpdatesOffset || minSeqNum || maxSeqNum || merkleRoot reportAcceptedMaxSeqIndex: 3, + configMu: sync.RWMutex{}, + + // The fields below are initially empty and set on ChangeConfig method + offchainConfig: CommitOffchainConfig{}, + gasPriceEstimator: prices.ExecGasPriceEstimator{}, }, nil } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_2_0.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_2_0.go index e4be425a45..b43096c579 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_2_0.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_2_0.go @@ -377,5 +377,10 @@ func NewCommitStoreV1_2_0(lggr logger.Logger, addr common.Address, ec client.Cli reportAcceptedSig: eventSig, // offset || priceUpdatesOffset || minSeqNum || maxSeqNum || merkleRoot reportAcceptedMaxSeqIndex: 3, + configMu: sync.RWMutex{}, + + // The fields below are initially empty and set on ChangeConfig method + offchainConfig: CommitOffchainConfig{}, + gasPriceEstimator: prices.DAGasPriceEstimator{}, }, nil } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/logpoller.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/logpoller.go index cd38580af7..afca3f98c2 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/logpoller.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/logpoller.go @@ -30,9 +30,10 @@ type LogPollerReader struct { func NewLogPollerReader(lp logpoller.LogPoller, lggr logger.Logger, client evmclient.Client) *LogPollerReader { return &LogPollerReader{ - lp: lp, - lggr: lggr, - client: client, + lp: lp, + lggr: lggr, + client: client, + dependencyCache: sync.Map{}, } } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_0_0.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_0_0.go index 71a7f9283f..775cb0f421 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_0_0.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_0_0.go @@ -368,5 +368,11 @@ func NewOffRampV1_0_0(lggr logger.Logger, addr common.Address, ec client.Client, executionReportArgs: executionReportArgs, eventSig: ExecutionStateChangedEventV1_0_0, eventIndex: executionStateChangedSequenceNumberIndex, + configMu: sync.RWMutex{}, + + // values set on the fly after ChangeConfig is called + gasPriceEstimator: prices.ExecGasPriceEstimator{}, + offchainConfig: ExecOffchainConfig{}, + onchainConfig: ExecOnchainConfig{}, }, nil } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_2_0.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_2_0.go index b0b2d01f25..6b509a16c2 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_2_0.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_v1_2_0.go @@ -276,5 +276,11 @@ func NewOffRampV1_2_0(lggr logger.Logger, addr common.Address, ec client.Client, OffRampV1_0_0: v100, offRamp: offRamp, executionReportArgs: executionReportArgs, + configMu: sync.RWMutex{}, + + // values set on the fly after ChangeConfig is called + gasPriceEstimator: prices.ExecGasPriceEstimator{}, + offchainConfig: ExecOffchainConfig{}, + onchainConfig: ExecOnchainConfig{}, }, nil }