From 59c81d21d275b271b44881af0eef4c5e5233ab50 Mon Sep 17 00:00:00 2001 From: 1xstj <106580853+1xstj@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:28:12 +0000 Subject: [PATCH] working distributions --- Cargo.lock | 2 + node/src/chainspec/mainnet.rs | 28 +++++---- node/src/distributions/mainnet.rs | 68 ++++++++++++++++++---- node/src/mainnet_fixtures.rs | 72 +++++++++++++---------- primitives/src/lib.rs | 17 +++--- runtime/mainnet/Cargo.toml | 4 ++ runtime/mainnet/src/filters.rs | 3 + runtime/mainnet/src/lib.rs | 94 ++++++++++++++++++++++++++++++- runtime/testnet/src/lib.rs | 8 +-- 9 files changed, 222 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0b6dcbf0..1a8c81eb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13301,10 +13301,12 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-insecure-randomness-collective-flip", + "pallet-jobs", "pallet-nomination-pools", "pallet-offences", "pallet-preimage", "pallet-proxy", + "pallet-roles", "pallet-scheduler", "pallet-session", "pallet-staking", diff --git a/node/src/chainspec/mainnet.rs b/node/src/chainspec/mainnet.rs index c806d540c..6b0f6423e 100644 --- a/node/src/chainspec/mainnet.rs +++ b/node/src/chainspec/mainnet.rs @@ -36,9 +36,9 @@ use sp_runtime::{ use tangle_primitives::types::{BlockNumber, Signature}; use tangle_runtime::{ AccountId, BabeConfig, Balance, BalancesConfig, ClaimsConfig, EVMChainIdConfig, - Eth2ClientConfig, ImOnlineConfig, MaxVestingSchedules, Perbill, RuntimeGenesisConfig, - SessionConfig, StakerStatus, StakingConfig, SudoConfig, SystemConfig, TreasuryPalletId, - VestingConfig, UNIT, WASM_BINARY, + Eth2ClientConfig, ImOnlineConfig, MaxVestingSchedules, Perbill, RoleKeyId, + RuntimeGenesisConfig, SessionConfig, StakerStatus, StakingConfig, SudoConfig, SystemConfig, + TreasuryPalletId, VestingConfig, UNIT, WASM_BINARY, }; use webb_consensus_types::network_config::{Network, NetworkConfig}; @@ -64,14 +64,14 @@ where /// Generate an babe authority key. pub fn authority_keys_from_seed( - controller: &str, stash: &str, -) -> (AccountId, BabeId, GrandpaId, ImOnlineId) { +) -> (AccountId, BabeId, GrandpaId, ImOnlineId, RoleKeyId) { ( get_account_id_from_seed::(stash), - get_from_seed::(controller), - get_from_seed::(controller), + get_from_seed::(stash), + get_from_seed::(stash), get_from_seed::(stash), + get_from_seed::(stash), ) } @@ -83,8 +83,9 @@ fn generate_session_keys( babe: BabeId, grandpa: GrandpaId, im_online: ImOnlineId, + role: RoleKeyId, ) -> tangle_runtime::opaque::SessionKeys { - tangle_runtime::opaque::SessionKeys { babe, grandpa, im_online } + tangle_runtime::opaque::SessionKeys { babe, grandpa, im_online, role } } pub fn local_mainnet_config(chain_id: u64) -> Result { @@ -105,10 +106,7 @@ pub fn local_mainnet_config(chain_id: u64) -> Result { // Wasm binary wasm_binary, // Initial validators - vec![ - authority_keys_from_seed("Alice", "Alice//stash"), - authority_keys_from_seed("Bob", "Bob//stash"), - ], + vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], // Endowed accounts vec![ (get_account_id_from_seed::("Alice"), endowment), @@ -168,7 +166,7 @@ pub fn tangle_mainnet_config(chain_id: u64) -> Result { // Initial validators get_initial_authorities(), // Endowed accounts - vec![mainnet::get_treasury_balance(), mainnet::get_foundation_balance()], + vec![mainnet::get_treasury_balance(), mainnet::get_foundation_endowment()], // Sudo account get_root_key(), // EVM chain ID @@ -205,7 +203,7 @@ pub fn tangle_mainnet_config(chain_id: u64) -> Result { #[allow(clippy::too_many_arguments)] fn mainnet_genesis( wasm_binary: &[u8], - initial_authorities: Vec<(AccountId, BabeId, GrandpaId, ImOnlineId)>, + initial_authorities: Vec<(AccountId, BabeId, GrandpaId, ImOnlineId, RoleKeyId)>, endowed_accounts: Vec<(AccountId, Balance)>, root_key: AccountId, chain_id: u64, @@ -260,7 +258,7 @@ fn mainnet_genesis( ( x.0.clone(), x.0.clone(), - generate_session_keys(x.1.clone(), x.2.clone(), x.3.clone()), + generate_session_keys(x.1.clone(), x.2.clone(), x.3.clone(), x.4.clone()), ) }) .collect::>(), diff --git a/node/src/distributions/mainnet.rs b/node/src/distributions/mainnet.rs index 9bf0ae17f..64a0510eb 100644 --- a/node/src/distributions/mainnet.rs +++ b/node/src/distributions/mainnet.rs @@ -20,8 +20,7 @@ use sp_core::H160; use sp_runtime::{traits::AccountIdConversion, AccountId32}; use std::{collections::BTreeMap, str::FromStr}; use tangle_primitives::types::BlockNumber; -use tangle_runtime::UNIT; -use tangle_testnet_runtime::{AccountId, Balance, ExistentialDeposit}; +use tangle_runtime::{AccountId, Balance, ExistentialDeposit, Perbill, UNIT}; /// The contents of the file should be a map of accounts to balances. fn read_contents_to_substrate_accounts(path_str: &str) -> BTreeMap { @@ -98,12 +97,12 @@ pub struct DistributionResult { pub vesting_cliff: BlockNumber, } -fn ninety_nine_percent_endowment(endowment: u128) -> u128 { - endowment * 99 / 100 +fn ninety_five_percent_endowment(endowment: u128) -> u128 { + endowment * 95 / 100 } -fn one_percent_endowment(endowment: u128) -> u128 { - endowment - ninety_nine_percent_endowment(endowment) +fn five_percent_endowment(endowment: u128) -> u128 { + endowment - ninety_five_percent_endowment(endowment) } fn vesting_per_block(endowment: u128, blocks: u64) -> u128 { @@ -111,6 +110,26 @@ fn vesting_per_block(endowment: u128, blocks: u64) -> u128 { endowment / blocks as u128 } +fn get_team_distribution_share() -> Perbill { + Perbill::from_rational(25_u32, 100_u32) +} + +fn get_investor_distribution_share() -> Perbill { + Perbill::from_rational(20_u32, 100_u32) +} + +fn get_foundation_distribution_share() -> Perbill { + Perbill::from_rational(15_u32, 100_u32) +} + +fn get_treasury_distribution_share() -> Perbill { + Perbill::from_rational(34_u32, 100_u32) +} + +fn get_initial_liquidity_share() -> Perbill { + Perbill::from_rational(5_u32, 100_u32) +} + pub fn get_edgeware_genesis_balance_distribution() -> DistributionResult { let list = get_edgeware_genesis_list(); let endowment = ONE_PERCENT_TOTAL_SUPPLY / list.len() as u128; @@ -193,12 +212,24 @@ pub fn get_investor_balance_distribution() -> Vec<(MultiAddress, u128, u64, u64, compute_balance_distribution_with_cliff_and_vesting(investor_accounts) } -pub fn get_team_balance_distribution() -> Vec<(MultiAddress, u128, u64, u64, u128)> { +pub fn get_team_endowment() -> Vec<(MultiAddress, u128)> { + // TODO : Ensure this sums up to 5% let team_accounts: Vec<(MultiAddress, u128)> = get_team_balance_distribution_list() .into_iter() .map(|(address, balance)| (MultiAddress::Native(address), balance as u128)) .collect(); - compute_balance_distribution_with_cliff_and_vesting(team_accounts) + team_accounts +} + +pub fn get_team_balance_distribution() -> Vec<(MultiAddress, u128, u64, u64, u128)> { + // the team vesting is completely sent to a single account and vested and claimed by that + // account TODO : Finalise this account + let pallet_id = tangle_primitives::treasury::TREASURY_PALLET_ID; + let address: AccountId = pallet_id.into_account_truncating(); + let balance = + (get_team_distribution_share() - get_initial_liquidity_share()).mul_floor(TOTAL_SUPPLY); + let team_account = (MultiAddress::Native(address), balance as u128); + compute_balance_distribution_with_cliff_and_vesting(vec![team_account]) } pub fn get_treasury_balance() -> (AccountId, u128) { @@ -207,11 +238,24 @@ pub fn get_treasury_balance() -> (AccountId, u128) { (acc, UNIT * 100_000) } -pub fn get_foundation_balance() -> (AccountId, u128) { +pub fn get_foundation_endowment() -> (AccountId, u128) { // TODO : Setup foundation account here let pallet_id = tangle_primitives::treasury::TREASURY_PALLET_ID; let acc: AccountId = pallet_id.into_account_truncating(); - (acc, UNIT * 100_000) + let balance = (get_foundation_distribution_share() * get_initial_liquidity_share()) + .mul_floor(TOTAL_SUPPLY); + (acc, balance) +} + +pub fn get_foundation_balance_distribution() -> Vec<(MultiAddress, u128, u64, u64, u128)> { + // TODO : Setup foundation account here + let pallet_id = tangle_primitives::treasury::TREASURY_PALLET_ID; + let address: AccountId = pallet_id.into_account_truncating(); + let balance = get_foundation_distribution_share().mul_floor(TOTAL_SUPPLY) - + get_initial_liquidity_share() + .mul_floor(get_foundation_distribution_share().mul_floor(TOTAL_SUPPLY)); + let foundation_account = (MultiAddress::Native(address), balance as u128); + compute_balance_distribution_with_cliff_and_vesting(vec![foundation_account]) } pub fn compute_balance_distribution_with_cliff_and_vesting( @@ -225,7 +269,7 @@ pub fn compute_balance_distribution_with_cliff_and_vesting( value, ONE_YEAR_BLOCKS, TWO_YEARS_BLOCKS - ONE_YEAR_BLOCKS, - one_percent_endowment(value), + five_percent_endowment(value), ) }) .collect() @@ -240,7 +284,7 @@ pub fn get_distribution_for( let mut claims = vec![]; let mut vesting = vec![]; arr.into_iter().filter(|(_, value)| *value > 0).for_each(|(address, value)| { - let claimable_amount = one_percent_endowment(value); + let claimable_amount = five_percent_endowment(value); let vested_amount = value - claimable_amount; let cliff_fraction = vesting_cliff as f64 / total_vesting_schedule as f64; let remaining_fraction = 1.0 - cliff_fraction; diff --git a/node/src/mainnet_fixtures.rs b/node/src/mainnet_fixtures.rs index 92bc5e0ed..8e99a27eb 100644 --- a/node/src/mainnet_fixtures.rs +++ b/node/src/mainnet_fixtures.rs @@ -20,12 +20,12 @@ use sc_consensus_grandpa::AuthorityId as GrandpaId; use sc_network::config::MultiaddrWithPeerId; use sp_consensus_babe::AuthorityId as BabeId; use sp_core::crypto::UncheckedInto; -use tangle_testnet_runtime::AccountId; +use tangle_crypto_primitives::crypto::AuthorityId as RoleKeyId; +use tangle_runtime::AccountId; /// Mainnet root key pub fn get_root_key() -> AccountId { - // Standalone sudo key: 5CDZpRSZ14TmXorHTsTeksY7223FzsaLXPbpTPBUV6NaZSr1 - hex!["06c225d97d596c57e620aba15e1a8a69c7b334ffdab175788c6553f7dd181a56"].into() + hex!["9c2c928c3b9ac62c6dc4caaf5777c16ce28984dedc92687ef427f8f4f6d61d2f"].into() } /// Mainnet bootnodes @@ -37,7 +37,7 @@ pub fn get_bootnodes() -> Vec { "/ip4/18.119.14.21/tcp/30333/p2p/12D3KooWJP5NbEjEK1YihofJm3MMSJWrbRWjeEkRf3LtKvkj6mr9" .parse() .unwrap(), - "/ip4/18.188.183.185/tcp/30333/p2p/12D3KooWDL3KiR6CpnEbgUgheje1cMGQtwH4euxGMPQBkwU5cZdu" + "/ip4/3.15.186.160/tcp/30333/p2p/12D3KooWDL3KiR6CpnEbgUgheje1cMGQtwH4euxGMPQBkwU5cZdu" .parse() .unwrap(), "/ip4/3.137.213.159/tcp/30333/p2p/12D3KooWS4aniCJTz2RiNfNUka8TTa3gXak63FJgdAgfAWLCnsAi" @@ -49,57 +49,67 @@ pub fn get_bootnodes() -> Vec { ] } -/// Standalone initial authorities -pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineId)> { +/// Tangle runtime initial authorities +pub fn get_initial_authorities() -> Vec<(AccountId, BabeId, GrandpaId, ImOnlineId, RoleKeyId)> { vec![ - // standalone 1 + // tangle 1 ( - hex!["6c99e8e4ae3fe7e3328d7e9d85eb98e86bdc6410695797349fa536ebb9bb0a4a"].into(), - hex!["d8a00a2454cd7455c040e363e6e76f4abd9e4d3876253964d9f40a66ad79694b"] + hex!["4e85271af1330e5e9384bd3ac5bdc04c0f8ef5a8cc29c1a8ae483d674164745c"].into(), + hex!["82a764a9835b2ac7aacd8ec96479d872e91256fba11cc0393b0e98dd320bbf38"] .unchecked_into(), - hex!["5bcf983a969f8de7628b271a5bf523924856c3935b15eb3e03f20146ced2c57f"] + hex!["71bf01524c555f1e0f6b7dc7243caf00851d3afc543422f98d3eb6bca78acd8c"] .unchecked_into(), - hex!["0297bc051d94b25787482e60fa4eba19f15af30fa244240ae4439d219ee00e78"] + hex!["2c7d0dbc639d8d52d02e9e03b6dd19b50f44a6a491ca75c9ebd6a1a29782e743"] + .unchecked_into(), + hex!["02a1af3c93d94e9b658a9aaa994bfa3fc156c9d38c60872d3dd33f63cd7aa12a6b"] .unchecked_into(), ), - // standalone 2 + // tangle 2 ( - hex!["444dbfd0220eb1a993a7a2b9e1530aee1d17388ba3db34a0ee2b8ff971bfd073"].into(), - hex!["f02ee9baa32c490cf06eabe3580a90be704618f04636b321ee599c8912392c7a"] + hex!["587c2ef00ec0a1b98af4c655763acd76ece690fccbb255f01663660bc274960d"].into(), + hex!["020af75377d0b400946938970c47055a2a48ad4fd728a427b7a1dd96e75db65f"] + .unchecked_into(), + hex!["61f771ebfdb0a6de08b8e0ca7a39a01f24e7eaa3d1e7f1001e6503490c25c044"] .unchecked_into(), - hex!["2d6ac10cde791863771847c035c36e13ad60e6129465e1aefad8f5fee8dff5c7"] + hex!["ecb58b3d1eaaad8ef42c27e183e41830628ca5fee5bb06cdf13883e57c4a0770"] .unchecked_into(), - hex!["de6d5010678fd2175fe70c857d3eba80838e3735b1051f4aed98671800ec483f"] + hex!["0305c8dd5a251ed604350f50a993edc9baa66fb72b56091346316dd94052a068fa"] .unchecked_into(), ), - // standalone 3 + // tangle 3 ( - hex!["2c4e648b0fbbb88ff6b92b208273eb144383b2b19edc992e91448a4371d4d97d"].into(), - hex!["a41b35f75e5509ce96e62bc27bb9a1b5587cc3d596f8afa867962b0e03230513"] + hex!["a24f729f085de51eebaeaeca97d6d499761b8f6daeca9b99d754a06ef8bcec3f"].into(), + hex!["a8f14e015ced0b21e680e577231519c33484d1b63f5529bf4fbb137a920bb82e"] + .unchecked_into(), + hex!["a41a815db90b9bd3d9ec462f90ba77ba1d627a9fccc9f7847e34c9e9e9b57c90"] .unchecked_into(), - hex!["340e5969c8dd40ff77184fa73fbdcda77dcc90dd9b68b8b28eef5f01ce42339c"] + hex!["2ef4f718a407e0b4d86913a989f749b7edfe836bae1d726b07f9c419ad94c42c"] .unchecked_into(), - hex!["8472336050c4e4a51ac69865a4a31c6dd0e5c2f79555d8646cafb3bd8f12d75c"] + hex!["02825faaf113b15b28dfdfe52eeee66554fe2892825e146d20ac49dd7c37d6e793"] .unchecked_into(), ), - // standalone 4 + // tangle 4 ( - hex!["c884c8eb280327221a3ae6a45fe6c8805f09bcfc11b409c8e2daa621c0d99608"].into(), - hex!["06e0a0d39503a101ca9c36f84b3ccf53015ee625a546bc570e550af963d13164"] + hex!["0a55e5245382700f35d16a5ea6d60a56c36c435bef7204353b8c36871f347857"].into(), + hex!["2296eb6f84cafd066c07e19fd127e7f5ca0d6e26ce305f9facc0e0221c7ecb1a"] .unchecked_into(), - hex!["57eda010788108257f4c148cf0c3112d620b9067546777dc393a65dd34732079"] + hex!["b0f002333f4fd657155dfcb4ac5c6ce04d0b2c68b64befa178d4357ceb05fe2d"] .unchecked_into(), - hex!["029cb182ddb9c5560aaa299f7b445e575007b8295bd85a80a7b2eb7baa3e2b7c"] + hex!["dc8be4d69084d5bb8a6a0cd48c4d3ab82def85e996b87c63176b49f70c028c35"] + .unchecked_into(), + hex!["02745849fbb4cf0f1f9f310cf67740431fd4cd1b4292bb1a3efeb93956e612e75f"] .unchecked_into(), ), - // standalone 5 + // tangle 5 ( - hex!["483e0b8d6801c51115fd4b124c91e2d5dcd642b30335f6c5a1738ea18f66c251"].into(), - hex!["ce80df4851003f6ffd4ee88d9be85966f1de8b2e494c009dbf336177485f023f"] + hex!["e0948453e7acbc6ac937e124eb01580191e99f4262d588d4524994deb6134349"].into(), + hex!["0e08bb5a9cc4e7dbd279ba53bd5aecd78956c34a2dae678c5490c52bc754521e"] + .unchecked_into(), + hex!["d2eb206f8c7a64ce47828b33314806ac6cb915d464990eaff9f6435880c6e54f"] .unchecked_into(), - hex!["9027284e6cad3f73eee950695c56f87330311331139616640c9168934dba82df"] + hex!["363e33c500396cc52ef58924a005227eed67801bd376ca886fd6432ba7070711"] .unchecked_into(), - hex!["1ea007d87f91f96c31b1062548eb77c40d47a43f1c84c36caa8586fc7c359729"] + hex!["03dd29b916c41662207e2e5b7dd7c5c7054681bef8897bd4f0634b9075463159ca"] .unchecked_into(), ), ] diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index c97866057..40a91c434 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -103,7 +103,7 @@ pub mod currency { pub const WEIGHT_FEE: Balance = 100 * MEGAWEI; /// Return the cost to add an item to storage based on size pub const fn deposit(items: u32, bytes: u32) -> Balance { - items as Balance * 20 * DOLLAR + (bytes as Balance) * 100 * MILLICENT + items as Balance * 10 * DOLLAR + (bytes as Balance) * 100 * MILLICENT } } @@ -226,13 +226,12 @@ pub mod evm { pub mod democracy { use crate::{currency::UNIT, time::MINUTES, Balance, BlockNumber}; - - pub const LAUNCH_PERIOD: BlockNumber = 28 * 24 * 60 * MINUTES; - pub const VOTING_PERIOD: BlockNumber = 28 * 24 * 60 * MINUTES; - pub const FASTTRACK_VOTING_PERIOD: BlockNumber = 3 * 24 * 60 * MINUTES; - pub const MINIMUM_DEPOSIT: Balance = 100 * UNIT; - pub const ENACTMENT_PERIOD: BlockNumber = 30 * 24 * 60 * MINUTES; - pub const COOLOFF_PERIOD: BlockNumber = 28 * 24 * 60 * MINUTES; + pub const LAUNCH_PERIOD: BlockNumber = 10 * 24 * 60 * MINUTES; // 10 days + pub const VOTING_PERIOD: BlockNumber = 10 * 24 * 60 * MINUTES; // 10 days + pub const FASTTRACK_VOTING_PERIOD: BlockNumber = 3 * 24 * 60 * MINUTES; // 3 days + pub const MINIMUM_DEPOSIT: Balance = 1000 * UNIT; // 1000 TNT + pub const ENACTMENT_PERIOD: BlockNumber = 3 * 24 * 60 * MINUTES; // 3 days + pub const COOLOFF_PERIOD: BlockNumber = 3 * 24 * 60 * MINUTES; // 3 days pub const MAX_PROPOSALS: u32 = 100; } @@ -260,7 +259,7 @@ pub mod treasury { pub const PROPOSAL_BOND: Permill = Permill::from_percent(5); pub const PROPOSAL_BOND_MINIMUM: Balance = UNIT; pub const SPEND_PERIOD: BlockNumber = DAYS; - pub const BURN: Permill = Permill::from_percent(50); + pub const BURN: Permill = Permill::from_percent(0); pub const TIP_COUNTDOWN: BlockNumber = DAYS; pub const TIP_FINDERS_FEE: Percent = Percent::from_percent(20); pub const TIP_REPORT_DEPOSIT_BASE: Balance = UNIT; diff --git a/runtime/mainnet/Cargo.toml b/runtime/mainnet/Cargo.toml index 0db5fafcf..f4b96b518 100644 --- a/runtime/mainnet/Cargo.toml +++ b/runtime/mainnet/Cargo.toml @@ -89,6 +89,8 @@ pallet-vesting = { workspace = true } # Webb dependencies tangle-crypto-primitives = { workspace = true } tangle-primitives = { workspace = true } +pallet-roles = { workspace = true } +pallet-jobs = { workspace = true } # Frontier dependencies fp-account = { workspace = true } @@ -202,7 +204,9 @@ std = [ "pallet-airdrop-claims/std", "pallet-identity/std", "frame-system-benchmarking?/std", + "pallet-roles/std", "sp-storage/std", + "pallet-jobs/std", # Tangle dependencies "tangle-primitives/std", diff --git a/runtime/mainnet/src/filters.rs b/runtime/mainnet/src/filters.rs index 0e43f65dd..315bc3848 100644 --- a/runtime/mainnet/src/filters.rs +++ b/runtime/mainnet/src/filters.rs @@ -37,6 +37,9 @@ impl Contains for MainnetCallFilter { RuntimeCall::Democracy(_) | // disallow council RuntimeCall::Council(_) | + // Block jobs and roles pallet + RuntimeCall::Roles(_) | + RuntimeCall::Jobs(_) | // Filter light client calls RuntimeCall::Eth2Client(_) => false, diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index 67ce9f01d..23b1bf00d 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -63,14 +63,22 @@ use sp_runtime::{ ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perquintill, SaturatedConversion, }; use sp_staking::currency_to_vote::U128CurrencyToVote; +use tangle_primitives::jobs::{traits::JobToFee, JobSubmission}; + +#[cfg(any(feature = "std", test))] +pub use frame_system::Call as SystemCall; +use sp_runtime::DispatchResult; +use sp_staking::{ + offence::{OffenceError, ReportOffence}, + SessionIndex, +}; use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; use static_assertions::const_assert; - -#[cfg(any(feature = "std", test))] -pub use frame_system::Call as SystemCall; +pub use tangle_crypto_primitives::crypto::AuthorityId as RoleKeyId; +use tangle_primitives::jobs::{traits::MPCHandler, JobWithResult, ValidatorOffenceType}; pub use frame_support::{ construct_runtime, @@ -188,6 +196,7 @@ pub mod opaque { pub babe: Babe, pub grandpa: Grandpa, pub im_online: ImOnline, + pub role: Roles, } } } @@ -1042,6 +1051,83 @@ impl pallet_airdrop_claims::Config for Runtime { type WeightInfo = (); } +pub struct MockMPCHandler; + +impl MPCHandler for MockMPCHandler { + fn verify(_data: JobWithResult) -> DispatchResult { + Ok(()) + } + + fn verify_validator_report( + _validator: AccountId, + _offence: ValidatorOffenceType, + _signatures: Vec>, + ) -> DispatchResult { + Ok(()) + } + + fn validate_authority_key(_validator: AccountId, _authority_key: Vec) -> DispatchResult { + Ok(()) + } +} + +type IdTuple = pallet_session::historical::IdentificationTuple; +type Offence = pallet_roles::offences::ValidatorOffence; +/// A mock offence report handler. +pub struct OffenceHandler; +impl ReportOffence for OffenceHandler { + fn report_offence(_reporters: Vec, _offence: Offence) -> Result<(), OffenceError> { + Ok(()) + } + + fn is_known_offence(_offenders: &[IdTuple], _time_slot: &SessionIndex) -> bool { + false + } +} + +parameter_types! { + pub InflationRewardPerSession: Balance = 10_000; + pub Reward : tangle_primitives::roles::ValidatorRewardDistribution = tangle_primitives::roles::ValidatorRewardDistribution::try_new(Percent::from_rational(1_u32,2_u32), Percent::from_rational(1_u32,2_u32)).unwrap(); +} + +impl pallet_roles::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type JobsHandler = Jobs; + type RoleKeyId = RoleKeyId; + type MaxRolesPerAccount = ConstU32<2>; + type MPCHandler = MockMPCHandler; + type InflationRewardPerSession = InflationRewardPerSession; + type ValidatorSet = Historical; + type ReportOffences = OffenceHandler; + type ValidatorRewardDistribution = Reward; + type WeightInfo = (); +} + +pub struct MockJobToFeeHandler; + +impl JobToFee for MockJobToFeeHandler { + type Balance = Balance; + + fn job_to_fee(_job: &JobSubmission) -> Balance { + Default::default() + } +} + +parameter_types! { + pub const JobsPalletId: PalletId = PalletId(*b"py/jobss"); +} + +impl pallet_jobs::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type ForceOrigin = EnsureRootOrHalfCouncil; + type Currency = Balances; + type JobToFee = MockJobToFeeHandler; + type RolesHandler = Roles; + type MPCHandler = MockMPCHandler; + type PalletId = JobsPalletId; + type WeightInfo = (); +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime { @@ -1092,6 +1178,8 @@ construct_runtime!( Claims: pallet_airdrop_claims, Eth2Client: pallet_eth2_light_client, + Roles: pallet_roles, + Jobs: pallet_jobs } ); diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index fe469eb0f..96603efa6 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -161,7 +161,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("tangle-testnet"), impl_name: create_runtime_str!("tangle-testnet"), authoring_version: 1, - spec_version: 601, // v0.6.1 + spec_version: 602, // v0.6.2 impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -999,9 +999,9 @@ impl pallet_transaction_pause::Config for Runtime { } parameter_types! { - pub const BasicDeposit: Balance = deposit(1, 258); - pub const FieldDeposit: Balance = deposit(0, 66); - pub const SubAccountDeposit: Balance = deposit(1, 53); + pub const BasicDeposit: Balance = deposit(0, 100); // purposely set low, do not copy for mainnet + pub const FieldDeposit: Balance = deposit(0, 100); // purposely set low, do not copy for mainnet + pub const SubAccountDeposit: Balance = deposit(1, 1); // purposely set low, do not copy for mainnet pub const MaxSubAccounts: u32 = 100; #[derive(Serialize, Deserialize)] pub const MaxAdditionalFields: u32 = 100;