diff --git a/pallets/anonymity-mining/src/lib.rs b/pallets/anonymity-mining/src/lib.rs index ccdca0252..c3781f8a8 100644 --- a/pallets/anonymity-mining/src/lib.rs +++ b/pallets/anonymity-mining/src/lib.rs @@ -64,6 +64,10 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 #[pallet::without_storage_info] pub struct Pallet(_); @@ -140,7 +144,13 @@ pub mod pallet { #[pallet::getter(fn parameters)] /// Details of the module's parameters pub(super) type Parameters, I: 'static = ()> = - StorageValue<_, Vec, ValueQuery>; + + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 + /// Please use BoundedVec insted Vec + StorageValue<_, Vec, ValueQuery>; #[pallet::storage] #[pallet::getter(fn get_pool_weight)] diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index 3de829a85..3494ffc9f 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -95,6 +95,10 @@ pub mod pallet { } #[pallet::pallet] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 #[pallet::without_storage_info] pub struct Pallet(_); @@ -256,6 +260,9 @@ pub mod pallet { /// /// Emits 'Registered` event when successful. #[pallet::weight(::WeightInfo::register())] + // HB Milestone Review 1 + // It is not necessary to declare the #[transactional] macro anymore since it is added by + // default. https://github.com/paritytech/substrate/pull/11431 #[transactional] pub fn register( origin: OriginFor, @@ -283,6 +290,9 @@ pub mod pallet { // TODO: No tests #[pallet::weight(::WeightInfo::update())] + // HB Milestone Review 1 + // It is not necessary to declare the #[transactional] macro anymore since it is added by + // default. https://github.com/paritytech/substrate/pull/11431 #[transactional] pub fn update( origin: OriginFor, @@ -329,6 +339,9 @@ pub mod pallet { /// /// Emits `MetadataSet` event when successful. #[pallet::weight(::WeightInfo::set_metadata())] + // HB Milestone Review 1 + // It is not necessary to declare the #[transactional] macro anymore since it is added by + // default. https://github.com/paritytech/substrate/pull/11431 #[transactional] pub fn set_metadata( origin: OriginFor, @@ -363,6 +376,9 @@ pub mod pallet { /// /// Emits `LocationSet` event when successful. #[pallet::weight(::WeightInfo::set_location())] + // HB Milestone Review 1 + // It is not necessary to declare the #[transactional] macro anymore since it is added by + // default. https://github.com/paritytech/substrate/pull/11431 #[transactional] pub fn set_location( origin: OriginFor, diff --git a/pallets/hasher/src/lib.rs b/pallets/hasher/src/lib.rs index 00d9ce4c8..b5225581c 100644 --- a/pallets/hasher/src/lib.rs +++ b/pallets/hasher/src/lib.rs @@ -60,6 +60,10 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 #[pallet::without_storage_info] pub struct Pallet(_); @@ -106,6 +110,12 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn parameters)] /// Details of the module's parameters + /// + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 + /// Please use BoundedVec insted Vec pub(super) type Parameters, I: 'static = ()> = StorageValue<_, Vec, ValueQuery>; diff --git a/pallets/key-storage/src/lib.rs b/pallets/key-storage/src/lib.rs index 108835fc0..58edbe567 100644 --- a/pallets/key-storage/src/lib.rs +++ b/pallets/key-storage/src/lib.rs @@ -43,6 +43,10 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 #[pallet::without_storage_info] pub struct Pallet(_); diff --git a/pallets/linkable-tree/src/lib.rs b/pallets/linkable-tree/src/lib.rs index 2478650bf..73837b255 100644 --- a/pallets/linkable-tree/src/lib.rs +++ b/pallets/linkable-tree/src/lib.rs @@ -100,11 +100,22 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 #[pallet::without_storage_info] pub struct Pallet(_); #[pallet::config] /// The module configuration trait. + /// + /// HB Milestone Review 1 + /// Is the tightly coupling `+ pallet_mt::Config` needed in this case? + /// For example, you can get rid of `+ pallet_mt::Config` and just import the TreeInterface + /// from the pallet without requiring this inherince. + /// https://docs.substrate.io/build/pallet-coupling/ + pub trait Config: frame_system::Config + pallet_mt::Config { /// The overarching event type. type RuntimeEvent: From> diff --git a/pallets/mixer/src/lib.rs b/pallets/mixer/src/lib.rs index c80451067..c37bb11f6 100644 --- a/pallets/mixer/src/lib.rs +++ b/pallets/mixer/src/lib.rs @@ -101,6 +101,10 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 #[pallet::without_storage_info] pub struct Pallet(_); @@ -240,7 +244,9 @@ pub mod pallet { Self::deposit_event(Event::MixerCreation { tree_id }); Ok(().into()) } - + // HB Milestone Review 1 + // It is not necessary to declare the #[transactional] macro anymore since it is added by + // default. https://github.com/paritytech/substrate/pull/11431 #[transactional] #[pallet::weight(>::WeightInfo::deposit())] pub fn deposit( @@ -254,6 +260,9 @@ pub mod pallet { Ok(().into()) } + // HB Milestone Review 1 + // It is not necessary to declare the #[transactional] macro anymore since it is added by + // default. https://github.com/paritytech/substrate/pull/11431 #[transactional] #[pallet::weight(>::WeightInfo::withdraw())] pub fn withdraw( diff --git a/pallets/mt/src/lib.rs b/pallets/mt/src/lib.rs index 411770980..574f6680b 100644 --- a/pallets/mt/src/lib.rs +++ b/pallets/mt/src/lib.rs @@ -86,6 +86,10 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 #[pallet::without_storage_info] pub struct Pallet(_); @@ -173,6 +177,11 @@ pub mod pallet { /// The default hashes for this tree pallet #[pallet::storage] #[pallet::getter(fn default_hashes)] + /// HB Milestone Review 1 + /// Macro without_storage_info should not be used any more since unbounded Vecs might interfeer + /// in the proof_size calculation of the new Weights v2 struct. + /// Please check: https://github.com/paritytech/substrate/issues/8629 + /// Please use BoundedVec insted Vec pub(super) type DefaultHashes, I: 'static = ()> = StorageValue<_, Vec, ValueQuery>; @@ -382,6 +391,9 @@ impl, I: 'static> TreeInterface, depth: u8) -> Result { // Setting the next tree id let tree_id = Self::next_tree_id(); + // HB Milestone review 1: + // The "+=" might cause an overflow depending on the type provided on TreeId. I would change + // this operation to saturating_add() NextTreeId::::mutate(|id| *id += One::one()); // get unit of two let two: T::LeafIndex = Self::two(); @@ -449,6 +461,9 @@ impl, I: 'static> TreeInterface::insert(id, root_index, hash); + // HB Milestone review 1: + // The "+=" might cause an overflow depending on the type provided on TreeId. I would change + // this operation to saturating_add() ( same as NextRootIndex mutator) NextLeafIndex::::mutate(id, |i| *i += One::one()); // return the root @@ -473,7 +488,9 @@ impl, I: 'static> TreeInspector