Skip to content

Commit

Permalink
chore(v1.0.0): Clean up and constants fix (#3265)
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx authored Sep 15, 2023
1 parent 44d16ff commit b9641da
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 322 deletions.
6 changes: 3 additions & 3 deletions node/service/src/chain_spec/vara.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{crypto::UncheckedInto, sr25519};
use sp_runtime::{Perbill, Perquintill};
use vara_runtime::{
constants::currency::{DOLLARS, EXISTENTIAL_DEPOSIT, UNITS as TOKEN},
constants::currency::{ECONOMIC_UNITS, EXISTENTIAL_DEPOSIT, UNITS as TOKEN},
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
ImOnlineConfig, NominationPoolsConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig,
StakingRewardsConfig, SudoConfig, SystemConfig, VestingConfig, WASM_BINARY,
Expand Down Expand Up @@ -617,8 +617,8 @@ fn testnet_genesis(
transaction_payment: Default::default(),
treasury: Default::default(),
nomination_pools: NominationPoolsConfig {
min_create_bond: 10 * DOLLARS,
min_join_bond: DOLLARS,
min_create_bond: 10 * ECONOMIC_UNITS,
min_join_bond: ECONOMIC_UNITS,
..Default::default()
},
vesting: VestingConfig { vesting: vec![] },
Expand Down
44 changes: 27 additions & 17 deletions node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ pub fn genesis_config(code: Option<&[u8]>) -> GenesisConfig {
#[cfg(feature = "vara-native")]
pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> GenesisConfig {
let mut endowed = vec![
(alice(), 111 * DOLLARS),
(bob(), 100 * DOLLARS),
(charlie(), 100_000_000 * DOLLARS),
(dave(), 111 * DOLLARS),
(eve(), 101 * DOLLARS),
(ferdie(), 100 * DOLLARS),
(alice(), 111 * ECONOMIC_UNITS),
(bob(), 100 * ECONOMIC_UNITS),
(charlie(), 100_000_000 * ECONOMIC_UNITS),
(dave(), 111 * ECONOMIC_UNITS),
(eve(), 101 * ECONOMIC_UNITS),
(ferdie(), 100 * ECONOMIC_UNITS),
];

endowed.extend(
extra_endowed
.into_iter()
.map(|endowed| (endowed, 100 * DOLLARS)),
.map(|endowed| (endowed, 100 * ECONOMIC_UNITS)),
);

GenesisConfig {
Expand Down Expand Up @@ -98,9 +98,19 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Gen
},
staking: StakingConfig {
stakers: vec![
(dave(), alice(), 111 * DOLLARS, StakerStatus::Validator),
(eve(), bob(), 100 * DOLLARS, StakerStatus::Validator),
(ferdie(), charlie(), 100 * DOLLARS, StakerStatus::Validator),
(
dave(),
alice(),
111 * ECONOMIC_UNITS,
StakerStatus::Validator,
),
(eve(), bob(), 100 * ECONOMIC_UNITS, StakerStatus::Validator),
(
ferdie(),
charlie(),
100 * ECONOMIC_UNITS,
StakerStatus::Validator,
),
],
validator_count: 3,
minimum_validator_count: 3,
Expand Down Expand Up @@ -128,18 +138,18 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Gen
#[cfg(all(not(feature = "vara-native"), feature = "gear-native"))]
pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> GenesisConfig {
let mut endowed = vec![
(alice(), 111 * DOLLARS),
(bob(), 100 * DOLLARS),
(charlie(), 100_000_000 * DOLLARS),
(dave(), 111 * DOLLARS),
(eve(), 101 * DOLLARS),
(ferdie(), 100 * DOLLARS),
(alice(), 111 * ECONOMIC_UNITS),
(bob(), 100 * ECONOMIC_UNITS),
(charlie(), 100_000_000 * ECONOMIC_UNITS),
(dave(), 111 * ECONOMIC_UNITS),
(eve(), 101 * ECONOMIC_UNITS),
(ferdie(), 100 * ECONOMIC_UNITS),
];

endowed.extend(
extra_endowed
.into_iter()
.map(|endowed| (endowed, 100 * DOLLARS)),
.map(|endowed| (endowed, 100 * ECONOMIC_UNITS)),
);

GenesisConfig {
Expand Down
2 changes: 0 additions & 2 deletions pallets/gas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ mod mock;
#[cfg(test)]
mod tests;

pub mod migrations;

type BlockGasLimitOf<T> = <T as Config>::BlockGasLimit;
type AccountIdOf<T> = <T as frame_system::Config>::AccountId;

Expand Down
243 changes: 0 additions & 243 deletions pallets/gas/src/migrations.rs

This file was deleted.

7 changes: 2 additions & 5 deletions pallets/staking-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,11 @@ pub(crate) const NOM_1_CONTROLLER: AccountId = 41;
pub(crate) const ROOT: AccountId = 101;

pub(crate) const INITIAL_TOTAL_TOKEN_SUPPLY: u128 = 1_000_000 * UNITS;
pub(crate) const EXISTENTIAL_DEPOSIT: u128 = 10 * MILLICENTS; // 10
pub(crate) const EXISTENTIAL_DEPOSIT: u128 = 10 * UNITS / 100_000; // 10
pub(crate) const VALIDATOR_STAKE: u128 = 100 * UNITS; // 10
pub(crate) const ENDOWMENT: u128 = 100 * UNITS;

pub(crate) const UNITS: u128 = 100_000; // 10^(-5) precision
pub(crate) const DOLLARS: u128 = UNITS; // 1 to 1
pub(crate) const CENTS: u128 = DOLLARS / 100; // 1_000
pub(crate) const MILLICENTS: u128 = CENTS / 1_000; // 1
pub(crate) const MILLISECONDS_PER_YEAR: u64 = 1_000 * 3_600 * 24 * 36_525 / 100;
pub(crate) const MILLISECS_PER_BLOCK: u64 = 2_400;
pub(crate) const SESSION_DURATION: u64 = 1000;
Expand Down Expand Up @@ -394,7 +391,7 @@ impl pallet_bags_list::Config<pallet_bags_list::Instance1> for Test {

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: u128 = DOLLARS;
pub const ProposalBondMinimum: u128 = UNITS;
pub const SpendPeriod: u32 = 100;
pub const Burn: Permill = Permill::from_percent(50);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
Expand Down
2 changes: 2 additions & 0 deletions runtime/gear/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
pub mod currency {
use runtime_primitives::Balance;

pub const UNITS: Balance = 1_000_000_000_000; // 10^(-12) precision

/// The existential deposit.
pub const EXISTENTIAL_DEPOSIT: Balance = 500;

Expand Down
2 changes: 1 addition & 1 deletion runtime/gear/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
#[allow(unused)]
use crate::*;

pub type Migrations = (pallet_gear_gas::migrations::MigrateToV3<Runtime>,);
pub type Migrations = ();
Loading

0 comments on commit b9641da

Please sign in to comment.