Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add Collectives Parachain #1346

Merged
merged 53 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
413b111
add new runtime and remove unnecessary pallets
joepetrowski May 23, 2022
f2e20ae
make runtime build
joepetrowski May 23, 2022
77f7d65
add collectives to collator node
joepetrowski May 23, 2022
75e7d74
sketch alliance config in runtime
joepetrowski May 23, 2022
0cb20d9
Slash handler was supposed to be commented out (for now)
joepetrowski May 23, 2022
f8843aa
correct signature
joepetrowski May 23, 2022
5e65175
move to impls
joepetrowski May 23, 2022
755f5f3
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jun 10, 2022
628cad6
add alliance to runtime
joepetrowski Jun 11, 2022
1b82389
rustfmt
joepetrowski Jun 11, 2022
3de8e69
IsReserve, remove Ping, update fn deposit
joepetrowski Jun 17, 2022
0d3a72f
merge master
joepetrowski Jun 17, 2022
0f82205
add transaction_payment event
joepetrowski Jun 17, 2022
5dededb
Update parachains/runtimes/collectives/collectives-polkadot/src/lib.rs
joepetrowski Jun 17, 2022
315560b
fmt
joepetrowski Jun 17, 2022
d0d190b
add genesis config to chain spec
joepetrowski Jun 17, 2022
408aedb
try merge master
joepetrowski Jun 17, 2022
24cdf21
fix merge
joepetrowski Jun 17, 2022
0461bb6
local and dev configs only (for now)
joepetrowski Jun 17, 2022
f2704ad
merge cargo.lock
joepetrowski Jun 17, 2022
3657e78
merge master
joepetrowski Jun 18, 2022
7413c46
remove duplicate imports
joepetrowski Jun 19, 2022
e4433f2
Collectives polkadot runtime to cargo workspace members (#1397)
muharem Jun 21, 2022
1b3440e
Collectives polkadot runtime: use unit type impl for identity verifie…
muharem Jun 21, 2022
b507e86
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jun 21, 2022
426b9d7
apply fn rename
joepetrowski Jun 21, 2022
2290b5b
fmt
joepetrowski Jun 21, 2022
db78514
Merge branch 'master' into joe-alliance
gilescope Jun 23, 2022
8adf0e5
one less todo
gilescope Jun 23, 2022
aeeaea5
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jun 29, 2022
cbf45d4
Less code in magic macros (#1407)
gilescope Jul 1, 2022
4a0662a
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Jul 7, 2022
26301ad
Bench alliance (#1427)
gilescope Jul 12, 2022
938a8b8
enable ci jobs
alvicsam Jul 12, 2022
6db029b
fix publish bench results jobs
alvicsam Jul 12, 2022
9163d64
Merge branch 'master' into joe-alliance
gilescope Jul 12, 2022
6d5d16e
chainspecs for collectives-westend (#1441)
gilescope Jul 19, 2022
60b48f0
lock
joepetrowski Jul 21, 2022
7061e23
merge master
joepetrowski Jul 21, 2022
6087ae8
Collectives: teleport slashed assets (#1433)
muharem Jul 21, 2022
4ea4992
Move alliance proposal provider to impls.rs (#1464)
muharem Jul 21, 2022
a36dc29
Bumping spec version
gilescope Jul 25, 2022
177783d
merge master
joepetrowski Aug 3, 2022
95f4d86
cargo lock
joepetrowski Aug 4, 2022
8d104b6
slurp collectives digest to make appear in release notes (#1473)
gilescope Aug 4, 2022
450e398
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Aug 9, 2022
4194b2e
reorder barrier
joepetrowski Aug 9, 2022
01107b2
Update parachains/runtimes/collectives/collectives-polkadot/src/xcm_c…
joepetrowski Aug 9, 2022
930a76a
Merge remote-tracking branch 'origin' into joe-alliance
joepetrowski Aug 11, 2022
659ecd3
address review
joepetrowski Aug 11, 2022
f5237a9
clean construct runtime
joepetrowski Aug 11, 2022
bc62984
fmt
joepetrowski Aug 11, 2022
c22d6b6
looks pretty but brings in too much
joepetrowski Aug 11, 2022
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
87 changes: 87 additions & 0 deletions Cargo.lock

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

17 changes: 17 additions & 0 deletions parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ where
}
}

/*
TODO:COLLECTIVES

pub struct ToParentTreasury<R>(PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToParentTreasury<R>
where
R: pallet_balances::Config,
AccountIdOf<R>:
From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
{
fn on_unbalanced(amount: NegativeImbalance<R>) {
polkadot_xcm::Pallet::<R>::teleport();
}
}
*/

/// Implementation of `OnUnbalanced` that deals with the fees by combining tip and fee and passing
/// the result on to `ToStakingPot`.
pub struct DealWithFees<R>(PhantomData<R>);
Expand Down
159 changes: 159 additions & 0 deletions parachains/runtimes/collectives/collectives-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
[package]
name = "collectives-polkadot-runtime"
version = "1.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
description = "Polkadot Collectives Parachain Runtime"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.17", default-features = false }
serde = { version = "1.0.137", optional = true, features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
smallvec = "1.6.1"

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" }
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "master" }
pallet-alliance = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }

# Polkadot
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }

# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0" }
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
cumulus-primitives-timestamp = { path = "../../../../primitives/timestamp", default-features = false }
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../common", default-features = false }

[dev-dependencies]
hex-literal = "0.3.4"

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }

[features]
default = [ "std" ]
runtime-benchmarks = [
"hex-literal",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking",
"frame-system/runtime-benchmarks",
"pallet-alliance/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
]
try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
]
std = [
"codec/std",
"log/std",
"scale-info/std",
"serde",
"frame-executive/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-alliance/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-collective/std",
"pallet-multisig/std",
"pallet-proxy/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-utility/std",
"pallet-xcm/std",
"polkadot-core-primitives/std",
"polkadot-parachain/std",
"polkadot-runtime-common/std",
"polkadot-runtime-constants/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-inherents/std",
"sp-io/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcm/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
"pallet-collator-selection/std",
"parachain-info/std",
"parachains-common/std",
]
9 changes: 9 additions & 0 deletions parachains/runtimes/collectives/collectives-polkadot/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use substrate_wasm_builder::WasmBuilder;

fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (C) 2021 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.

pub mod currency {
use polkadot_core_primitives::Balance;
use polkadot_runtime_constants as constants;

/// The existential deposit. Set to 1/10 of its parent Relay Chain (v9200).
joepetrowski marked this conversation as resolved.
Show resolved Hide resolved
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;

pub const UNITS: Balance = constants::currency::UNITS;
pub const DOLLARS: Balance = constants::currency::DOLLARS;
pub const CENTS: Balance = constants::currency::CENTS;
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
// 1/100 of Polkadot v9200
joepetrowski marked this conversation as resolved.
Show resolved Hide resolved
constants::currency::deposit(items, bytes) / 100
}
}

/// Fee-related.
pub mod fee {
use frame_support::weights::{
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial,
};
use polkadot_core_primitives::Balance;
use smallvec::smallvec;
pub use sp_runtime::Perbill;

/// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);

/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
/// node's balance type.
///
/// This should typically create a mapping between the following ranges:
/// - [0, MAXIMUM_BLOCK_WEIGHT]
/// - [Balance::min, Balance::max]
///
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
/// - Setting it to `0` will essentially disable the weight fee.
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
pub struct WeightToFee;
impl WeightToFeePolynomial for WeightToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
// in a parachain, we map to 1/10 of that, or 1/100 CENT
let p = super::currency::CENTS;
let q = 100 * Balance::from(ExtrinsicBaseWeight::get());
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}
}
Loading