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

Fix smoke tests #14655

Merged
merged 21 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,28 @@ CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_nodeNotInRegistry_
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_removeChainConfigs_Success() (gas: 270824)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_selectorNotFound_Reverts() (gas: 14952)
CCIPHome_applyChainConfigUpdates:test_getPaginatedCCIPHomes_Success() (gas: 370980)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_DONIdMismatch_reverts() (gas: 27108)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_DONIdMismatch_reverts() (gas: 27137)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_InnerCallReverts_reverts() (gas: 11783)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_InvalidSelector_reverts() (gas: 11038)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_reverts() (gas: 26121)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_success() (gas: 1412263)
CCIPHome_constructor:test_constructor_CapabilitiesRegistryAddressZero_reverts() (gas: 63866)
CCIPHome_constructor:test_constructor_success() (gas: 3498390)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_reverts() (gas: 26150)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_success() (gas: 1436726)
CCIPHome_constructor:test_constructor_CapabilitiesRegistryAddressZero_reverts() (gas: 63878)
CCIPHome_constructor:test_constructor_success() (gas: 3521034)
CCIPHome_constructor:test_getCapabilityConfiguration_success() (gas: 9173)
CCIPHome_constructor:test_supportsInterface_success() (gas: 9865)
CCIPHome_getAllConfigs:test_getAllConfigs_success() (gas: 2735455)
CCIPHome_getConfigDigests:test_getConfigDigests_success() (gas: 2513909)
CCIPHome_getAllConfigs:test_getAllConfigs_success() (gas: 2765282)
CCIPHome_getConfigDigests:test_getConfigDigests_success() (gas: 2539724)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_CanOnlySelfCall_reverts() (gas: 9110)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_ConfigDigestMismatch_reverts() (gas: 21877)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_NoOpStateTransitionNotAllowed_reverts() (gas: 8796)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_success() (gas: 2556754)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_ConfigDigestMismatch_reverts() (gas: 23052)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_NoOpStateTransitionNotAllowed_reverts() (gas: 8818)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_multiplePlugins_success() (gas: 5096112)
CCIPHome_revokeCandidate:test_revokeCandidate_CanOnlySelfCall_reverts() (gas: 9068)
CCIPHome_revokeCandidate:test_revokeCandidate_ConfigDigestMismatch_reverts() (gas: 18421)
CCIPHome_revokeCandidate:test_revokeCandidate_ConfigDigestMismatch_reverts() (gas: 19128)
CCIPHome_revokeCandidate:test_revokeCandidate_RevokingZeroDigestNotAllowed_reverts() (gas: 8773)
CCIPHome_revokeCandidate:test_revokeCandidate_success() (gas: 29506)
CCIPHome_setCandidate:test_setCandidate_CanOnlySelfCall_reverts() (gas: 19022)
CCIPHome_setCandidate:test_setCandidate_ConfigDigestMismatch_reverts() (gas: 1385010)
CCIPHome_setCandidate:test_setCandidate_success() (gas: 1355245)
CCIPHome_revokeCandidate:test_revokeCandidate_success() (gas: 30676)
CCIPHome_setCandidate:test_setCandidate_CanOnlySelfCall_reverts() (gas: 19051)
CCIPHome_setCandidate:test_setCandidate_ConfigDigestMismatch_reverts() (gas: 1388198)
CCIPHome_setCandidate:test_setCandidate_success() (gas: 1357740)
CommitStore_constructor:test_Constructor_Success() (gas: 2855567)
CommitStore_isUnpausedAndRMNHealthy:test_RMN_Success() (gas: 73954)
CommitStore_report:test_InvalidIntervalMinLargerThanMax_Revert() (gas: 28739)
Expand Down
1 change: 1 addition & 0 deletions contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ compileContract () {
compileContract ccip/offRamp/EVM2EVMOffRamp.sol
compileContract ccip/offRamp/OffRamp.sol
compileContract ccip/rmn/RMNRemote.sol
compileContract ccip/rmn/RMNHome.sol
compileContract ccip/applications/PingPongDemo.sol
compileContract ccip/applications/SelfFundedPingPong.sol
compileContract ccip/applications/EtherSenderReceiver.sol
Expand Down
35 changes: 18 additions & 17 deletions contracts/src/v0.8/ccip/capability/CCIPHome.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ contract CCIPHome is OwnerIsCreator, ITypeAndVersion, ICapabilityConfiguration,
s_configs;

/// @notice The total number of configs ever set, used for generating the version of the configs.
/// @dev Used to ensure unique digests across all configurations.
uint32 private s_currentVersion = 0;
/// @notice The index of the active config.
uint32 private s_activeConfigIndex = 0;
/// @notice The index of the active config on a per-don and per-plugin basis.
mapping(uint32 donId => mapping(Internal.OCRPluginType pluginType => uint32)) private s_activeConfigIndexes;

/// @notice Constructor for the CCIPHome contract takes in the address of the capabilities registry. This address
/// is the only allowed caller to mutate the configuration through beforeCapabilityConfigSet.
Expand Down Expand Up @@ -263,21 +264,21 @@ contract CCIPHome is OwnerIsCreator, ITypeAndVersion, ICapabilityConfiguration,
Internal.OCRPluginType pluginType
) public view returns (bytes32 activeConfigDigest, bytes32 candidateConfigDigest) {
return (
s_configs[donId][pluginType][_getActiveIndex()].configDigest,
s_configs[donId][pluginType][_getCandidateIndex()].configDigest
s_configs[donId][pluginType][_getActiveIndex(donId, pluginType)].configDigest,
s_configs[donId][pluginType][_getCandidateIndex(donId, pluginType)].configDigest
);
}

/// @notice Returns the active config digest for for a given key.
/// @param donId The key of the plugin to get the config digests for.
function getActiveDigest(uint32 donId, Internal.OCRPluginType pluginType) public view returns (bytes32) {
return s_configs[donId][pluginType][_getActiveIndex()].configDigest;
return s_configs[donId][pluginType][_getActiveIndex(donId, pluginType)].configDigest;
}

/// @notice Returns the candidate config digest for for a given key.
/// @param donId The key of the plugin to get the config digests for.
function getCandidateDigest(uint32 donId, Internal.OCRPluginType pluginType) public view returns (bytes32) {
return s_configs[donId][pluginType][_getCandidateIndex()].configDigest;
return s_configs[donId][pluginType][_getCandidateIndex(donId, pluginType)].configDigest;
}

/// @notice The offchain code can use this to fetch an old config which might still be in use by some remotes. Use
Expand Down Expand Up @@ -310,12 +311,12 @@ contract CCIPHome is OwnerIsCreator, ITypeAndVersion, ICapabilityConfiguration,
uint32 donId,
Internal.OCRPluginType pluginType
) external view returns (VersionedConfig memory activeConfig, VersionedConfig memory candidateConfig) {
VersionedConfig memory storedActiveConfig = s_configs[donId][pluginType][_getActiveIndex()];
VersionedConfig memory storedActiveConfig = s_configs[donId][pluginType][_getActiveIndex(donId, pluginType)];
if (storedActiveConfig.configDigest != ZERO_DIGEST) {
activeConfig = storedActiveConfig;
}

VersionedConfig memory storedCandidateConfig = s_configs[donId][pluginType][_getCandidateIndex()];
VersionedConfig memory storedCandidateConfig = s_configs[donId][pluginType][_getCandidateIndex(donId, pluginType)];
if (storedCandidateConfig.configDigest != ZERO_DIGEST) {
candidateConfig = storedCandidateConfig;
}
Expand Down Expand Up @@ -353,7 +354,7 @@ contract CCIPHome is OwnerIsCreator, ITypeAndVersion, ICapabilityConfiguration,
uint32 newVersion = ++s_currentVersion;
newConfigDigest = _calculateConfigDigest(donId, pluginType, abi.encode(config), newVersion);

VersionedConfig storage existingConfig = s_configs[donId][pluginType][_getCandidateIndex()];
VersionedConfig storage existingConfig = s_configs[donId][pluginType][_getCandidateIndex(donId, pluginType)];
existingConfig.configDigest = newConfigDigest;
existingConfig.version = newVersion;
existingConfig.config = config;
Expand All @@ -373,7 +374,7 @@ contract CCIPHome is OwnerIsCreator, ITypeAndVersion, ICapabilityConfiguration,
revert RevokingZeroDigestNotAllowed();
}

uint256 candidateConfigIndex = _getCandidateIndex();
uint256 candidateConfigIndex = _getCandidateIndex(donId, pluginType);
if (s_configs[donId][pluginType][candidateConfigIndex].configDigest != configDigest) {
revert ConfigDigestMismatch(s_configs[donId][pluginType][candidateConfigIndex].configDigest, configDigest);
}
Expand All @@ -400,19 +401,19 @@ contract CCIPHome is OwnerIsCreator, ITypeAndVersion, ICapabilityConfiguration,
revert NoOpStateTransitionNotAllowed();
}

uint256 candidateConfigIndex = _getCandidateIndex();
uint256 candidateConfigIndex = _getCandidateIndex(donId, pluginType);
if (s_configs[donId][pluginType][candidateConfigIndex].configDigest != digestToPromote) {
revert ConfigDigestMismatch(s_configs[donId][pluginType][candidateConfigIndex].configDigest, digestToPromote);
}

VersionedConfig storage activeConfig = s_configs[donId][pluginType][_getActiveIndex()];
VersionedConfig storage activeConfig = s_configs[donId][pluginType][_getActiveIndex(donId, pluginType)];
if (activeConfig.configDigest != digestToRevoke) {
revert ConfigDigestMismatch(activeConfig.configDigest, digestToRevoke);
}

delete activeConfig.configDigest;

s_activeConfigIndex ^= 1;
s_activeConfigIndexes[donId][pluginType] ^= 1;
if (digestToRevoke != ZERO_DIGEST) {
emit ActiveConfigRevoked(digestToRevoke);
}
Expand Down Expand Up @@ -444,12 +445,12 @@ contract CCIPHome is OwnerIsCreator, ITypeAndVersion, ICapabilityConfiguration,
);
}

function _getActiveIndex() private view returns (uint32) {
return s_activeConfigIndex;
function _getActiveIndex(uint32 donId, Internal.OCRPluginType pluginType) private view returns (uint32) {
return s_activeConfigIndexes[donId][pluginType];
}

function _getCandidateIndex() private view returns (uint32) {
return s_activeConfigIndex ^ 1;
function _getCandidateIndex(uint32 donId, Internal.OCRPluginType pluginType) private view returns (uint32) {
return s_activeConfigIndexes[donId][pluginType] ^ 1;
}

// ================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity ^0.8.0;

import {CCIPHome} from "../../capability/CCIPHome.sol";

import {OffRamp} from "../../offRamp/OffRamp.sol";
import {RMNRemote} from "../../rmn/RMNRemote.sol";

/// @dev this file exposes structs that are otherwise internal to the CCIP codebase
Expand All @@ -13,4 +15,7 @@ interface ICCIPEncodingUtils {

/// @dev the OCR3Config Config struct is used in integration / E2E tests
function exposeOCR3Config(CCIPHome.OCR3Config[] calldata config) external view returns (bytes memory);

/// @dev used to encode commit reports for onchain transmission.
function exposeCommitReport(OffRamp.CommitReport memory commitReport) external view returns (bytes memory);
}
Loading
Loading