-
Notifications
You must be signed in to change notification settings - Fork 988
[Merged by Bors] - Post merge local testnets #3807
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
Closed
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
ad4c9d8
Add EL scripts
pawanjay176 3bc7d64
Embed interop validators into genesis
pawanjay176 d991078
Working post bellatrix local testnet
pawanjay176 26da254
Cleanup
pawanjay176 b1dd81e
appease clippy
pawanjay176 e949793
Merge branch 'unstable' into merge-local-testnet
pawanjay176 d4c39b6
Merge branch 'unstable' into merge-local-testnet
pawanjay176 002d57d
Remove unnecessary change
pawanjay176 6878292
Add ability to create testnets from a mnemonic
pawanjay176 0756c25
Fix mnemonic validator generation
pawanjay176 df82d65
Fix local testnet scripts to use mnemonic based keypairs
pawanjay176 cebc86f
Fix doppelganger scripts
pawanjay176 908193a
Fix doppelganger CI
pawanjay176 b9b74b7
Fix env variable
pawanjay176 bbdebc0
Update README
pawanjay176 f1350b8
Fix CI
pawanjay176 dca4dfa
Apply suggestions from code review
pawanjay176 724f619
Fix more stuff from review
pawanjay176 3a9d2a9
Fix withdrawal credentials in genesis state
pawanjay176 47d019e
Fix doppelganger beacon node url; use separate genesis for dg tests
pawanjay176 fa76fd7
mnemonics -> mnemonic
pawanjay176 9f9b3ac
Fixes from review
pawanjay176 585486a
Prefund known accounts for future use
pawanjay176 1f44c51
Add note for MacOS
pawanjay176 6c59864
Remove macos explicit instructions
pawanjay176 801ab3a
Merge branch 'unstable' into merge-local-testnet
pawanjay176 4850594
Remove anvil from local testnet stuff
pawanjay176 9273463
Update lcli/src/main.rs
pawanjay176 7554d84
Use ExecutionBlockHash::from_root
pawanjay176 5aa429a
Fix local-testnet CI
pawanjay176 567f496
Try to fix workflow file
pawanjay176 ec848d2
Fix workflow file
pawanjay176 a048c86
Another attempt
pawanjay176 0a68641
Fix start testnet command
pawanjay176 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| use account_utils::eth2_keystore::{keypair_from_secret, Keystore, KeystoreBuilder}; | ||
| use account_utils::random_password; | ||
| use clap::ArgMatches; | ||
| use eth2_wallet::bip39::Seed; | ||
| use eth2_wallet::bip39::{Language, Mnemonic}; | ||
| use eth2_wallet::{recover_validator_secret_from_mnemonic, KeyType}; | ||
| use rayon::prelude::*; | ||
| use std::fs; | ||
| use std::path::PathBuf; | ||
| use validator_dir::Builder as ValidatorBuilder; | ||
|
|
||
| /// Generates validator directories with keys derived from the given mnemonic. | ||
| pub fn generate_validator_dirs( | ||
| indices: &[usize], | ||
| mnemonic_phrase: &str, | ||
| validators_dir: PathBuf, | ||
| secrets_dir: PathBuf, | ||
| ) -> Result<(), String> { | ||
| if !validators_dir.exists() { | ||
| fs::create_dir_all(&validators_dir) | ||
| .map_err(|e| format!("Unable to create validators dir: {:?}", e))?; | ||
| } | ||
|
|
||
| if !secrets_dir.exists() { | ||
| fs::create_dir_all(&secrets_dir) | ||
| .map_err(|e| format!("Unable to create secrets dir: {:?}", e))?; | ||
| } | ||
| let mnemonic = Mnemonic::from_phrase(mnemonic_phrase, Language::English).map_err(|e| { | ||
| format!( | ||
| "Unable to derive mnemonic from string {:?}: {:?}", | ||
| mnemonic_phrase, e | ||
| ) | ||
| })?; | ||
|
|
||
| let seed = Seed::new(&mnemonic, ""); | ||
|
|
||
| let _: Vec<_> = indices | ||
| .par_iter() | ||
| .map(|index| { | ||
| let voting_password = random_password(); | ||
|
|
||
| let derive = |key_type: KeyType, password: &[u8]| -> Result<Keystore, String> { | ||
| let (secret, path) = recover_validator_secret_from_mnemonic( | ||
| seed.as_bytes(), | ||
| *index as u32, | ||
| key_type, | ||
| ) | ||
| .map_err(|e| format!("Unable to recover validator keys: {:?}", e))?; | ||
|
|
||
| let keypair = keypair_from_secret(secret.as_bytes()) | ||
| .map_err(|e| format!("Unable build keystore: {:?}", e))?; | ||
|
|
||
| KeystoreBuilder::new(&keypair, password, format!("{}", path)) | ||
| .map_err(|e| format!("Unable build keystore: {:?}", e))? | ||
| .build() | ||
| .map_err(|e| format!("Unable build keystore: {:?}", e)) | ||
| }; | ||
|
|
||
| let voting_keystore = derive(KeyType::Voting, voting_password.as_bytes()).unwrap(); | ||
|
|
||
| println!("Validator {}", index + 1); | ||
|
|
||
| ValidatorBuilder::new(validators_dir.clone()) | ||
| .password_dir(secrets_dir.clone()) | ||
| .store_withdrawal_keystore(false) | ||
| .voting_keystore(voting_keystore, voting_password.as_bytes()) | ||
| .build() | ||
| .map_err(|e| format!("Unable to build validator: {:?}", e)) | ||
| .unwrap() | ||
| }) | ||
| .collect(); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn run(matches: &ArgMatches) -> Result<(), String> { | ||
| let validator_count: usize = clap_utils::parse_required(matches, "count")?; | ||
| let base_dir: PathBuf = clap_utils::parse_required(matches, "base-dir")?; | ||
| let node_count: Option<usize> = clap_utils::parse_optional(matches, "node-count")?; | ||
| let mnemonic_phrase: String = clap_utils::parse_required(matches, "mnemonic-phrase")?; | ||
| if let Some(node_count) = node_count { | ||
| let validators_per_node = validator_count / node_count; | ||
| let validator_range = (0..validator_count).collect::<Vec<_>>(); | ||
| let indices_range = validator_range | ||
| .chunks(validators_per_node) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| for (i, indices) in indices_range.iter().enumerate() { | ||
| let validators_dir = base_dir.join(format!("node_{}", i + 1)).join("validators"); | ||
| let secrets_dir = base_dir.join(format!("node_{}", i + 1)).join("secrets"); | ||
| generate_validator_dirs(indices, &mnemonic_phrase, validators_dir, secrets_dir)?; | ||
| } | ||
| } else { | ||
| let validators_dir = base_dir.join("validators"); | ||
| let secrets_dir = base_dir.join("secrets"); | ||
| generate_validator_dirs( | ||
| (0..validator_count).collect::<Vec<_>>().as_slice(), | ||
| &mnemonic_phrase, | ||
| validators_dir, | ||
| secrets_dir, | ||
| )?; | ||
| } | ||
| Ok(()) | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.