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

Initial review of Moonbeam (Phase 0) #924

Merged
merged 29 commits into from
Oct 29, 2021
Merged
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3d53eb2
Initial review of Moonbeam
Oct 21, 2021
df14246
Take decision on RewardAddressChange support
Oct 25, 2021
b7e5452
Add unit test to cover currency constants in Moonbeam runtime
notlesh Oct 26, 2021
0ae2b25
Add more currency-related tests to Moonbeam
notlesh Oct 26, 2021
83ad20a
Implement currency constants test for other runtimes
notlesh Oct 26, 2021
5efa962
cargo fmt
notlesh Oct 26, 2021
7291c0b
[Moonbeam] Set minimal Staking to 10_000 for phase 0 and 1
librelois Oct 28, 2021
436d9db
[Moonbeam] Setup proxy deposit base and factor to 0
librelois Oct 28, 2021
1b0c6a8
Update runtime/moonbeam/src/lib.rs
4meta5 Oct 28, 2021
e2938bd
update test currency_constants
librelois Oct 28, 2021
ab30e8e
fmt
librelois Oct 28, 2021
53b7f31
update test currency_constants (2)
librelois Oct 28, 2021
37c3f7b
add missing import for test currency_constants
librelois Oct 28, 2021
9135f45
moonbeam: fast_track is available
librelois Oct 28, 2021
59355bc
moonbeam: test join_collator_candidates: all amounts should be increased
librelois Oct 28, 2021
5a19866
moonbeam integration tests: multiply all amounts by 100
librelois Oct 28, 2021
119afbd
fmt
librelois Oct 28, 2021
ec32814
Attempt at fixing reward integration tests for moonbeam
notlesh Oct 28, 2021
b2d8321
Update balances to make ethereum rpc tests on moonbeam
notlesh Oct 28, 2021
8e9a60c
Properly fix reward_block_authors_with_parachain_bond_reserved
notlesh Oct 28, 2021
a2434ad
Clean up
notlesh Oct 28, 2021
6371199
cargo fmt
notlesh Oct 28, 2021
79b564f
Revert debug output
notlesh Oct 28, 2021
dd7fb4c
Don't bump InflationInfo by 100X...
notlesh Oct 28, 2021
935c643
More clean up
notlesh Oct 28, 2021
620e6be
Updates factor variable name
Oct 28, 2021
3300967
cargo fmt
Oct 28, 2021
aaef41a
Update runtime/moonbeam/src/lib.rs
crystalin Oct 28, 2021
90db1c8
Merge branch 'master' into crystalin-moonbeam-setup
Oct 29, 2021
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
82 changes: 48 additions & 34 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use cumulus_pallet_parachain_system::RelaychainBlockNumberProvider;
use fp_rpc::TransactionStatus;
use frame_support::{
construct_runtime, parameter_types,
traits::{Contains, Get, Imbalance, InstanceFilter, OnUnbalanced},
traits::{Contains, Everything, Get, Imbalance, InstanceFilter, OnUnbalanced},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, GetDispatchInfo, IdentityFee, Weight,
Expand Down Expand Up @@ -86,6 +86,8 @@ pub type Precompiles = MoonbeamPrecompiles<Runtime>;
pub mod currency {
use super::Balance;

pub const MOONRIVER_FACTOR: Balance = 100; // 100 more total supply

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Moonbeam is the flagship product, does it make more sense to have such a factor in the Moonriver runtime?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but this would imply division (or multiplying by a fraction) :)

I agree, though, it makes more sense to define this either (1) as a portion of total/genesis supply or (2) relative to GMLR

pub const WEI: Balance = 1;
pub const KILOWEI: Balance = 1_000;
pub const MEGAWEI: Balance = 1_000_000;
Expand All @@ -95,11 +97,11 @@ pub mod currency {
pub const GLMR: Balance = 1_000_000_000_000_000_000;
pub const KILOGLMR: Balance = 1_000_000_000_000_000_000_000;

pub const TRANSACTION_BYTE_FEE: Balance = 10 * MICROGLMR;
pub const STORAGE_BYTE_FEE: Balance = 100 * MICROGLMR;
pub const TRANSACTION_BYTE_FEE: Balance = 10 * MICROGLMR * MOONRIVER_FACTOR;
pub const STORAGE_BYTE_FEE: Balance = 100 * MICROGLMR * MOONRIVER_FACTOR;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 1 * GLMR + (bytes as Balance) * STORAGE_BYTE_FEE
items as Balance * 1 * GLMR * MOONRIVER_FACTOR + (bytes as Balance) * STORAGE_BYTE_FEE
}
}

