Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes without_storage_info macro from pallets #1122

Merged
merged 15 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP: Removed macro, fixing max encoded len info missing
  • Loading branch information
mustermeiszer committed Dec 6, 2022
commit d0ecc24f32acee6a4e7eb575cabebb519098d0c9
2 changes: 1 addition & 1 deletion libs/types/src/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use sp_std::{
vec::Vec,
};

#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct FulfillmentWithPrice<BalanceRatio> {
pub of_amount: Perquintill,
pub price: BalanceRatio,
Expand Down
5 changes: 2 additions & 3 deletions pallets/anchors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![allow(clippy::all)]

use cfg_traits::fees::{Fee, Fees};
use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dispatch::{DispatchError, DispatchResult},
storage::child,
Expand Down Expand Up @@ -81,7 +81,7 @@ const ANCHOR_PREFIX: &[u8; 6] = b"anchor";
const EVICT_PRE_COMMIT_LIST_SIZE: u32 = 100;

/// The data structure for storing pre-committed anchors.
#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo)]
#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct PreCommitData<Hash, AccountId, BlockNumber, Balance> {
signing_root: Hash,
Expand Down Expand Up @@ -112,7 +112,6 @@ pub mod pallet {
// method.
#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
1 change: 0 additions & 1 deletion pallets/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub mod pallet {
// for the pallet.
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

// ------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion pallets/claims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ pub mod pallet {
// for the pallet.
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

// ------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions pallets/collator-allowlist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
Expand All @@ -49,7 +48,7 @@ pub mod pallet {
type WeightInfo: WeightInfo;

/// The Validator Id type
type ValidatorId: Member + Parameter + MaybeSerializeDeserialize;
type ValidatorId: Member + Parameter + MaybeSerializeDeserialize + MaxEncodedLen;

/// Type representing the underlying validator registration center.
/// It offers us the API we need to check whether a collator
Expand Down
1 change: 0 additions & 1 deletion pallets/connectors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
4 changes: 2 additions & 2 deletions pallets/crowdloan-claim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ pub mod pallet {
// for the pallet.
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -233,7 +232,8 @@ pub mod pallet {
+ Member
+ Ord
+ Parameter
+ Into<AccountId32>;
+ Into<AccountId32>
+ MaxEncodedLen;

/// The maximum length (i.e. depth of the tree) we allow a proof to have.
/// This mitigates DDoS attacks solely. We choose 30, which by a base 2 merkle-tree
Expand Down
1 change: 0 additions & 1 deletion pallets/crowdloan-reward/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ pub mod pallet {
// Declare pallet structure placeholder
#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

// ----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions pallets/fees/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ pub mod pallet {
// method.
#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
pub trait Config: frame_system::Config + pallet_authorship::Config {
/// Key type used for storing and identifying fees.
type FeeKey: FeeKey + EncodeLike;
type FeeKey: FeeKey + EncodeLike + MaxEncodedLen;

/// The currency mechanism.
type Currency: Currency<Self::AccountId>;
Expand Down
10 changes: 5 additions & 5 deletions pallets/interest-accrual/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
use cfg_primitives::{Moment, SECONDS_PER_YEAR};
use cfg_traits::InterestAccrual;
use cfg_types::adjustments::Adjustment;
use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::traits::UnixTime;
use scale_info::TypeInfo;
use sp_arithmetic::traits::{checked_pow, One, Zero};
Expand Down Expand Up @@ -89,14 +89,14 @@ pub struct RateDetailsV0<InterestRate, Moment> {
pub last_updated: Moment,
}

#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo)]
#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct RateDetails<InterestRate> {
pub accumulated_rate: InterestRate,
pub reference_count: u32,
}

#[derive(Encode, Decode, TypeInfo, PartialEq)]
#[derive(Encode, Decode, TypeInfo, PartialEq, MaxEncodedLen)]
#[repr(u32)]
pub enum Release {
V0,
Expand All @@ -119,7 +119,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
Expand All @@ -145,7 +144,8 @@ pub mod pallet {
+ Default
+ Copy
+ TypeInfo
+ FixedPointNumber<Inner = Self::Balance>;
+ FixedPointNumber<Inner = Self::Balance>
+ MaxEncodedLen;

type Time: UnixTime;

Expand Down
6 changes: 3 additions & 3 deletions pallets/investments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub mod pallet {
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;

/// The underlying investments one can invest into
type InvestmentId: Member + Parameter + Copy;
type InvestmentId: Member + Parameter + Copy + MaxEncodedLen;

/// Something that knows how to handle accounting for the given investments
/// and provides metadata about them
Expand Down Expand Up @@ -218,7 +218,8 @@ pub mod pallet {
+ Default
+ Copy
+ FixedPointNumber<Inner = Self::Amount>
+ FixedPointNumberExtension;
+ FixedPointNumberExtension
+ MaxEncodedLen;

/// The bound on how many fulfilled orders we cache until
/// the user needs to collect them.
Expand All @@ -243,7 +244,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::hooks]
Expand Down
7 changes: 3 additions & 4 deletions pallets/keystore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ mod tests;

pub mod weights;

#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub enum KeyPurpose {
P2PDiscovery,
P2PDocumentSigning,
}

#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub enum KeyType {
ECDSA,
EDDSA,
}

#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct Key<BlockNumber, Balance> {
purpose: KeyPurpose,
key_type: KeyType,
Expand Down Expand Up @@ -98,7 +98,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

/// Keys that are currently stored.
Expand Down
1 change: 0 additions & 1 deletion pallets/loans/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
7 changes: 4 additions & 3 deletions pallets/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#![allow(clippy::type_complexity)]

use codec::{Decode, Encode};
use frame_support::{dispatch::DispatchResult, ensure, traits::Currency};
use frame_support::{
dispatch::DispatchResult, ensure, pallet_prelude::MaxEncodedLen, traits::Currency,
};
pub use pallet::*;
use scale_info::TypeInfo;
pub use weights::*;
Expand All @@ -27,7 +29,7 @@ type BalanceOf<T> = <<T as pallet_vesting::Config>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;

#[derive(Encode, Decode, PartialEq, Clone, TypeInfo)]
#[derive(Encode, Decode, PartialEq, Clone, TypeInfo, MaxEncodedLen)]
pub enum MigrationStatus {
Inactive,
Ongoing,
Expand Down Expand Up @@ -57,7 +59,6 @@ pub mod pallet {
// method.
#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
1 change: 0 additions & 1 deletion pallets/nft-sales/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
1 change: 0 additions & 1 deletion pallets/nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ pub mod pallet {
// for the pallet.
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

// ------------------------------------------------------------------------
Expand Down
9 changes: 6 additions & 3 deletions pallets/permissions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ pub mod pallet {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;

type Scope: Member + Parameter;
type Scope: Member + Parameter + MaxEncodedLen;

type Role: Member + Parameter;

type Storage: Member + Parameter + Properties<Property = Self::Role> + Default;
type Storage: Member
+ Parameter
+ Properties<Property = Self::Role>
+ Default
+ MaxEncodedLen;

type Editors: Contains<(Self::AccountId, Option<Self::Role>, Self::Scope, Self::Role)>;

Expand All @@ -66,7 +70,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::storage]
Expand Down
1 change: 0 additions & 1 deletion pallets/pool-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::storage]
Expand Down
1 change: 0 additions & 1 deletion pallets/pool-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::storage]
Expand Down
16 changes: 8 additions & 8 deletions pallets/pool-system/src/pool_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use cfg_primitives::Moment;
use cfg_types::epoch::EpochState;
use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dispatch::{DispatchError, DispatchResult},
traits::Get,
Expand All @@ -37,7 +37,7 @@ impl<PoolId> TypeId for PoolLocator<PoolId> {
const TYPE_ID: [u8; 4] = *b"pool";
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct ReserveDetails<Balance> {
/// Investments will be allowed up to this amount.
pub max: Balance,
Expand Down Expand Up @@ -84,7 +84,7 @@ where
}
}

#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct ScheduledUpdateDetails<Rate, MaxTokenNameLength, MaxTokenSymbolLength, MaxTranches>
where
MaxTokenNameLength: Get<u32>,
Expand All @@ -101,7 +101,7 @@ pub struct PoolLocator<PoolId> {
pub pool_id: PoolId,
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct PoolDetails<
CurrencyId,
TrancheCurrency,
Expand Down Expand Up @@ -133,20 +133,20 @@ pub struct PoolDetails<
pub reserve: ReserveDetails<Balance>,
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub enum PoolStatus {
Open,
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct PoolParameters {
/// Minimum duration for an epoch.
pub min_epoch_time: Moment,
/// Maximum time between the NAV update and the epoch closing.
pub max_nav_age: Moment,
}

#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct PoolChanges<Rate, MaxTokenNameLength, MaxTokenSymbolLength, MaxTranches>
where
MaxTokenNameLength: Get<u32>,
Expand All @@ -161,7 +161,7 @@ where
}

/// Information about the deposit that has been taken to create a pool
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, Default, TypeInfo)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, Default, TypeInfo, MaxEncodedLen)]
pub struct PoolDepositInfo<AccountId, Balance> {
pub depositor: AccountId,
pub deposit: Balance,
Expand Down
1 change: 0 additions & 1 deletion pallets/restricted-tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::event]
Expand Down