Skip to content
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
Prev Previous commit
Next Next commit
fix runtime
  • Loading branch information
Michal Swietek committed Nov 22, 2022
commit b21e7112fddf8c4f763906175cb22821d2ee02d6
19 changes: 7 additions & 12 deletions bin/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ pub use frame_support::{
};
use frame_support::{
sp_runtime::Perquintill,
traits::{ConstU32, EqualPrivilegeOnly, SortedMembers, U128CurrencyToVote},
traits::{ConstU32, EqualPrivilegeOnly, SortedMembers, U128CurrencyToVote, WithdrawReasons},
weights::constants::WEIGHT_PER_MILLIS,
PalletId,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
pub use pallet_balances::Call as BalancesCall;
use pallet_contracts::weights::WeightInfo;
use pallet_contracts_primitives::{
CodeUploadResult, ContractExecResult, ContractInstantiateResult, GetStorageResult,
};
pub use pallet_timestamp::Call as TimestampCall;
use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};
pub use primitives::Balance;
Expand All @@ -48,7 +45,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, One,
OpaqueKeys, Verify,
OpaqueKeys, Verify, Bounded
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, MultiSignature, RuntimeAppPublic,
Expand Down Expand Up @@ -274,6 +271,7 @@ parameter_types! {
pub FeeVariability: Multiplier = Multiplier::saturating_from_rational(67, 1000);
// Fee should never be lower than the computational cost.
pub MinimumMultiplier: Multiplier = Multiplier::one();
pub MaximumMultiplier: Multiplier = Bounded::max_value();
}

