Skip to content

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

Open
wants to merge 10 commits into
base: unstable
Choose a base branch
from
Open

Config Validation #7341

wants to merge 10 commits into from

Conversation

Patchoulis
Copy link

@Patchoulis Patchoulis commented Apr 21, 2025

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.

@chong-he chong-he added enhancement New feature or request ready-for-review The code is ready for review labels Apr 21, 2025
Copy link
Member

@macladson macladson left a 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

@macladson macladson added work-in-progress PR is a work-in-progress and removed ready-for-review The code is ready for review labels Apr 21, 2025
@Patchoulis
Copy link
Author

I'll do that, as well as take a look at the tests. Appreciate the review!

Comment on lines +1725 to +1733
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(())
}
Copy link
Member

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

@Patchoulis Patchoulis requested a review from macladson April 26, 2025 07:18
@Patchoulis
Copy link
Author

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.

Copy link

mergify bot commented May 19, 2025

Some required checks have failed. Could you please take a look @Patchoulis? 🙏

@mergify mergify bot added the waiting-on-author The reviewer has suggested changes and awaits thier implementation. label May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting-on-author The reviewer has suggested changes and awaits thier implementation. work-in-progress PR is a work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants