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

contracts: Cap the maximum amount of storage a contract can accumulate #7526

Closed
athei opened this issue Nov 12, 2020 · 1 comment
Closed
Labels
I2-security The client fails to follow expected, security-sensitive, behaviour.

Comments

@athei
Copy link
Member

athei commented Nov 12, 2020

As explained in #6594 having contracts with large amount of storage can lead to a DoS vector when a contract is removed. The long term solution is the described lazy storage removal. As an interim solution we can also cap the allowed storage size so that removing a contract never takes longer than the allotted block time. The following steps are necessary for that:

  • Cap the maximum number of storage items a contract can have.
  • Don't remove a contract on call when the rent can't be payed. Merely deny access.
  • Declare the claim_surcharge pre weight according to the maximum amount of storage items. Use post dispatch correction to return the actual weight and disable fees on success.
@athei
Copy link
Member Author

athei commented Dec 4, 2020

It turns out that removing those keys is really expensive. My prototypical implementation determined that we need to cap the number of storage items around 10_000 if we would go down this path. This is way too low given that every map entry in ink! uses one storage item.

Instead, we go through with the original plan of lazy storage removal. A first step in that direction is made here.

@athei athei closed this as completed Dec 4, 2020
@athei athei moved this to Done in Smart Contracts Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I2-security The client fails to follow expected, security-sensitive, behaviour.
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant