Skip to content
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

Properly fill genesis_data defaults #215

Merged

Conversation

pacrob
Copy link
Contributor

@pacrob pacrob commented Jun 5, 2024

What was wrong?

Filling geth_kwargs defaults by just creating a model from the dict works fine because its only member that is a dict (suffix_kwargs) defaults to None. genesis_data["config"] does have default values, so just creating a GenesisData model from the dict does not fill the sub-dict properly.

How was it fixed?

Added a fill_default_genesis_data function and test.

Todo:

  • Clean up commit history
  • Add or update documentation related to these changes
  • Add entry to the release notes

Cute Animal Picture

image

@pacrob pacrob changed the base branch from main to typed-py-geth June 5, 2024 21:41
@pacrob pacrob force-pushed the test-filling-defaults-with-models branch from 1cff0fc to 665e946 Compare June 5, 2024 21:45
@pacrob pacrob marked this pull request as ready for review June 5, 2024 21:46
@pacrob pacrob requested review from fselmo, kclowes and reedsa June 5, 2024 21:47
if genesis_data.get("config"):
try:
genesis_data_config_filled = GenesisDataConfig(**genesis_data["config"])
except ValidationError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it's worth adding a test for hitting the error conditions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! added.

@pacrob pacrob force-pushed the test-filling-defaults-with-models branch from 99bfa6c to 68ee2b2 Compare June 6, 2024 16:34
@pacrob pacrob requested a review from kclowes June 6, 2024 16:40
Copy link
Contributor

@fselmo fselmo left a comment

Choose a reason for hiding this comment

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

lgtm 👍🏼... just left a small nit on a validation method from a previous PR. Take or leave.

@@ -135,13 +145,37 @@ def validate_genesis_data(genesis_data: GenesisDataTypedDict) -> bool:
raise PyGethValueError(
f"error while validating genesis_data config field: {e}"
)

return True
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we can probably leave this out and return None in the signature. Generally I don't expect validation methods to return anything, except raise if appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed! makes sense

@pacrob pacrob force-pushed the test-filling-defaults-with-models branch from 03a8386 to 294691c Compare June 6, 2024 19:12
@pacrob pacrob merged commit 2c9119a into ethereum:typed-py-geth Jun 6, 2024
108 checks passed
@pacrob pacrob deleted the test-filling-defaults-with-models branch June 6, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants