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

contracts: Fix possible overflow in storage size calculation #7885

Merged
1 commit merged into from
Jan 14, 2021

Conversation

athei
Copy link
Member

@athei athei commented Jan 12, 2021

Fixes #2672

For the reasons explained in the linked issue we replace unchecked and saturating math by checked math. Every contract call that tries to accumulate more storage than can be hold by the u32 type will be trapped.

It is extremely unlikely that such a large contract will be economically feasible.

@athei athei added A0-please_review Pull request needs code review. B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. labels Jan 12, 2021
Copy link
Contributor

@gui1117 gui1117 left a comment

Choose a reason for hiding this comment

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

I feel like I would prefer returning result than having a documented panics, but maybe in this context it is fine.

But PR is good to me

frame/contracts/src/storage.rs Show resolved Hide resolved
@athei
Copy link
Member Author

athei commented Jan 14, 2021

bot merge

@ghost
Copy link

ghost commented Jan 14, 2021

Trying merge.

@ghost ghost merged commit fae26bb into master Jan 14, 2021
@ghost ghost deleted the at-contract-overflow branch January 14, 2021 12:44
This pull request was closed.
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
Status: Done
Development

Successfully merging this pull request may close these issues.

Contract storage size panic on u32 overflow
4 participants