Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fa1554c
Merge pull request #77 from OriginTrail/develop
NZT48 Apr 22, 2024
05896ae
Add sudo for Devnet
NZT48 Apr 22, 2024
8613065
Merge pull request #83 from OriginTrail/feature/polkadot-v1.9.0
NZT48 Jul 24, 2024
1de59f8
Setup chain id for evm
NZT48 Jul 25, 2024
c1e38c2
Updated Devnet to Polkadot 1.9.0
NZT48 Jul 25, 2024
cd407a8
Adjust base fee
NZT48 Jul 30, 2024
6d763df
Merge branch 'release/devnet' into hotfix/base-fee
NZT48 Jul 30, 2024
d274626
Merge pull request #85 from OriginTrail/hotfix/base-fee
NZT48 Jul 30, 2024
3567ccb
Merge branch 'release/devnet' into hotfix/disable-native-executor
NZT48 Aug 9, 2024
da7292a
Merge pull request #90 from OriginTrail/hotfix/disable-native-executor
NZT48 Aug 9, 2024
6cabf28
Feature/polkadot v1.11.0 (#92)
Mihajlo-Pavlovic Aug 15, 2024
538ecf7
Devnet release 1.5.0 (#95)
Mihajlo-Pavlovic Aug 20, 2024
1f03678
Merge pull request #112 from OriginTrail/release/testnet
Mihajlo-Pavlovic Nov 7, 2024
bb81154
Add Zombienet config
NZT48 Dec 22, 2024
e2b743a
Add parachain staking pallet implementation
NZT48 Dec 22, 2024
0cf4666
Ignore deprecation notice for run command
NZT48 Dec 22, 2024
2c8247e
Add parachain staking weights
NZT48 Dec 22, 2024
e5ea1b6
Integrate parachain staking into runtime
NZT48 Dec 22, 2024
5beb40c
Setup parachain staking in chain spec generation
NZT48 Dec 22, 2024
0d12dea
Allign mainnet and devnet
Mihajlo-Pavlovic Jan 6, 2025
4b682f0
Update versions
Mihajlo-Pavlovic Mar 14, 2025
5bca3c4
Merge pull request #114 from OriginTrail/feature/staking
Mihajlo-Pavlovic Mar 14, 2025
477c414
Merge branch 'release/devnet' into develop
Mihajlo-Pavlovic Mar 14, 2025
7c559f7
Merge pull request #115 from OriginTrail/develop
Mihajlo-Pavlovic Mar 14, 2025
09d94bd
Version bump
Mihajlo-Pavlovic Mar 14, 2025
0849536
Update runtime version
Mihajlo-Pavlovic Mar 14, 2025
418184f
Fix SECONDS_PER_BLOCK
Mihajlo-Pavlovic Mar 20, 2025
9fe9889
Merge pull request #116 from OriginTrail/fix/inflation-block-time
Mihajlo-Pavlovic Mar 21, 2025
8107321
Merge pull request #117 from OriginTrail/develop
Mihajlo-Pavlovic Mar 21, 2025
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
54 changes: 52 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ slices = "0.2.0"
smallvec = "1.10.0"
serde = { version = "1.0.152", default-features = false }
serde_json = "1.0.92"
itertools = { version = "0.11", default-features = false, features = [
"use_alloc",
] }
rustc-hex = { version = "2.0.1", default-features = false }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
Expand Down Expand Up @@ -80,9 +84,11 @@ sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", defau
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
sp-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
Expand All @@ -105,6 +111,7 @@ pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", default-fea
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
Expand Down Expand Up @@ -177,6 +184,13 @@ xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-s
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }

# Staking
substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", default-features = false }
pallet-parachain-staking = { path = "pallets/parachain-staking", default-features = false }
#pallet-evm-precompile-parachain-staking = { path = "precompiles/parachain-staking", default-features = false }
# num-integer = { version = "0.1", default-features = false }
# sp-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }

# Local
neuroweb-runtime = { path = "./runtime" }
precompile-utils = { path = "./precompiles/utils", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ To run a full network with multiple NeuroWeb nodes (collators and non-collators)
#### Run A Relay Chain

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/).

NeuroWeb is currently compatible with Polkadot v1.11.0 version.

#### Parachain Nodes (Collators)
Expand Down
3 changes: 2 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "neuroweb-node"
version = "1.5.0"
version = "1.6.0"
authors = ["TraceLabs"]
description = "NeuroWeb - Cumulus FRAME-based Substrate Node"
license = "GPL-3.0-only"
Expand All @@ -21,6 +21,7 @@ codec = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["arbitrary_precision"] }
jsonrpsee = { workspace = true }
itertools = { workspace = true }

