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

Parse genesis account amount as string #422

Merged
merged 1 commit into from
Sep 11, 2023
Merged

Conversation

JamesHinshelwood
Copy link
Contributor

Annoyingly toml (the crate) doesn't support u128 (toml-rs/toml#540), so we instead take the configured values as strings and parse them into u128s later.

Annoyingly `toml` (the crate) doesn't support `u128`
(toml-rs/toml#540), so we instead take
the configured values as strings and parse them into `u128`s
later.
@JamesHinshelwood JamesHinshelwood merged commit d8916a7 into main Sep 11, 2023
5 checks passed
Copy link
Contributor

@theo-zil theo-zil left a comment

Choose a reason for hiding this comment

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

Whoops, I should've checked this PR first before commenting about this on the other one.

I wonder if it would be ergonomic to use a custom deserializer function that uses deserialize_string() from serde and then .parse()s it into a u128 in-place? The benefit being proper type-safety in our Config type, where a malformed string would fail on file parsing, rather than happily progressing through to application logic with a malformed config and then being liable to fail on a parse() call way down in the State constructor.

But pragmatically speaking we will always construct a State very early when starting the node so it'll still fail fast, so if this sounds like a hassle then I've no major qualms with merging as-is.

EDIT: Didn't notice auto-merge was on, haha. Fair enough, sounds like we're doing it this way then, if you think it'd be worthwhile to come back to my suggestion then we can open an issue for later, since like I said pragmatically speaking this is fine as far as I'm concerned.

@JamesHinshelwood JamesHinshelwood deleted the amount-as-str branch September 11, 2023 13:21
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.

None yet

2 participants