-
Notifications
You must be signed in to change notification settings - Fork 632
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
refactor: remove block vrf verification from epoch manager #12447
base: stefan/remove_verify_chunk_header
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,6 +233,13 @@ pub trait EpochManagerAdapter: Send + Sync { | |
height: BlockHeight, | ||
) -> Result<AccountId, EpochError>; | ||
|
||
/// Block producers and stake for given height for the main block. Return EpochError if outside of known boundaries. | ||
fn get_block_producer_info( | ||
&self, | ||
epoch_id: &EpochId, | ||
height: BlockHeight, | ||
) -> Result<ValidatorStake, EpochError>; | ||
|
||
/// Chunk producer info for given height for given shard. Return EpochError if outside of known boundaries. | ||
fn get_chunk_producer_info( | ||
&self, | ||
|
@@ -324,15 +331,6 @@ pub trait EpochManagerAdapter: Send + Sync { | |
next_epoch_info: EpochInfo, | ||
) -> Result<(), EpochError>; | ||
|
||
fn verify_block_vrf( | ||
&self, | ||
epoch_id: &EpochId, | ||
block_height: BlockHeight, | ||
prev_random_value: &CryptoHash, | ||
vrf_value: &near_crypto::vrf::Value, | ||
vrf_proof: &near_crypto::vrf::Proof, | ||
) -> Result<(), Error>; | ||
|
||
/// Verify validator signature for the given epoch. | ||
/// Note: doesn't account for slashed accounts within given epoch. USE WITH CAUTION. | ||
fn verify_validator_signature( | ||
|
@@ -691,8 +689,16 @@ impl EpochManagerAdapter for EpochManagerHandle { | |
epoch_id: &EpochId, | ||
height: BlockHeight, | ||
) -> Result<AccountId, EpochError> { | ||
self.get_block_producer_info(epoch_id, height).map(|validator| validator.take_account_id()) | ||
} | ||
|
||
fn get_block_producer_info( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pugachAG, how comfortable are we with exposing block producer info? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't see any issues with that, especially considering that we already expose chunk producer info this way |
||
&self, | ||
epoch_id: &EpochId, | ||
height: BlockHeight, | ||
) -> Result<ValidatorStake, EpochError> { | ||
let epoch_manager = self.read(); | ||
Ok(epoch_manager.get_block_producer_info(epoch_id, height)?.take_account_id()) | ||
Ok(epoch_manager.get_block_producer_info(epoch_id, height)?) | ||
} | ||
|
||
fn get_chunk_producer_info( | ||
|
@@ -796,27 +802,6 @@ impl EpochManagerAdapter for EpochManagerHandle { | |
) | ||
} | ||
|
||
fn verify_block_vrf( | ||
&self, | ||
epoch_id: &EpochId, | ||
block_height: BlockHeight, | ||
prev_random_value: &CryptoHash, | ||
vrf_value: &near_crypto::vrf::Value, | ||
vrf_proof: &near_crypto::vrf::Proof, | ||
) -> Result<(), Error> { | ||
let epoch_manager = self.read(); | ||
let validator = epoch_manager.get_block_producer_info(epoch_id, block_height)?; | ||
let public_key = near_crypto::key_conversion::convert_public_key( | ||
validator.public_key().unwrap_as_ed25519(), | ||
) | ||
.unwrap(); | ||
|
||
if !public_key.is_vrf_valid(&prev_random_value.as_ref(), vrf_value, vrf_proof) { | ||
return Err(Error::InvalidRandomnessBeaconOutput); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn verify_validator_signature( | ||
&self, | ||
epoch_id: &EpochId, | ||
|
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: could we put
verify_block_vrf
as part of imports instead of fully qualifying?