-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat: CCIPConfig, adding exhaustive checks for p2pIds and bootstrapP2PIds #1178
Conversation
Signed-off-by: 0xsuryansh <[email protected]>
LCOV of commit
|
Signed-off-by: 0xsuryansh <[email protected]>
@@ -146,6 +147,16 @@ func P2pIDsFromInts(ints []int64) [][32]byte { | |||
p2pID := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(i)).PeerID() | |||
p2pIDs = append(p2pIDs, p2pID) | |||
} | |||
sort.Slice(p2pIDs, func(i, j int) bool { | |||
for k := 0; k < 32; k++ { | |||
if p2pIDs[i][k] < p2pIDs[j][k] { |
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.
Wow does this work as expected?
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.
Ah nvm I thought you were comparing arrays.
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.
Is this basically the same as converting to a uint256
and comparing? I think it is but not 100% sure. If it is, it might be easier to grok this sort that way instead of this.
@@ -0,0 +1,5 @@ | |||
--- |
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 remove the changeset, we do not use them in ccip
@@ -536,6 +557,130 @@ contract CCIPConfig_validateConfig is CCIPConfigSetup { | |||
vm.expectRevert(abi.encodeWithSelector(CCIPConfig.NodeNotInRegistry.selector, nonExistentP2PId)); | |||
s_ccipCC.validateConfig(config); | |||
} |
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.
q: are we still planning the fuzz test for validateConfig
?
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.
Added a ticket for this, will pick this up ref : https://smartcontract-it.atlassian.net/browse/CCIP-2004
Motivation
In
CCIPConfig._validateConfig
we try to do an exhaustive amount of validations,the following validations remained
Ticket CCIP-2595
Solution
Created a library
SortedSetValidationUtil
in chainlink main-repo smartcontractkit/chainlink#13774 to support these sort, duplicate and subset check inCCIPConfig
.These changes are cherry-picked
This library can also be used in the optimisation of
CCIPConfigArraysValidation._ensureInRegistry
Regarding 1 : Since each p2pId at index i corresponds to the signer at index i both arrays can't be sorted at the same time.
Hence, we are going the enforce that p2pIds and bootstrapP2PIds are sent sorted on function calls to in
CCIPConfig
contract. This means that these exhaustive checks forbytes[] signers
andbytes[] transmitters
needs to be done in off-chain tooling.