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

[CLI] Make the number of validators configurable for sui genesis and sui start #20511

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

stefan-mysten
Copy link
Contributor

Description

This PR enables sui genesis and sui start to pass the committee-size argument specifying the number of validators that should be started in the local network.

Note that if sui start --committee-size 3 is executed with no .sui or genesis data, on a subsequent run the --committee-size arg will be ignored.

Test plan

Locally. Checked the number of generated config files for validators + GraphQL query.

sui start --committee-size 3 --with-graphql

➜  sui_config ls -l
total 3104
-rw-r--r--  1 s    staff    5338 Dec  4 21:15 127.0.0.1-51144.yaml
-rw-r--r--  1 s    staff    5338 Dec  4 21:15 127.0.0.1-51158.yaml
-rw-r--r--  1 s    staff    5338 Dec  4 21:15 127.0.0.1-51172.yaml
drwxr-xr-x  5 s  staff     160 Dec  4 21:15 authorities_db/
---
{
  "data": {
    "epoch": {
      "validatorSet": {
        "pendingActiveValidatorsSize": 0,
        "activeValidators": {
          "nodes": [
            {
              "address": {
                "address": "0xf6f511d0d450bfe2cc6cfabcc00024fcef2ede7a63b47eefcf0c086249fb4642"
              },
              "name": "validator-1",
              "description": ""
            },
            {
              "address": {
                "address": "0x478572ac85ffeba294d8cbbb87ae4c2b0c223a224ec34e9b75c45b5c210a9fe5"
              },
              "name": "validator-0",
              "description": ""
            },
            {
              "address": {
                "address": "0x7242e93071987c25454a64ae07f6640008d706647e2b9106ac61ac3d2e2d47af"
              },
              "name": "validator-2",
              "description": ""
            }
          ]
        },
        "totalStake": "0"
      }
    }
  }
}

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI: Added the --committee-size argument to sui start and sui genesis to configure the number of validators to start with the local network.
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2024 8:03pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Dec 6, 2024 8:03pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Dec 6, 2024 8:03pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Dec 6, 2024 8:03pm

Comment on lines +1024 to +1028
let committee_size = match committee_size {
Some(x) => NonZeroUsize::new(x),
None => NonZeroUsize::new(DEFAULT_NUMBER_OF_AUTHORITIES),
}
.ok_or_else(|| anyhow!("Committee size must be at least 1."))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let committee_size = match committee_size {
Some(x) => NonZeroUsize::new(x),
None => NonZeroUsize::new(DEFAULT_NUMBER_OF_AUTHORITIES),
}
.ok_or_else(|| anyhow!("Committee size must be at least 1."))?;
let committee_size = match committee_size {
Some(x) => {
if network_config.is_some() { println!("WARNING...") }
NonZeroUsize::new(x),
}
None => NonZeroUsize::new(DEFAULT_NUMBER_OF_AUTHORITIES),
}
.ok_or_else(|| anyhow!("Committee size must be at least 1."))?;

I'm guessing you would see this behavior in the --help given the /// comments? but it also might not hurt to just warn/error. It's debatable though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably a good idea to warn, though I think this needs to be done on start command rather than genesis.

@bmwill
Copy link
Contributor

bmwill commented Dec 5, 2024

fwiw this likely isn't going to be sufficient as iirc Consensus won't work with smaller committee sizes. cc @mwtian to confirm this. So we'd need this plus some consensus changes to be able to really support smaller committee sizes with sui start

@mwtian
Copy link
Member

mwtian commented Dec 5, 2024

The consensus changes to support 1-node committee can be done in parallel. I can give it a shot this week.

@stefan-mysten
Copy link
Contributor Author

The consensus changes to support 1-node committee can be done in parallel. I can give it a shot this week.

Thanks @mwtian! Happy to also help there if you need me to (though never looked at that code).

@stefan-mysten
Copy link
Contributor Author

#20530 has landed, so we can land this as well!

@bmwill
Copy link
Contributor

bmwill commented Dec 6, 2024

Time to go change a bunch of tests to only use a single validator!

@stefan-mysten stefan-mysten temporarily deployed to sui-typescript-aws-kms-test-env December 6, 2024 20:02 — with GitHub Actions Inactive
@stefan-mysten stefan-mysten enabled auto-merge (squash) December 6, 2024 20:03
@stefan-mysten stefan-mysten merged commit 0d64196 into MystenLabs:main Dec 6, 2024
48 checks passed
@stefan-mysten stefan-mysten deleted the cli_cfg_validators branch December 6, 2024 20:33
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