Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
8fa85ca
all the big things begin small
gpestana Oct 2, 2023
d138012
Staking parachain runtime compiing; added to polkadot parachain
gpestana Oct 20, 2023
4d0b6fc
fixes
gpestana Oct 21, 2023
afadcd8
Adds staking-rococoi cumulus runtime
gpestana Dec 2, 2023
754fa02
Adds chain-spec gen to CLI
gpestana Dec 11, 2023
02a7216
chain-spec changes
gpestana Dec 12, 2023
507cd0b
zombinet staking example
gpestana Jan 2, 2024
ae21aeb
pulls the correct staking wasm binary
gpestana Jan 3, 2024
f3ee2a4
Merge branch 'master' into staking-parachain-exp
Ank4n Feb 12, 2024
eae3618
fix compilation
Ank4n Feb 12, 2024
167e666
[WIP] PoV friendly, multi-block Election Provider Multi-Phase pallet …
gpestana Feb 15, 2024
fc42c1b
Merge branch 'staking-parachain-exp' into gpestana/staking-cumulus-si…
gpestana Feb 16, 2024
3914c5c
removes epm-single block from cumulus runtime
gpestana Feb 16, 2024
ac3d4a9
Adds cumulus runtime
gpestana Feb 16, 2024
fe3a246
a
gpestana Feb 16, 2024
d0a2ba7
dependency fixes
gpestana Feb 16, 2024
ac72e52
fix
gpestana Feb 16, 2024
4141ae5
Merge branch 'master' into staking-parachain-exp
gpestana Feb 16, 2024
4d83405
runtimes working with EPM-MB; zombienet OK
gpestana Feb 19, 2024
addc764
unsigned
gpestana Apr 2, 2024
da404e2
more on unsigned / paged
gpestana Apr 5, 2024
f7a2564
unsigned mining and submission (with partial checks)
gpestana Apr 6, 2024
bf7c03e
unsigned pallet in rococo runtime
gpestana Apr 8, 2024
46ccbb2
changes in the parachain-polkadot bin to enable offchain worker
gpestana Apr 10, 2024
c966f80
enables offchain worker in the client
gpestana Apr 10, 2024
7c82265
uses async wrap up for the unsigned election
gpestana Apr 10, 2024
1b87b06
cleanup
gpestana Apr 11, 2024
76d1e42
clears local cache unsigned
gpestana Apr 15, 2024
0708f08
adds more tests
gpestana Apr 16, 2024
82b3e8e
Adds tests
gpestana Apr 23, 2024
e617589
fixes unsigned election; disable desired_winners check for now
gpestana Apr 25, 2024
da35ce8
refactors and adds more tests; docs improvements
gpestana Apr 26, 2024
c3b42ec
more tests for signed pallet + docs
gpestana Apr 27, 2024
e5f8e6c
rustdoc compiling
gpestana Apr 27, 2024
c91cefc
more comments
gpestana Apr 27, 2024
9e067bf
adds validators in genesis
gpestana Apr 30, 2024
f783ba0
runtime fixes
gpestana Apr 30, 2024
2c853f8
Merge branch 'master' into staking-parachain-exp
gpestana Apr 30, 2024
ef8aecc
Merge branch 'master' into staking-parachain-exp
gpestana Apr 30, 2024
688d3d5
Merge branch 'master' into staking-parachain-exp
gpestana May 1, 2024
f9f3096
parachain working after merge with master; removes westend staking
gpestana May 1, 2024
fafc9dd
Adds template-based parachain test setup for staking
gpestana May 1, 2024
dae4da4
chainspec gen
gpestana May 2, 2024
ae742ba
clean up chain spec
gpestana May 2, 2024
73380db
all working now
gpestana May 5, 2024
169e0eb
config nits for pov testing
gpestana May 6, 2024
4dede9c
dedicated block for target snapshot; config nits
gpestana May 7, 2024
950432a
benchmarking
gpestana Aug 5, 2024
6cccd38
Merge branch 'master' into staking-parachain-exp_merged
gpestana Aug 5, 2024
70dc0a2
nits to build node and runtime
gpestana Aug 5, 2024
02479d5
adds weights from benchs to EPM pallets
gpestana Aug 7, 2024
06eec4f
basis for EPM with multiblock
gpestana Aug 9, 2024
6cdd117
runtimes compiling with MB multiphase
gpestana Aug 9, 2024
695d576
bench fixes
gpestana Aug 14, 2024
9971994
Merge branch 'master' into staking-parachain-exp
gpestana Aug 14, 2024
43ef8ac
fixes some runtimes etc
gpestana Aug 14, 2024
e72dabd
".git/.scripts/commands/fmt/fmt.sh"
Aug 14, 2024
997c114
ensures EPM-MB integration tests build
gpestana Aug 14, 2024
8bf5345
adds to EPM-MB pallet stack to polkadot-sdk runtime
gpestana Aug 20, 2024
6b3f531
Merge branch 'master' into staking-parachain-exp
gpestana Aug 20, 2024
44c3571
fixes paged election to paged exposures conversion
gpestana Aug 28, 2024
5b81cea
bunch of things
gpestana Sep 3, 2024
44a02ea
logs
gpestana Sep 3, 2024
8554ca5
adds stuff
gpestana Sep 13, 2024
dbeefb3
reliability nit fix and final POV setup experiments
gpestana Sep 16, 2024
5875c7f
adds realistic measurement; nits
gpestana Sep 17, 2024
d6070c6
tests
gpestana Oct 1, 2024
a54b505
WIP: Adds `MinerConfig` for staking-miner (#5983)
gpestana Oct 12, 2024
a0652f9
Merge branch 'staking-parachain-exp' of github.com:paritytech/polkado…
gpestana Oct 12, 2024
500f483
configs nits
gpestana Oct 12, 2024
ced85e0
Merge branch 'master' into staking-parachain-exp-merge
gpestana Oct 12, 2024
8d8541d
adds miner config to westendpolkadot
gpestana Oct 13, 2024
bda47bd
fix nits after merge
gpestana Oct 13, 2024
7561caa
init: adds EPM-MB, multipaged types and primitives
gpestana Oct 13, 2024
dca655b
refactors staking pallet with new paginated types
gpestana Oct 13, 2024
d1712ba
refactors election-multiphase pallet with new paginated types
gpestana Oct 13, 2024
d362ed7
adds ElectionProvider::ongoing to trait and impls
gpestana Oct 14, 2024
f431339
nits for dependent pallets
gpestana Oct 14, 2024
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
3,534 changes: 1,809 additions & 1,725 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,10 @@ members = [
"substrate/frame/core-fellowship",
"substrate/frame/delegated-staking",
"substrate/frame/democracy",
"substrate/frame/election-provider-multi-block",
"substrate/frame/election-provider-multi-block/integration-tests",
"substrate/frame/election-provider-multi-phase",
"substrate/frame/election-provider-multi-phase/test-staking-e2e",
#"substrate/frame/election-provider-multi-phase/test-staking-e2e",
"substrate/frame/election-provider-support",
"substrate/frame/election-provider-support/benchmarking",
"substrate/frame/election-provider-support/solution-type",
Expand Down Expand Up @@ -911,6 +913,7 @@ pallet-default-config-example = { path = "substrate/frame/examples/default-confi
pallet-delegated-staking = { path = "substrate/frame/delegated-staking", default-features = false }
pallet-democracy = { path = "substrate/frame/democracy", default-features = false }
pallet-dev-mode = { path = "substrate/frame/examples/dev-mode", default-features = false }
pallet-election-provider-multi-block = { path = "substrate/frame/election-provider-multi-block", default-features = false }
pallet-election-provider-multi-phase = { path = "substrate/frame/election-provider-multi-phase", default-features = false }
pallet-election-provider-support-benchmarking = { path = "substrate/frame/election-provider-support/benchmarking", default-features = false }
pallet-elections-phragmen = { path = "substrate/frame/elections-phragmen", default-features = false }
Expand Down Expand Up @@ -997,7 +1000,6 @@ pallet-xcm-benchmarks = { path = "polkadot/xcm/pallet-xcm-benchmarks", default-f
pallet-xcm-bridge-hub = { path = "bridges/modules/xcm-bridge-hub", default-features = false }
pallet-xcm-bridge-hub-router = { path = "bridges/modules/xcm-bridge-hub-router", default-features = false }
parachain-info = { path = "cumulus/parachains/pallets/parachain-info", default-features = false, package = "staging-parachain-info" }
parachain-template-runtime = { path = "templates/parachain/runtime" }
parachains-common = { path = "cumulus/parachains/common", default-features = false }
parachains-relay = { path = "bridges/relays/parachains" }
parachains-runtimes-test-utils = { path = "cumulus/parachains/runtimes/test-utils", default-features = false }
Expand Down Expand Up @@ -1279,6 +1281,8 @@ spinners = { version = "4.1.1" }
ss58-registry = { version = "1.34.0", default-features = false }
ssz_rs = { version = "0.9.0", default-features = false }
ssz_rs_derive = { version = "0.9.0", default-features = false }
staking-rococo-runtime = { path = "cumulus/parachains/runtimes/staking/staking-rococo" }
staking-runtime = { path = "templates/parachain/runtime" }
static_assertions = { version = "1.1.0", default-features = false }
static_init = { version = "1.0.3" }
structopt = { version = "0.3" }
Expand Down
16 changes: 15 additions & 1 deletion cumulus/client/consensus/aura/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,26 @@ where
{
tracing::info!(
target: crate::LOG_TARGET,
"PoV size {{ header: {}kb, extrinsics: {}kb, storage_proof: {}kb }}",
"PoV size {{ header: {}kb, extrinsics: {}kb, storage_proof: {}kb }} (max storage_proof: {}kb)",
block_data.header().encode().len() as f64 / 1024f64,
block_data.extrinsics().encode().len() as f64 / 1024f64,
block_data.storage_proof().encode().len() as f64 / 1024f64,
max_pov_size as f64 / 1024f64,
);

// if storage proof > max_pov_size, log and panic as inclusion will not work.
if block_data.storage_proof().encode().len() > max_pov_size {
tracing::error!(
target: crate::LOG_TARGET,
"\n\n ⚠️ ⚠️ PoV STORAGE PROOF OVER LIMIT ({:?}kb > {:?}kb, ie. {:?}% overflow)\n",
block_data.storage_proof().encode().len() as f64 / 1024f64,
max_pov_size as f64 / 1024f64,
(block_data.storage_proof().encode().len() * 100 / max_pov_size),

);
panic!("chain bricked due to PoV limits");
}

if let MaybeCompressedPoV::Compressed(ref pov) = collation.proof_of_validity {
tracing::info!(
target: crate::LOG_TARGET,
Expand Down
84 changes: 84 additions & 0 deletions cumulus/parachains/chain-specs/staking-rococo.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions cumulus/parachains/runtimes/staking/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Staking Parachain

*Note: the Staking Parachain implementation is still in experimental phase. Both design and
implementation is fluid and may change at any time. See <https://hackmd.io/okXqe3csRd2Qmo6eXCNQ3Q>
for more information on the design decisions.*

Implementation of Staking Chain, a blockchain to support staking in the Polkadot and Kusama
networks.

**Staking Chain allows users to**:

- Teleport DOT from Asset Hub to use as staking funds (native staking).
- Use reserved DOT asset in Asset Hub as staking funds (remote staking).
- Set the intent to become a validator.
- Set the intent to become a nominator and/or join nomination pools.
- Stake assets natively and remotely through the Assets Hub.

### Staking Chain and Assets Hub

The Staking Chain provides the following information to the Assets Hub:

- When to mint a new batch of inflation DOT tokens.
- The previous era durantion and the overall amount of staked DOT.

### Staking Chain and Relay Chain:

The Staking Chain provides the following information to the Relay Chain:

- When a new validator set should be enabled.
- Which validators should be part of the new validator set.
- Which active validators should be disabled (due to offence).

The Staking Chain receives the following information from the Relay Chain:

- Reward points for block authors.
- Validator offences.

Staking Chain must stay fully aligned with the Realy Chain it is connected to. As such, it will
accept the Relay Chain's governance as its own. In addition, we assume that the Relay Chain trusts
the Staking Chain, namely when the Stackin Chain:

- Announces a new set active validators.
- Processes offences and applies slashes.
- Accounces the staked amount, era duration and transition when calculating the inflation minting.

### Reserving Assets on Staking Chain

System parachains (e.g. governance) may reserve native DOT assets from the Staking Chain to use
locally.
70 changes: 70 additions & 0 deletions cumulus/parachains/runtimes/staking/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[package]
name = "staking-common"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
description = "Staking common utilities"
license = "Apache-2.0"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
log = { version = "0.4.20", default-features = false }
impl-trait-for-tuples = "0.2.2"

# Substrate
frame-support = { path = "../../../../../substrate/frame/support", default-features = false }
sp-api = { path = "../../../../../substrate/primitives/api", default-features = false }
sp-std = { path = "../../../../../substrate/primitives/std", default-features = false }
sp-runtime = { path = "../../../../../substrate/primitives/runtime", default-features = false }
sp-core = { path = "../../../../../substrate/primitives/core", default-features = false }
sp-staking = { path = "../../../../../substrate/primitives/staking", default-features = false, features = ["serde"] }
pallet-staking = { path = "../../../../../substrate/frame/staking", default-features = false }
pallet-election-provider-multi-block = { path = "../../../../../substrate/frame/election-provider-multi-block", default-features = false }

# Polkadot
pallet-xcm = { path = "../../../../../polkadot/xcm/pallet-xcm", default-features = false }
xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false }
xcm-builder = { package = "staging-xcm-builder", path = "../../../../../polkadot/xcm/xcm-builder", default-features = false }
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../polkadot/xcm/xcm-executor", default-features = false }

# Cumulus
parachains-common = { path = "../../../common", default-features = false }
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }

[build-dependencies]
substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder" }

[features]
default = ["std"]
std = [
"codec/std",
"cumulus-primitives-core/std",
"frame-support/std",
"log/std",
"pallet-election-provider-multi-block/std",
"pallet-staking/std",
"pallet-xcm/std",
"parachains-common/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]

runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]
53 changes: 53 additions & 0 deletions cumulus/parachains/runtimes/staking/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::traits::ConstU32;
use parachains_common::Balance;

/// The type used for currency conversion.
///
/// This must only be used as long as the balance type is `u128`.
pub type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;

pub type VoterIndex = u32;
pub type TargetIndex = u16;

/// Convert a balance to an unsigned 256-bit number, use in nomination pools.
pub struct BalanceToU256;
impl sp_runtime::traits::Convert<Balance, sp_core::U256> for BalanceToU256 {
fn convert(n: Balance) -> sp_core::U256 {
n.into()
}
}

/// Convert an unsigned 256-bit number to balance, use in nomination pools.
pub struct U256ToBalance;
impl sp_runtime::traits::Convert<sp_core::U256, Balance> for U256ToBalance {
fn convert(n: sp_core::U256) -> Balance {
use frame_support::traits::Defensive;
n.try_into().defensive_unwrap_or(Balance::MAX)
}
}

/// A reasonable benchmarking config for staking pallet.
pub struct StakingBenchmarkingConfig;
impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
type MaxValidators = ConstU32<1000>;
type MaxNominators = ConstU32<1000>;
}

pub type OnChainAccuracy = sp_runtime::Perbill;
Loading