VC: accept unknown fields in chain spec (#2277)

## Issue Addressed

Closes #2274

## Proposed Changes

* Modify the `YamlConfig` to collect unknown fields into an `extra_fields` map, instead of failing hard.
* Log a debug message if there are extra fields returned to the VC from one of its BNs.

This restores Lighthouse's compatibility with Teku beacon nodes (and therefore Infura)
This commit is contained in:
Michael Sproul
2021-03-26 04:53:57 +00:00
parent 9a71a7e486
commit f9d60f5436
23 changed files with 102 additions and 54 deletions

View File

@@ -89,7 +89,7 @@ impl ValidatorDir {
}
/// Returns the `dir` provided to `Self::open`.
pub fn dir(&self) -> &PathBuf {
pub fn dir(&self) -> &Path {
&self.dir
}
@@ -204,7 +204,7 @@ impl ValidatorDir {
/// Attempts to load and decrypt a Keypair given path to the keystore.
pub fn unlock_keypair<P: AsRef<Path>>(
keystore_path: &PathBuf,
keystore_path: &Path,
password_dir: P,
) -> Result<Keypair, Error> {
let keystore = Keystore::from_json_reader(
@@ -229,8 +229,8 @@ pub fn unlock_keypair<P: AsRef<Path>>(
/// Attempts to load and decrypt a Keypair given path to the keystore and the password file.
pub fn unlock_keypair_from_password_path(
keystore_path: &PathBuf,
password_path: &PathBuf,
keystore_path: &Path,
password_path: &Path,
) -> Result<Keypair, Error> {
let keystore = Keystore::from_json_reader(
&mut OpenOptions::new()
@@ -242,7 +242,7 @@ pub fn unlock_keypair_from_password_path(
.map_err(Error::UnableToReadKeystore)?;
let password: PlainText = read(password_path)
.map_err(|_| Error::UnableToReadPassword(password_path.clone()))?
.map_err(|_| Error::UnableToReadPassword(password_path.into()))?
.into();
keystore
.decrypt_keypair(password.as_bytes())

View File

@@ -182,7 +182,7 @@ fn concurrency() {
let harness = Harness::new();
let val_dir = harness.create_and_test(&BuildConfig::default());
let path = val_dir.dir().clone();
let path = val_dir.dir().to_owned();
// Should not re-open whilst opened after build.
ValidatorDir::open(&path).unwrap_err();