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/network): Adds new_regtest() constructors to testnet::Parameters and Network #8413

Merged
merged 56 commits into from
Apr 25, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Apr 18, 2024

Motivation

We want to support Regtest in Zebra.

This PR adds methods for creating a new Network or testnet::Parameters with the Regtest parameters as the values of fields that exist on testnet::Parameters so far.

We'll need to add at least a few more fields (see 'Follow Up Work') that are needed for Regtest to testnet::Parameters and set them as their Regtest values in these methods for Zebra to support a minimal version of Regtest. Creating the genesis block may also rely on adding more parameters.

Closes #7839.

Depends-On: #8411.

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 new_regtest() constructor methods to testnet::Parameters and zebra_chain::Network
  • Calls Network::new_regtest() instead of unimplemented!() in the zebra_network::Config deserialization
  • Adds with_sapling_hrps() method on ParametersBuilder and uses it to set the Regtest HRPs in new_regtest()

Related Cleanups:

  • Returns an error when deserializing the config if it uses any default initial peers for a configured testnet
  • Allows for defining testnet_parameters in the config on Mainnet and Regtest (and the Regtest activation heights on other networks)
  • Refactors Testnet parameters and Regtest activation heights part of zebra_network::Config deserialization
  • Uses default Testnet activation heights as the default configured Testnet activation heights
  • Uses the activation heights from ParametersBuilder in testnet::Parameters::default()

Testing

  • Updates the latest stored config
  • Checks the default Regtest activation heights in activates_network_upgrades_correctly()
  • Adds a test for checking that ParametersBuilder validates configured Sapling HRPs as expected

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

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
Co-authored-by: Marek <mail@marek.onl>
…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-new-regtest branch from 741c158 to b38dbfd Compare April 19, 2024 19:44
Base automatically changed from params-network-name to main April 24, 2024 11:03
@upbqdn
Copy link
Member

upbqdn commented Apr 24, 2024

@arya2, this PR needs a manual merge conflict resolution.

upbqdn
upbqdn previously approved these changes Apr 24, 2024
upbqdn
upbqdn previously approved these changes Apr 24, 2024
@arya2 arya2 requested a review from upbqdn April 24, 2024 17:37
@arya2 arya2 requested a review from upbqdn April 24, 2024 20:35
mergify bot added a commit that referenced this pull request Apr 25, 2024
@arya2
Copy link
Contributor Author

arya2 commented Apr 25, 2024

@Mergifyio refresh

Copy link
Contributor

mergify bot commented Apr 25, 2024

refresh

✅ Pull request refreshed

mergify bot added a commit that referenced this pull request Apr 25, 2024
@mergify mergify bot merged commit e5d4d73 into main Apr 25, 2024
191 checks passed
@mergify mergify bot deleted the params-new-regtest branch April 25, 2024 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes C-feature Category: New features C-testing Category: These are tests C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG NU-6 Network Upgrade: NU6 specific tasks P-Medium ⚡
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a regtest() constructor method to Network
2 participants