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

fix(core): properly parse genesis alloc storage #2205

Merged
merged 3 commits into from Feb 27, 2023

Conversation

Rjected
Copy link
Contributor

@Rjected Rjected commented Feb 27, 2023

Motivation

Previously we were not properly parsing the storage field of GenesisAlloc. The first issue was in using serde(flatten), which is just incorrect because storage is not encoded flattened. The second issue was in the parsing of H256 keys and values. Some of the storage values in hive genesis examples were encoded in less than 64 hex characters, such as the string 0x22. This would not succeed normal H256 parsing, but is consistent with JSON-RPC unformatted encoding.

Solution

  • Introduce from_unformatted_hex_map to properly deserialize the storage map.
  • Modify existing genesis parsing tests to check parsed storage and code values against expected values.
  • Introduce new genesis parsing test from the hive smoke tests, checking full struct equality.

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog
  • Breaking changes

 * Previously we were not properly parsing the storage field of
   GenesisAlloc. The first issue was in using serde(flatten), which is
   just incorrect because storage is not encoded flattened. The second
   issue was in the parsing of H256 keys and values. Some of the storage
   values in hive genesis examples were encoded in less than 64 hex
   characters, such as the string `0x12`. This would not succeed normal
   H256 parsing.
 * Introduce from_unformatted_hex_map to properly deserialize the
   storage map.
 * Modify existing genesis parsing tests to check parsed storage and
   code values against expected values.
 * Introduce new genesis parsing test from the hive smoke tests,
   checking full struct equality.
@gakonst gakonst merged commit 537d0a9 into gakonst:master Feb 27, 2023
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