-
Notifications
You must be signed in to change notification settings - Fork 2
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
pallet-randomness-beacon: security and genesis #133
base: main
Are you sure you want to change the base?
Conversation
pallets/randomness-beacon/src/lib.rs
Outdated
@@ -173,6 +181,13 @@ pub mod pallet { | |||
GenesisRoundNotSet, | |||
/// The genesis is already set. | |||
GenesisRoundAlreadySet, | |||
/// There must be at least one signature to construct an asig | |||
ZeroHeightProvided, | |||
/// There number of aggregated signatures exceeds the maximum rounds we can verify per |
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.
Typo here. I think it should say "The number of..."
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
fn check_inherent(call: &Self::Call, _data: &InherentData) -> Result<(), Self::Error> { | ||
match call { | ||
Call::try_submit_asig { .. } => Ok(()), | ||
_ => unreachable!("other calls are not inherents"), |
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've seen this elsewhere in Substrate, do you know why panicing instead of returning an error?
/// A dummy `on_initialize` to return the amount of weight that `on_finalize` requires to | ||
/// execute. | ||
fn on_initialize(_n: BlockNumberFor<T>) -> Weight { | ||
// weight of `on_finalize` | ||
T::WeightInfo::on_finalize() | ||
} |
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 do we return the on_finalize weight?
/// At the end of block execution, the `on_finalize` hook checks that the timestamp was | ||
/// updated. Upon success, it removes the boolean value from storage. If the value resolves |
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 guess you meant the 'aggregated signatures' instead of 'timestamp'?
// aggregate old asig/apk with the new one and verify the aggregation | ||
// Q: do we care about the entire linear history of message hashes? |
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.
This is useful for searching for the keyword 'todo'
// Q: do we care about the entire linear history of message hashes? | |
// TODO: do we care about the entire linear history of message hashes? |
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 just had a few minor comments, but looks good
This PR focuses on ensuring the integrity and security of the randomness beacon pallet.
try_sumit_asig
extrinsic to be callable a single time per block. While the initial intention was to use a signed payload with an unsigned transaction to provide security to the extrinsic, this proved infeasible unless an offchain worker is used. OCWs do not guarantee execution, making this unviable. More simply, the extrinsic operates similarly to pallet_timestamp, simply ensuring that the extrinsic can be called once per block. Since the call is submitted as an inherent, the validator-authored call is the first one in the transaction pool that is executed even if others try to submit calls. In addition, subsequent calls within the same block would fail regardless, as invalid (forgery attack) and duplicate signatures are rejected (replay attack). This closes pallet-randomness-beacon: inherent security #117