Skip to content

Commit

Permalink
Merge branch 'main' into toufeeq/tokenomics
Browse files Browse the repository at this point in the history
  • Loading branch information
ToufeeqP committed Oct 23, 2023
2 parents df0dbbc + d795fb9 commit 1a9833f
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 68 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ pub fn new_full_base(
};

let grandpa_config = sc_consensus_grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: std::time::Duration::from_millis(333),
justification_period: 512,
name: Some(name),
Expand Down
4 changes: 2 additions & 2 deletions pallets/system/src/header_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ pub fn build_extension<M: Metrics>(
metrics: &M,
) -> HeaderExtension {
use avail_core::header::extension::{v1, v2};
// TODO Marko Move to OnceLock https://doc.rust-lang.org/stable/std/sync/struct.OnceLock.html on sub-upgrade v1 branch
use once_cell::sync::Lazy;
static PMP: Lazy<kate::pmp::m1_blst::M1NoPrecomp> =
once_cell::sync::Lazy::new(|| kate::testnet::multiproof_params(256, 256));

const MIN_WIDTH: usize = 4;
let timer = std::time::Instant::now();
let grid = kate::gridgen::EvaluationGrid::from_extrinsics(
app_extrinsics.to_vec(),
4, //TODO: where should this minimum grid width be specified
MIN_WIDTH,
block_length.cols.0.saturated_into(), // even if we run on a u16 target this is fine
block_length.rows.0.saturated_into(),
seed,
Expand Down
4 changes: 0 additions & 4 deletions pallets/system/src/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@ where
/// type Public = MultiSigner: From<sr25519::Public>;
/// type Signature = MulitSignature: From<sr25519::Signature>;
/// ```
// TODO [#5662] Potentially use `IsWrappedBy` types, or find some other way to make it easy to
// obtain unwrapped crypto (and wrap it back).
pub trait AppCrypto<Public, Signature> {
/// A application-specific crypto.
type RuntimeAppPublic: RuntimeAppPublic;
Expand Down Expand Up @@ -449,8 +447,6 @@ pub trait AppCrypto<Public, Signature> {
///
/// This trait adds extra bounds to `Public` and `Signature` types of the runtime
/// that are necessary to use these types for signing.
// TODO [#5663] Could this be just `T::Signature as traits::Verify>::Signer`?
// Seems that this may cause issues with bounds resolution.
pub trait SigningTypes: crate::Config {
/// A public key that is capable of identifying `AccountId`s.
///
Expand Down
75 changes: 44 additions & 31 deletions runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ use static_assertions::const_assert;

use crate::BlockNumber;

/// cannot have validators higher than this count.
pub type MaxAuthorities = ConstU32<100_000>;
/// cannot have active validators higher than this count.
pub type MaxActiveValidators = ConstU32<1200>;

parameter_types! {
/// We take the top 12500 nominators as electing voters..
pub const MaxElectingVoters: u32 = 22_500;
/// ... and all of the validators as electable targets. Whilst this is the case, we cannot and
/// shall not increase the size of the validator intentions.
pub const MaxElectableTargets: u16 = u16::MAX;
}

/// Money matters.
pub mod currency {
use super::Balance;
Expand Down Expand Up @@ -109,7 +122,6 @@ pub mod system {

pub type MaxConsumers = ConstU32<16>;
pub type SS58Prefix = ConstU16<42>;
pub type MaxAuthorities = ConstU32<128>;

/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
/// This is used to limit the maximal weight of a single extrinsic.
Expand Down Expand Up @@ -162,9 +174,6 @@ pub mod balances {
parameter_types! {
pub const ExistentialDeposit :Balance = 10 * CENTS; // 0.1 AVLs
}

pub type MaxLocks = ConstU32<32>;
pub type MaxReserves = ConstU32<32>;
}

pub mod council {
Expand Down Expand Up @@ -224,22 +233,22 @@ pub mod staking {
VoterIndex = u32,
TargetIndex = u16,
Accuracy = sp_runtime::PerU16,
MaxVoters = staking::MaxElectingVoters,
MaxVoters = MaxElectingVoters,
>(16)
);

#[cfg(feature = "fast-runtime")]
parameter_types! {
pub const SessionsPerEra: sp_staking::SessionIndex = 1;
pub const BondingDuration: sp_staking::EraIndex = 2; // 2 eras
pub const SlashDeferDuration: sp_staking::EraIndex = 1; // 1/2 the bonding duration.
pub const SlashDeferDuration: sp_staking::EraIndex = BondingDuration::get() - 1;
}

#[cfg(not(feature = "fast-runtime"))]
parameter_types! {
pub const SessionsPerEra: sp_staking::SessionIndex = 6;
pub const BondingDuration: sp_staking::EraIndex = 112; // 28 days
pub const SlashDeferDuration: sp_staking::EraIndex = BondingDuration::get() / 4; // 1/4 the bonding duration.
pub const BondingDuration: sp_staking::EraIndex = 28; // 28 days
pub const SlashDeferDuration: sp_staking::EraIndex = BondingDuration::get() - 1; // 27 Days
}

parameter_types! {
Expand Down Expand Up @@ -273,7 +282,6 @@ pub mod staking {
pub const OffchainRepeat: BlockNumber = 5;
}

pub type MaxElectingVoters = ConstU32<512>;
pub type MaxNominatorRewardedPerValidator = ConstU32<256>;
pub type MaxUnlockingChunks = ConstU32<32>;
pub type HistoryDepth = ConstU32<84>;
Expand All @@ -285,10 +293,10 @@ pub mod staking {
pub type MaxOnChainElectableTargets = ConstU16<512>;
// The maximum winners that can be elected by the Election pallet which is equivalent to the
// maximum active validators the staking pallet can have.
pub type MaxActiveValidators = system::MaxAuthorities;
pub type MaxActiveValidators = MaxAuthorities;

// signed config
pub type SignedMaxSubmissions = ConstU32<32>;
pub type SignedMaxSubmissions = ConstU32<16>;
pub type SignedMaxRefunds = ConstU32<4>;
}

Expand All @@ -309,22 +317,6 @@ pub mod babe {
}
}

pub mod technical {
use super::{time::*, *};

#[cfg(feature = "fast-runtime")]
parameter_types! {
pub const TechnicalMotionDuration: BlockNumber = 2 * MINUTES;
}
#[cfg(not(feature = "fast-runtime"))]
parameter_types! {
pub const TechnicalMotionDuration: BlockNumber = 2 * DAYS;
}

pub type TechnicalMaxProposals = ConstU32<32>;
pub type TechnicalMaxMembers = ConstU32<16>;
}

pub mod im {

use super::*;
Expand All @@ -334,8 +326,6 @@ pub mod im {

}

pub type MaxKeys = ConstU32<256>;
pub type MaxPeerInHeartbeats = ConstU32<1_024>;
pub type MaxPeerDataEncodingSize = ConstU32<1_024>;
}

Expand All @@ -354,8 +344,8 @@ pub mod bounty {

#[cfg(not(feature = "fast-runtime"))]
parameter_types! {
pub const DepositPayoutDelay: BlockNumber = DAYS;
pub const UpdatePeriod: BlockNumber = 14 * DAYS;
pub const DepositPayoutDelay: BlockNumber = 8 * DAYS;
pub const UpdatePeriod: BlockNumber = 90 * DAYS;
}

#[cfg(feature = "fast-runtime")]
Expand Down Expand Up @@ -398,3 +388,26 @@ pub mod nomad {
}
pub type MaxMessageBodyBytes = ConstU32<2048>;
}

/// Macro to set a value (e.g. when using the `parameter_types` macro) to either a production value
/// or to an environment variable or testing value (in case the `fast-runtime` feature is selected).
/// Note that the environment variable is evaluated _at compile time_.
///
/// Usage:
/// ```Rust
/// parameter_types! {
/// // Note that the env variable version parameter cannot be const.
/// pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "KSM_LAUNCH_PERIOD");
/// pub const VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES);
/// }
/// ```
#[macro_export]
macro_rules! prod_or_fast {
($prod:expr, $test:expr) => {
if cfg!(feature = "fast-runtime") {
$test
} else {
$prod
}
};
}
59 changes: 32 additions & 27 deletions runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use crate::voter_bags;
use crate::SessionKeys;
use crate::SLOT_DURATION;
use crate::{
constants, deposit, weights, AccountId, AccountIndex, Babe, Balances, Block, BlockNumber,
Bounties, ElectionProviderMultiPhase, GrandpaId, Hash, Historical, ImOnline, ImOnlineId, Index,
Indices, Moment, NominationPools, Offences, OriginCaller, PalletInfo, Preimage,
ReserveIdentifier, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason, RuntimeOrigin,
RuntimeVersion, Session, Signature, SignedPayload, Staking, System, TechnicalCommittee,
Timestamp, TransactionPayment, Treasury, UncheckedExtrinsic, VoterList, VERSION,
constants, prod_or_fast, weights, AccountId, AccountIndex, Babe, Balances, Block,
BlockNumber, Bounties, ElectionProviderMultiPhase, GrandpaId, Hash, Historical, ImOnline,
ImOnlineId, Index, Indices, Moment, NominationPools, Offences, OriginCaller, PalletInfo,
Preimage, ReserveIdentifier, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason,
RuntimeOrigin, RuntimeVersion, Session, Signature, SignedPayload, Staking, System,
TechnicalCommittee, Timestamp, TransactionPayment, Treasury, UncheckedExtrinsic, VoterList,
MINUTES, VERSION,
};
use avail_core::currency::{Balance, AVL, CENTS};
use avail_core::AppId;
Expand All @@ -20,10 +21,10 @@ use frame_election_provider_support::BalancingConfig;
use frame_election_provider_support::ElectionDataProvider;
use frame_election_provider_support::SequentialPhragmen;
use frame_election_provider_support::VoteWeight;
use frame_support::pallet_prelude::ConstU32;
use frame_support::pallet_prelude::Get;
use frame_support::pallet_prelude::Weight;
use frame_support::traits::tokens::Imbalance;
use frame_support::traits::ConstU32;
use frame_support::traits::ContainsLengthBound;
use frame_support::traits::EqualPrivilegeOnly;
use frame_support::traits::Everything;
Expand Down Expand Up @@ -142,7 +143,7 @@ impl pallet_offences::Config for Runtime {
}

impl pallet_authority_discovery::Config for Runtime {
type MaxAuthorities = constants::system::MaxAuthorities;
type MaxAuthorities = constants::MaxAuthorities;
}

parameter_types! {
Expand Down Expand Up @@ -311,10 +312,9 @@ impl pallet_utility::Config for Runtime {
}

parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = deposit(1, 88);
pub const DepositBase: Balance = 2 * AVL;
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);
pub const DepositFactor: Balance = 5 * CENTS;
}

impl pallet_multisig::Config for Runtime {
Expand Down Expand Up @@ -368,7 +368,7 @@ impl pallet_babe::Config for Runtime {
type ExpectedBlockTime = constants::time::ExpectedBlockTime;
type KeyOwnerProof =
<Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
type MaxAuthorities = constants::system::MaxAuthorities;
type MaxAuthorities = constants::MaxAuthorities;
type WeightInfo = ();
}

Expand All @@ -388,9 +388,9 @@ impl pallet_balances::Config for Runtime {
type ExistentialDeposit = constants::balances::ExistentialDeposit;
type FreezeIdentifier = ();
type MaxFreezes = ();
type MaxHolds = constants::balances::MaxReserves;
type MaxLocks = constants::balances::MaxLocks;
type MaxReserves = constants::balances::MaxReserves;
type MaxHolds = ConstU32<2>;
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = ReserveIdentifier;
type RuntimeEvent = RuntimeEvent;
type RuntimeHoldReason = RuntimeHoldReason;
Expand All @@ -399,8 +399,8 @@ impl pallet_balances::Config for Runtime {

impl pallet_im_online::Config for Runtime {
type AuthorityId = ImOnlineId;
type MaxKeys = constants::im::MaxKeys;
type MaxPeerInHeartbeats = constants::im::MaxPeerInHeartbeats;
type MaxKeys = ConstU32<10_000>;
type MaxPeerInHeartbeats = ConstU32<10_000>;
type NextSessionRotation = Babe;
type ReportUnresponsiveness = Offences;
type RuntimeEvent = RuntimeEvent;
Expand All @@ -421,19 +421,24 @@ impl pallet_grandpa::Config for Runtime {
constants::babe::ReportLongevity,
>;
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
type MaxAuthorities = constants::system::MaxAuthorities;
type MaxAuthorities = constants::MaxAuthorities;
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
}

parameter_types! {
pub const TechnicalMotionDuration: BlockNumber = prod_or_fast!(5 * DAYS, 5 * MINUTES);
}
pub type TechnicalMaxMembers = ConstU32<100>;

pub type TechnicalCollective = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCollective> for Runtime {
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type MaxMembers = constants::technical::TechnicalMaxMembers;
type MaxMembers = TechnicalMaxMembers;
type MaxProposalWeight = constants::council::MaxProposalWeight;
type MaxProposals = constants::technical::TechnicalMaxProposals;
type MotionDuration = constants::technical::TechnicalMotionDuration;
type MaxProposals = ConstU32<100>;
type MotionDuration = TechnicalMotionDuration;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -443,7 +448,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {

impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
type AddOrigin = EnsureRoot<AccountId>;
type MaxMembers = constants::technical::TechnicalMaxMembers;
type MaxMembers = TechnicalMaxMembers;
type MembershipChanged = TechnicalCommittee;
type MembershipInitialized = TechnicalCommittee;
type PrimeOrigin = EnsureRoot<AccountId>;
Expand Down Expand Up @@ -485,9 +490,9 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type Fallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
type ForceOrigin = EnsureRoot<AccountId>;
type GovernanceFallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
type MaxElectableTargets = constants::staking::MaxOnChainElectableTargets;
type MaxElectingVoters = constants::staking::MaxElectingVoters;
type MaxWinners = constants::staking::MaxActiveValidators;
type MaxElectableTargets = constants::MaxElectableTargets;
type MaxElectingVoters = constants::MaxElectingVoters;
type MaxWinners = constants::MaxActiveValidators;
type MinerConfig = Self;
type MinerTxPriority = constants::staking::MultiPhaseUnsignedPriority;
type OffchainRepeat = constants::staking::OffchainRepeat;
Expand Down Expand Up @@ -599,8 +604,8 @@ impl onchain::Config for OnChainSeqPhragmen {
pallet_election_provider_multi_phase::SolutionAccuracyOf<Runtime>,
>;
type System = Runtime;
type TargetsBound = constants::staking::MaxValidators;
type VotersBound = constants::staking::MaxOnChainElectingVoters;
type TargetsBound = constants::MaxElectableTargets;
type VotersBound = constants::MaxElectingVoters;
type WeightInfo = frame_election_provider_support::weights::SubstrateWeight<Runtime>;
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod weights;

pub use avail_core::currency::{Balance, AVL, CENTS, MILLICENTS};
pub use avail_core::{header::Header as DaHeader, AppId};
use constants::{currency::*, time::*};
use constants::time::*;
pub use frame_support::{
construct_runtime, debug,
dispatch::DispatchClass,
Expand Down

0 comments on commit 1a9833f

Please sign in to comment.