Skip to content

Conversation

@michaelsproul
Copy link
Member

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)

Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we added deny_unknown_fields because we realised we were silently ignoring some parameters in ef_tests. Perhaps we could retain this functionality by doing something like:

#[cfg_attr(feature = "strict_yaml_config", serde(deny_unknown_fields))]

And then turning that on in ef_tests. What are your thoughts? I'm not fully set on doing this.

@michaelsproul
Copy link
Member Author

michaelsproul commented Mar 25, 2021

IIRC, we added deny_unknown_fields because we realised we were silently ignoring some parameters in ef_tests.

Ah yeah, good idea! I think most errors would be caught by the test below (which used not exist), but it doesn't hurt to be extra-strict in testing:

// Check that the config from the Eth2.0 spec tests matches our minimal/mainnet config.
fn config_test<E: EthSpec + TypeName>() {
let config_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("eth2.0-spec-tests")
.join("tests")
.join(E::name())
.join("config")
.join("phase0.yaml");
let yaml_config = YamlConfig::from_file(&config_path).expect("config file loads OK");
let spec = E::default_spec();
let yaml_from_spec = YamlConfig::from_spec::<E>(&spec);
assert_eq!(yaml_config.apply_to_chain_spec::<E>(&spec), Some(spec));
assert_eq!(yaml_from_spec, yaml_config);
}

I'll add the cfg

@michaelsproul
Copy link
Member Author

Actually, it can be more lightweight than that. We can just assert that extra_fields is empty.

@michaelsproul
Copy link
Member Author

Done. Let me know if that soln suits you @paulhauner 😊

Comment on lines +126 to +128
-A clippy::from-over-into \
-A clippy::upper-case-acronyms \
-A clippy::vec-init-then-push
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were a large number of places where we violated these lints, so I think we should leave them for another time. Particularly so we don't introduce unnecessary noise to conflict with other larger refactors that are ongoing (e.g. #2279).

Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The extra_fields trick is cool, I didn't know we could do that!

EDIT: looks like CI is a little unhappy.

@michaelsproul
Copy link
Member Author

bors r+

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Mar 26, 2021
bors bot pushed a commit that referenced this pull request Mar 26, 2021
## 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)
paulhauner added a commit to paulhauner/lighthouse that referenced this pull request Mar 26, 2021
commit 84cbc2f
Author: Michael Sproul <[email protected]>
Date:   Fri Mar 26 14:34:44 2021 +1100

    Fixup release test

commit b34429a
Author: Michael Sproul <[email protected]>
Date:   Fri Mar 26 12:30:17 2021 +1100

    Fix Clippy + Rust 1.51.0 issues

commit d16d847
Author: Michael Sproul <[email protected]>
Date:   Fri Mar 26 11:09:10 2021 +1100

    Be strict about extra fields in EF tests

commit d831e8a
Author: Michael Sproul <[email protected]>
Date:   Tue Mar 23 11:07:18 2021 +1100

    VC: accept unknown fields in chain spec
@bors
Copy link

bors bot commented Mar 26, 2021

@bors bors bot changed the title VC: accept unknown fields in chain spec [Merged by Bors] - VC: accept unknown fields in chain spec Mar 26, 2021
@bors bors bot closed this Mar 26, 2021
@michaelsproul michaelsproul deleted the vc-unknown-fields branch March 26, 2021 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0 ready-for-merge This PR is ready to merge. val-client Relates to the validator client binary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants