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

chore(consensus): remove default value for chain_id config parameter #2898

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

guy-starkware
Copy link
Contributor

@guy-starkware guy-starkware commented Dec 23, 2024

I'm trying to make changes to the consensus config. Starting with removing the default values for some of the parameters.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

guy-starkware commented Dec 23, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@guy-starkware guy-starkware marked this pull request as ready for review December 23, 2024 11:16
@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch 4 times, most recently from 594052e to b05dd24 Compare December 26, 2024 10:54
@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch 6 times, most recently from edaa530 to a19d841 Compare December 30, 2024 15:04
@guy-starkware guy-starkware changed the title chore(consensus): remove default values for some config parameters chore(consensus): remove default value for chain_id config parameter Dec 30, 2024
@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch from a19d841 to ee9fa2d Compare January 5, 2025 11:14
Copy link
Contributor

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 8 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @guy-starkware)


-- commits line 2 at r2:

Suggestion:

chore(consensus): remove default value for chain_id config parameter

@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch from ee9fa2d to bcabfe7 Compare January 8, 2025 14:25
Copy link
Contributor Author

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @asmaastarkware)


-- commits line 2 at r2:
Done.

@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch 2 times, most recently from 7078ff6 to 9f1b01c Compare January 12, 2025 11:09
@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch from 9f1b01c to 8d4f147 Compare January 12, 2025 15:23
@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch 2 times, most recently from 147811a to f6cb2c3 Compare January 14, 2025 13:23
Copy link
Contributor

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 of 9 files reviewed, 2 unresolved discussions (waiting on @asmaastarkware and @guy-starkware)


crates/papyrus_node/src/bin/central_source_integration_test.rs line 20 at r4 (raw file):

    fs::create_dir_all(path.clone()).expect("Should make a temporary `data` directory");
    let config = NodeConfig::load_and_process(vec![
        "Placeholder-binary-name".to_owned(),

Config boilerplate?

Code quote:

      "Placeholder-binary-name".to_owned(),

crates/starknet_integration_tests/src/flow_test_setup.rs line 193 at r4 (raw file):

    let broadcast_channels = network_config_into_broadcast_channels(
        channels_network_config,
        papyrus_network::gossipsub_impl::Topic::new(TEST_CONSENSUS_PROPOSALS_TOPIC),

Is this the same value as before? If so then is there a reason we can't import it?

Code quote:

        papyrus_network::gossipsub_impl::Topic::new(TEST_CONSENSUS_PROPOSALS_TOPIC),

crates/papyrus_node/src/config/config_test.rs line 72 at r4 (raw file):

    args.append(&mut additional_args.into_iter().map(|s| s.to_owned()).collect());
    args
}

and remove all the vec![] from the callsites.

It's out of scope, so this is suggestion is optional, but better not have all of those unnecessary allocations.

Suggestion:

fn get_args(additional_args: impl IntoIterator<Item = impl ToString>) -> Vec<String> {
    let mut args = vec!["Papyrus".to_owned()];
    args.extend(required_args());
    args.extend(additional_args.into_iter().map(|s| s.to_string()));
    args
}

@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch from f6cb2c3 to d94f865 Compare January 15, 2025 09:12
Copy link
Contributor Author

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 of 9 files reviewed, 2 unresolved discussions (waiting on @asmaastarkware and @giladchase)


crates/papyrus_node/src/bin/central_source_integration_test.rs line 20 at r4 (raw file):

Previously, giladchase wrote…

Config boilerplate?

Yes, the parser expects the first word to be the binary name.


crates/papyrus_node/src/config/config_test.rs line 72 at r4 (raw file):

Previously, giladchase wrote…

and remove all the vec![] from the callsites.

It's out of scope, so this is suggestion is optional, but better not have all of those unnecessary allocations.

Cool. I didn't know you could do that!


crates/starknet_integration_tests/src/flow_test_setup.rs line 193 at r4 (raw file):

Previously, giladchase wrote…

Is this the same value as before? If so then is there a reason we can't import it?

I'm not sure if it is the same value, but the other const is going to disappear in one of the next PRs, but the config it is going into is not going to be available in this test, so I'm just putting a replacement.

I'm not sure when this went into this PR, maybe I can remove it for now.

Copy link
Contributor

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 8 files at r1, 3 of 4 files at r2, 2 of 4 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @asmaastarkware)


crates/papyrus_node/src/config/config_test.rs line 72 at r4 (raw file):

Previously, guy-starkware wrote…

Cool. I didn't know you could do that!

😬

In general this trick is applicable whenever someone passes an array/vec only for the sake of iterating over it. This type is way more flexible for callers, and doesn't force callers to allocate anything in order to use it.

In fact it appears that this is applicable up the stack in load_and_process, which keep passing vecs around only for the sake of consuming them through iteration, but that one's already too much out of scope here.


crates/starknet_integration_tests/src/flow_test_setup.rs line 193 at r4 (raw file):

Previously, guy-starkware wrote…

I'm not sure if it is the same value, but the other const is going to disappear in one of the next PRs, but the config it is going into is not going to be available in this test, so I'm just putting a replacement.

I'm not sure when this went into this PR, maybe I can remove it for now.

If it is removed later then leaving it here is fine.


crates/papyrus_node/src/config/config_test.rs line 78 at r5 (raw file):

    env::set_current_dir(resolve_project_relative_path("").unwrap())
        .expect("Couldn't set working dir.");
    NodeConfig::load_and_process(get_args(vec!["--chain_id", "SN_MAIN"]))

Now that get_args accepts anything that supports into_iter, you no longer have to allocate a vec and an on-stack array suffices (so this spares an extra heap allocation).

Ditto for the rest of the callsites.

Suggestion:

["--chain_id", "SN_MAIN"]))

Copy link
Contributor Author

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @asmaastarkware)


crates/papyrus_node/src/config/config_test.rs line 72 at r4 (raw file):

Previously, giladchase wrote…

😬

In general this trick is applicable whenever someone passes an array/vec only for the sake of iterating over it. This type is way more flexible for callers, and doesn't force callers to allocate anything in order to use it.

In fact it appears that this is applicable up the stack in load_and_process, which keep passing vecs around only for the sake of consuming them through iteration, but that one's already too much out of scope here.

I can fix that in a separate PR if you think it is worth the effort.


crates/papyrus_node/src/config/config_test.rs line 78 at r5 (raw file):

Previously, giladchase wrote…

Now that get_args accepts anything that supports into_iter, you no longer have to allocate a vec and an on-stack array suffices (so this spares an extra heap allocation).

Ditto for the rest of the callsites.

Got it!


crates/starknet_integration_tests/src/flow_test_setup.rs line 193 at r4 (raw file):

Previously, giladchase wrote…

If it is removed later then leaving it here is fine.

Too late. It's gone. It's a few PRs up the stack before we reach where I remove it, so it's better to keep it for now.

@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch from d94f865 to 174e78f Compare January 15, 2025 10:06
Copy link
Contributor

@giladchase giladchase left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 8 of 10 files reviewed, 1 unresolved discussion (waiting on @asmaastarkware and @dan-starkware)


crates/papyrus_node/src/config/config_test.rs line 72 at r4 (raw file):

Previously, guy-starkware wrote…

I can fix that in a separate PR if you think it is worth the effort.

Nah it's fine to leave it, it's too much into "creating our own tasks" territory.

Copy link
Contributor

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)

@guy-starkware guy-starkware force-pushed the guyn/config/remove_some_defaults branch from 174e78f to 6df7549 Compare January 15, 2025 13:07
Copy link
Contributor Author

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 8 files at r1, 3 of 4 files at r2, 2 of 4 files at r4, 2 of 2 files at r6, 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)

@guy-starkware guy-starkware added this pull request to the merge queue Jan 16, 2025
Merged via the queue into main with commit be32bfa Jan 16, 2025
18 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants