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(chain): Adds a network_name field to testnet::Parameters #8411

Merged
merged 44 commits into from
Apr 24, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Apr 18, 2024

Motivation

We want to allow for configuring the network name so that cached chain states for different networks are stored separately and configured network names can be displayed in Zebra's logs or elsewhere.

Closes #8327.

Depends-On: #8383.

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 network_name fields to testnet::Parameters and ParametersBuilder
    • Sets default network name to Testnet and default configured Testnet name to UnknownTestnet
  • Adds accessor method for testnet::Parameters
  • Defines a constant with disallowed network names and max name length
  • Applies constraints on network name in the builder method for setting the network name:
    • Max length of 30
    • Only alphanumeric characters or _ (because the lowercase form will be part of the cache directory path)
    • No reserved network names
  • Returns the network name from testnet::Parameters instead of hard-coded values in Display trait impl for Network
  • Adds an optional config field for defining the network name

Related cleanups:

  • Renames ParametersBuilder::activation_heights() to with_activation_heights()
  • Removes unnecessary .filter() in ParametersBuilder::with_activation_heights()

Testing

Adds a test to check that:

  • It panics when setting the network name as a reserved name
  • It panics when other constraints are violated (if the name is too long or disallowed characters)
  • Valid network names are set and displayed
  • Network is displayed correctly for Mainnet and the default Testnet

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 new_regtest() constructor method to testnet::Parameters and Network (#7839)

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 self-assigned this Apr 18, 2024
@arya2 arya2 requested review from a team as code owners April 18, 2024 03:25
@arya2 arya2 requested review from oxarbitrage and removed request for a team April 18, 2024 03:25
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Apr 18, 2024
@arya2 arya2 force-pushed the params-network-name branch from 736572c to a842c12 Compare April 18, 2024 18:06
Base automatically changed from activ-heights-param-impl to main April 19, 2024 01:20
@mergify mergify bot requested a review from a team as a code owner April 19, 2024 01:20
@mergify mergify bot requested review from upbqdn and removed request for a team April 19, 2024 01:20
@oxarbitrage oxarbitrage removed request for a team and oxarbitrage April 19, 2024 17:23
@arya2
Copy link
Contributor Author

arya2 commented Apr 24, 2024

@oxarbitrage Looks like rejection_restores_internal_state_genesis does sometimes fail on Windows: https://github.com/ZcashFoundation/zebra/actions/runs/8808071916/job/24176434273?pr=8411#step:12:4695

I didn't find "invalid quick check" in the logs, and check_for_duplicate_trees() returns early if there was an error, so it must be one of the detailed checks.

@mergify mergify bot merged commit 275e99e into main Apr 24, 2024
191 checks passed
@mergify mergify bot deleted the params-network-name branch April 24, 2024 11:03
@arya2 arya2 added this to the Regtest Network support milestone Apr 24, 2024
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 A-state Area: State / database changes C-testing Category: These are tests C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG I-usability Zebra is hard to understand or use NU-6 Network Upgrade: NU6 specific tasks P-Medium ⚡
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a name field to NetworkParameters to be used at the end of the cache dir path
2 participants