# Local
neuroweb-runtime = { workspace = true }
Expand Down
55 changes: 45 additions & 10 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
use cumulus_primitives_core::ParaId;
use neuroweb_runtime::{AccountId, AuraId,
EVMConfig, Signature, EXISTENTIAL_DEPOSIT};
use neuroweb_runtime::{pallet_parachain_staking::{
inflation::{perbill_annual_to_perbill_round, BLOCKS_PER_YEAR},
InflationInfo, Range,
}, AccountId, AuraId, Balance, EVMConfig, MinCandidateStk, Signature, OTP};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public, H160, U256};
use sp_runtime::traits::{IdentifyAccount, Verify};
use sp_runtime::{Perbill, Percent, traits::{IdentifyAccount, Verify}};
use std::{collections::BTreeMap, str::FromStr};
use itertools::Itertools;

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

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
pub const COLLATOR_COMMISSION: Perbill = Perbill::from_percent(10);
pub const PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(0);
pub const BLOCKS_PER_ROUND: u32 = 3600; // 6 hours of blocks
pub const NUM_SELECTED_CANDIDATES: u32 = 1; // For start

pub fn neuroweb_inflation_config() -> InflationInfo<Balance> {
fn to_round_inflation(annual: Range<Perbill>) -> Range<Perbill> {
perbill_annual_to_perbill_round(
annual,
// rounds per year
BLOCKS_PER_YEAR / BLOCKS_PER_ROUND,
)
}
let annual =
Range { min: Perbill::from_percent(2), ideal: Perbill::from_percent(3), max: Perbill::from_percent(3) };

InflationInfo {
// staking expectations
expect: Range { min: 100_000 * OTP, ideal: 200_000 * OTP, max: 500_000 * OTP },
// annual inflation
annual,
round: to_round_inflation(annual),
}
}

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -174,13 +201,8 @@ fn testnet_genesis(
parachain_id: id,
..Default::default()
},
collator_selection: neuroweb_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
..Default::default()
},
session: neuroweb_runtime::SessionConfig {
keys: invulnerables
keys: invulnerables.clone()
.into_iter()
.map(|(acc, aura)| {
(
Expand All @@ -200,6 +222,10 @@ fn testnet_genesis(
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
sudo: neuroweb_runtime::SudoConfig {
// Assign network admin rights.
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
},
vesting: Default::default(),
treasury: Default::default(),
evm: EVMConfig {
Expand Down Expand Up @@ -242,6 +268,15 @@ fn testnet_genesis(
council: Default::default(),
democracy: Default::default(),
transaction_payment: Default::default(),
parachain_staking: neuroweb_runtime::ParachainStakingConfig {
candidates: invulnerables.clone().into_iter().map(|account| (account.0, MinCandidateStk::get())).collect_vec(),
delegations: vec![],
blocks_per_round: BLOCKS_PER_ROUND,
num_selected_candidates: NUM_SELECTED_CANDIDATES,
parachain_bond_reserve_percent: PARACHAIN_BOND_RESERVE_PERCENT,
collator_commission: COLLATOR_COMMISSION,
inflation_config: neuroweb_inflation_config()
}
};

serde_json::to_value(&config).expect("Could not build genesis config.")
Expand Down
1 change: 1 addition & 0 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ pub fn run() -> Result<()> {
match cmd {
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
#[allow(deprecated)]
runner.sync_run(|config| cmd.run::<HashingFor<Block>, ()>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
Expand Down
79 changes: 79 additions & 0 deletions pallets/parachain-staking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[package]
name = "pallet-parachain-staking"
description = "Parachain staking pallet for collator selection and reward distribution"
authors = { workspace = true }
edition = "2021"
version = "1.0.0"

[dependencies]
serde = { workspace = true }
log = { workspace = true }

codec = { workspace = true, features = [
"derive",
] }
scale-info = { workspace = true, features = ["derive"] }

# FRAME
frame-benchmarking = { workspace = true, optional = true }
frame-support.workspace = true
frame-system.workspace = true
sp-runtime.workspace = true
sp-std.workspace = true
sp-core.workspace = true
substrate-fixed.workspace = true
sp-staking.workspace = true
pallet-authorship.workspace = true
pallet-session.workspace = true

[dev-dependencies]
pallet-balances.workspace = true
pallet-aura.workspace = true
pallet-timestamp.workspace = true
similar-asserts = "1.1.0"
sp-io.workspace = true
sp-consensus-aura.workspace = true

[features]
default = [ "std" ]
std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-session/std",
"pallet-timestamp/std",
"codec/std",
"scale-info/std",
"serde/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
"substrate-fixed/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-benchmarking?/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-session/try-runtime",
"pallet-timestamp/try-runtime",
"sp-runtime/try-runtime",
]
Loading
Loading