feat: rearrange submissions storage map and apply more submission limits #14
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.
Rationale for this change
There is an edge case that wasn't accounted for in the current pallet-indexing implementation. While submissions were rejected when an account submitted multiple times for the same batch with the same data, they were not rejected if they submitted multiple times for the same batch with different data. Furthermore, while there was a submission count limit for a single data hash, there was no limit being applied across all submissions for a given batch id. This leads to a potential attack vector, a submitter could submit disagreeing data and increase the storage size for a single batch id as much as they wanted.
This makes a couple changes to handle submission structures and limits better. Firstly, the submissions storage map has been rearranged to enforce some of the desired limitations with typing alone. While before the structure was..
Now, it is
This new mapping makes it so there is only one data hash per submitter per quorum scope per batch.
Furthermore, the extrinsics have been changed so that the MAX_SUBMITTERS limits apply across all submissions per quorum scope per batch, instead of all submissions per data hash.
What changes are included in this PR?
Are these changes tested?
Yes.