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

Anchor pre-PR: Modularize vc #6778

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
392e2ae
Starting to modularize the VC
AgeManning Oct 1, 2024
d82c4f7
Revert changes to eth2
AgeManning Oct 1, 2024
d7cba1c
More progress
AgeManning Oct 2, 2024
ec088c2
More progress
AgeManning Oct 2, 2024
56bc62b
Compiles
AgeManning Oct 3, 2024
7eb8bf8
Merge latest unstable and make it compile
AgeManning Oct 8, 2024
37db363
Fix some lints
AgeManning Oct 8, 2024
07a614a
Tests compile
AgeManning Oct 21, 2024
dc3afb7
Merge latest unstable
AgeManning Oct 22, 2024
a9bf6e9
Remove unnecessary deps
AgeManning Oct 23, 2024
eaabfd5
Merge latest unstable
AgeManning Oct 29, 2024
2a09bef
Correct release tests
AgeManning Oct 30, 2024
3a6800f
Merge latest unstable
AgeManning Oct 31, 2024
171070d
Merge remote-tracking branch 'origin/unstable' into modularize-vc
michaelsproul Nov 1, 2024
d6a110f
Merge branch 'unstable' into modularize-vc
AgeManning Nov 3, 2024
88ffce6
Revert unnecessary cargo lock changes
michaelsproul Nov 5, 2024
6268d00
Update validator_client/beacon_node_fallback/Cargo.toml
michaelsproul Nov 7, 2024
5c772ae
Update validator_client/http_metrics/Cargo.toml
michaelsproul Nov 7, 2024
7607d0b
Update validator_client/http_metrics/src/lib.rs
michaelsproul Nov 7, 2024
2be5764
Update validator_client/initialized_validators/Cargo.toml
michaelsproul Nov 7, 2024
bf02b7b
Update validator_client/signing_method/Cargo.toml
michaelsproul Nov 7, 2024
5804a35
Update validator_client/validator_metrics/Cargo.toml
michaelsproul Nov 7, 2024
aecbacd
Update validator_client/validator_services/Cargo.toml
michaelsproul Nov 7, 2024
4126a51
Update validator_client/validator_store/Cargo.toml
michaelsproul Nov 7, 2024
f62239a
Update validator_client/validator_store/src/lib.rs
michaelsproul Nov 7, 2024
ba11ca0
Merge remote-tracking branch 'origin/unstable' into modularize-vc
michaelsproul Nov 7, 2024
7c7ea26
Fix format string
michaelsproul Nov 7, 2024
4e4dc11
Rename doppelganger trait
michaelsproul Nov 7, 2024
ac6becf
Don't drop the tempdir
michaelsproul Nov 7, 2024
75a5858
Cargo fmt
michaelsproul Nov 8, 2024
bcd5340
Merge branch 'unstable' into modularize-vc
ThreeHrSleep Jan 9, 2025
dd24897
Merge branch 'anchor' into modularize-vc-changes
ThreeHrSleep Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
668 changes: 332 additions & 336 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,20 @@ members = [
"validator_client/http_metrics",
"validator_client/initialized_validators",
"validator_client/signing_method",
"validator_client/beacon_node_fallback",
"validator_client/doppelganger_service",
"validator_client/graffiti_file",
"validator_client/http_api",
"validator_client/http_metrics",
"validator_client/initialized_validators",
"validator_client/signing_method",
"validator_client/slashing_protection",
"validator_client/validator_metrics",
"validator_client/validator_services",
"validator_client/validator_store",
"validator_client/validator_metrics",
"validator_client/validator_services",
"validator_client/validator_store",

"validator_manager",

Expand Down Expand Up @@ -201,7 +211,7 @@ tempfile = "3"
tokio = { version = "1", features = [
"rt-multi-thread",
"sync",
"signal",
"signal", "macros",
"macros",
] }
tokio-stream = { version = "0.1", features = ["sync"] }
Expand Down
1 change: 1 addition & 0 deletions lighthouse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ sensitive_url = { workspace = true }
slashing_protection = { workspace = true }
tempfile = { workspace = true }
validator_dir = { workspace = true }

zeroize = { workspace = true }

[[test]]
Expand Down
2 changes: 1 addition & 1 deletion testing/web3signer_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ tempfile = { workspace = true }
tokio = { workspace = true }
types = { workspace = true }
url = { workspace = true }
validator_store = { workspace = true }
zip = { workspace = true }
validator_store = { workspace = true }
10 changes: 5 additions & 5 deletions validator_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ beacon_node_fallback = { workspace = true }
clap = { workspace = true }
clap_utils = { workspace = true }
directory = { workspace = true }
dirs = { workspace = true }
doppelganger_service = { workspace = true }
environment = { workspace = true }
dirs = { workspace = true }
eth2 = { workspace = true }
fdlimit = "0.3.0"
environment = { workspace = true }
graffiti_file = { workspace = true }
hyper = { workspace = true }
initialized_validators = { workspace = true }
Expand All @@ -30,14 +29,15 @@ monitoring_api = { workspace = true }
parking_lot = { workspace = true }
reqwest = { workspace = true }
sensitive_url = { workspace = true }
serde = { workspace = true }
slashing_protection = { workspace = true }
serde = { workspace = true }
slog = { workspace = true }
slot_clock = { workspace = true }
tokio = { workspace = true }
types = { workspace = true }
validator_http_api = { workspace = true }
validator_http_metrics = { workspace = true }
validator_metrics = { workspace = true }
validator_services = { workspace = true }
validator_store = { workspace = true }
tokio = { workspace = true }
fdlimit = "0.3.0"
3 changes: 2 additions & 1 deletion validator_client/doppelganger_service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ types = { workspace = true }

[dev-dependencies]
futures = { workspace = true }
logging = { workspace = true }
logging = {workspace = true }

6 changes: 3 additions & 3 deletions validator_client/graffiti_file/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ name = "graffiti_file"
path = "src/lib.rs"

[dependencies]
bls = { workspace = true }
serde = { workspace = true }
slog = { workspace = true }
bls = { workspace = true }
types = { workspace = true }
slog = { workspace = true }

[dev-dependencies]
hex = { workspace = true }
tempfile = { workspace = true }
hex = { workspace = true }
21 changes: 10 additions & 11 deletions validator_client/http_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ path = "src/lib.rs"

[dependencies]
account_utils = { workspace = true }
beacon_node_fallback = { workspace = true }
bls = { workspace = true }
beacon_node_fallback = { workspace = true }
deposit_contract = { workspace = true }
doppelganger_service = { workspace = true }
directory = { workspace = true }
dirs = { workspace = true }
doppelganger_service = { workspace = true }
graffiti_file = { workspace = true }
eth2 = { workspace = true }
eth2_keystore = { workspace = true }
ethereum_serde_utils = { workspace = true }
filesystem = { workspace = true }
graffiti_file = { workspace = true }
initialized_validators = { workspace = true }
lighthouse_version = { workspace = true }
logging = { workspace = true }
parking_lot = { workspace = true }
filesystem = { workspace = true }
rand = { workspace = true }
sensitive_url = { workspace = true }
serde = { workspace = true }
signing_method = { workspace = true }
sensitive_url = { workspace = true }
slashing_protection = { workspace = true }
slog = { workspace = true }
slot_clock = { workspace = true }
Expand All @@ -39,15 +39,14 @@ tempfile = { workspace = true }
tokio = { workspace = true }
tokio-stream = { workspace = true }
types = { workspace = true }
url = { workspace = true }
validator_dir = { workspace = true }
validator_services = { workspace = true }
validator_store = { workspace = true }
warp = { workspace = true }
validator_services = { workspace = true }
url = { workspace = true }
warp_utils = { workspace = true }
warp = { workspace = true }
zeroize = { workspace = true }

[dev-dependencies]
futures = { workspace = true }
itertools = { workspace = true }
rand = { workspace = true, features = ["small_rng"] }
futures = { workspace = true }
rand = { workspace = true, features = ["small_rng"] }
2 changes: 1 addition & 1 deletion validator_client/http_api/src/create_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use account_utils::{
eth2_wallet::{bip39::Mnemonic, WalletBuilder},
random_mnemonic, random_password,
};
use zeroize::Zeroizing;
use eth2::lighthouse_vc::types::{self as api_types};
use slot_clock::SlotClock;
use std::path::{Path, PathBuf};
use types::ChainSpec;
use types::EthSpec;
use validator_dir::{keystore_password_path, Builder as ValidatorDirBuilder};
use validator_store::ValidatorStore;
use zeroize::Zeroizing;

/// Create some validator EIP-2335 keystores and store them on disk. Then, enroll the validators in
/// this validator client.
Expand Down
4 changes: 2 additions & 2 deletions validator_client/http_api/src/keystores.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Implementation of the standard keystore management API.
use account_utils::validator_definitions::PasswordStorage;
use account_utils::{validator_definitions::PasswordStorage};
use zeroize::Zeroizing;
use eth2::lighthouse_vc::{
std_types::{
DeleteKeystoreStatus, DeleteKeystoresRequest, DeleteKeystoresResponse,
Expand All @@ -22,7 +23,6 @@ use validator_dir::{keystore_password_path, Builder as ValidatorDirBuilder};
use validator_store::ValidatorStore;
use warp::Rejection;
use warp_utils::reject::{custom_bad_request, custom_server_error};
use zeroize::Zeroizing;

pub fn list<T: SlotClock + 'static, E: EthSpec>(
validator_store: Arc<ValidatorStore<T, E>>,
Expand Down
9 changes: 4 additions & 5 deletions validator_client/http_api/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use account_utils::validator_definitions::ValidatorDefinitions;
use account_utils::{
eth2_wallet::WalletBuilder, mnemonic_from_phrase, random_mnemonic, random_password,
};
use zeroize::Zeroizing;
use deposit_contract::decode_eth1_tx_data;
use doppelganger_service::DoppelgangerService;
use eth2::{
Expand All @@ -28,7 +29,6 @@ use task_executor::test_utils::TestRuntime;
use tempfile::{tempdir, TempDir};
use tokio::sync::oneshot;
use validator_store::{Config as ValidatorStoreConfig, ValidatorStore};
use zeroize::Zeroizing;

pub const PASSWORD_BYTES: &[u8] = &[42, 50, 37];
pub const TEST_DEFAULT_FEE_RECIPIENT: Address = Address::repeat_byte(42);
Expand Down Expand Up @@ -74,7 +74,6 @@ impl ApiTester {

let validator_dir = tempdir().unwrap();
let secrets_dir = tempdir().unwrap();
let token_path = tempdir().unwrap().path().join(PK_FILENAME);

let validator_defs = ValidatorDefinitions::open_or_create(validator_dir.path()).unwrap();

Expand All @@ -87,7 +86,7 @@ impl ApiTester {
.await
.unwrap();

let api_secret = ApiSecret::create_or_open(token_path).unwrap();
let api_secret = ApiSecret::create_or_open(validator_dir.path()).unwrap();
let api_pubkey = api_secret.api_token();

let config = ValidatorStoreConfig {
Expand Down Expand Up @@ -202,8 +201,8 @@ impl ApiTester {
}

pub fn invalid_token_client(&self) -> ValidatorClientHttpClient {
let tmp = tempdir().unwrap().path().join("invalid-token.txt");
let api_secret = ApiSecret::create_or_open(tmp).unwrap();
let tmp = tempdir().unwrap();
let api_secret = ApiSecret::create_or_open(tmp.path()).unwrap();
let invalid_pubkey = api_secret.api_token();
ValidatorClientHttpClient::new(self.url.clone(), invalid_pubkey).unwrap()
}
Expand Down
28 changes: 12 additions & 16 deletions validator_client/http_api/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use initialized_validators::{Config as InitializedValidatorsConfig, InitializedV
use crate::{ApiSecret, Config as HttpConfig, Context};
use account_utils::{
eth2_wallet::WalletBuilder, mnemonic_from_phrase, random_mnemonic, random_password,
random_password_string, validator_definitions::ValidatorDefinitions,
random_password_string, validator_definitions::ValidatorDefinitions, ZeroizeString,
};
use deposit_contract::decode_eth1_tx_data;
use eth2::{
Expand All @@ -33,7 +33,6 @@ use task_executor::test_utils::TestRuntime;
use tempfile::{tempdir, TempDir};
use types::graffiti::GraffitiString;
use validator_store::{Config as ValidatorStoreConfig, ValidatorStore};
use zeroize::Zeroizing;

const PASSWORD_BYTES: &[u8] = &[42, 50, 37];
pub const TEST_DEFAULT_FEE_RECIPIENT: Address = Address::repeat_byte(42);
Expand All @@ -53,10 +52,8 @@ struct ApiTester {

impl ApiTester {
pub async fn new() -> Self {
let config = ValidatorStoreConfig {
fee_recipient: Some(TEST_DEFAULT_FEE_RECIPIENT),
..Default::default()
};
let mut config = ValidatorStoreConfig::default();
config.fee_recipient = Some(TEST_DEFAULT_FEE_RECIPIENT);
Self::new_with_config(config).await
}

Expand All @@ -65,7 +62,6 @@ impl ApiTester {

let validator_dir = tempdir().unwrap();
let secrets_dir = tempdir().unwrap();
let token_path = tempdir().unwrap().path().join("api-token.txt");

let validator_defs = ValidatorDefinitions::open_or_create(validator_dir.path()).unwrap();

Expand All @@ -78,7 +74,7 @@ impl ApiTester {
.await
.unwrap();

let api_secret = ApiSecret::create_or_open(&token_path).unwrap();
let api_secret = ApiSecret::create_or_open(validator_dir.path()).unwrap();
let api_pubkey = api_secret.api_token();

let spec = Arc::new(E::default_spec());
Expand Down Expand Up @@ -130,7 +126,6 @@ impl ApiTester {
allow_origin: None,
allow_keystore_export: true,
store_passwords_in_secrets_dir: false,
http_token_path: token_path,
},
sse_logging_components: None,
log,
Expand All @@ -141,7 +136,7 @@ impl ApiTester {
let (listening_socket, server) =
super::serve(ctx, test_runtime.task_executor.exit()).unwrap();

tokio::spawn(server);
tokio::spawn(async { server.await });

let url = SensitiveUrl::parse(&format!(
"http://{}:{}",
Expand All @@ -165,8 +160,8 @@ impl ApiTester {
}

pub fn invalid_token_client(&self) -> ValidatorClientHttpClient {
let tmp = tempdir().unwrap().path().join("invalid-token.txt");
let api_secret = ApiSecret::create_or_open(tmp).unwrap();
let tmp = tempdir().unwrap();
let api_secret = ApiSecret::create_or_open(tmp.path()).unwrap();
let invalid_pubkey = api_secret.api_token();
ValidatorClientHttpClient::new(self.url.clone(), invalid_pubkey.clone()).unwrap()
}
Expand Down Expand Up @@ -287,7 +282,7 @@ impl ApiTester {
.collect::<Vec<_>>();

let (response, mnemonic) = if s.specify_mnemonic {
let mnemonic = Zeroizing::from(random_mnemonic().phrase().to_string());
let mnemonic = ZeroizeString::from(random_mnemonic().phrase().to_string());
let request = CreateValidatorsMnemonicRequest {
mnemonic: mnemonic.clone(),
key_derivation_path_offset: s.key_derivation_path_offset,
Expand Down Expand Up @@ -347,21 +342,22 @@ impl ApiTester {
.set_nextaccount(s.key_derivation_path_offset)
.unwrap();

for validator in response.iter().take(s.count) {
for i in 0..s.count {
let keypairs = wallet
.next_validator(PASSWORD_BYTES, PASSWORD_BYTES, PASSWORD_BYTES)
.unwrap();
let voting_keypair = keypairs.voting.decrypt_keypair(PASSWORD_BYTES).unwrap();

assert_eq!(
validator.voting_pubkey,
response[i].voting_pubkey,
voting_keypair.pk.clone().into(),
"the locally generated voting pk should match the server response"
);

let withdrawal_keypair = keypairs.withdrawal.decrypt_keypair(PASSWORD_BYTES).unwrap();

let deposit_bytes = serde_utils::hex::decode(&validator.eth1_deposit_tx_data).unwrap();
let deposit_bytes =
serde_utils::hex::decode(&response[i].eth1_deposit_tx_data).unwrap();

let (deposit_data, _) =
decode_eth1_tx_data(&deposit_bytes, E::default_spec().max_effective_balance)
Expand Down
Loading
Loading