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

storage: Fix partial key storage iteration #1298

Merged
merged 7 commits into from
Dec 1, 2023
Merged

Conversation

lexnv
Copy link
Collaborator

@lexnv lexnv commented Nov 30, 2023

This PR fixes the partial key storage iteration.

The storage key constructed by partial inputs was converted to the root storage key entry.
This meant that any partial input parameters provided to the key were completely ignored; and resulted in a wrongful behavior of iterating over all storage entries, rather than just the ones starting with the partial key.

To mitigate this behavior, the address bytes take into account the provided parameter inputs.
This loosens the expectations of utils::storage_address_bytes, which now only returns errors if the provided input types exceed the number of types from the metadata. Before this PR, the function expected an identical match in terms of the number of inputs.

Testing Done

  • Manual testing with the metadata from "wss://rpc.relay.blockchain.enjin.io:443"
  • Added an unit test that creates two assets, and checks that partial iterations result in the expected number of items

Closes: #1251

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv requested a review from a team as a code owner November 30, 2023 16:21
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv changed the title storage: Allow partial iteration storage: Fix partial key storage iteration Dec 1, 2023
Copy link
Contributor

@tadeohepperle tadeohepperle left a comment

Choose a reason for hiding this comment

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

Ah nice, great work! :)

@lexnv lexnv merged commit b03679f into master Dec 1, 2023
10 checks passed
@lexnv lexnv deleted the lexnv/fix-partial-iter branch December 1, 2023 13:33
@jsdw jsdw mentioned this pull request Dec 7, 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.

Iterating over StorageDoubleMap with partial keys not working
3 participants