impl pallet_transaction_payment::Config for Runtime {
Expand All @@ -282,7 +280,7 @@ impl pallet_transaction_payment::Config for Runtime {
type LengthToFee = IdentityFee<Balance>;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate =
TargetedFeeAdjustment<Self, TargetSaturationLevel, FeeVariability, MinimumMultiplier>;
TargetedFeeAdjustment<Self, TargetSaturationLevel, FeeVariability, MinimumMultiplier,MaximumMultiplier>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
}

Expand All @@ -301,8 +299,7 @@ impl pallet_scheduler::Config for Runtime {
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type PreimageProvider = ();
type NoPreimagePostponement = ();
type Preimages = ();
}

impl pallet_sudo::Config for Runtime {
Expand Down Expand Up @@ -549,6 +546,7 @@ where

parameter_types! {
pub const MinVestedTransfer: Balance = MICRO_AZERO;
pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
}

impl pallet_vesting::Config for Runtime {
Expand All @@ -557,6 +555,7 @@ impl pallet_vesting::Config for Runtime {
type BlockNumberToBalance = ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = pallet_vesting::weights::SubstrateWeight<Runtime>;
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
// Maximum number of vesting schedules an account may have at a given moment
// follows polkadot https://github.com/paritytech/polkadot/blob/9ce5f7ef5abb1a4291454e8c9911b304d80679f9/runtime/polkadot/src/lib.rs#L980
const MAX_VESTING_SCHEDULES: u32 = 28;
Expand Down Expand Up @@ -637,9 +636,6 @@ impl pallet_utility::Config for Runtime {
type PalletsOrigin = OriginCaller;
}

// Prints debug output of the `contracts` pallet to stdout if the node is started with `-lruntime::contracts=debug`.
const CONTRACTS_DEBUG_OUTPUT: bool = true;

parameter_types! {
// Refundable deposit per storage item
pub const DepositPerItem: Balance = 32 * DEPOSIT_PER_BYTE;
Expand Down Expand Up @@ -675,7 +671,6 @@ impl pallet_contracts::Config for Runtime {
type Schedule = Schedule;
type CallStack = [pallet_contracts::Frame<Self>; 31];
type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
type ContractAccessWeight = pallet_contracts::DefaultContractAccessWeight<BlockWeights>;
type MaxCodeLen = ConstU32<{ 128 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>;
}
Expand Down
1 change: 1 addition & 0 deletions pallets/aleph/src/migrations/v1_to_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use frame_support::{
#[cfg(feature = "try-runtime")]
use pallets_support::ensure_storage_version;
use pallets_support::StorageMigration;
#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;

use crate::Config;
Expand Down
22 changes: 11 additions & 11 deletions pallets/aleph/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use frame_support::{
construct_runtime, parameter_types, sp_io,
traits::{OnFinalize, OnInitialize},
weights::RuntimeDbWeight,
weights::{RuntimeDbWeight, Weight},
};
use primitives::AuthorityId;
use sp_api_hidden_includes_construct_runtime::hidden_include::traits::GenesisBuild;
Expand Down Expand Up @@ -44,7 +44,7 @@ impl_opaque_keys! {
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1024));
pub const TestDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 25,
write: 100
Expand All @@ -55,16 +55,16 @@ impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type Origin = Origin;
type Call = Call;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = TestDbWeight;
type Version = ();
Expand Down Expand Up @@ -92,15 +92,15 @@ impl pallet_balances::Config for Test {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
}

impl pallet_session::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ValidatorId = u64;
type ValidatorIdOf = ConvertInto;
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
Expand All @@ -113,10 +113,10 @@ impl pallet_session::Config for Test {

impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
where
Call: From<C>,
RuntimeCall: From<C>,
{
type Extrinsic = TestXt<Call, ()>;
type OverarchingCall = Call;
type Extrinsic = TestXt<RuntimeCall, ()>;
type OverarchingCall = RuntimeCall;
}

parameter_types! {
Expand All @@ -132,7 +132,7 @@ impl pallet_timestamp::Config for Test {

impl Config for Test {
type AuthorityId = AuthorityId;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SessionInfoProvider = Session;
type SessionManager = ();
}
Expand Down
14 changes: 8 additions & 6 deletions pallets/elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct ValidatorTotalRewards<T>(pub BTreeMap<T, TotalReward>);
#[frame_support::pallet]
pub mod pallet {
use frame_election_provider_support::{
ElectionDataProvider, ElectionProvider, Support, Supports,
ElectionDataProvider, ElectionProvider, ElectionProviderBase, Support, Supports,
};
use frame_support::{log, pallet_prelude::*, traits::Get};
use frame_system::{
Expand Down Expand Up @@ -462,12 +462,18 @@ pub mod pallet {
BanReasonTooBig,
}

impl<T: Config> ElectionProvider for Pallet<T> {
impl<T: Config> ElectionProviderBase for Pallet<T> {
type AccountId = T::AccountId;
type BlockNumber = T::BlockNumber;
type Error = ElectionError;
type DataProvider = T::DataProvider;

fn ongoing() -> bool {
false
}
}

impl<T: Config> ElectionProvider for Pallet<T> {
/// We calculate the supports for each validator. The external validators are chosen as:
/// 1) "`NextEraNonReservedValidators` that are staking and are not banned" in case of Permissioned ElectionOpenness
/// 2) "All staking and not banned validators" in case of Permissionless ElectionOpenness
Expand Down Expand Up @@ -541,9 +547,5 @@ pub mod pallet {

Ok(supports.into_iter().collect())
}

fn ongoing() -> bool {
false
}
}
}
1 change: 1 addition & 0 deletions pallets/elections/src/migrations/v1_to_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use frame_support::{
#[cfg(feature = "try-runtime")]
use pallets_support::ensure_storage_version;
use pallets_support::StorageMigration;
#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;

use crate::{migrations::Validators, Config, EraValidators};
Expand Down
1 change: 1 addition & 0 deletions pallets/elections/src/migrations/v2_to_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use frame_support::{
use pallets_support::ensure_storage_version;
use pallets_support::StorageMigration;
use primitives::CommitteeSeats;
#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;

use crate::{migrations::Validators, Config, EraValidators};
Expand Down
20 changes: 10 additions & 10 deletions pallets/elections/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use frame_election_provider_support::{data_provider, ElectionDataProvider, VoteW
use frame_support::{
construct_runtime, parameter_types, sp_io,
traits::{ConstU32, GenesisBuild},
weights::RuntimeDbWeight,
weights::{RuntimeDbWeight, Weight},
BasicExternalities, BoundedVec,
};
use primitives::{BanConfig, CommitteeSeats};
Expand Down Expand Up @@ -41,7 +41,7 @@ pub(crate) type Balance = u128;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1024));
pub const TestDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 25,
write: 100
Expand All @@ -52,16 +52,16 @@ impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type Origin = Origin;
type Call = Call;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = TestDbWeight;
type Version = ();
Expand All @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
Expand All @@ -93,10 +93,10 @@ impl pallet_balances::Config for Test {

impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
where
Call: From<C>,
RuntimeCall: From<C>,
{
type Extrinsic = TestXt<Call, ()>;
type OverarchingCall = Call;
type Extrinsic = TestXt<RuntimeCall, ()>;
type OverarchingCall = RuntimeCall;
}

parameter_types! {
Expand Down Expand Up @@ -170,7 +170,7 @@ impl EraInfoProvider for MockProvider {

impl Config for Test {
type EraInfoProvider = MockProvider;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DataProvider = StakingMock;
type SessionPeriod = SessionPeriod;
type SessionManager = ();
Expand Down
2 changes: 1 addition & 1 deletion pallets/support/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use frame_support::{
codec::{Decode, Encode},
sp_io,
storage::storage_prefix,
sp_std::vec::Vec
};
use frame_support::{
pallet_prelude::{PalletInfoAccess, StorageVersion, Weight},
traits::OnRuntimeUpgrade,
sp_std::vec::Vec
};

/// In order to run both pre- and post- checks around every migration, we entangle methods of
Expand Down