-
Notifications
You must be signed in to change notification settings - Fork 867
Config Validation #7341
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
base: unstable
Are you sure you want to change the base?
Config Validation #7341
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Looks like this needs a quick cargo fmt --all
Some of the tests don't seem happy either
I'll do that, as well as take a look at the tests. Appreciate the review! |
pub fn validate_extra_fields(&self) -> Result<(), String> { | ||
for key in self.future_fields.keys() { | ||
if !FUTURE_FIELDS.contains(&key.as_str()) { | ||
return Err(format!("Unknown or disallowed field found: {}", key)); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach. Simple and flexible.
Let me know if you get stuck fixing any of the tests
Alright, I fixed up the tests. Most of the issues were simply because the validation and removal of defaults meant I had to add the missing fields in the existing configs. For this, I ended up using the original default values to maintain the same functionality as before. |
Some required checks have failed. Could you please take a look @Patchoulis? 🙏 |
Issue Addressed
#6208
Proposed Changes
A few changes. First, as discussed in the discord, the defaults have been removed to ensure that all expected fields are provided.
Second, I do validate that no additional values are present. However, as discussed with sproul, there are some legitimate reasons to add some for future forks. I ended up solving this by adding a small modifiable constant which allows specified optional fields to exist.
I'm doing some tests to ensure presets like SLOTS_PER_EPOCH are also disallowed, but this should also solve that problem.
Additional Info
Please provide any additional information. For example, future considerations
or information useful for reviewers.