From 8fd87ef1ed945a1ab292699373a0e29acf36cf2c Mon Sep 17 00:00:00 2001 From: Jean Arnaud Date: Wed, 6 Mar 2024 17:21:18 +0100 Subject: [PATCH 1/3] Move price registry sync to start of Observation --- core/services/ocr2/plugins/ccip/ccipexec/ocr2.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go b/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go index 6f6a384fc2..e01a1dfa29 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go @@ -100,6 +100,12 @@ func (r *ExecutionReportingPlugin) Observation(ctx context.Context, timestamp ty if err := ccipcommon.VerifyNotDown(ctx, r.lggr, r.commitStoreReader, r.onRampReader); err != nil { return nil, err } + + // Ensure that the source price registry is synchronized with the onRamp. + if err := r.ensurePriceRegistrySynchronization(ctx); err != nil { + return nil, fmt.Errorf("ensuring price registry synchronization: %w", err) + } + // Expire any inflight reports. r.inflightReports.expire(lggr) inFlight := r.inflightReports.getAll() @@ -1042,11 +1048,6 @@ func (r *ExecutionReportingPlugin) prepareTokenExecData(ctx context.Context) (ex return execTokenData{}, err } - // Ensure that the source price registry is synchronized with the onRamp. - if err = r.ensurePriceRegistrySynchronization(ctx); err != nil { - return execTokenData{}, fmt.Errorf("ensuring price registry synchronization: %w", err) - } - sourceFeeTokens, err := r.sourcePriceRegistry.GetFeeTokens(ctx) if err != nil { return execTokenData{}, fmt.Errorf("get source fee tokens: %w", err) From bd21a392302869f3e699bbd8dd75d9acf439a3b5 Mon Sep 17 00:00:00 2001 From: Jean Arnaud Date: Wed, 6 Mar 2024 17:36:59 +0100 Subject: [PATCH 2/3] Const for config set event --- .../ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go | 6 ++++-- .../ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go | 8 +++++--- .../ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go | 8 +++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go index 2ff76f2718..e4377c27ee 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go @@ -25,6 +25,7 @@ import ( const ( CCIPSendRequestedEventName = "CCIPSendRequested" + ConfigSetEventName = "ConfigSet" ) var _ ccipdata.OnRampReader = &OnRamp{} @@ -52,6 +53,7 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd } onRampABI := abihelpers.MustParseABI(evm_2_evm_onramp_1_0_0.EVM2EVMOnRampABI) eventSig := abihelpers.MustGetEventID(CCIPSendRequestedEventName, onRampABI) + configSetEventSig := abihelpers.MustGetEventID(ConfigSetEventName, onRampABI) filters := []logpoller.Filter{ { Name: logpoller.FilterName(ccipdata.COMMIT_CCIP_SENDS, onRampAddress), @@ -60,7 +62,7 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd }, { Name: logpoller.FilterName(ccipdata.CONFIG_CHANGED, onRampAddress), - EventSigs: []common.Hash{abihelpers.MustGetEventID("ConfigSet", onRampABI)}, + EventSigs: []common.Hash{configSetEventSig}, Addresses: []common.Address{onRampAddress}, }, } @@ -80,7 +82,7 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd sendRequestedEventSig: eventSig, cachedSourcePriceRegistryAddress: cache.NewLogpollerEventsBased[cciptypes.Address]( sourceLP, - []common.Hash{abihelpers.MustGetEventID("ConfigSet", onRampABI)}, + []common.Hash{configSetEventSig}, onRampAddress, ), cachedStaticConfig: cachedStaticConfig, diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go index 088f801cc7..95d0bff989 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go @@ -27,11 +27,13 @@ import ( var ( // Backwards compat for integration tests CCIPSendRequestEventSig common.Hash + ConfigSetEventSig common.Hash ) const ( CCIPSendRequestSeqNumIndex = 4 CCIPSendRequestedEventName = "CCIPSendRequested" + ConfigSetEventName = "ConfigSet" ) func init() { @@ -40,6 +42,7 @@ func init() { panic(err) } CCIPSendRequestEventSig = abihelpers.MustGetEventID(CCIPSendRequestedEventName, onRampABI) + ConfigSetEventSig = abihelpers.MustGetEventID(ConfigSetEventName, onRampABI) } var _ ccipdata.OnRampReader = &OnRamp{} @@ -67,7 +70,6 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd if err != nil { return nil, err } - onRampABI := abihelpers.MustParseABI(evm_2_evm_onramp_1_2_0.EVM2EVMOnRampABI) // Subscribe to the relevant logs // Note we can keep the same prefix across 1.0/1.1 and 1.2 because the onramp addresses will be different filters := []logpoller.Filter{ @@ -78,7 +80,7 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd }, { Name: logpoller.FilterName(ccipdata.CONFIG_CHANGED, onRampAddress), - EventSigs: []common.Hash{abihelpers.MustGetEventID("ConfigSet", onRampABI)}, + EventSigs: []common.Hash{ConfigSetEventSig}, Addresses: []common.Address{onRampAddress}, }, } @@ -97,7 +99,7 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd sendRequestedEventSig: CCIPSendRequestEventSig, cachedSourcePriceRegistryAddress: cache.NewLogpollerEventsBased[cciptypes.Address]( sourceLP, - []common.Hash{abihelpers.MustGetEventID("ConfigSet", onRampABI)}, + []common.Hash{ConfigSetEventSig}, onRampAddress, ), cachedStaticConfig: cachedStaticConfig, diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go index e7648eef62..b8b131e78b 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go @@ -28,11 +28,13 @@ import ( var ( // Backwards compat for integration tests CCIPSendRequestEventSig common.Hash + ConfigSetEventSig common.Hash ) const ( CCIPSendRequestSeqNumIndex = 4 CCIPSendRequestedEventName = "CCIPSendRequested" + ConfigSetEventName = "ConfigSet" ) func init() { @@ -41,6 +43,7 @@ func init() { panic(err) } CCIPSendRequestEventSig = abihelpers.MustGetEventID(CCIPSendRequestedEventName, onRampABI) + ConfigSetEventSig = abihelpers.MustGetEventID(ConfigSetEventName, onRampABI) } var _ ccipdata.OnRampReader = &OnRamp{} @@ -68,7 +71,6 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd if err != nil { return nil, err } - onRampABI := abihelpers.MustParseABI(evm_2_evm_onramp.EVM2EVMOnRampABI) // Subscribe to the relevant logs // Note we can keep the same prefix across 1.0/1.1 and 1.2 because the onramp addresses will be different filters := []logpoller.Filter{ @@ -79,7 +81,7 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd }, { Name: logpoller.FilterName(ccipdata.CONFIG_CHANGED, onRampAddress), - EventSigs: []common.Hash{abihelpers.MustGetEventID("ConfigSet", onRampABI)}, + EventSigs: []common.Hash{ConfigSetEventSig}, Addresses: []common.Address{onRampAddress}, }, } @@ -98,7 +100,7 @@ func NewOnRamp(lggr logger.Logger, sourceSelector, destSelector uint64, onRampAd sendRequestedEventSig: CCIPSendRequestEventSig, cachedSourcePriceRegistryAddress: cache.NewLogpollerEventsBased[cciptypes.Address]( sourceLP, - []common.Hash{abihelpers.MustGetEventID("ConfigSet", onRampABI)}, + []common.Hash{ConfigSetEventSig}, onRampAddress, ), cachedStaticConfig: cachedStaticConfig, From cf190c644ed65caab90acad2ede11281f859a334 Mon Sep 17 00:00:00 2001 From: Jean Arnaud Date: Wed, 6 Mar 2024 18:53:19 +0100 Subject: [PATCH 3/3] Fix test --- core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go index 5a8b7b2851..86fcbe580c 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go @@ -1855,7 +1855,7 @@ func Test_prepareTokenExecData(t *testing.T) { reportingPlugin := ExecutionReportingPlugin{ onRampReader: onrampReader, offRampReader: offrampReader, - sourcePriceRegistry: nil, // will be updated at first use. + sourcePriceRegistry: sourcePriceRegistry, sourcePriceRegistryProvider: sourcePriceRegistryProvider, destPriceRegistry: destPriceRegistry, gasPriceEstimator: gasPriceEstimator,