Skip to content

Commit

Permalink
Increase max signers (#1405)
Browse files Browse the repository at this point in the history
Improve tests and error checks

---------

Co-authored-by: app-token-issuer-infra-releng[bot] <120227048+app-token-issuer-infra-releng[bot]@users.noreply.github.com>
  • Loading branch information
1 parent e1577f6 commit 62ba1f0
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 362 deletions.
94 changes: 47 additions & 47 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ BurnWithFromMintTokenPool_lockOrBurn:test_Setup_Success() (gas: 23951)
CCIPClientExample_sanity:test_ImmutableExamples_Success() (gas: 2132684)
CCIPConfigSetup:test_getCapabilityConfiguration_Success() (gas: 9517)
CCIPConfig_ConfigStateMachine:test__computeConfigDigest_Success() (gas: 70831)
CCIPConfig_ConfigStateMachine:test__computeNewConfigWithMeta_InitToRunning_Success() (gas: 363544)
CCIPConfig_ConfigStateMachine:test__computeNewConfigWithMeta_RunningToStaging_Success() (gas: 488615)
CCIPConfig_ConfigStateMachine:test__computeNewConfigWithMeta_StagingToRunning_Success() (gas: 453319)
CCIPConfig_ConfigStateMachine:test__computeNewConfigWithMeta_InitToRunning_Success() (gas: 363682)
CCIPConfig_ConfigStateMachine:test__computeNewConfigWithMeta_RunningToStaging_Success() (gas: 488896)
CCIPConfig_ConfigStateMachine:test__computeNewConfigWithMeta_StagingToRunning_Success() (gas: 453458)
CCIPConfig_ConfigStateMachine:test__groupByPluginType_TooManyOCR3Configs_Reverts() (gas: 37049)
CCIPConfig_ConfigStateMachine:test__groupByPluginType_threeCommitConfigs_Reverts() (gas: 61065)
CCIPConfig_ConfigStateMachine:test__groupByPluginType_threeExecutionConfigs_Reverts() (gas: 60985)
Expand All @@ -54,9 +54,9 @@ CCIPConfig_ConfigStateMachine:test__validateConfigTransition_RunningToStaging_Wr
CCIPConfig_ConfigStateMachine:test__validateConfigTransition_StagingToRunning_Success() (gas: 376425)
CCIPConfig_ConfigStateMachine:test__validateConfigTransition_StagingToRunning_WrongConfigDigest_Reverts() (gas: 157312)
CCIPConfig_ConfigStateMachine:test_getCapabilityConfiguration_Success() (gas: 9605)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_CommitAndExecConfig_Success() (gas: 1850870)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_CommitConfigOnly_Success() (gas: 1068182)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_ExecConfigOnly_Success() (gas: 1068213)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_CommitAndExecConfig_Success() (gas: 1851149)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_CommitConfigOnly_Success() (gas: 1068320)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_ExecConfigOnly_Success() (gas: 1068351)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_Reverts() (gas: 9599)
CCIPConfig_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_ZeroLengthConfig_Success() (gas: 16057)
CCIPConfig_beforeCapabilityConfigSet:test_getCapabilityConfiguration_Success() (gas: 9605)
Expand All @@ -67,31 +67,31 @@ CCIPConfig_chainConfig:test_applyChainConfigUpdates_removeChainConfigs_Success()
CCIPConfig_chainConfig:test_applyChainConfigUpdates_selectorNotFound_Reverts() (gas: 14829)
CCIPConfig_chainConfig:test_getCapabilityConfiguration_Success() (gas: 9626)
CCIPConfig_chainConfig:test_getPaginatedCCIPConfigs_Success() (gas: 370249)
CCIPConfig_constructor:test_constructor_Success() (gas: 3602871)
CCIPConfig_constructor:test_constructor_ZeroAddressNotAllowed_Revert() (gas: 61769)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_InitToRunning_Success() (gas: 1057248)
CCIPConfig_constructor:test_constructor_Success() (gas: 3597863)
CCIPConfig_constructor:test_constructor_ZeroAddressNotAllowed_Revert() (gas: 61761)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_InitToRunning_Success() (gas: 1057386)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_InvalidConfigLength_Reverts() (gas: 27561)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_InvalidConfigStateTransition_Reverts() (gas: 23127)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_RunningToStaging_Success() (gas: 2009044)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_StagingToRunning_Success() (gas: 2615819)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_RunningToStaging_Success() (gas: 2009377)
CCIPConfig_updatePluginConfig:test__updatePluginConfig_StagingToRunning_Success() (gas: 2616263)
CCIPConfig_updatePluginConfig:test_getCapabilityConfiguration_Success() (gas: 9605)
CCIPConfig_validateConfig:test__validateConfig_BootstrapP2PIdsHasDuplicates_Reverts() (gas: 294864)
CCIPConfig_validateConfig:test__validateConfig_BootstrapP2PIdsNotASubsetOfP2PIds_Reverts() (gas: 298296)
CCIPConfig_validateConfig:test__validateConfig_BootstrapP2PIdsNotSorted_Reverts() (gas: 295009)
CCIPConfig_validateConfig:test__validateConfig_ChainSelectorNotFound_Reverts() (gas: 294328)
CCIPConfig_validateConfig:test__validateConfig_ChainSelectorNotSet_Reverts() (gas: 291402)
CCIPConfig_validateConfig:test__validateConfig_FMustBePositive_Reverts() (gas: 292367)
CCIPConfig_validateConfig:test__validateConfig_FTooHigh_Reverts() (gas: 292511)
CCIPConfig_validateConfig:test__validateConfig_NodeNotInRegistry_Reverts() (gas: 299453)
CCIPConfig_validateConfig:test__validateConfig_NotEnoughTransmitters_Reverts() (gas: 1159741)
CCIPConfig_validateConfig:test__validateConfig_OfframpAddressCannotBeZero_Reverts() (gas: 291231)
CCIPConfig_validateConfig:test__validateConfig_P2PIdsHasDuplicates_Reverts() (gas: 295878)
CCIPConfig_validateConfig:test__validateConfig_P2PIdsLengthNotMatching_Reverts() (gas: 293200)
CCIPConfig_validateConfig:test__validateConfig_P2PIdsNotSorted_Reverts() (gas: 295594)
CCIPConfig_validateConfig:test__validateConfig_Success() (gas: 302066)
CCIPConfig_validateConfig:test__validateConfig_TooManyBootstrapP2PIds_Reverts() (gas: 294510)
CCIPConfig_validateConfig:test__validateConfig_TooManySigners_Reverts() (gas: 1215496)
CCIPConfig_validateConfig:test__validateConfig_TooManyTransmitters_Reverts() (gas: 1213899)
CCIPConfig_validateConfig:test__validateConfig_ABIEncodedAddress_OfframpAddressCannotBeZero_Reverts() (gas: 292159)
CCIPConfig_validateConfig:test__validateConfig_BootstrapP2PIdsHasDuplicates_Reverts() (gas: 295946)
CCIPConfig_validateConfig:test__validateConfig_BootstrapP2PIdsNotASubsetOfP2PIds_Reverts() (gas: 299396)
CCIPConfig_validateConfig:test__validateConfig_BootstrapP2PIdsNotSorted_Reverts() (gas: 296081)
CCIPConfig_validateConfig:test__validateConfig_ChainSelectorNotFound_Reverts() (gas: 294926)
CCIPConfig_validateConfig:test__validateConfig_ChainSelectorNotSet_Reverts() (gas: 291771)
CCIPConfig_validateConfig:test__validateConfig_FMustBePositive_Reverts() (gas: 292999)
CCIPConfig_validateConfig:test__validateConfig_FTooHigh_Reverts() (gas: 293164)
CCIPConfig_validateConfig:test__validateConfig_NodeNotInRegistry_Reverts() (gas: 348310)
CCIPConfig_validateConfig:test__validateConfig_NotEnoughTransmitters_Reverts() (gas: 1209654)
CCIPConfig_validateConfig:test__validateConfig_OfframpAddressCannotBeZero_Reverts() (gas: 291876)
CCIPConfig_validateConfig:test__validateConfig_P2PIdsHasDuplicates_Reverts() (gas: 295780)
CCIPConfig_validateConfig:test__validateConfig_P2PIdsLengthNotMatching_Reverts() (gas: 293785)
CCIPConfig_validateConfig:test__validateConfig_P2PIdsNotSorted_Reverts() (gas: 296150)
CCIPConfig_validateConfig:test__validateConfig_Success() (gas: 302468)
CCIPConfig_validateConfig:test__validateConfig_TooManyBootstrapP2PIds_Reverts() (gas: 295556)
CCIPConfig_validateConfig:test__validateConfig_TooManySigners_Reverts() (gas: 494442)
CCIPConfig_validateConfig:test_getCapabilityConfiguration_Success() (gas: 9584)
CommitStore_constructor:test_Constructor_Success() (gas: 3091326)
CommitStore_isUnpausedAndRMNHealthy:test_RMN_Success() (gas: 73420)
Expand Down Expand Up @@ -536,20 +536,20 @@ MultiAggregateRateLimiter_updateRateLimitTokens:test_UpdateRateLimitTokens_Remov
MultiAggregateRateLimiter_updateRateLimitTokens:test_ZeroDestToken_Revert() (gas: 18287)
MultiAggregateRateLimiter_updateRateLimitTokens:test_ZeroSourceToken_Revert() (gas: 18216)
MultiOCR3Base_setOCR3Configs:test_FMustBePositive_Revert() (gas: 59331)
MultiOCR3Base_setOCR3Configs:test_FTooHigh_Revert() (gas: 44289)
MultiOCR3Base_setOCR3Configs:test_RepeatSignerAddress_Revert() (gas: 283606)
MultiOCR3Base_setOCR3Configs:test_RepeatTransmitterAddress_Revert() (gas: 422233)
MultiOCR3Base_setOCR3Configs:test_FTooHigh_Revert() (gas: 43602)
MultiOCR3Base_setOCR3Configs:test_RepeatSignerAddress_Revert() (gas: 283585)
MultiOCR3Base_setOCR3Configs:test_RepeatTransmitterAddress_Revert() (gas: 422210)
MultiOCR3Base_setOCR3Configs:test_SetConfigIgnoreSigners_Success() (gas: 511089)
MultiOCR3Base_setOCR3Configs:test_SetConfigWithSigners_Success() (gas: 828394)
MultiOCR3Base_setOCR3Configs:test_SetConfigWithSigners_Success() (gas: 828371)
MultiOCR3Base_setOCR3Configs:test_SetConfigWithoutSigners_Success() (gas: 456841)
MultiOCR3Base_setOCR3Configs:test_SetConfigsZeroInput_Success() (gas: 12376)
MultiOCR3Base_setOCR3Configs:test_SetMultipleConfigs_Success() (gas: 2140127)
MultiOCR3Base_setOCR3Configs:test_SignerCannotBeZeroAddress_Revert() (gas: 141723)
MultiOCR3Base_setOCR3Configs:test_StaticConfigChange_Revert() (gas: 807279)
MultiOCR3Base_setOCR3Configs:test_TooManySigners_Revert() (gas: 171322)
MultiOCR3Base_setOCR3Configs:test_TooManyTransmitters_Revert() (gas: 30289)
MultiOCR3Base_setOCR3Configs:test_TransmitterCannotBeZeroAddress_Revert() (gas: 254091)
MultiOCR3Base_setOCR3Configs:test_UpdateConfigSigners_Success() (gas: 860006)
MultiOCR3Base_setOCR3Configs:test_SetMultipleConfigs_Success() (gas: 2140058)
MultiOCR3Base_setOCR3Configs:test_SignerCannotBeZeroAddress_Revert() (gas: 141702)
MultiOCR3Base_setOCR3Configs:test_StaticConfigChange_Revert() (gas: 807256)
MultiOCR3Base_setOCR3Configs:test_TooManySigners_Revert() (gas: 158772)
MultiOCR3Base_setOCR3Configs:test_TooManyTransmitters_Revert() (gas: 112266)
MultiOCR3Base_setOCR3Configs:test_TransmitterCannotBeZeroAddress_Revert() (gas: 254068)
MultiOCR3Base_setOCR3Configs:test_UpdateConfigSigners_Success() (gas: 859969)
MultiOCR3Base_setOCR3Configs:test_UpdateConfigTransmittersWithoutSigners_Success() (gas: 475059)
MultiOCR3Base_transmit:test_ConfigDigestMismatch_Revert() (gas: 42837)
MultiOCR3Base_transmit:test_ForkedChain_Revert() (gas: 48442)
Expand Down Expand Up @@ -640,12 +640,12 @@ OffRamp_ccipReceive:test_Reverts() (gas: 15773)
OffRamp_commit:test_InvalidIntervalMinLargerThanMax_Revert() (gas: 67458)
OffRamp_commit:test_InvalidInterval_Revert() (gas: 59778)
OffRamp_commit:test_InvalidRootRevert() (gas: 58858)
OffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6536301)
OffRamp_commit:test_NoConfig_Revert() (gas: 6120044)
OffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6534892)
OffRamp_commit:test_NoConfig_Revert() (gas: 6118635)
OffRamp_commit:test_OnlyGasPriceUpdates_Success() (gas: 105929)
OffRamp_commit:test_OnlyPriceUpdateStaleReport_Revert() (gas: 115981)
OffRamp_commit:test_OnlyTokenPriceUpdates_Success() (gas: 105950)
OffRamp_commit:test_PriceSequenceNumberCleared_Success() (gas: 349072)
OffRamp_commit:test_PriceSequenceNumberCleared_Success() (gas: 349049)
OffRamp_commit:test_ReportAndPriceUpdate_Success() (gas: 158960)
OffRamp_commit:test_ReportOnlyRootSuccess_gas() (gas: 136092)
OffRamp_commit:test_RootAlreadyCommitted_Revert() (gas: 136492)
Expand All @@ -654,9 +654,9 @@ OffRamp_commit:test_StaleReportWithRoot_Success() (gas: 224806)
OffRamp_commit:test_UnauthorizedTransmitter_Revert() (gas: 117632)
OffRamp_commit:test_Unhealthy_Revert() (gas: 77674)
OffRamp_commit:test_ValidPriceUpdateThenStaleReportWithRoot_Success() (gas: 204296)
OffRamp_commit:test_WrongConfigWithoutSigners_Revert() (gas: 6530690)
OffRamp_commit:test_WrongConfigWithoutSigners_Revert() (gas: 6529281)
OffRamp_commit:test_ZeroEpochAndRound_Revert() (gas: 47832)
OffRamp_constructor:test_Constructor_Success() (gas: 6123343)
OffRamp_constructor:test_Constructor_Success() (gas: 6121934)
OffRamp_constructor:test_SourceChainSelector_Revert() (gas: 137089)
OffRamp_constructor:test_ZeroChainSelector_Revert() (gas: 103806)
OffRamp_constructor:test_ZeroNonceManager_Revert() (gas: 101677)
Expand All @@ -667,12 +667,12 @@ OffRamp_execute:test_IncorrectArrayType_Revert() (gas: 17305)
OffRamp_execute:test_LargeBatch_Success() (gas: 1812704)
OffRamp_execute:test_MultipleReportsWithPartialValidationFailures_Success() (gas: 357260)
OffRamp_execute:test_MultipleReports_Success() (gas: 284815)
OffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6587413)
OffRamp_execute:test_NoConfig_Revert() (gas: 6170896)
OffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6586004)
OffRamp_execute:test_NoConfig_Revert() (gas: 6169487)
OffRamp_execute:test_NonArray_Revert() (gas: 27809)
OffRamp_execute:test_SingleReport_Success() (gas: 175620)
OffRamp_execute:test_UnauthorizedTransmitter_Revert() (gas: 147848)
OffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6948937)
OffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6947505)
OffRamp_execute:test_ZeroReports_Revert() (gas: 17225)
OffRamp_executeSingleMessage:test_MessageSender_Revert() (gas: 18257)
OffRamp_executeSingleMessage:test_NonContractWithTokens_Success() (gas: 249037)
Expand Down
37 changes: 18 additions & 19 deletions contracts/src/v0.8/ccip/capability/CCIPConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator
error ChainSelectorNotSet();
error TooManyOCR3Configs();
error TooManySigners();
error TooManyTransmitters();
error TooManyBootstrapP2PIds();
error P2PIdsLengthNotMatching(uint256 p2pIdsLength, uint256 signersLength, uint256 transmittersLength);
error NotEnoughTransmitters(uint256 got, uint256 minimum);
Expand All @@ -60,6 +59,15 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator
/// @notice The canonical capabilities registry address.
address internal immutable i_capabilitiesRegistry;

