-
Notifications
You must be signed in to change notification settings - Fork 7
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
[STACKED] Command to generate presigned exit message #55
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
pub mod constants; | ||
pub(crate) mod operator; | ||
|
||
use regex::Regex; | ||
|
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod bls_to_execution_change; | ||
pub mod existing_mnemonic; | ||
pub mod new_mnemonic; | ||
pub mod presigned_exit_message; |
This file contains 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,100 @@ | ||
use clap::{arg, Parser}; | ||
|
||
use crate::voluntary_exit::operator::SignedVoluntaryExitOperator; | ||
use crate::{chain_spec::validators_root_and_spec, voluntary_exit}; | ||
|
||
#[derive(Clone, Parser)] | ||
pub struct PresignedExitMessageSubcommandOpts { | ||
/// The mnemonic that you used to generate your | ||
/// keys. | ||
/// | ||
/// It is recommended not to use this | ||
/// argument, and wait for the CLI to ask you | ||
/// for your mnemonic as otherwise it will | ||
/// appear in your shell history. | ||
#[arg(long)] | ||
pub mnemonic: String, | ||
|
||
/// The name of Ethereum PoS chain you are targeting. | ||
/// | ||
/// Use "mainnet" if you are | ||
/// depositing ETH | ||
#[arg(value_enum, long)] | ||
pub chain: Option<crate::networks::SupportedNetworks>, | ||
|
||
/// The index of the first validator's keys you wish to generate the address for | ||
/// e.g. if you generated 3 keys before (index #0, index #1, index #2) | ||
/// and you want to generate for the 2nd validator, | ||
/// the validator_start_index would be 1. | ||
/// If no index specified, it will be set to 0. | ||
#[arg(long, visible_alias = "validator_seed_index")] | ||
pub validator_seed_index: u32, | ||
|
||
/// On-chain beacon index of the validator. | ||
#[arg(long, visible_alias = "validator_beacon_index")] | ||
pub validator_beacon_index: u32, | ||
|
||
/// Epoch number which must be included in the presigned exit message. | ||
#[arg(long, visible_alias = "execution_address")] | ||
pub epoch: u64, | ||
|
||
/// Path to a custom Eth PoS chain config | ||
#[arg(long, visible_alias = "testnet_config")] | ||
pub testnet_config: Option<String>, | ||
|
||
/// Custom genesis validators root for the custom testnet, passed as hex string. | ||
/// See https://eth2book.info/capella/part3/containers/state/ for value | ||
/// description | ||
#[arg(long, visible_alias = "genesis_validators_root")] | ||
pub genesis_validators_root: Option<String>, | ||
} | ||
|
||
impl PresignedExitMessageSubcommandOpts { | ||
pub fn run(&self) { | ||
let chain = if self.chain.is_some() && self.testnet_config.is_some() { | ||
panic!("should only pass one of testnet_config or chain") | ||
} else if self.testnet_config.is_some() { | ||
// Signalizes custom testnet config will be used | ||
None | ||
} else { | ||
self.chain.clone() | ||
}; | ||
|
||
let (genesis_validators_root, spec) = validators_root_and_spec( | ||
chain.clone(), | ||
if chain.is_some() { | ||
None | ||
} else { | ||
Some(( | ||
self.genesis_validators_root | ||
.clone() | ||
.expect("Genesis validators root parameter must be set"), | ||
self.testnet_config | ||
.clone() | ||
.expect("Testnet config must be set"), | ||
)) | ||
}, | ||
); | ||
|
||
let (voluntary_exit, key_material) = voluntary_exit::voluntary_exit_message_from_mnemonic( | ||
self.mnemonic.as_bytes(), | ||
self.validator_seed_index as u64, | ||
self.validator_beacon_index as u64, | ||
self.epoch, | ||
); | ||
|
||
let signed_voluntary_exit = | ||
voluntary_exit.sign(&key_material.keypair.sk, genesis_validators_root, &spec); | ||
|
||
signed_voluntary_exit.clone().validate( | ||
&key_material.keypair.pk, | ||
&spec, | ||
&genesis_validators_root, | ||
); | ||
let export = signed_voluntary_exit.export(); | ||
|
||
let presigned_exit_message_json = | ||
serde_json::to_string_pretty(&export).expect("could not parse validator export"); | ||
println!("{}", presigned_exit_message_json); | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.
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.
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.
why are we showing curl command instead of cli cmd?
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.
The command right now does not support sending output to beacon node; it should be easy to add though given
openssl-sys
is already a dependency. I will do it in #54 as this PR only touches presigned exit message, but bls-to-execution-changeThere 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.
Sending to beacon node was implemented in 64ef067