mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 03:31:45 +00:00
Implement VC API (#1657)
## Issue Addressed
NA
## Proposed Changes
- Implements a HTTP API for the validator client.
- Creates EIP-2335 keystores with an empty `description` field, instead of a missing `description` field. Adds option to set name.
- Be more graceful with setups without any validators (yet)
- Remove an error log when there are no validators.
- Create the `validator` dir if it doesn't exist.
- Allow building a `ValidatorDir` without a withdrawal keystore (required for the API method where we only post a voting keystore).
- Add optional `description` field to `validator_definitions.yml`
## TODO
- [x] Signature header, as per https://github.com/sigp/lighthouse/issues/1269#issuecomment-649879855
- [x] Return validator descriptions
- [x] Return deposit data
- [x] Respect the mnemonic offset
- [x] Check that mnemonic can derive returned keys
- [x] Be strict about non-localhost
- [x] Allow graceful start without any validators (+ create validator dir)
- [x] Docs final pass
- [x] Swap to EIP-2335 description field.
- [x] Fix Zerioze TODO in VC api types.
- [x] Zeroize secp256k1 key
## Endpoints
- [x] `GET /lighthouse/version`
- [x] `GET /lighthouse/health`
- [x] `GET /lighthouse/validators`
- [x] `POST /lighthouse/validators/hd`
- [x] `POST /lighthouse/validators/keystore`
- [x] `PATCH /lighthouse/validators/:validator_pubkey`
- [ ] ~~`POST /lighthouse/validators/:validator_pubkey/exit/:epoch`~~ Future works
## Additional Info
TBC
This commit is contained in:
@@ -78,13 +78,11 @@ impl Harness {
|
||||
* Build the `ValidatorDir`.
|
||||
*/
|
||||
|
||||
let builder = Builder::new(
|
||||
self.validators_dir.path().into(),
|
||||
self.password_dir.path().into(),
|
||||
)
|
||||
// Note: setting the withdrawal keystore here ensure that it can get overriden by later
|
||||
// calls to `random_withdrawal_keystore`.
|
||||
.store_withdrawal_keystore(config.store_withdrawal_keystore);
|
||||
let builder = Builder::new(self.validators_dir.path().into())
|
||||
.password_dir(self.password_dir.path())
|
||||
// Note: setting the withdrawal keystore here ensure that it can get replaced by
|
||||
// further calls to `random_withdrawal_keystore`.
|
||||
.store_withdrawal_keystore(config.store_withdrawal_keystore);
|
||||
|
||||
let builder = if config.random_voting_keystore {
|
||||
builder.random_voting_keystore().unwrap()
|
||||
@@ -208,13 +206,11 @@ fn without_voting_keystore() {
|
||||
let harness = Harness::new();
|
||||
|
||||
assert!(matches!(
|
||||
Builder::new(
|
||||
harness.validators_dir.path().into(),
|
||||
harness.password_dir.path().into(),
|
||||
)
|
||||
.random_withdrawal_keystore()
|
||||
.unwrap()
|
||||
.build(),
|
||||
Builder::new(harness.validators_dir.path().into(),)
|
||||
.password_dir(harness.password_dir.path())
|
||||
.random_withdrawal_keystore()
|
||||
.unwrap()
|
||||
.build(),
|
||||
Err(BuilderError::UninitializedVotingKeystore)
|
||||
))
|
||||
}
|
||||
@@ -225,26 +221,22 @@ fn without_withdrawal_keystore() {
|
||||
let spec = &MainnetEthSpec::default_spec();
|
||||
|
||||
// Should build without withdrawal keystore if not storing the it or creating eth1 data.
|
||||
Builder::new(
|
||||
harness.validators_dir.path().into(),
|
||||
harness.password_dir.path().into(),
|
||||
)
|
||||
.random_voting_keystore()
|
||||
.unwrap()
|
||||
.store_withdrawal_keystore(false)
|
||||
.build()
|
||||
.unwrap();
|
||||
Builder::new(harness.validators_dir.path().into())
|
||||
.password_dir(harness.password_dir.path())
|
||||
.random_voting_keystore()
|
||||
.unwrap()
|
||||
.store_withdrawal_keystore(false)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
matches!(
|
||||
Builder::new(
|
||||
harness.validators_dir.path().into(),
|
||||
harness.password_dir.path().into(),
|
||||
)
|
||||
.random_voting_keystore()
|
||||
.unwrap()
|
||||
.store_withdrawal_keystore(true)
|
||||
.build(),
|
||||
Builder::new(harness.validators_dir.path().into(),)
|
||||
.password_dir(harness.password_dir.path())
|
||||
.random_voting_keystore()
|
||||
.unwrap()
|
||||
.store_withdrawal_keystore(true)
|
||||
.build(),
|
||||
Err(BuilderError::UninitializedWithdrawalKeystore)
|
||||
),
|
||||
"storing the keystore requires keystore"
|
||||
@@ -252,14 +244,12 @@ fn without_withdrawal_keystore() {
|
||||
|
||||
assert!(
|
||||
matches!(
|
||||
Builder::new(
|
||||
harness.validators_dir.path().into(),
|
||||
harness.password_dir.path().into(),
|
||||
)
|
||||
.random_voting_keystore()
|
||||
.unwrap()
|
||||
.create_eth1_tx_data(42, spec)
|
||||
.build(),
|
||||
Builder::new(harness.validators_dir.path().into(),)
|
||||
.password_dir(harness.password_dir.path())
|
||||
.random_voting_keystore()
|
||||
.unwrap()
|
||||
.create_eth1_tx_data(42, spec)
|
||||
.build(),
|
||||
Err(BuilderError::UninitializedWithdrawalKeystore)
|
||||
),
|
||||
"storing the keystore requires keystore"
|
||||
|
||||
Reference in New Issue
Block a user