uint8 internal constant MAX_OCR3_CONFIGS_PER_PLUGIN = 2;
uint8 internal constant MAX_OCR3_CONFIGS_PER_DON = 4;
uint256 internal constant CONFIG_DIGEST_PREFIX_MASK = type(uint256).max << (256 - 16); // 0xFFFF00..0
/// @dev must be equal to libocr multi role: https://github.com/smartcontractkit/libocr/blob/ae747ca5b81236ffdbf1714318c652e923a5ff4d/offchainreporting2plus/types/config_digest.go#L28
uint256 internal constant CONFIG_DIGEST_PREFIX = 0x000a << (256 - 16); // 0x000a00..00
bytes32 internal constant EMPTY_ENCODED_ADDRESS_HASH = keccak256(abi.encode(address(0)));
/// @dev 256 is the hard limit due to the bit encoding of their indexes into a uint256.
uint256 internal constant MAX_NUM_ORACLES = 256;

/// @notice chain configuration for each chain that CCIP is deployed on.
mapping(uint64 chainSelector => CCIPConfigTypes.ChainConfig chainConfig) internal s_chainConfigurations;

Expand All @@ -73,13 +81,6 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator
uint32 donId => mapping(Internal.OCRPluginType pluginType => CCIPConfigTypes.OCR3ConfigWithMeta[] ocr3Configs)
) internal s_ocr3Configs;

uint8 internal constant MAX_OCR3_CONFIGS_PER_PLUGIN = 2;
uint8 internal constant MAX_OCR3_CONFIGS_PER_DON = 4;
uint8 internal constant MAX_NUM_ORACLES = 31;
uint256 internal constant CONFIG_DIGEST_PREFIX_MASK = type(uint256).max << (256 - 16); // 0xFFFF00..0
/// @dev must be equal to libocr multi role: https://github.com/smartcontractkit/libocr/blob/ae747ca5b81236ffdbf1714318c652e923a5ff4d/offchainreporting2plus/types/config_digest.go#L28
uint256 internal constant CONFIG_DIGEST_PREFIX = 0x000a << (256 - 16); // 0x000a00..00

/// @param capabilitiesRegistry the canonical capabilities registry address.
constructor(address capabilitiesRegistry) {
if (capabilitiesRegistry == address(0)) {
Expand Down Expand Up @@ -388,26 +389,24 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator
if (cfg.pluginType != Internal.OCRPluginType.Commit && cfg.pluginType != Internal.OCRPluginType.Execution) {
revert InvalidPluginType();
}
// TODO: can we do more sophisticated validation than this?
if (cfg.offrampAddress.length == 0) revert OfframpAddressCannotBeZero();
if (cfg.offrampAddress.length == 0 || keccak256(cfg.offrampAddress) == EMPTY_ENCODED_ADDRESS_HASH) {
revert OfframpAddressCannotBeZero();
}
if (!s_remoteChainSelectors.contains(cfg.chainSelector)) revert ChainSelectorNotFound(cfg.chainSelector);

// Some of these checks below are done in OCR2/3Base config validation, so we do them again here.
// Role DON OCR configs will have all the Role DON signers but only a subset of transmitters.
if (cfg.signers.length > MAX_NUM_ORACLES) revert TooManySigners();
if (cfg.transmitters.length > MAX_NUM_ORACLES) revert TooManyTransmitters();

// We check for chain config presence above, so fChain here must be non-zero.
uint256 minTransmittersLength = 3 * s_chainConfigurations[cfg.chainSelector].fChain + 1;
if (cfg.transmitters.length < minTransmittersLength) {
revert NotEnoughTransmitters(cfg.transmitters.length, minTransmittersLength);
}
if (cfg.F == 0) revert FMustBePositive();
if (cfg.signers.length <= 3 * cfg.F) revert FTooHigh();

if (cfg.p2pIds.length != cfg.signers.length || cfg.p2pIds.length != cfg.transmitters.length) {
uint256 numberOfSigners = cfg.signers.length;
if (numberOfSigners > MAX_NUM_ORACLES) revert TooManySigners();
if (numberOfSigners != cfg.p2pIds.length || numberOfSigners != cfg.transmitters.length) {
revert P2PIdsLengthNotMatching(cfg.p2pIds.length, cfg.signers.length, cfg.transmitters.length);
}
if (cfg.F == 0) revert FMustBePositive();
if (numberOfSigners <= 3 * cfg.F) revert FTooHigh();

if (cfg.bootstrapP2PIds.length > cfg.p2pIds.length) revert TooManyBootstrapP2PIds();

// check for duplicate p2p ids and bootstrapP2PIds.
Expand Down
18 changes: 8 additions & 10 deletions contracts/src/v0.8/ccip/ocr/MultiOCR3Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
/// with multiple OCR plugin support.
abstract contract MultiOCR3Base is ITypeAndVersion, OwnerIsCreator {
// Maximum number of oracles the offchain reporting protocol is designed for
uint256 internal constant MAX_NUM_ORACLES = 31;
uint256 internal constant MAX_NUM_ORACLES = 256;

/// @notice Triggers a new run of the offchain reporting protocol
/// @param ocrPluginType OCR plugin type for which the config was set
Expand Down Expand Up @@ -154,13 +154,12 @@ abstract contract MultiOCR3Base is ITypeAndVersion, OwnerIsCreator {
_clearOracleRoles(ocrPluginType, ocrConfig.signers);

address[] memory signers = ocrConfigArgs.signers;
ocrConfig.signers = signers;

uint8 signersLength = uint8(signers.length);
configInfo.n = signersLength;
if (signers.length > MAX_NUM_ORACLES) revert InvalidConfig(InvalidConfigErrorType.TOO_MANY_SIGNERS);
if (signers.length <= 3 * ocrConfigArgs.F) revert InvalidConfig(InvalidConfigErrorType.F_TOO_HIGH);

if (signersLength > MAX_NUM_ORACLES) revert InvalidConfig(InvalidConfigErrorType.TOO_MANY_SIGNERS);
if (signersLength <= 3 * ocrConfigArgs.F) revert InvalidConfig(InvalidConfigErrorType.F_TOO_HIGH);
configInfo.n = uint8(signers.length);
ocrConfig.signers = signers;

_assignOracleRoles(ocrPluginType, signers, Role.Signer);
}
Expand Down Expand Up @@ -288,17 +287,16 @@ abstract contract MultiOCR3Base is ITypeAndVersion, OwnerIsCreator {
bytes32 hashedReport,
bytes32[] memory rs,
bytes32[] memory ss,
bytes32 rawVs // signatures
bytes32 rawVs
) internal view {
// Verify signatures attached to report
// Verify signatures attached to report. Using a uint256 means we can only verify up to 256 oracles.
uint256 signed = 0;

uint256 numberOfSignatures = rs.length;
for (uint256 i; i < numberOfSignatures; ++i) {
// Safe from ECDSA malleability here since we check for duplicate signers.
address signer = ecrecover(hashedReport, uint8(rawVs[i]) + 27, rs[i], ss[i]);
// Since we disallow address(0) as a valid signer address, it can
// never have a signer role.
// Since we disallow address(0) as a valid signer address, it can never have a signer role.
Oracle memory oracle = s_oracles[ocrPluginType][signer];
if (oracle.role != Role.Signer) revert UnauthorizedSigner();
if (signed & (0x1 << oracle.index) != 0) revert NonUniqueSignatures();
Expand Down
Loading

0 comments on commit 62ba1f0

Please sign in to comment.