kleros / stake-curate

Curate with indefinite, capital-efficient stake.
8 stars 3 forks source link

Consider discarding items rewrittable storage #22

Closed greenlucid closed 2 years ago

greenlucid commented 2 years ago

This is a hard call to make but I wanted to write it somewhere so that I can reflect on it later. Currently, stake-curate has rewrittable item storage. This means that creating new items should be significantly cheaper if you're choosing used slots. More even so taking into account the saving is in L2 gas, since stake-curate will live in a rollup.

Recently, a decision involved allowing to write arbitrary data as bytes in the items (#17). In order to make it easier for other contracts to interface with stake-curate, the id of an item should be predictable. This is not compatible with rewrittable storage.

we can either approach it as "not our problem" and keep the position of the items unpredictable, and force proxies to deal with that complexity. This will mean significantly cheaper item submissions in reused slots. (It's not that hard to deal with that complexity, it's just annoying. proxies would have to deal with timestamps, etc. But they probably would need that anyway.)

Or we can dump the rewrittable storage idea entirely. This makes reading data onchain easier. It also simplifies a few methods. It also reduces some complexity off the user, and eliminates the need for the user to understand the slot system. Two routes:

This is going to be a hard call so I'll take my time figuring out what better for the project

greenlucid commented 2 years ago

I decided against this

greenlucid commented 2 years ago

Revisiting this. There are upsides I missed:

another cool thing about this is, some lists would be able to keep the entire history of the item, without the current issue of

  1. item gets created
  2. item is challenged and removed
  3. correct version of the item gets uploaded (thus, losing its reference to the previous one)

with this structure, instead, a list policy can enforce that the item has to be reclaimed. then, the history of the item (evidence thread + editions) wont be lost. this makes special sense for wiki use case. reclaiming is not a feature yet, but it could be added.

greenlucid commented 2 years ago

Additionally, it could make sense to also stop making Dispute structs rewrittable. If so, then they should be set to zero to trigger refunds. But, this is not as important. Should also be considered that allowing refunds to this will result in cheaper overflow attack for Disputes, whereas, in the rewrittable Dispute system, the number expresses the amount of Disputes that can be open simultaneously. (Of course, an attacker can create Disputes that will never finish, but still, it is fundamentally different)