-
Notifications
You must be signed in to change notification settings - Fork 336
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
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
3d53eb2
Initial review of Moonbeam
df14246
Take decision on RewardAddressChange support
b7e5452
Add unit test to cover currency constants in Moonbeam runtime
notlesh 0ae2b25
Add more currency-related tests to Moonbeam
notlesh 83ad20a
Implement currency constants test for other runtimes
notlesh 5efa962
cargo fmt
notlesh 7291c0b
[Moonbeam] Set minimal Staking to 10_000 for phase 0 and 1
librelois 436d9db
[Moonbeam] Setup proxy deposit base and factor to 0
librelois 1b0c6a8
Update runtime/moonbeam/src/lib.rs
4meta5 e2938bd
update test currency_constants
librelois ab30e8e
fmt
librelois 53b7f31
update test currency_constants (2)
librelois 37c3f7b
add missing import for test currency_constants
librelois 9135f45
moonbeam: fast_track is available
librelois 59355bc
moonbeam: test join_collator_candidates: all amounts should be increased
librelois 5a19866
moonbeam integration tests: multiply all amounts by 100
librelois 119afbd
fmt
librelois ec32814
Attempt at fixing reward integration tests for moonbeam
notlesh b2d8321
Update balances to make ethereum rpc tests on moonbeam
notlesh 8e9a60c
Properly fix reward_block_authors_with_parachain_bond_reserved
notlesh a2434ad
Clean up
notlesh 6371199
cargo fmt
notlesh 79b564f
Revert debug output
notlesh dd7fb4c
Don't bump InflationInfo by 100X...
notlesh 935c643
More clean up
notlesh 620e6be
Updates factor variable name
3300967
cargo fmt
aaef41a
Update runtime/moonbeam/src/lib.rs
crystalin 90db1c8
Merge branch 'master' into crystalin-moonbeam-setup
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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, | ||||||
|
@@ -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 | ||||||
|
||||||
pub const WEI: Balance = 1; | ||||||
pub const KILOWEI: Balance = 1_000; | ||||||
pub const MEGAWEI: Balance = 1_000_000; | ||||||
|
@@ -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 | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -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() | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -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. | ||||||
|
@@ -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; | ||||||
|
@@ -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; | ||||||
|
@@ -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) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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; | ||||||
|
@@ -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; | ||||||
|
@@ -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 = | ||||||
|
@@ -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 | ||||||
|
@@ -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 { | ||||||
|
@@ -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. | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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