-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCIP-2639] ccip capability launcher component (#1123)
## Motivation We need a component that consumes capability registry syncer updates and launches CCIP oracles accordingly. ## Solution Build a launcher component that implements the `registrysyncer.Launcher` interface. The setup of the `launcher` package is as follows: * bluegreen.go: defines structures that encapsulates ccip deployments, i.e exec and commit oracles, and the blue/green deployment logic. * diff.go: pure functions that diff registry states in order to determine if there are any added, updated, or deleted dons that we should care about. * launcher.go: defines the `launcher` type which implements the `registrysyncer.Launcher` interface. The `Launch` function is called by the registry syncer whenever a new registry state is fetched. Note that this registry state is not always different, we will most likely be called with the same state more often than not, as the registry doesn't change that often. It uses a handful of pure functions and applies state updates only in a single function, `processDiff`. On the contracts: * Break out the types defined in `CCIPConfig.sol` into a separate CCIPConfigTypes.sol which is then imported in CCIPConfig.sol and the OCR config encoding interface, a helper used in tests. * Use `Internal.OCRPluginType` instead of `PluginType` in order to be consistent with the OCR3Base contracts that will be deployed on dests
- Loading branch information
Showing
38 changed files
with
4,620 additions
and
4,931 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
contracts/src/v0.8/ccip/capability/interfaces/ICapabilitiesRegistry.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
contracts/src/v0.8/ccip/capability/interfaces/IOCR3ConfigEncoder.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import {CCIPConfigTypes} from "../libraries/CCIPConfigTypes.sol"; | ||
|
||
/// @dev This is so that we can generate gethwrappers and easily encode/decode OCR3Config | ||
/// in the offchain integration tests. | ||
interface IOCR3ConfigEncoder { | ||
/// @dev Encodes an array of OCR3Config into a bytes array. For test usage only. | ||
function exposeOCR3Config(CCIPConfigTypes.OCR3Config[] calldata config) external view returns (bytes memory); | ||
} |
56 changes: 56 additions & 0 deletions
56
contracts/src/v0.8/ccip/capability/libraries/CCIPConfigTypes.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import {Internal} from "../../libraries/Internal.sol"; | ||
|
||
library CCIPConfigTypes { | ||
/// @notice ConfigState indicates the state of the configuration. | ||
/// A DON's configuration always starts out in the "Init" state - this is the starting state. | ||
/// The only valid transition from "Init" is to the "Running" state - this is the first ever configuration. | ||
/// The only valid transition from "Running" is to the "Staging" state - this is a blue/green proposal. | ||
/// The only valid transition from "Staging" is back to the "Running" state - this is a promotion. | ||
/// TODO: explain rollbacks? | ||
enum ConfigState { | ||
Init, | ||
Running, | ||
Staging | ||
} | ||
|
||
/// @notice Chain configuration. | ||
/// Changes to chain configuration are detected out-of-band in plugins and decoded offchain. | ||
struct ChainConfig { | ||
bytes32[] readers; // The P2P IDs of the readers for the chain. These IDs must be registered in the capabilities registry. | ||
uint8 fChain; // The fault tolerance parameter of the chain. | ||
bytes config; // The chain configuration. This is kept intentionally opaque so as to add fields in the future if needed. | ||
} | ||
|
||
/// @notice Chain configuration information struct used in applyChainConfigUpdates and getAllChainConfigs. | ||
struct ChainConfigInfo { | ||
uint64 chainSelector; | ||
ChainConfig chainConfig; | ||
} | ||
|
||
/// @notice OCR3 configuration. | ||
struct OCR3Config { | ||
Internal.OCRPluginType pluginType; // ────────╮ The plugin that the configuration is for. | ||
uint64 chainSelector; // | The (remote) chain that the configuration is for. | ||
uint8 F; // | The "big F" parameter for the role DON. | ||
uint64 offchainConfigVersion; // ─────────────╯ The version of the offchain configuration. | ||
bytes offrampAddress; // The remote chain offramp address. | ||
bytes32[] bootstrapP2PIds; // The bootstrap P2P IDs of the oracles that are part of the role DON. | ||
// len(p2pIds) == len(signers) == len(transmitters) == 3 * F + 1 | ||
// NOTE: indexes matter here! The p2p ID at index i corresponds to the signer at index i and the transmitter at index i. | ||
// This is crucial in order to build the oracle ID <-> peer ID mapping offchain. | ||
bytes32[] p2pIds; // The P2P IDs of the oracles that are part of the role DON. | ||
bytes[] signers; // The onchain signing keys of nodes in the don. | ||
bytes[] transmitters; // The onchain transmitter keys of nodes in the don. | ||
bytes offchainConfig; // The offchain configuration for the OCR3 protocol. Protobuf encoded. | ||
} | ||
|
||
/// @notice OCR3 configuration with metadata, specifically the config count and the config digest. | ||
struct OCR3ConfigWithMeta { | ||
OCR3Config config; // The OCR3 configuration. | ||
uint64 configCount; // The config count used to compute the config digest. | ||
bytes32 configDigest; // The config digest of the OCR3 configuration. | ||
} | ||
} |
441 changes: 224 additions & 217 deletions
441
contracts/src/v0.8/ccip/test/capability/CCIPConfig.t.sol
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48 changes: 24 additions & 24 deletions
48
core/gethwrappers/ccip/generated/ccip_config/ccip_config.go
Large diffs are not rendered by default.
Oops, something went wrong.
196 changes: 196 additions & 0 deletions
196
core/gethwrappers/ccip/generated/ocr3_config_encoder/ocr3_config_encoder.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.