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

zcash_protocol: Add constructors to LocalNetwork #1281

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Oscar-Pepper
Copy link
Contributor

Adds commonly used constructors to LocalNetwork struct.

nuttycom
nuttycom previously approved these changes Apr 3, 2024
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

utACK

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 63.35%. Comparing base (e0227ed) to head (f668e1f).
Report is 104 commits behind head on main.

❗ Current head f668e1f differs from pull request most recent head 68d2add. Consider uploading reports for the commit 68d2add to get more accurate results

Files Patch % Lines
components/zcash_protocol/src/local_consensus.rs 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1281      +/-   ##
==========================================
- Coverage   63.40%   63.35%   -0.06%     
==========================================
  Files         121      121              
  Lines       13757    13768      +11     
==========================================
  Hits         8723     8723              
- Misses       5034     5045      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Reviewed 68d2add.

@@ -10,6 +10,8 @@ and this library adheres to Rust's notion of
### Added
- `zcash_protocol::memo`:
- `impl TryFrom<&MemoBytes> for Memo`
- `zcash_protocol::local_consensus`:
- `new`, `all_upgrades_active` and `canopy_active` constructors to `LocalNetwork`
Copy link
Contributor

Choose a reason for hiding this comment

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

PR needs a rebase because this now merge-conflicts with the 0.1.1 release (in that it will end up editing the 0.1.1 changelog).

Comment on lines +52 to +57
overwinter: u64,
sapling: u64,
blossom: u64,
heartwood: u64,
canopy: u64,
nu5: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realised that all of these arguments are u64. Two questions:

  • Why not BlockHeight?
  • If not BlockHeight, why u64? The internal casts to u32 will silently truncate the heights, which is undocumented and confusing. Additionally, these truncations occur after the assertion, which means that a caller can bypass the ordering requirement by setting the high bits of the heights.

The latter question is blocking; these should be u32 at a minimum, and I don't see a good reason for these to not be BlockHeight.


/// Construct a new `LocalNetwork` with all network upgrades up to and including canopy
/// initally active.
pub fn canopy_active(nu5_activation_height: u64) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto: this should at least be u32, and probably a BlockHeight.

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.

3 participants