Skip to content

Commit 340be0f

Browse files
committed
fix: revert change to enequeue_signature and update function doc
1 parent 1670a85 commit 340be0f

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

pallets/msa/src/lib.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,12 +1499,6 @@ impl<T: Config> Pallet<T> {
14991499
/// Raises `SignatureAlreadySubmitted` if the signature exists in the registry.
15001500
/// Raises `SignatureRegistryLimitExceeded` if the oldest signature of the list has not yet expired.
15011501
///
1502-
/// Example list:
1503-
/// - `1,2 (oldest)`
1504-
/// - `2,3`
1505-
/// - `3,4`
1506-
/// - 4 (newest in pointer storage)`
1507-
///
15081502
/// # Errors
15091503
/// * [`Error::ProofNotYetValid`]
15101504
/// * [`Error::ProofHasExpired`]
@@ -1551,6 +1545,27 @@ impl<T: Config> Pallet<T> {
15511545
}
15521546

15531547
/// Do the actual enqueuing into the list storage and update the pointer
1548+
///
1549+
/// The signature registry consist of two storage items:
1550+
/// - `PayloadSignatureRegistryList` - a linked list of signatures, in which each entry
1551+
/// points to the next newest signature. The list is stored as a mapping of
1552+
/// `MultiSignature` to a tuple of `(BlockNumberFor<T>, MultiSignature)`.
1553+
/// The tuple contains the expiration block number and the next signature in the list.
1554+
/// - `PayloadSignatureRegistryPointer` - a struct containing the newest signature,
1555+
/// the oldest signature, the count of signatures, and the expiration block number of the newest signature.
1556+
///
1557+
/// NOTE: 'newest' and 'oldest' refer to the order in which the signatures were added to the list,
1558+
/// which is not necessarily the order in which they expire.
1559+
///
1560+
/// Example: (key [signature], value [next newest signature])
1561+
/// - `1,2 (oldest)`
1562+
/// - `2,3`
1563+
/// - `3,4`
1564+
/// - 4 (newest in pointer storage)`
1565+
///
1566+
// DEVELOPER NOTE: As currently implemented, the signature registry list will continue to grow until it reaches
1567+
// the maximum number of signatures, at which point it will remain at that size, only ever replacing the oldest
1568+
// signature with the newest one. This is a trade-off between storage space and performance.
15541569
fn enqueue_signature(
15551570
signature: &MultiSignature,
15561571
signature_expires_at: BlockNumberFor<T>,
@@ -1595,7 +1610,7 @@ impl<T: Config> Pallet<T> {
15951610
}
15961611

15971612
// Add the newest signature if we are not the first
1598-
if pointer.count != 0 && current_block.le(&pointer.newest_expires_at) {
1613+
if pointer.count != 0 {
15991614
<PayloadSignatureRegistryList<T>>::insert(
16001615
pointer.newest,
16011616
(pointer.newest_expires_at, signature.clone()),

0 commit comments

Comments
 (0)