[Merged by Bors] - Improve ergonomics of adding a new network config#2489
Closed
paulhauner wants to merge 12 commits intosigp:unstablefrom
Closed
[Merged by Bors] - Improve ergonomics of adding a new network config#2489paulhauner wants to merge 12 commits intosigp:unstablefrom
paulhauner wants to merge 12 commits intosigp:unstablefrom
Conversation
paulhauner
added a commit
that referenced
this pull request
Aug 4, 2021
commit e22b271 Author: Paul Hauner <paul@paulhauner.com> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
Closed
paulhauner
added a commit
that referenced
this pull request
Aug 4, 2021
commit e22b271 Author: Paul Hauner <paul@paulhauner.com> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
paulhauner
added a commit
that referenced
this pull request
Aug 6, 2021
commit e22b271 Author: Paul Hauner <paul@paulhauner.com> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
paulhauner
added a commit
that referenced
this pull request
Aug 9, 2021
commit e22b271 Author: Paul Hauner <paul@paulhauner.com> Date: Wed Aug 4 10:55:15 2021 +1000 Separate name_ident and name_str commit d7e8408 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:58:54 2021 +1000 Naming consistency fix commit cd73518 Author: Paul Hauner <paul@paulhauner.com> Date: Tue Aug 3 10:44:26 2021 +1000 Refactor for a single source of truth commit 83280d6 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 18:27:51 2021 +1000 Add test for name consistency commit 99be2ea Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:55:40 2021 +1000 Switch define_nets to lower case commit 777b419 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:52:41 2021 +1000 Add instructional comments commit 33dda79 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:36:14 2021 +1000 Use hardcoded list in CLI commit 892efe4 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:34:58 2021 +1000 Add paste to eth2_config mod commit 03d6e49 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:23:06 2021 +1000 Add hardcoded net names commit d3dadc8 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:10:01 2021 +1000 Use paste in eth2_network_config commit 5053f53 Author: Paul Hauner <paul@paulhauner.com> Date: Mon Aug 2 15:03:15 2021 +1000 Add define_nets!
realbigsean
requested changes
Aug 10, 2021
Member
realbigsean
left a comment
There was a problem hiding this comment.
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! { |
Member
There was a problem hiding this comment.
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) => {{ |
Member
There was a problem hiding this comment.
Suggested change
| ($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 |
Member
There was a problem hiding this comment.
Suggested change
| /// 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 |
Member
Author
|
Thanks @realbigsean, great suggestions. Ready for review! |
Member
Author
|
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Aug 30, 2021
## 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
lighthousebinary.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_configcrate. No repetition 🎉