-
Notifications
You must be signed in to change notification settings - Fork 807
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
[Merged by Bors] - Improve ergonomics of adding a new network config #2489
Conversation
commit e22b271 Author: Paul Hauner <[email protected]> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
commit e22b271 Author: Paul Hauner <[email protected]> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
commit e22b271 Author: Paul Hauner <[email protected]> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
commit e22b271 Author: Paul Hauner <[email protected]> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <[email protected]> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <[email protected]> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks sweet! Quite the macro rabbit hole here, didn't realize how much one can do. Just found some small things.
common/eth2_config/src/lib.rs
Outdated
/// perform the final step of using `std::include_bytes` to bake the files (bytes) into the binary. | ||
macro_rules! define_hardcoded_nets { | ||
($(($name_ident: ident, $name_str: tt, $genesis_is_known: ident)),+) => { | ||
paste! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any paste!
identifiers [< .. >]
in the macro so not sure it's necessary here
common/eth2_config/src/lib.rs
Outdated
/// Creates a `HardcodedNet` definition for some network. | ||
#[macro_export] | ||
macro_rules! define_net { | ||
($this_crate: tt, $mod: ident, $include_file: tt) => {{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
($this_crate: tt, $mod: ident, $include_file: tt) => {{ | |
($this_crate: ident, $mod: ident, $include_file: tt) => {{ |
Seems like this works as is, but should this be ident
?
common/eth2_config/src/lib.rs
Outdated
|
||
/// Defines an `Eth2NetArchiveAndDirectory` for some network. | ||
/// | ||
/// It also defines a `include_<title>_bytes!` macro which provides a wrapper around |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// It also defines a `include_<title>_bytes!` macro which provides a wrapper around | |
/// It also defines a `include_<title>_file!` macro which provides a wrapper around |
Thanks @realbigsean, great suggestions. Ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
bors r+ |
## Issue Addressed NA ## Proposed Changes This PR adds some more fancy macro magic to make it easier to add a new built-in (aka "baked-in") testnet config to the `lighthouse` binary. Previously, a user needed to modify several files and repeat themselves several times. Now, they only need to add a single definition in the `eth2_config` crate. No repetition 🎉
Pull request successfully merged into unstable. Build succeeded: |
Issue Addressed
NA
Proposed Changes
This PR adds some more fancy macro magic to make it easier to add a new built-in (aka "baked-in") testnet config to the
lighthouse
binary.Previously, a user needed to modify several files and repeat themselves several times. Now, they only need to add a single definition in the
eth2_config
crate. No repetition 🎉