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 mocknet helpers #1273

Merged
merged 3 commits into from
May 24, 2022
Merged

Add mocknet helpers #1273

merged 3 commits into from
May 24, 2022

Conversation

prasannavl
Copy link
Member

@prasannavl prasannavl commented May 24, 2022

/kind feature

Adds the following undocumented flags:

  • -mocknet - Enables mocked mainnet for testing. Useless without further patch.
  • -mocknet-blocktime=<secs> - Block time option when mocknet is enabled
  • -mocknet-key=<pubkey> - Adds an optional foundation key into mocknet for testing.

Has the patch file: contrib/devtools/mocknet.patch.

  • The patch nullifies the difficulty of mocknet, so that it's easier to mine with any MNs that's carried over into mocknet.
  • The patch is technically not required and can just be a part of the main code, as it is gated. However, just to ensure there is no accidental or potential exploit that can utilize it, it is for now kept completely off the main code and carried as an optional patch.

Procedure for mock testing mainnet:

  • git apply contrib/devtools/mocknet.patch
  • Change the fork height as desired on chainparams.
  • Start with `-mocknet [-mocknet-blocktime=] [-mocknet-key="pubkey"]

This allows easier testing, and further automated mocked testing of mainnet. It is possible to fully bake in a MN into mocknet as well, but requires further work. For now, MNs need to carried over.

@Mixa84
Copy link
Contributor

Mixa84 commented May 24, 2022

I would put everything in the .patch as if other modification gets into the master, users will be able to start the node with -mocknet and then it will probably fork their node as nTargetSpacing and nTargetTimespanV2 are different...

@prasannavl
Copy link
Member Author

prasannavl commented May 24, 2022

True, but I don't think it matters, as the difficulty is unchanged. So they will never be able to mine on the new one unless they have the mining power - it's not theoretically possible for the fork to catch up, even if the MN used gets very very lucky.

Also to note: Since the work proof is unchanged, the nodes without -mocknet or with it but without the patch will reject these blocks.

@prasannavl prasannavl merged commit 353f1f6 into master May 24, 2022
@prasannavl prasannavl deleted the pvl/mocknet branch May 24, 2022 11:05
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.

4 participants