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

Add voluntary exit via validator manager #6612

Open
wants to merge 14 commits into
base: unstable
Choose a base branch
from
456 changes: 224 additions & 232 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions book/src/help_vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Commands:
delete
Deletes one or more validators from a validator client using the HTTP
API.
exit
Exit validator using the HTTP API for a given validator keystore.
help
Print this message or the help of the given subcommand(s)

Expand Down
2 changes: 2 additions & 0 deletions common/filesystem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const OWNER_SID_STR: &str = "S-1-3-4";
const OWNER_ACL_ENTRY_FLAGS: u8 = 0;
/// Generic Rights:
/// - https://docs.microsoft.com/en-us/windows/win32/fileio/file-security-and-access-rights
///
/// Individual Read/Write/Execute Permissions (referenced in generic rights link):
/// - https://docs.microsoft.com/en-us/windows/win32/wmisdk/file-and-directory-access-rights-constants
///
/// STANDARD_RIGHTS_ALL
/// - https://docs.microsoft.com/en-us/windows/win32/secauthz/access-mask
#[cfg(windows)]
Expand Down
25 changes: 18 additions & 7 deletions validator_client/http_api/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use std::time::Duration;
use task_executor::test_utils::TestRuntime;
use tempfile::{tempdir, TempDir};
use tokio::sync::oneshot;
use types::ChainSpec;
use validator_store::{Config as ValidatorStoreConfig, ValidatorStore};

pub const PASSWORD_BYTES: &[u8] = &[42, 50, 37];
Expand Down Expand Up @@ -61,6 +62,7 @@ pub struct ApiTester {
pub _server_shutdown: oneshot::Sender<()>,
pub validator_dir: TempDir,
pub secrets_dir: TempDir,
pub spec: Arc<ChainSpec>,
}

impl ApiTester {
Expand All @@ -69,6 +71,19 @@ impl ApiTester {
}

pub async fn new_with_http_config(http_config: HttpConfig) -> Self {
let slot_clock =
TestingSlotClock::new(Slot::new(0), Duration::from_secs(0), Duration::from_secs(1));
let genesis_validators_root = Hash256::repeat_byte(42);
let spec = Arc::new(E::default_spec());
Self::new_with_options(http_config, slot_clock, genesis_validators_root, spec).await
}

pub async fn new_with_options(
http_config: HttpConfig,
slot_clock: TestingSlotClock,
genesis_validators_root: Hash256,
spec: Arc<ChainSpec>,
) -> Self {
let log = test_logger();

let validator_dir = tempdir().unwrap();
Expand All @@ -93,20 +108,15 @@ impl ApiTester {
..Default::default()
};

let spec = Arc::new(E::default_spec());

let slashing_db_path = validator_dir.path().join(SLASHING_PROTECTION_FILENAME);
let slashing_protection = SlashingDatabase::open_or_create(&slashing_db_path).unwrap();

let slot_clock =
TestingSlotClock::new(Slot::new(0), Duration::from_secs(0), Duration::from_secs(1));

let test_runtime = TestRuntime::default();

let validator_store = Arc::new(ValidatorStore::<_, E>::new(
initialized_validators,
slashing_protection,
Hash256::repeat_byte(42),
genesis_validators_root,
spec.clone(),
Some(Arc::new(DoppelgangerService::new(log.clone()))),
slot_clock.clone(),
Expand All @@ -130,7 +140,7 @@ impl ApiTester {
validator_store: Some(validator_store.clone()),
graffiti_file: None,
graffiti_flag: Some(Graffiti::default()),
spec,
spec: spec.clone(),
config: http_config,
log,
sse_logging_components: None,
Expand Down Expand Up @@ -166,6 +176,7 @@ impl ApiTester {
_server_shutdown: shutdown_tx,
validator_dir,
secrets_dir,
spec,
}
}

Expand Down
1 change: 1 addition & 0 deletions validator_client/signing_method/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub enum SigningMethod {

/// The additional information used to construct a signature. Mostly used for protection from replay
/// attacks.
#[derive(Debug)]
pub struct SigningContext {
pub domain: Domain,
pub epoch: Epoch,
Expand Down
4 changes: 4 additions & 0 deletions validator_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ eth2 = { workspace = true }
hex = { workspace = true }
tokio = { workspace = true }
derivative = { workspace = true }
logging = { workspace = true }

[dev-dependencies]
tempfile = { workspace = true }
regex = { workspace = true }
validator_http_api = { workspace = true }
http_api = { workspace = true }
beacon_chain = { workspace = true }

Loading