-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version abstraction part 2 #180
Conversation
if err != nil { | ||
return nil, nil, err | ||
} | ||
priceGetterObject, err := pricegetter.NewPipelineGetter(pluginConfig.TokenPricesUSDPipeline, pr, jb.ID, jb.ExternalJobID, jb.Name.ValueOrZero(), lggr) | ||
|
||
// Load all the readers relevant for this plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be possible to push all contract interactions and initial validations into the readers, but can be done in a follow up
@@ -88,66 +80,3 @@ func TestGetCommitPluginFilterNamesFromSpec(t *testing.T) { | |||
} | |||
|
|||
} | |||
|
|||
func TestGetCommitPluginFilterNames(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
covered by the assertFilterRegistration tests in ccipdata (isolated filter tests per reader)
@@ -59,7 +50,7 @@ type update struct { | |||
value *big.Int | |||
} | |||
|
|||
type CommitPluginConfig struct { | |||
type CommitPluginStaticConfig struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the factory object contains some static config that persists in memory across instances. Naming that static config so thats clear. Then when a new reporting plugin is created, we copy the static config into an instance object CommitReportPlugin (true factory pattern). Can do the same to the exec plugin in a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I see what you did, ignore my previous comment
// between plugin instances (ie between SetConfigs onchain) | ||
config CommitPluginStaticConfig | ||
|
||
// Dynamic readers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
following the same pattern that was here prior except with readers instead of filters. There is likely a cleaner overall solution that involves using oracle.Close() for cleanup (called in both config change and job spec delete), but leaving that out of scope for now as it likely also depends on resolving the feeds transactionality issue (see comment in UnregisterFiltersXX)
|
||
// NewReportingPlugin returns the ccip CommitReportingPlugin and satisfies the ReportingPluginFactory interface. | ||
func (rf *CommitReportingPluginFactory) NewReportingPlugin(config types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) { | ||
destPriceReg, err := rf.config.commitStore.ConfigChanged(config.OnchainConfig, config.OffchainConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing the config as blogs to the version specific commit store minimizes version switches as the version specific reader knows how to parse its own config
execLggr := lggr.Named("CCIPExecution").With( | ||
"sourceChain", ChainName(int64(chainId)), | ||
"destChain", ChainName(destChainID)) | ||
// TODO: we don't support onramp source registry changes without a reboot yet? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important follow up needed
} | ||
} | ||
|
||
// Backwards compat for tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick follow up is to always use readers in tests, not too difficult but involves mocking a call to TypeAndVersion. Leaving out of scope for now and just enc/dec v1 reports
@@ -38,145 +36,10 @@ func NewLogPollerReader(lp logpoller.LogPoller, lggr logger.Logger, client evmcl | |||
} | |||
} | |||
|
|||
func (c *LogPollerReader) GetTokenPriceUpdatesCreatedAfter(ctx context.Context, priceRegistryAddress common.Address, ts time.Time, confs int) ([]Event[price_registry.PriceRegistryUsdPerTokenUpdated], error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogPollerReader is broken down into PriceRegistryReader,CommitStoreReader and OffRampReader. Only element that remains is the LatestBlock
|
||
// Do not change the JSON format of this struct without consulting with | ||
// the RDD people first. | ||
type ExecOffchainConfig struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has not changed across versions yet, leaving as a common struct until it breaks
if err != nil { | ||
return nil, err | ||
} | ||
fn, err := ccip.CommitReportToEthTxMeta(typ, ver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required as reports are version dependent
…ractkit/ccip into feature/backwards-compat-part2
core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_v1_0_0.go
Outdated
Show resolved
Hide resolved
Followed up with @dimkouv offline to clarify a few things. Some follow ups planned:
|
@@ -26,6 +26,7 @@ type FakeCommitStore struct { | |||
|
|||
func NewFakeCommitStore(t *testing.T, nextSeqNum uint64) (*FakeCommitStore, common.Address) { | |||
addr := utils.RandomAddress() | |||
//mockCommitStore := mock_contracts.NewCommitStoreInterface(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: duplicate
var ( | ||
_ OffRampReader = &OffRampV1_0_0{} | ||
ExecutionStateChangedEventV1_0_0 = abihelpers.MustGetEventID("ExecutionStateChanged", abihelpers.MustParseABI(evm_2_evm_offramp.EVM2EVMOffRampABI)) | ||
ExecutionStateChangedSeqNrV1_0_0 = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would prefer ExecutionStateChangedSeqNrIndexV1_0_0 since this is the index, SeqNr
might be misleading
} | ||
return commitReportToEthTxMeta(commitReport) | ||
}, nil | ||
// TODO: 1.2 will split |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self
core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader.go
Show resolved
Hide resolved
Co-authored-by: Matt Yang <[email protected]> Co-authored-by: dimkouv <[email protected]>
Motivation
Solution