Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix forum state bloat in #2196
In this PR I implement what we decided to do to solve the problem of state bloat in the forum pallet here.
Originally, we've solved the problem of state bloat in the forum pallet, by requiring a deposit for thread and post creation. Furthermore, the thread stored within its structure all the posts, using this, to delete a thread it was constant in time and when a thread was deleted all the deposit from all posts was given to the thread deleter(normally the thread creator).
However, this had the problem of making the structure of a thread to big which we would need to deal with in the weight functions, see: #2234
To solve this we wanted to return each post to its own storage. The problem if we make the thread deletion as a side effect delete all its posts, it'd be too costly, on the other side, if we require the creator of the post to delete each of their posts that would generate too much traffic.
To solve the last problem we decided that we can have both editable and non-editable posts. Editable posts work as the posts have always worked, non-editable don't need to occupy storage, so there is no deletion after a thread is deleted. We expect most posts to be non-editable and that would mean that this would greatly reduce traffic and dependence on each user deleting their posts.
Furthermore, we allow users who are not the posters to delete other users posts given this 2 conditions:
PostLifeTime
since the post was last editedIn this way we make sure that a post will be delted by other users opportunistically.
To motivate a user to delete their post, now deleting a post recover its original deposit. And the thread only recover its original deposit(not from all posts).
Included in this PR
To introduce the changes I described above I needed to include the following:
delete_thread
to only be used by thread creator instead of only the moderator/lead as to prevent a moderator/lead from deleting a thread just to recover its deposit(also to allow the correct functioning for a user to recover their deposit by deleting it). If a moderator/lead wants to remove a thread they need to usemoderate_thread
which slash the deposit instead of giving it to any one account.delete_posts
which allows deletion of posts by the user(allowing multiple post deletion at the same time to reduce the cost of doing so and reducing traffic)Furthermore, we removed the storage limits for threads and posts since that is dealt with by the deposits.
Companion handbook PR: Joystream/handbook#38