Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use storage::exists host function instead of ::get. #7445

Merged
merged 2 commits into from
Oct 28, 2020
Merged

Conversation

tomusdrw
Copy link
Contributor

It seems that currently the unhashed storage does not check existence in the most efficient way.

I suspect that due to old-clients compatibility we've decided to initially implement exists using sp_io::storage::read, but it obviously is sub-optimal, cause reads the entire value under the key, luckily transfers no bytes over to the WASM side, but merely check if it's not None.

The PR changes the method implementation to use sp_io::storage::exists instead, which is generally more optimized.

@tomusdrw tomusdrw added A0-please_review Pull request needs code review. B5-clientnoteworthy C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Oct 28, 2020
@bkchr bkchr removed the D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. label Oct 28, 2020
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Please merge master to fix the companion.

@bkchr bkchr merged commit b8b8106 into master Oct 28, 2020
@bkchr bkchr deleted the td-storage-exists branch October 28, 2020 12:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants