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

add(consensus): Adds disable_pow and genesis_hash fields, converts equihash::Solution to an enum #8421

Merged
merged 69 commits into from
Apr 26, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Apr 20, 2024

Motivation

We want to support Regtest in Zebra by committing the Regtest genesis block.

Closes #8412.
Closes #8366.
Closes #8362.
Closes #7846.

Depends-On: #8413.

PR Author Checklist

Check before marking the PR as ready for review:

  • Will the PR name make sense to users?
  • Does the PR have a priority label?
  • Have you added or updated tests?
  • Is the documentation up to date?
For significant changes:
  • Is there a summary in the CHANGELOG?
  • Can these changes be split into multiple PRs?

If a checkbox isn't relevant to the PR, mark it as done.

Solution

  • Adds genesis_hash and disable_pow fields
  • Adds a copy of the Regtest genesis block from zcashd
  • Converts equihash::Solution to an enum to represent the smaller solutions for Regtest
  • Updates Network::checkpoint_list() method to return the genesis checkpoint for Regtest

Related Cleanups:

  • Moves the check for the genesis hash in CheckpointList::from_list() to Network::checkpoint_list() and check that its the first item in the checkpoints that's the genesis hash rather than the first item in the BTreeMap.

Testing

  • Adds a test to check that the Regtest genesis block from zcashd can be validated and committed.
  • Updates a test to check that getting the Regtest checkpoint list won't panic

Review

Anyone can review.

Reviewer Checklist

Check before approving the PR:

  • Does the PR scope match the ticket?
  • Are there enough tests to make sure it works? Do the tests cover the PR motivation?
  • Are all the PR blockers dealt with?
    PR blockers can be dealt with in new tickets or PRs.

And check the PR Author checklist is complete.

Follow Up Work

  • Add a target_difficulty_limit field to testnet::Parameters and set it as U256::from_big_endian(&[0x0f].repeat(8)) for Regtest

arya2 and others added 30 commits April 1, 2024 21:45
…orkKind` as zebra_network::Config::network field type, and converts 'Network' to `NetworkKind` before serializing
…red configs can be parsed, adds an intermediate representation of activation heights
…serde(default)]

- Panics if a non-zero activation height is provided for the `Genesis` network upgrade
- Always sets the `Genesis` and `BeforeOverwinter` network upgrade activation heights to 0 and 1, `BeforeOverwinter` could be overwritten by a later network upgrade
- Makes the `activation_heights` field on `Parameters` private, adds/uses an accessor method instead, and adds a builder struct and `build()` method
… the next NetworkUpgrade if it doesn't find the activation height of `&self`
…s test, moves struct with activation heights outside deserialization impl and accepts it in `ParametersBuilder::activation_heights()` instead of a Vec
@arya2 arya2 force-pushed the params-genesis-hash branch from 622293f to d4f6a0e Compare April 22, 2024 23:51
zebra-chain/src/parameters/network/testnet.rs Outdated Show resolved Hide resolved
zebra-chain/src/parameters/network/testnet.rs Outdated Show resolved Hide resolved
zebra-chain/src/parameters/network/testnet.rs Show resolved Hide resolved
zebra-chain/src/parameters/network_upgrade.rs Outdated Show resolved Hide resolved
zebra-chain/src/work/equihash.rs Outdated Show resolved Hide resolved
@arya2 arya2 force-pushed the params-genesis-hash branch from b7ddb90 to 0f91dd0 Compare April 23, 2024 23:47
@arya2 arya2 requested a review from a team as a code owner April 23, 2024 23:58
upbqdn
upbqdn previously approved these changes Apr 24, 2024
@arya2
Copy link
Contributor Author

arya2 commented Apr 24, 2024

Looks like a test failed due to a port conflict: https://github.com/ZcashFoundation/zebra/actions/runs/8820097707/job/24212898628?pr=8421#step:12:2817

I'll re-run it once the rest of the workflow is done.

Base automatically changed from params-new-regtest to main April 25, 2024 04:04
@mergify mergify bot dismissed upbqdn’s stale review April 25, 2024 04:04

The base branch was changed.

@mergify mergify bot requested a review from a team as a code owner April 25, 2024 04:04
@mergify mergify bot requested review from oxarbitrage and removed request for a team April 25, 2024 04:04
mergify bot added a commit that referenced this pull request Apr 26, 2024
@mergify mergify bot merged commit d84d735 into main Apr 26, 2024
155 checks passed
@mergify mergify bot deleted the params-genesis-hash branch April 26, 2024 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Consensus rule updates A-network Area: Network protocol updates or fixes C-enhancement Category: This is an improvement C-feature Category: New features C-testing Category: These are tests NU-6 Network Upgrade: NU6 specific tasks P-Medium ⚡
Projects
None yet
2 participants