Skip to content

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

Merged
Flouse merged 1 commit intomainfrom
yangby/bugfix/nondeterministic-genesis-generate
Sep 5, 2023
Merged

fix(tool): genesis-generator is nondeterministic#1400
Flouse merged 1 commit intomainfrom
yangby/bugfix/nondeterministic-genesis-generate

Conversation

@chaoticlonghair
Copy link
Copy Markdown
Contributor

@chaoticlonghair chaoticlonghair 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

@chaoticlonghair chaoticlonghair 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
@chaoticlonghair

This comment was marked as off-topic.

@github-actions
Copy link
Copy Markdown

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
@chaoticlonghair
Copy link
Copy Markdown
Contributor Author

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

@Flouse Flouse merged commit 8815f58 into main Sep 5, 2023
@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