-
Notifications
You must be signed in to change notification settings - Fork 34
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
base: ccip-develop
Are you sure you want to change the base?
Conversation
I see you updated files related to
|
I see you updated files related to |
LCOV of commit
|
the following funcs are left: * getAllOCRConfigs * getAllChainConfigs * getCapabilityConfiguration * beforeCapabilityConfigSet * _updatePluginConfig
Go solidity wrappers are out-of-date, regenerate them via the |
a2449dc
to
a15d291
Compare
contracts/src/v0.8/ccip/capability/interfaces/ICapabilityRegistry.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
// staging -> running (promotion) | ||
// everything else is invalid and should revert. | ||
function _validateConfigStateTransition(ConfigState currentState, ConfigState newState) internal pure { | ||
// TODO: may be able to save gas if we put this in the if condition. |
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: bit of an over-optimization but technically you just need to check newState - currentState
, and allow it only if it is +1, or -1 if currentState = 2
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.
I think that may not work due to the enums being unsigned integers (you won't get -1 but 255 or smth). I think we could just ditch enums and use signed int8's though. Will make a ticket for this.
* remove unused errors * struct packing and comments * some renames for clarity * bytes32 instead of bytes in some places * fixed size array instead of dynamic * uint64[] array instead of ChainConfigUpdate
* gas optimization in getAllChainConfigs * comment move to @/dev
/// @param configLen The length of the configuration. | ||
/// @return The config state. | ||
function _stateFromConfigLength(uint256 configLen) internal pure returns (ConfigState) { | ||
if (configLen == 0) { |
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.
It may be useful to leave some @dev
comments explaining how the configLen
s match to the ConfigState
.
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/capability/CCIPCapabilityConfiguration.sol
Outdated
Show resolved
Hide resolved
/// @param chainSelectorRemoves The chain configurations to remove. | ||
/// @param adds The chain configurations to add. | ||
function applyChainConfigUpdates( | ||
uint64[] calldata chainSelectorRemoves, |
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.
uint64[] calldata chainSelectorRemoves, | |
uint64[] calldata removedChainSelectors, |
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.
They aren't removed yet when you pass them in the arg, might be a bit confusing naming it that way?
// Process removals first. | ||
for (uint256 i = 0; i < chainSelectorRemoves.length; i++) { | ||
// check if the chain selector is in s_chainSelectors first. | ||
bool present = s_chainSelectors.contains(chainSelectorRemoves[i]); |
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.
bool present = s_chainSelectors.contains(chainSelectorRemoves[i]); | |
bool isValidChainSelector = s_chainSelectors.contains(chainSelectorRemoves[i]); |
@@ -0,0 +1,36 @@ | |||
// SPDX-License-Identifier: MIT |
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 interface
has already been defined here.
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.
Ya will have to import that instead when its available in ccip-develop
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.
LGTM
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: