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

CU-24fwjma Add MaxEncodedLen implementations in pallets #580

Merged
merged 2 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions frame/composable-traits/src/bonded_finance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait BondedFinance {
}

/// The Bond duration.
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub enum BondDuration<BlockNumber> {
/// Finite duration, liquidity is returned after a number of `blocks`.
Finite { return_in: BlockNumber },
Expand All @@ -35,7 +35,7 @@ pub enum BondDuration<BlockNumber> {
}

/// The Bond offer.
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct BondOffer<AccountId, AssetId, Balance, BlockNumber> {
/// The account that will receive the locked assets.
pub beneficiary: AccountId,
Expand All @@ -53,7 +53,7 @@ pub struct BondOffer<AccountId, AssetId, Balance, BlockNumber> {
}

/// The Bond reward. Asset and rules reward will be given.
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct BondOfferReward<AssetId, Balance, BlockNumber> {
/// The actual reward asset.
pub asset: AssetId,
Expand Down
4 changes: 2 additions & 2 deletions frame/composable-traits/src/governance.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use frame_support::{
codec::{Decode, Encode},
codec::{Decode, Encode, MaxEncodedLen},
RuntimeDebug,
};
use frame_system::RawOrigin;
use scale_info::TypeInfo;

/// Like `RawOrigin`, but always signed.
#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo)]
#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)]
pub enum SignedRawOrigin<AccountId> {
/// The system itself ordained this dispatch to happen: this is the highest privilege level.
Root,
Expand Down
6 changes: 3 additions & 3 deletions frame/composable-traits/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub const ONE_HOUR: DurationSeconds = 60 * 60;
/// accounts to length of year)
pub const SECONDS_PER_YEAR_NAIVE: DurationSeconds = 365 * 24 * ONE_HOUR;

#[derive(Decode, Encode, Clone, TypeInfo, Debug, PartialEq)]
#[derive(Decode, Encode, Clone, Debug, PartialEq, TypeInfo)]
pub enum TimeReleaseFunction {
LinearDecrease(LinearDecrease),
StairstepExponentialDecrease(StairstepExponentialDecrease),
Expand All @@ -28,13 +28,13 @@ impl Default for TimeReleaseFunction {
}
}

#[derive(Default, Decode, Encode, Clone, TypeInfo, Debug, PartialEq)]
#[derive(Default, Decode, Encode, Clone, Debug, PartialEq, TypeInfo)]
pub struct LinearDecrease {
/// Seconds after start when the amount reaches zero
pub total: DurationSeconds,
}

#[derive(Default, Decode, Encode, Clone, TypeInfo, Debug, PartialEq)]
#[derive(Default, Decode, Encode, Clone, Debug, PartialEq, TypeInfo)]
pub struct StairstepExponentialDecrease {
// Length of time between drops
pub step: DurationSeconds,
Expand Down
2 changes: 1 addition & 1 deletion frame/composable-traits/src/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum FundsAvailability<Balance> {
MustLiquidate,
}

#[derive(Copy, Clone, Encode, Decode, Debug, PartialEq, TypeInfo)]
#[derive(Copy, Clone, Encode, Decode, Debug, PartialEq, MaxEncodedLen, TypeInfo)]
pub enum Deposit<Balance, BlockNumber> {
/// Indicates that the vault has deposited an amount large enough to forever be exempt from
/// rent payments.
Expand Down
2 changes: 1 addition & 1 deletion frame/composable-traits/src/vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub trait VestedTransfer {
///
/// Benefits would be granted gradually, `per_period` amount every `period`
/// of blocks after `start`.
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub struct VestingSchedule<BlockNumber, Balance: HasCompact> {
/// Vesting starting block
pub start: BlockNumber,
Expand Down
2 changes: 1 addition & 1 deletion frame/crowdloan-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub mod pallet {

use super::models::{EcdsaSignature, EthereumAddress, Proof, RemoteAccount};

#[derive(Encode, Decode, PartialEq, Copy, Clone, TypeInfo)]
#[derive(Encode, Decode, PartialEq, Copy, Clone, MaxEncodedLen, TypeInfo)]
pub struct Reward<Balance, BlockNumber> {
pub(crate) total: Balance,
pub(crate) claimed: Balance,
Expand Down
8 changes: 5 additions & 3 deletions frame/crowdloan-rewards/src/models.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{MultiSignature, RuntimeDebug};

Expand All @@ -8,14 +8,16 @@ pub enum Proof<AccountId> {
Ethereum(EcdsaSignature),
}

#[derive(Hash, Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, TypeInfo)]
#[derive(Hash, Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum RemoteAccount<AccountId> {
RelayChain(AccountId),
Ethereum(EthereumAddress),
}

#[derive(Hash, Clone, Copy, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo)]
#[derive(
Hash, Clone, Copy, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, MaxEncodedLen, TypeInfo,
)]
pub struct EthereumAddress(pub [u8; 20]);

#[cfg(feature = "std")]
Expand Down
2 changes: 1 addition & 1 deletion frame/lending/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub mod pallet {
<T as Config>::LiquidationStrategyId,
>;

#[derive(Default, Debug, Copy, Clone, Encode, Decode, PartialEq, TypeInfo)]
#[derive(Default, Debug, Copy, Clone, Encode, Decode, PartialEq, MaxEncodedLen, TypeInfo)]
#[repr(transparent)]
pub struct MarketIndex(u32);

Expand Down
2 changes: 1 addition & 1 deletion frame/liquidations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub mod pallet {
}
}

#[derive(Clone, Debug, Encode, Decode, TypeInfo, PartialEq)]
#[derive(Clone, Debug, PartialEq, Encode, Decode, TypeInfo)]
pub enum LiquidationStrategyConfiguration<ParachainId> {
DutchAuction(TimeReleaseFunction),
UniswapV2 { slippage: Perquintill },
Expand Down
4 changes: 2 additions & 2 deletions frame/mosaic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ pub mod pallet {
Outgoing,
}

#[derive(Clone, Debug, Encode, Decode, TypeInfo, PartialEq)]
#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq)]
pub struct AssetInfo<BlockNumber, Balance, Decayer> {
pub last_mint_block: BlockNumber,
pub budget: Balance,
pub penalty: Balance,
pub penalty_decayer: Decayer,
}

#[derive(Clone, Debug, Encode, Decode, TypeInfo, PartialEq)]
#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq)]
pub struct NetworkInfo<Balance> {
pub enabled: bool,
pub max_transfer_size: Balance,
Expand Down
6 changes: 3 additions & 3 deletions frame/mosaic/src/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use frame_support::pallet_prelude::*;

/// A wrapper around the `Relayer` configuration which forces the user to respect the TTL and update
/// the relayer `AccountId` if mandated.
#[derive(Decode, Encode, TypeInfo)]
#[derive(Decode, Encode, MaxEncodedLen, TypeInfo)]
pub struct StaleRelayer<AccountId, BlockNumber> {
relayer: RelayerConfig<AccountId, BlockNumber>,
}
Expand All @@ -22,7 +22,7 @@ impl<AccountId, BlockNumber: PartialOrd> StaleRelayer<AccountId, BlockNumber> {
}

/// Configuration for the relayer account.
#[derive(PartialEq, Eq, Debug, Decode, Encode, TypeInfo)]
#[derive(PartialEq, Eq, Debug, Decode, Encode, MaxEncodedLen, TypeInfo)]
pub struct RelayerConfig<AccountId, BlockNumber> {
/// Current AccountId used by the relayer.
current: AccountId,
Expand All @@ -45,7 +45,7 @@ impl<AccountId, BlockNumber> From<RelayerConfig<AccountId, BlockNumber>>
}

/// Next relayer configuration to be used.
#[derive(PartialEq, Eq, Debug, Decode, Encode, TypeInfo)]
#[derive(PartialEq, Eq, Debug, Decode, Encode, MaxEncodedLen, TypeInfo)]
pub struct Next<AccountId, BlockNumber> {
ttl: BlockNumber,
account: AccountId,
Expand Down
2 changes: 1 addition & 1 deletion frame/vault/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use scale_info::TypeInfo;
bitflags! {
/// Capabilities (or more accurately, `incapabilities`) restrict functionality of specific vault
/// instances.
#[derive(Encode, Decode, TypeInfo)]
#[derive(Encode, Decode, MaxEncodedLen, TypeInfo)]
pub struct Capabilities: u32 {
/// Tomb-stoning a vault is schedules it for deletion.
const TOMBSTONED = 0b000000001;
Expand Down
2 changes: 1 addition & 1 deletion frame/vault/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use frame_support::pallet_prelude::*;
use scale_info::TypeInfo;
use sp_runtime::Perquintill;

#[derive(Copy, Clone, Encode, Decode, Default, Debug, PartialEq, TypeInfo)]
#[derive(Copy, Clone, Encode, Decode, Default, Debug, PartialEq, MaxEncodedLen, TypeInfo)]
pub struct VaultInfo<AccountId, Balance, CurrencyId, BlockNumber> {
pub asset_id: CurrencyId,
pub lp_token_id: CurrencyId,
Expand Down