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

fix(tool): genesis-generator is nondeterministic #1400

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Sep 4, 2023

What this PR does / why we need it?

Bug

  • The entries in config_path will be in a random order.

    let entries = fs::read_dir(config_path)
    .unwrap()
    .filter_map(|res| {
    res.ok().and_then(|e| {
    let path = e.path();
    if path.extension().map(|e| e == "toml").unwrap_or_default() {
    Some(path)
    } else {
    None
    }
    })
    })
    .collect::<Vec<_>>();

  • So, the order of verifiers list is nondeterministic.

    let ve_list = entries
    .iter()
    .map(|file_name| {
    let config: Config = parse_file(file_name, false).unwrap();
    let priv_key = config.privkey;
    get_ve(Hex::encode(priv_key.as_ref()), propose_weight, vote_weight)
    })
    .collect::<Vec<_>>();

  • Current multi nodes genesis can be generated after applying the following patch:

    -    let ve_list = entries
    -        .iter()
    -        .map(|file_name| {
    +    let ve_list = vec![2, 3, 4, 1]
    +        .into_iter()
    +        .map(|id| {
    +            let file_name = format!("../chain/nodes/node_{id}.toml");
                 let config: Config = parse_file(file_name, false).unwrap();
                 let priv_key = config.privkey;
                 get_ve(Hex::encode(priv_key.as_ref()), propose_weight, vote_weight)
             })
             .collect::<Vec<_>>();

What is the impact of this PR?

No Breaking Change

PR relation:

  • Ref #
CI Settings

CI Usage

Tip: Check the CI you want to run below, and then comment /run-ci.

CI Switch

  • E2E Tests
  • Web3 Compatible Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests

CI Description

CI Name Description
Chaos CI Test the liveness and robustness of Axon under terrible network condition
Cargo Clippy Run cargo clippy --all --all-targets --all-features
Coverage Test Get the unit test coverage report
E2E Test Run end-to-end test to check interfaces
Code Format Run cargo +nightly fmt --all -- --check and cargo sort -gwc
Web3 Compatible Test Test the Web3 compatibility of Axon
v3 Core Test Run the compatibility tests provided by Uniswap V3
OCT 1-5 | 6-10 | 11 | 12-15 | 16-19 Run the compatibility tests provided by OpenZeppelin

@yangby-cryptape yangby-cryptape requested a review from a team as a code owner September 4, 2023 16:37
@github-actions github-actions bot added the bugfix label Sep 4, 2023
@yangby-cryptape

This comment was marked as off-topic.

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

CI tests run on commit:

CI test list:

  • E2E Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests

Please check ci test results later.

@KaoImin KaoImin added this pull request to the merge queue Sep 5, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 5, 2023
@yangby-cryptape
Copy link
Collaborator Author

Before the required check "web3-compatible-test" fixed, no PR can merged.

@Flouse Flouse merged commit 8815f58 into main Sep 5, 2023
26 checks passed
@Flouse Flouse deleted the yangby/bugfix/nondeterministic-genesis-generate branch September 5, 2023 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants