mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-16 20:39:10 +00:00
Support multiple BLS implementations (#1335)
## Issue Addressed NA ## Proposed Changes - Refactor the `bls` crate to support multiple BLS "backends" (e.g., milagro, blst, etc). - Removes some duplicate, unused code in `common/rest_types/src/validator.rs`. - Removes the old "upgrade legacy keypairs" functionality (these were unencrypted keys that haven't been supported for a few testnets, no one should be using them anymore). ## Additional Info Most of the files changed are just inconsequential changes to function names. ## TODO - [x] Optimization levels - [x] Infinity point: https://github.com/supranational/blst/issues/11 - [x] Ensure milagro *and* blst are tested via CI - [x] What to do with unsafe code? - [x] Test infinity point in signature sets
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#![cfg(not(debug_assertions))]
|
||||
|
||||
use account_manager::{
|
||||
upgrade_legacy_keypairs::{CMD as UPGRADE_CMD, *},
|
||||
validator::{create::*, CMD as VALIDATOR_CMD},
|
||||
wallet::{
|
||||
create::{CMD as CREATE_CMD, *},
|
||||
@@ -16,7 +15,6 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
use std::str::from_utf8;
|
||||
use tempfile::{tempdir, TempDir};
|
||||
use types::Keypair;
|
||||
use validator_dir::ValidatorDir;
|
||||
|
||||
// TODO: create tests for the `lighthouse account validator deposit` command. This involves getting
|
||||
@@ -365,56 +363,3 @@ fn validator_create() {
|
||||
|
||||
assert_eq!(dir_child_count(validator_dir.path()), 6);
|
||||
}
|
||||
|
||||
fn write_legacy_keypair<P: AsRef<Path>>(name: &str, dir: P) -> Keypair {
|
||||
let keypair = Keypair::random();
|
||||
|
||||
let mut keypair_bytes = keypair.pk.as_bytes().to_vec();
|
||||
keypair_bytes.extend_from_slice(keypair.sk.as_bytes().as_ref());
|
||||
|
||||
fs::write(dir.as_ref().join(name), &keypair_bytes).unwrap();
|
||||
|
||||
keypair
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upgrade_legacy_keypairs() {
|
||||
let validators_dir = tempdir().unwrap();
|
||||
let secrets_dir = tempdir().unwrap();
|
||||
|
||||
let validators = (0..2)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
let validator_dir = validators_dir.path().join(format!("myval{}", i));
|
||||
|
||||
fs::create_dir_all(&validator_dir).unwrap();
|
||||
|
||||
let voting_keypair = write_legacy_keypair(VOTING_KEYPAIR_FILE, &validator_dir);
|
||||
let withdrawal_keypair = write_legacy_keypair(WITHDRAWAL_KEYPAIR_FILE, &validator_dir);
|
||||
|
||||
(validator_dir, voting_keypair, withdrawal_keypair)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
account_cmd()
|
||||
.arg(UPGRADE_CMD)
|
||||
.arg(format!("--{}", VALIDATOR_DIR_FLAG))
|
||||
.arg(validators_dir.path().as_os_str())
|
||||
.arg(format!("--{}", SECRETS_DIR_FLAG))
|
||||
.arg(secrets_dir.path().as_os_str())
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
for (validator_dir, voting_keypair, withdrawal_keypair) in validators {
|
||||
let dir = ValidatorDir::open(&validator_dir).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
voting_keypair.pk,
|
||||
dir.voting_keypair(secrets_dir.path()).unwrap().pk
|
||||
);
|
||||
assert_eq!(
|
||||
withdrawal_keypair.pk,
|
||||
dir.withdrawal_keypair(secrets_dir.path()).unwrap().pk
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user