-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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 audit feedback on committee creation #16909
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
// `try_create_next_committee` will abort if bridge_pubkey_bytes are not unique and | ||
// that will fail the end of epoch transaction (possibly "forever", well, we | ||
// need to deploy proper validator changes to stop end of epoch from failing). | ||
assert!(check_uniqueness_bridge_keys(self, bridge_pubkey_bytes), EDuplicatePubkey); |
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.
I could just call the API here and have the assert
inside check_uniqueness_bridge_keys
if anybody feels strongly about it let me know
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.
assert inside check_uniqueness_bridge_keys
is slightly preferential to me, but not a strong opinion
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.
changed
test_utils::destroy(committee); | ||
test_scenario::return_shared(system_state); | ||
test_scenario::end(scenario); |
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.
nit: You could avoid non-needed code on failure-expecting tests by aborting (abort 1337
)
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.
I could, just leaving that in line with the other tests.
Having said so and given I need to review tests and code coverage I may apply that story to all existing tests in that future PR.
Thanks for the hint, I keep forgetting that and go trough tricks every time I write 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.
til
if (registration.bridge_pubkey_bytes == bridge_pubkey_bytes) { | ||
if (found) { | ||
return false | ||
}; | ||
found = true; |
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.
nit: I'd probably pass down the sender's address too and check as the "found" thing messed with my brain (but could be me malfunctioning)
if (registration.bridge_pubkey_bytes == bridge_pubkey_bytes && registration.sui_address != sender ) { return false }
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.
not sure I follow, the found
is to make sure that bridge_pubkey_bytes
is unique in the list of proposed committee upgrade.
I may be missing something here
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.
it messed with my brain as well and could be me malfunctioning too.
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.
renamed the field and added comments that should hopefully help fix the confusion
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.
LGTM
@@ -164,9 +165,35 @@ module bridge::committee { | |||
registration | |||
}; | |||
|
|||
// check uniqeuness of the bridge pubkey. |
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.
uniqueness
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.
fixed
// `try_create_next_committee` will abort if bridge_pubkey_bytes are not unique and | ||
// that will fail the end of epoch transaction (possibly "forever", well, we | ||
// need to deploy proper validator changes to stop end of epoch from failing). | ||
assert!(check_uniqueness_bridge_keys(self, bridge_pubkey_bytes), EDuplicatePubkey); |
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.
assert inside check_uniqueness_bridge_keys
is slightly preferential to me, but not a strong opinion
if (registration.bridge_pubkey_bytes == bridge_pubkey_bytes) { | ||
if (found) { | ||
return false | ||
}; | ||
found = true; |
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.
it messed with my brain as well and could be me malfunctioning too.
test_utils::destroy(committee); | ||
test_scenario::return_shared(system_state); | ||
test_scenario::end(scenario); |
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.
til
## Description As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee. Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem. This should prevent the problem from happeing. ## Test Plan Added unit test --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
## Description As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee. Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem. This should prevent the problem from happeing. ## Test Plan Added unit test --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
## Description As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee. Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem. This should prevent the problem from happeing. ## Test Plan Added unit test --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
## Description As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee. Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem. This should prevent the problem from happeing. ## Test Plan Added unit test --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
## Description As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee. Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem. This should prevent the problem from happeing. ## Test Plan Added unit test --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
## Description As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee. Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem. This should prevent the problem from happeing. ## Test Plan Added unit test --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
Description
As reported by audit if a validator registers with an already used pubkey for the bridge (whether maliciously or not) the creation of the committee will fail and as such an end of epoch would fail attempting to create the committee.
Moreover there is no way at the moment to flush the proposed committee (in that respect, should we have an API for it?) and it would require an emergency release to take care of the problem.
This should prevent the problem from happeing.
Test Plan
Added unit test
If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section.
Type of Change (Check all that apply)
Release notes