Expand Down Expand Up @@ -351,7 +353,7 @@ parameter_types! {
pub struct FixedGasPrice;
impl FeeCalculator for FixedGasPrice {
fn min_gas_price() -> U256 {
(1 * currency::GIGAWEI).into()
(1 * currency::GIGAWEI * currency::MOONRIVER_FACTOR).into()
}
}

Expand Down Expand Up @@ -405,15 +407,15 @@ impl pallet_scheduler::Config for Runtime {
parameter_types! {
/// The maximum amount of time (in blocks) for council members to vote on motions.
/// Motions may end in fewer blocks if enough votes are cast to determine the result.
pub const CouncilMotionDuration: BlockNumber = 7 * DAYS;
pub const CouncilMotionDuration: BlockNumber = 3 * DAYS;
/// The maximum number of Proposlas that can be open in the council at once.
pub const CouncilMaxProposals: u32 = 100;
/// The maximum number of council members.
pub const CouncilMaxMembers: u32 = 100;

/// The maximum amount of time (in blocks) for technical committee members to vote on motions.
/// Motions may end in fewer blocks if enough votes are cast to determine the result.
pub const TechCommitteeMotionDuration: BlockNumber = 7 * DAYS;
pub const TechCommitteeMotionDuration: BlockNumber = 3 * DAYS;
/// The maximum number of Proposlas that can be open in the technical committee at once.
pub const TechCommitteeMaxProposals: u32 = 100;
/// The maximum number of technical committee members.
Expand Down Expand Up @@ -446,20 +448,19 @@ impl pallet_collective::Config<TechCommitteeInstance> for Runtime {
}

parameter_types! {
pub const LaunchPeriod: BlockNumber = 1 * DAYS;
pub const VotingPeriod: BlockNumber = 5 * DAYS;
pub const VoteLockingPeriod: BlockNumber = 1 * DAYS;
pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS;
pub const EnactmentPeriod: BlockNumber = 1 *DAYS;
pub const LaunchPeriod: BlockNumber = 7 * DAYS;
pub const VotingPeriod: BlockNumber = 14 * DAYS;
pub const VoteLockingPeriod: BlockNumber = 7 * DAYS;
pub const FastTrackVotingPeriod: BlockNumber = 1 * DAYS;
pub const EnactmentPeriod: BlockNumber = 2 * DAYS;
pub const CooloffPeriod: BlockNumber = 7 * DAYS;
pub const MinimumDeposit: Balance = 4 * currency::GLMR;
pub const MinimumDeposit: Balance = 4 * currency::GLMR * currency::MOONRIVER_FACTOR;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = 100;
pub const PreimageByteDeposit: Balance = currency::STORAGE_BYTE_FEE;
pub const InstantAllowed: bool = false;
pub const InstantAllowed: bool = true;
}

// todo : ensure better origins
impl pallet_democracy::Config for Runtime {
type Proposal = Call;
type Event = Event;
Expand Down Expand Up @@ -518,19 +519,31 @@ impl pallet_democracy::Config for Runtime {

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 1 * currency::GLMR;
pub const ProposalBondMinimum: Balance = 1 * currency::GLMR * currency::MOONRIVER_FACTOR;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const TreasuryId: PalletId = PalletId(*b"py/trsry");
pub const MaxApprovals: u32 = 100;
}

type TreasuryApproveOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilInstance>,
>;

type TreasuryRejectOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilInstance>,
>;

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryId;
type Currency = Balances;
// Democracy dispatches Root
type ApproveOrigin = EnsureRoot<AccountId>;
// Democracy dispatches Root
type RejectOrigin = EnsureRoot<AccountId>;
// At least three-fifths majority of the council is required (or root) to approve a proposal
type ApproveOrigin = TreasuryApproveOrigin;
// More than half of the council is required (or root) to reject a proposal
type RejectOrigin = TreasuryRejectOrigin;
type Event = Event;
// If spending proposal rejected, transfer proposer bond to treasury
type OnSlash = Treasury;
Expand Down Expand Up @@ -631,15 +644,15 @@ impl parachain_info::Config for Runtime {}
parameter_types! {
/// Minimum round length is 2 minutes (10 * 12 second block times)
pub const MinBlocksPerRound: u32 = 10;
/// Default BlocksPerRound is every hour (300 * 12 second block times)
pub const DefaultBlocksPerRound: u32 = 300;
/// Collator candidate exits are delayed by 2 hours (2 * 300 * block_time)
/// Default BlocksPerRound is every 4 hours (1200 * 12 second block times)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Default BlocksPerRound is every 4 hours (1200 * 12 second block times)
/// Default BlocksPerRound is every 4 hours

pub const DefaultBlocksPerRound: u32 = 4 * HOURS;
/// Collator candidate exits are delayed by 2 rounds
pub const LeaveCandidatesDelay: u32 = 2;
/// Nominator exits are delayed by 2 hours (2 * 300 * block_time)
/// Nominator exits are delayed by 2 rounds
pub const LeaveNominatorsDelay: u32 = 2;
/// Nomination revocations are delayed by 2 hours (2 * 300 * block_time)
/// Nomination revocations are delayed by 2 rounds
pub const RevokeNominationDelay: u32 = 2;
/// Reward payments are delayed by 2 hours (2 * 300 * block_time)
/// Reward payments are delayed by 2 rounds
pub const RewardPaymentDelay: u32 = 2;
/// Minimum 8 collators selected per round, default at genesis and minimum forever after
pub const MinSelectedCandidates: u32 = 8;
Expand All @@ -652,11 +665,11 @@ parameter_types! {
/// Default percent of inflation set aside for parachain bond every round
pub const DefaultParachainBondReservePercent: Percent = Percent::from_percent(30);
/// Minimum stake required to become a collator is 1_000
4meta5 marked this conversation as resolved.
Show resolved Hide resolved
pub const MinCollatorStk: u128 = 1 * currency::KILOGLMR;
pub const MinCollatorStk: u128 = 1 * currency::KILOGLMR * currency::MOONRIVER_FACTOR;
/// Minimum stake required to be reserved to be a candidate is 1_000
4meta5 marked this conversation as resolved.
Show resolved Hide resolved
pub const MinCollatorCandidateStk: u128 = 1 * currency::KILOGLMR;
pub const MinCollatorCandidateStk: u128 = 1 * currency::KILOGLMR * currency::MOONRIVER_FACTOR;
/// Minimum stake required to be reserved to be a nominator is 5
pub const MinNominatorStk: u128 = 5 * currency::GLMR;
pub const MinNominatorStk: u128 = 5 * currency::GLMR * currency::MOONRIVER_FACTOR;
}
impl parachain_staking::Config for Runtime {
type Event = Event;
Expand Down Expand Up @@ -710,7 +723,9 @@ impl pallet_crowdloan_rewards::Config for Runtime {
type MinimumReward = MinimumReward;
type RewardCurrency = Balances;
type RelayChainAccountId = AccountId32;
type RewardAddressChangeOrigin = EnsureSigned<Self::AccountId>;

// This will get accessible to users in future phases.
crystalin marked this conversation as resolved.
Show resolved Hide resolved
type RewardAddressChangeOrigin = EnsureRoot<Self::AccountId>;
type RewardAddressRelayVoteThreshold = RelaySignaturesThreshold;
type VestingBlockNumber = cumulus_primitives_core::relay_chain::BlockNumber;
type VestingBlockProvider =
Expand All @@ -719,7 +734,7 @@ impl pallet_crowdloan_rewards::Config for Runtime {
}

parameter_types! {
pub const DepositAmount: Balance = 100 * currency::GLMR;
pub const DepositAmount: Balance = 100 * currency::GLMR * currency::MOONRIVER_FACTOR;
}
// This is a simple session key manager. It should probably either work with, or be replaced
// entirely by pallet sessions
Expand Down Expand Up @@ -848,8 +863,7 @@ impl pallet_migrations::Config for Runtime {
>;
}

/// Call filter expected to be used during Phase 3 of the Moonbeam rollout
/// At least it was used in Moonriver phase3
/// Call filter used during Phase 3 of the Moonriver rollout
crystalin marked this conversation as resolved.
Show resolved Hide resolved
pub struct PhaseThreeFilter;
impl Contains<Call> for PhaseThreeFilter {
fn contains(c: &Call) -> bool {
Expand Down Expand Up @@ -941,7 +955,7 @@ pub type SignedExtra = (
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
frame_system::CheckWeight<Runtime>, // TODO : https://github.com/paritytech/substrate/pull/9834
crystalin marked this conversation as resolved.
Show resolved Hide resolved
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
Expand Down