Skip to content

Commit b9bb775

Browse files
Merge pull request #119 from OriginTrail/devnet-to-testnet-1.6
Testnet v1.6.0 Collators Staking
2 parents 87e9e5a + d8063ea commit b9bb775

File tree

26 files changed

+15481
-54
lines changed

26 files changed

+15481
-54
lines changed

Cargo.lock

Lines changed: 52 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ slices = "0.2.0"
4141
smallvec = "1.10.0"
4242
serde = { version = "1.0.152", default-features = false }
4343
serde_json = "1.0.92"
44+
itertools = { version = "0.11", default-features = false, features = [
45+
"use_alloc",
46+
] }
47+
rustc-hex = { version = "2.0.1", default-features = false }
4448

4549
# Substrate
4650
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
@@ -80,9 +84,11 @@ sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", defau
8084
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
8185
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
8286
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
87+
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
8388
sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
8489
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
8590
sp-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
91+
sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
8692
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
8793
sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
8894
sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
@@ -177,6 +183,13 @@ xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-s
177183
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
178184
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
179185

186+
# Staking
187+
substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", default-features = false }
188+
pallet-parachain-staking = { path = "pallets/parachain-staking", default-features = false }
189+
#pallet-evm-precompile-parachain-staking = { path = "precompiles/parachain-staking", default-features = false }
190+
# num-integer = { version = "0.1", default-features = false }
191+
# sp-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
192+
180193
# Local
181194
neuroweb-runtime = { path = "./runtime" }
182195
precompile-utils = { path = "./precompiles/utils", default-features = false }

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ To run a full network with multiple NeuroWeb nodes (collators and non-collators)
4747
#### Run A Relay Chain
4848

