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

Make automatic storage deposits resistant against changing deposit prices #12064

Closed
athei opened this issue Aug 18, 2022 · 0 comments · Fixed by #12083
Closed

Make automatic storage deposits resistant against changing deposit prices #12064

athei opened this issue Aug 18, 2022 · 0 comments · Fixed by #12083
Assignees
Labels
J0-enhancement An additional feature request. Z3-substantial Can be fixed by an experienced coder with a working knowledge of the codebase.

Comments

@athei
Copy link
Member

athei commented Aug 18, 2022

The Vision

Currently, automatic storage deposits do not gracefully handle when the runtime changes the price per byte or per storage item: We just refund bytes_removed * current_price. One can easily see that for rising prices that can lead to the contract running dry of deposits (removing the incentive to cleanup) or on falling prices accumulating too much deposit that can only be removed by terminating the contract.

@shawntabrizi brought up a better way of doing this. Albeit making the whole process much more complex and introducing its own problems it makes the situation much better: The refunds are pro rata of the accumulated storage: If I remove 1% of storage I get back 1% of the deposit. This makes sure that the contract never runs dry and never has too much deposit.

However, there is a side effect of that. On falling prices this opens up arbitrage opportunities: Creating and removing storage in quick succession to gain deposit back cause creating storage is less expensive than the refund one gets for the same amount. At the end of the this is just someone bringing the deposit of a contract to the level where it should be after the prices were adjusted. We argue that this is OK.

On raising prices the refund will be less than what the depositor originally payed for it (given the arbitrage already took place). We argue this is OK because the depositor still has an incentive to gets its storage cleaned up even though the reward got smaller.

The Plan

We will just implement this in a single PR.

Open Questions

  • Are the mentioned side effects a show stopper? We argue they are much better than what we have now.
  • This will require a big storage migration where we count every contracts storage items. Do we need to go the extra mile and split this over multiple blocks? I don't think there is a production chain with enough usage to justify this.
@athei athei added J0-enhancement An additional feature request. Z3-substantial Can be fixed by an experienced coder with a working knowledge of the codebase. labels Aug 18, 2022
@athei athei self-assigned this Aug 18, 2022
@athei athei moved this to Backlog 🗒 in Smart Contracts Aug 18, 2022
@athei athei moved this to Draft in Parity Roadmap Aug 18, 2022
@athei athei moved this from Draft to Open in Parity Roadmap Aug 18, 2022
@athei athei moved this from Backlog 🗒 to In Progress 🛠 in Smart Contracts Aug 22, 2022
Repository owner moved this from In Progress 🛠 to Done ✅ in Smart Contracts Sep 21, 2022
Repository owner moved this from Open to Closed in Parity Roadmap Sep 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. Z3-substantial Can be fixed by an experienced coder with a working knowledge of the codebase.
Projects
Status: Done
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant