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

[feat] CCIP capability config contract #858

Merged
merged 40 commits into from
Jun 21, 2024
Merged

Conversation

makramkd
Copy link
Contributor

@makramkd makramkd commented May 15, 2024

Motivation

The CCIP capability needs to fetch its configuration from somewhere - that somewhere is the CCIP capability configuration contract.

Solution

Implement the CCIP capability configuration contract in solidity. The solidity implementation almost matches the design doc exactly, except for getAllOCRConfigs() which I haven't implemented yet until we figure out the best function signature for it:

  • return all OCR configs for all plugins
  • take a donId, returns configs for all plugins
  • take a plugin type, return all configs (for all dons) for that plugin type
  • etc.

Copy link
Contributor

github-actions bot commented May 15, 2024

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

Copy link
Contributor

I see you updated files related to contracts. Please run pnpm changeset in the contracts directory to add a changeset.

Copy link
Contributor

github-actions bot commented May 15, 2024

LCOV of commit 9298f8a during Solidity Foundry #5632

Summary coverage rate:
  lines......: 98.9% (1578 of 1596 lines)
  functions..: 96.2% (303 of 315 functions)
  branches...: 91.9% (669 of 728 branches)

Files changed coverage rate: n/a

the following funcs are left:
* getAllOCRConfigs
* getAllChainConfigs
* getCapabilityConfiguration
* beforeCapabilityConfigSet
* _updatePluginConfig
@makramkd makramkd force-pushed the ccip/cr-config-contract branch from 51c50fa to ef97195 Compare June 20, 2024 18:30
@smartcontractkit smartcontractkit deleted a comment from github-actions bot Jun 20, 2024
@makramkd makramkd requested a review from RensR June 21, 2024 08:37
// TODO: check for duplicate signers, duplicate p2p ids, etc.
// TODO: check that p2p ids in cfg.bootstrapP2PIds are included in cfg.p2pIds.
for (uint256 i = 0; i < cfg.signers.length; ++i) {
_ensureInRegistry(cfg.p2pIds[i]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's very expensive to do an external call for each signer

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this validation at all? If the Capability Registry changes the p2p IDs, wouldn't this contract go out of sync w/ the registry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea behind this validation is to ensure that the p2p id we're setting in the ocr config is present in the registry, since the registry doesn't do that check (it just sees opaque bytes).

After discussing offline it seems like this will cost around 25k (+/- some stuff) gas for 31 oracles which is the worst case. Its not great but can be improved. Some suggestions:

  • Doing a nested for loop in my forge tests is less gassy by like 5k
  • Pre-sorting both lists of p2p ids given to the capability registry and in the ocr config, and doing a sorted comparison

Will create a ticket to address this after, seems like a good gas optimization task

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created CCIP-2613 to address this

@makramkd makramkd merged commit 292ac45 into ccip-develop Jun 21, 2024
80 checks passed
@makramkd makramkd deleted the ccip/cr-config-contract branch June 21, 2024 13:38
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.

4 participants