4949
To start a relay chain we recommend reading and following instructions in [Cumulus Workshop](https://docs.substrate.io/tutorials/build-a-parachain/prepare-a-local-relay-chain/).
50-
5150
NeuroWeb is currently compatible with Polkadot v1.11.0 version.
5251

5352
#### Parachain Nodes (Collators)

node/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "neuroweb-node"
3-
version = "1.5.0"
3+
version = "1.6.0"
44
authors = ["TraceLabs"]
55
description = "NeuroWeb - Cumulus FRAME-based Substrate Node"
66
license = "GPL-3.0-only"
@@ -21,6 +21,7 @@ codec = { workspace = true }
2121
serde = { workspace = true, features = ["derive"] }
2222
serde_json = { workspace = true, features = ["arbitrary_precision"] }
2323
jsonrpsee = { workspace = true }
24+
itertools = { workspace = true }
2425

2526
# Local
2627
neuroweb-runtime = { workspace = true }

node/src/chain_spec.rs

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,46 @@
11
use cumulus_primitives_core::ParaId;
2-
use neuroweb_runtime::{AccountId, AuraId,
3-
EVMConfig, Signature, EXISTENTIAL_DEPOSIT};
2+
use neuroweb_runtime::{pallet_parachain_staking::{
3+
inflation::{perbill_annual_to_perbill_round, BLOCKS_PER_YEAR},
4+
InflationInfo, Range,
5+
}, AccountId, AuraId, Balance, EVMConfig, MinCandidateStk, Signature, OTP};
46
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
57
use sc_service::ChainType;
68
use serde::{Deserialize, Serialize};
79
use sp_core::{sr25519, Pair, Public, H160, U256};
8-
use sp_runtime::traits::{IdentifyAccount, Verify};
10+
use sp_runtime::{Perbill, Percent, traits::{IdentifyAccount, Verify}};
911
use std::{collections::BTreeMap, str::FromStr};
12+
use itertools::Itertools;
1013

1114
/// Specialized `ChainSpec` for the normal parachain runtime.
1215
pub type ChainSpec =
1316
sc_service::GenericChainSpec<neuroweb_runtime::RuntimeGenesisConfig, Extensions>;
1417

1518
/// The default XCM version to set in genesis config.
16-
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
19+
pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
20+
pub const COLLATOR_COMMISSION: Perbill = Perbill::from_percent(10);
21+
pub const PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(0);
22+
pub const BLOCKS_PER_ROUND: u32 = 3600; // 6 hours of blocks
23+
pub const NUM_SELECTED_CANDIDATES: u32 = 1; // For start
24+
25+
pub fn neuroweb_inflation_config() -> InflationInfo<Balance> {
26+
fn to_round_inflation(annual: Range<Perbill>) -> Range<Perbill> {
27+
perbill_annual_to_perbill_round(
28+
annual,
29+
// rounds per year
30+
BLOCKS_PER_YEAR / BLOCKS_PER_ROUND,
31+
)
32+
}
33+
let annual =
34+
Range { min: Perbill::from_percent(2), ideal: Perbill::from_percent(3), max: Perbill::from_percent(3) };
35+
36+
InflationInfo {
37+
// staking expectations
38+
expect: Range { min: 100_000 * OTP, ideal: 200_000 * OTP, max: 500_000 * OTP },
39+
// annual inflation
40+
annual,
41+
round: to_round_inflation(annual),
42+
}
43+
}
1744

1845
/// Helper function to generate a crypto pair from seed
1946
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
@@ -174,13 +201,8 @@ fn testnet_genesis(
174201
parachain_id: id,
175202
..Default::default()
176203
},
177-
collator_selection: neuroweb_runtime::CollatorSelectionConfig {
178-
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
179-
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
180-
..Default::default()
181-
},
182204
session: neuroweb_runtime::SessionConfig {
183-
keys: invulnerables
205+
keys: invulnerables.clone()
184206
.into_iter()
185207
.map(|(acc, aura)| {
186208
(
@@ -242,6 +264,15 @@ fn testnet_genesis(
242264
council: Default::default(),
243265
democracy: Default::default(),
244266
transaction_payment: Default::default(),
267+
parachain_staking: neuroweb_runtime::ParachainStakingConfig {
268+
candidates: invulnerables.clone().into_iter().map(|account| (account.0, MinCandidateStk::get())).collect_vec(),
269+
delegations: vec![],
270+
blocks_per_round: BLOCKS_PER_ROUND,
271+
num_selected_candidates: NUM_SELECTED_CANDIDATES,
272+
parachain_bond_reserve_percent: PARACHAIN_BOND_RESERVE_PERCENT,
273+
collator_commission: COLLATOR_COMMISSION,
274+
inflation_config: neuroweb_inflation_config()
275+
}
245276
};
246277

247278
serde_json::to_value(&config).expect("Could not build genesis config.")

node/src/command.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ pub fn run() -> Result<()> {
188188
match cmd {
189189
BenchmarkCmd::Pallet(cmd) => {
190190
if cfg!(feature = "runtime-benchmarks") {
191+
#[allow(deprecated)]
191192
runner.sync_run(|config| cmd.run::<HashingFor<Block>, ()>(config))
192193
} else {
193194
Err("Benchmarking wasn't enabled when building the node. \
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[package]
2+
name = "pallet-parachain-staking"
3+
description = "Parachain staking pallet for collator selection and reward distribution"
4+
authors = { workspace = true }
5+
edition = "2021"
6+
version = "1.0.0"
7+
8+
[dependencies]
9+
serde = { workspace = true }
10+
log = { workspace = true }
11+
12+
codec = { workspace = true, features = [
13+
"derive",
14+
] }
15+
scale-info = { workspace = true, features = ["derive"] }
16+
17+
# FRAME
18+
frame-benchmarking = { workspace = true, optional = true }
19+
frame-support.workspace = true
20+
frame-system.workspace = true
21+
sp-runtime.workspace = true
22+
sp-std.workspace = true
23+
sp-core.workspace = true
24+
substrate-fixed.workspace = true
25+
sp-staking.workspace = true
26+
pallet-authorship.workspace = true
27+
pallet-session.workspace = true
28+
29+
[dev-dependencies]
30+
pallet-balances.workspace = true
31+
pallet-aura.workspace = true
32+
pallet-timestamp.workspace = true
33+
similar-asserts = "1.1.0"
34+
sp-io.workspace = true
35+
sp-consensus-aura.workspace = true
36+
37+
[features]
38+
default = [ "std" ]
39+
std = [
40+
"frame-benchmarking?/std",
41+
"frame-support/std",
42+
"frame-system/std",
43+
"log/std",
44+
"pallet-aura/std",
45+
"pallet-authorship/std",
46+
"pallet-balances/std",
47+
"pallet-session/std",
48+
"pallet-timestamp/std",
49+
"codec/std",
50+
"scale-info/std",
51+
"serde/std",
52+
"sp-consensus-aura/std",
53+
"sp-core/std",
54+
"sp-io/std",
55+
"sp-runtime/std",
56+
"sp-staking/std",
57+
"sp-std/std",
58+
"substrate-fixed/std",
59+
]
60+
runtime-benchmarks = [
61+
"frame-benchmarking",
62+
"frame-benchmarking?/runtime-benchmarks",
63+
"frame-support/runtime-benchmarks",
64+
"frame-system/runtime-benchmarks",
65+
"pallet-balances/runtime-benchmarks",
66+
"pallet-timestamp/runtime-benchmarks",
67+
"sp-runtime/runtime-benchmarks",
68+
"sp-staking/runtime-benchmarks",
69+
]
70+
try-runtime = [
71+
"frame-support/try-runtime",
72+
"frame-system/try-runtime",
73+
"pallet-aura/try-runtime",
74+
"pallet-authorship/try-runtime",
75+
"pallet-balances/try-runtime",
76+
"pallet-session/try-runtime",
77+
"pallet-timestamp/try-runtime",
78+
"sp-runtime/try-runtime",
79+
]

0 commit comments

Comments
 (0)