Skip to content
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

POS data verification #106

Merged
merged 5 commits into from
Jul 20, 2023
Merged

POS data verification #106

merged 5 commits into from
Jul 20, 2023

Conversation

poszu
Copy link
Collaborator

@poszu poszu commented Jul 17, 2023

Related to spacemeshos/post#180

Add a way to verify a fraction of labels of initialized POS.

@poszu poszu requested a review from fasmat July 17, 2023 15:18
@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Merging #106 (44c7379) into main (f6b4ba5) will increase coverage by 0.12%.
The diff coverage is 99.16%.

@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
+ Coverage   97.43%   97.56%   +0.12%     
==========================================
  Files          12       13       +1     
  Lines        1481     1601     +120     
==========================================
+ Hits         1443     1562     +119     
- Misses         38       39       +1     
Impacted Files Coverage Δ
src/pos_verification.rs 98.59% <98.59%> (ø)
src/metadata.rs 98.27% <100.00%> (+9.38%) ⬆️

src/pos_verification.rs Show resolved Hide resolved
Comment on lines +83 to +90
CpuInitializer::new(scrypt_params)
.initialize_to(
&mut expected_label.as_mut_slice(),
&commitment,
label_index..label_index + 1,
None,
)
.map_err(|e| VerificationError::InitError(format!("{e:?}")))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this instance be re-used? Creating a new instance of CpuInitializer for every label that is verified seems wasteful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's free:

post-rs/src/initialize.rs

Lines 96 to 100 in d70db43

impl CpuInitializer {
pub fn new(scrypt_params: ScryptParams) -> Self {
Self { scrypt_params }
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this still need to allocate the object and free it again on every iteration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It's on the stack, so nothing needs to be allocated. It will be completely optimized away.

@poszu poszu requested a review from fasmat July 19, 2023 14:27
@poszu poszu merged commit 913999a into main Jul 20, 2023
20 checks passed
@poszu poszu deleted the pos-data-verification branch July 20, 2023 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants