Skip to content

Conversation

@tlovell-sxt
Copy link
Contributor

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..

batch_id -> data_hash -> quorum_scope -> submitter_list

Now, it is

batch_id -> quorum_scope -> submitter -> data_hash

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?

  • feat: rearrange submissions storage map and apply more submission limits
  • feat: migrate storage from Submissions to SubmissionsV1

Are these changes tested?

Yes.

tlovell-sxt and others added 4 commits May 29, 2025 15:52
We need to incoroporate the polkadot migrations pallet into our runtime
if we want to be able to perform multi-block storage migrations. This is
especially relevant as we are entering a more stable development phase,
and all breaking storage changes in the future will need to be handled
via migrations.
A previous commit added an additional pallet (pallet-migrations) to the
runtime. In order to reflect this change in the versioning of the
runtime, the spec_version should be updated.
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..
```
batch_id -> data_hash -> quorum_scope -> submitter_list
```
Now, it is
```
batch_id -> quorum_scope -> submitter -> data_hash
```
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.
We are rearranging the submissions storage map so that it imposes
greater limits on the number of submissions per account per batch. In
order to apply these changes in a runtime upgrade, we need a storage
migration. This change implements this storage migration as multi-block
and registers it in the runtime.
@tlovell-sxt tlovell-sxt force-pushed the feat/pallet-migrations branch from e205443 to d099ed0 Compare June 19, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants