Skip to content
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

Merged
merged 33 commits into from
Oct 5, 2023
Merged

Conversation

connorwstein
Copy link
Collaborator

@connorwstein connorwstein commented Oct 2, 2023

Motivation

  • Same as part 1, support breaking ABI changes with minimal plugin impact

Solution

  • In part 2 we introduce CommitStoreReader, PriceRegistryReader and OffRampReaders which are version agnostic dependencies injected into the plugin. They abstract away all gethwrappers and lp filter handling. Goal is for the version type switch to only exist in the construction of the version agnostic reader.
  • Notes
    • abihelpers is now version agnostic
    • Type switch for which type of gas estimator to use is handled in the ConfigChanged impl

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.
Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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

Copy link
Contributor

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
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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?
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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

@connorwstein connorwstein marked this pull request as ready for review October 4, 2023 15:39
@connorwstein connorwstein requested a review from a team as a code owner October 4, 2023 15:39
@connorwstein connorwstein requested a review from a team as a code owner October 4, 2023 18:05
@connorwstein
Copy link
Collaborator Author

Followed up with @dimkouv offline to clarify a few things. Some follow ups planned:

  • Further unit testing of readers
  • Investigate pushing caching and all RPC handling into readers as well as reader composition

@@ -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)
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self

@connorwstein connorwstein merged commit 8e9719d into ccip-develop Oct 5, 2023
44 checks passed
@connorwstein connorwstein deleted the feature/backwards-compat-part2 branch October 5, 2023 22:03
asoliman92 pushed a commit that referenced this pull request Jul 31, 2024
Co-authored-by: Matt Yang <[email protected]>
Co-authored-by: dimkouv <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants