-
Notifications
You must be signed in to change notification settings - Fork 57
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
Validate transmitter lengths against F values #1432
Conversation
f39fe10
to
535a28e
Compare
LCOV of commit
|
28db659
to
0d6f63c
Compare
contracts/src/v0.8/ccip/capability/libraries/CCIPConfigTypes.sol
Outdated
Show resolved
Hide resolved
@@ -157,6 +163,9 @@ abstract contract MultiOCR3Base is ITypeAndVersion, OwnerIsCreator { | |||
|
|||
if (signers.length > MAX_NUM_ORACLES) revert InvalidConfig(InvalidConfigErrorType.TOO_MANY_SIGNERS); | |||
if (signers.length <= 3 * ocrConfigArgs.F) revert InvalidConfig(InvalidConfigErrorType.F_TOO_HIGH); | |||
// NOTE: Transmitters cannot exceed signers. Transmitters do not have to be >= 3F + 1 because they can match >= 3fChain + 1, where fChain <= F. | |||
// fChain is not represented in MultiOCR3Base - so we skip this check. |
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.
Why is it not?
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.
Mainly because fChain
is not part of the OCR config in the CCIPConfig logic, and not part of the blue/green deployments. We aimed to keep the OCR3 configs as consistent as possible.
fChain
can be updated outside of b/g flows (valid updates would be decreases), which would prompt updates in MultiOCR3 through the non b/g path - that would complicate tooling since we typically only update MultiOCR3 in the b/g update path
vm.assume(ocrConfig.transmitters.length <= 31); | ||
vm.assume(ocrConfig.signers.length <= 31); | ||
vm.assume(ocrConfig.transmitters.length <= 255); | ||
vm.assume(ocrConfig.signers.length <= 255); |
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.
These might be very restrictive assumes. Assume is only correct to exclude a very small set of inputs. The check below of > 0 is perfect for it. The check ocrConfig.transmitters.length <= ocrConfig.signers.length
is already too restrictive as it discards half of all inputs it tried.
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.
Could release the assumes, but then the test would be more complex to cover unhappy paths (which are already covered by non-fuzz tests)
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.
We can punt this test improvement
Quality Gate passedIssues Measures |
Motivation
Improves validations for OCR3 and CCIPConfig contracts
Solution
Covers validations:
fChain <= F
, sinceF
represents the full role DONlen(transmitters) <= len(signers)
, while still enforcinglen(transmitters) >= 3 * fChain + 1
len(signers) >= len(transmitters)
in MultiOCR3Tooling implications
chainConfigs
must be set before OCR3 configs due to the addedfChain == F
validationfChain
becomes higher thanF
after updates, existing OCR3 configs get invalidated without an on-chain check (since it is difficult to do). There should be an off-chain validation script that prevents this (first, F should be increased for all configs, only after which fChain can be increased)OffRamp
transmitters.length should be validated such that it meets the3 * fChain + 1
criteria off-chain, sincefChain
is not tracked in theOffRamp
Gas