-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
372 additions
and
397 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
36 changes: 3 additions & 33 deletions
36
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 |
---|---|---|
@@ -1,41 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {Types} from "../libraries/Types.sol"; | ||
|
||
/// @dev This is so that we can generate gethwrappers and easily encode/decode OCR3Config | ||
/// in the offchain integration tests. | ||
interface IOCR3ConfigEncoder { | ||
/// @notice PluginType indicates the type of plugin that the configuration is for. | ||
/// @param Commit The configuration is for the commit plugin. | ||
/// @param Execution The configuration is for the execution plugin. | ||
enum PluginType { | ||
Commit, | ||
Execution | ||
} | ||
|
||
/// @notice OCR3 configuration. | ||
struct OCR3Config { | ||
PluginType 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. | ||
} | ||
|
||
/// @dev Encodes an array of OCR3Config into a bytes array. For test usage only. | ||
function exposeOCR3Config(OCR3Config[] calldata config) external view returns (bytes memory); | ||
function exposeOCR3Config(Types.OCR3Config[] calldata config) external view returns (bytes memory); | ||
} |
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 Types { | ||
/// @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. | ||
} | ||
} |
Oops, something went wrong.