Skip to content

Commit

Permalink
Move comment, reducing MaxStorageRoots needs migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Jan 15, 2024
1 parent 5a982ed commit 33bb876
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pallets/relay-storage-roots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
//! roots are removed first, there is an additional `RelayStorageRootKeys` storage item that stores
//! a sorted list of all the keys. This is needed because it is not possible to iterate over a
//! mapping in order (unless if using an `Identity` hash). The `MaxStorageRoots` limit applies to
//! the number of items, not to their age.
//! the number of items, not to their age. Decreasing the value of `MaxStorageRoots` is a breaking
//! change and needs a migration to clean the `RelayStorageRoots` mapping.

#![cfg_attr(not(feature = "std"), no_std)]

Expand Down Expand Up @@ -117,9 +118,6 @@ pub mod pallet {
<RelayStorageRoot<T>>::remove(first_key);
}

// If `MaxStorageRoots` has decreased, we need to delete more than one storage root.
// But that would make this function have an unbounded amount of writes. So instead, we
// will only delete the first one, and leak the rest.
let keys = BoundedVec::truncate_from(keys.into());
<RelayStorageRootKeys<T>>::put(keys);
}
Expand Down

0 comments on commit 33bb876

Please sign in to comment.