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

[Feat] Increase MAX_CERTIFICATES on MainnetV0 #2586

Closed

Conversation

raychu86
Copy link
Contributor

@raychu86 raychu86 commented Dec 20, 2024

Motivation

This PR plans to increase the number N::MAX_CERTIFICATES value for MainnetV0. The main result of this change is that the maximum number of validators in a committee is also increased. Since Mainnet was launched, the codebase has undergone some extensive upgrades and optimizations and based on internal/external testing, we believe the number of validators can be expanded safely. The original maximum is 16 and this change increases that value to 25 (subject to change).

Increasing the number of validators creates a more robust and more decentralized network. This increase also has a number of other effects (increasing TPS, increasing network overhead, and increasing block size to name a few), so we must be vigilant when deciding to expand this number. As we further improve the network, we can iteratively increase the maximum number of validators in order to ensure network stability, even if it feels conservative.

Migration:

  • Introduce N::CONSENSUS_V3_HEIGHT to Network trait
    • This is the height for each network that snarkVM will swap from the v2 consensus to v3 consensus.
  • SnarkOS will require nodes to swap to the new version before height N::CONSENSUS_V3_HEIGHT, otherwise there may be some issues.
    • Validators need to change to the new version or risk possible forking
    • Clients need to change to the new version or risk sync halting

The migration and reward logic change will occur at the following block heights (These heights are subject to change):

Canary - Block 4,560,000 (~Jan 24, 2025 at the current 3.7s block times)

Testnet - Block 4,800,000 (~Jan 31, 2025 at the current 3.4s block times)

Mainnet - Block 4,900,000 (~Feb 18, 2025 at the current 3.0s block times)

These numbers were calculated by determining the planned release schedule and backing into the block height using the current block speeds and including a buffer between release and consensus change. This buffer is intended to give leeway for nodes to upgrade before the consensus change. The following table is the approximate timeline and buffers for the networks:

Network Release Date Buffer Consensus V3
Canary Jan 21, 2025 3 days Jan 24, 2025
Testnet Jan 28, 2025 3 days Jan 31, 2025
Mainnet Feb 11, 2025 7 days Feb 18, 2025

Test Plan

Tests have been added to ensure that the migration properly transitions the old MAX_CERTIFICATES_BEFORE_V3 value to the new MAX_CERTIFICATES value.

CI can be found here.

Related PRs

Migration will coincide with #2575.

TODO

  • Determine final numbers for MAX_CERTIFICATES and migration block heights
  • Run extensive devnet testing

@kpandl
Copy link
Collaborator

kpandl commented Jan 7, 2025

I've tested the PR, specifically bonding validators at various block heights (old and new consensus heights) and for various sizes (within the max number of validators, and above it). Most of the tests work fine.

There's just one edge case we should fix: it is now possible to run a new network with the latest N::MAX_CERTIFICATES from height 0 on. For example, you can run a new mainnet network using the devnet script with 25 validators. This shouldn't be possible, at height 0 only 16 validators should be allowed. To fix it, we need to make the following section dependent on the block height: https://github.com/AleoNet/snarkVM/blob/be48f30bfeb78f327a57d08f23f7a0aff4e65a95/ledger/committee/src/lib.rs#L73-L82

@vicsn vicsn added the v1.3.0 label Jan 14, 2025
@raychu86 raychu86 marked this pull request as draft January 15, 2025 01:37
@raychu86
Copy link
Contributor Author

ATTENTION: THIS PR WILL BE SUPERCEDED BY #2595 DUE TO BRANCHING ISSUES.

ALL DISCUSSION WILL BE MOVED THERE AND THIS BRANCH WILL BE CLOSED

@raychu86 raychu86 closed this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants