-
Notifications
You must be signed in to change notification settings - Fork 160
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: support drand quicknet #3873
Conversation
c1d9ed6
to
9e96b1e
Compare
9e96b1e
to
55eb7af
Compare
@@ -75,17 +74,10 @@ impl BeaconSchedule { | |||
parent_epoch: ChainEpoch, | |||
prev: &BeaconEntry, | |||
) -> Result<Vec<BeaconEntry>, anyhow::Error> { | |||
let (cb_epoch, curr_beacon) = self.beacon_for_epoch(epoch)?; |
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.
|
||
let chain_info = &config.chain_info; | ||
|
||
if cfg!(debug_assertions) && config.network_type == DrandNetwork::Mainnet { |
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 has been covered by unit tests
src/beacon/drand.rs
Outdated
}; | ||
// Signature | ||
let sig = Signature::from_bytes(curr.data())?; | ||
let sig_match = bls_signatures::verify_messages(&sig, &[&digest], &[self.pub_key.key()?]); |
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.
bls_signatures::verify_messages
is designed for validating bls_messages
in full tipsets, with 1 signature and a list of (message, public key) pairs to validate. While for drand beacon verification, there are 1 public key and a list of (message, signature) pairs to validate, so re-writing the logic to allow benefiting from parallelization.
.beacon_for_epoch(parent_epoch) | ||
.map_err(|e| Error::Validation(e.to_string()))?; | ||
|
||
if cb_epoch != pb_epoch { |
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.
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 expert-review, just a few nits
Cargo.toml
Outdated
@@ -26,6 +26,8 @@ bls-signatures = { version = "0.15", default-features = false, features = [ | |||
"multicore", | |||
"blst-portable", | |||
] } # prevent SIGINT on CI runners by using portable assembly | |||
blst = { version = "0.3", features = ["portable"] } |
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'm surprised that we need both these libraries - it looks like we're only using blst::BLST_ERROR
- can you confirm this is necessary?
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.
Good catch, it should be ok to downcast to anyhow::Error
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.
blst
removed
let max_round = curr_beacon.max_beacon_round_for_epoch(network_version, epoch); | ||
// We don't expect this to ever be the case |
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.
should we log or panic!
on this branch?
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 comment and logic are from the lotus PR, I'm not 100% sure if it's true and I'd be careful adding panic here that might crash forest in some edge cases
// We don't expect this to ever be the case
if maxRound == prev.Round {
return nil, nil
}
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.
let's add at least a massive error log so there's a chance it catches our attention, just in case
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.
@LesnyRumcajs Log added, please re-approve if it looks good.
src/networks/mainnet/mod.rs
Outdated
@@ -170,6 +170,11 @@ pub(super) static DRAND_SCHEDULE: [DrandPoint<'static>; 2] = [ | |||
height: SMOKE_HEIGHT, | |||
config: &DRAND_MAINNET, | |||
}, | |||
DrandPoint { | |||
// height is TDB |
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.
what does this mean?
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 need to update the right height to perform the upgrade later. It should be the Pineapple upgrade Epoch but it's not defined in forest yet.
Co-authored-by: Aatif Syed <38045910+aatifsyed@users.noreply.github.com>
@hanabi1224 shall we remove the changes included in #3887 from this PR? |
@LesnyRumcajs I plan to merge this after #3887 so the changes will be gone after resolving merge conflicts, sounds good? |
let entry = curr_beacon.entry(cur).await?; | ||
cur = entry.round() - 1; | ||
out.push(entry); | ||
// We only ever need one entry after nv22 (FIP-0063) |
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.
the quicknet change will be at exactly the same epoch as the nv22 upgrade?
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.
The logic and comments here replicate lotus, and yes, I think the planned upgrade epoch is the pineapple upgrade
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.
Did you manage to test it on a devnet?
@LesnyRumcajs Not yet, that would require the miner changes ready on lotus side as discussed in the sync call. On our side, I believe I just need to update the lotus tag and devnet upgrade epoch accordingly and it will be covered by the devnet checks CI job |
Co-authored-by: Hubert <hubert@chainsafe.io>
@LesnyRumcajs removed. |
cur = entry.round() - 1; | ||
out.push(entry); | ||
// We only ever need one entry after nv22 (FIP-0063) | ||
if network_version > NetworkVersion::V21 { |
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.
What if epoch
is between PineappleUpgradeHeight
and PineappleUpgradeHeight + 10
Summary of changes
Changes introduced in this pull request:
Implement quicket beacon verification with unit testsRefactor mainnet beacon verification to support batching with unit tests and replacebls_signatues::verify_messages
which is designed to verify bls messages in tipsets instead of beaconsverify_bls_aggregate
Reference issue to close (if applicable)
Closes #3763
Other information and links
Change checklist