Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kitchensink chain: Add BEEFY support #2856

Merged
merged 6 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
9 changes: 9 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions substrate/bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ rand = "0.8"
# primitives
sp-authority-discovery = { path = "../../../primitives/authority-discovery" }
sp-consensus-babe = { path = "../../../primitives/consensus/babe" }
beefy-primitives = { package = "sp-consensus-beefy", path = "../../../primitives/consensus/beefy" }
grandpa-primitives = { package = "sp-consensus-grandpa", path = "../../../primitives/consensus/grandpa" }
sp-api = { path = "../../../primitives/api" }
sp-core = { path = "../../../primitives/core" }
Expand All @@ -64,6 +65,7 @@ sp-consensus = { path = "../../../primitives/consensus/common" }
sp-transaction-storage-proof = { path = "../../../primitives/transaction-storage-proof" }
sp-io = { path = "../../../primitives/io" }
sp-mixnet = { path = "../../../primitives/mixnet" }
sp-mmr-primitives = { path = "../../../primitives/merkle-mountain-range" }
sp-statement-store = { path = "../../../primitives/statement-store" }

# client dependencies
Expand All @@ -79,7 +81,9 @@ sc-network-sync = { path = "../../../client/network/sync" }
sc-network-statement = { path = "../../../client/network/statement" }
sc-consensus-slots = { path = "../../../client/consensus/slots" }
sc-consensus-babe = { path = "../../../client/consensus/babe" }
beefy = { package = "sc-consensus-beefy", path = "../../../client/consensus/beefy" }
grandpa = { package = "sc-consensus-grandpa", path = "../../../client/consensus/grandpa" }
mmr-gadget = { path = "../../../client/merkle-mountain-range" }
sc-rpc = { path = "../../../client/rpc" }
sc-basic-authorship = { path = "../../../client/basic-authorship" }
sc-service = { path = "../../../client/service", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
wasm_runtime_overrides: None,
};

node_cli::service::new_full_base(config, None, false, |_, _| ())
node_cli::service::new_full_base(config, None, false, false, |_, _| ())
.expect("creating a full node doesn't fail")
}

Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/cli/benches/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
wasm_runtime_overrides: None,
};

node_cli::service::new_full_base(config, None, false, |_, _| ()).expect("Creates node")
node_cli::service::new_full_base(config, None, false, false, |_, _| ()).expect("Creates node")
}

fn create_accounts(num: usize) -> Vec<sr25519::Pair> {
Expand Down
56 changes: 49 additions & 7 deletions substrate/bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

//! Substrate chain configurations.

use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
use grandpa_primitives::AuthorityId as GrandpaId;
use kitchensink_runtime::{
constants::currency::*, wasm_binary_unwrap, Block, MaxNominations, SessionKeys, StakerStatus,
Expand Down Expand Up @@ -73,23 +74,37 @@ fn session_keys(
im_online: ImOnlineId,
authority_discovery: AuthorityDiscoveryId,
mixnet: MixnetId,
beefy: BeefyId,
) -> SessionKeys {
SessionKeys { grandpa, babe, im_online, authority_discovery, mixnet }
SessionKeys { grandpa, babe, im_online, authority_discovery, mixnet, beefy }
}

fn configure_accounts_for_staging_testnet() -> (
Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId, MixnetId)>,
Vec<(
AccountId,
AccountId,
GrandpaId,
BabeId,
ImOnlineId,
AuthorityDiscoveryId,
MixnetId,
BeefyId,
)>,
AccountId,
Vec<AccountId>,
) {
#[rustfmt::skip]
// stash, controller, session-key
// stash, controller, session-key, beefy id
// generated with secret:
// for i in 1 2 3 4 ; do for j in stash controller; do subkey inspect "$secret"/fir/$j/$i; done; done
//
// and
//
// for i in 1 2 3 4 ; do for j in session; do subkey --ed25519 inspect "$secret"//fir//$j//$i; done; done
// for i in 1 2 3 4 ; do for j in session; do subkey inspect --scheme ed25519 "$secret"//fir//$j//$i; done; done
//
// and
//
// for i in 1 2 3 4 ; do for j in session; do subkey inspect --scheme ecdsa "$secret"//fir//$j//$i; done; done

let initial_authorities: Vec<(
AccountId,
Expand All @@ -99,6 +114,7 @@ fn configure_accounts_for_staging_testnet() -> (
ImOnlineId,
AuthorityDiscoveryId,
MixnetId,
BeefyId,
)> = vec![
(
// 5Fbsd6WXDGiLTxunqeK5BATNiocfCqu9bS1yArVjCgeBLkVy
Expand All @@ -120,6 +136,9 @@ fn configure_accounts_for_staging_testnet() -> (
// 5EZaeQ8djPcq9pheJUhgerXQZt9YaHnMJpiHMRhwQeinqUW8
array_bytes::hex2array_unchecked("6e7e4eb42cbd2e0ab4cae8708ce5509580b8c04d11f6758dbf686d50fe9f9106")
.unchecked_into(),
// 5DMLFcDdLLQbw696YfHaWBpQR99HwR456ycSCfr6L7KXGYK8
array_bytes::hex2array_unchecked("035560fafa241739869360aa4b32bc98953172ceb41a19c6cc1a27962fb3d1ecec")
.unchecked_into(),
),
(
// 5ERawXCzCWkjVq3xz1W5KGNtVx2VdefvZ62Bw1FEuZW4Vny2
Expand All @@ -141,6 +160,9 @@ fn configure_accounts_for_staging_testnet() -> (
// 5DhLtiaQd1L1LU9jaNeeu9HJkP6eyg3BwXA7iNMzKm7qqruQ
array_bytes::hex2array_unchecked("482dbd7297a39fa145c570552249c2ca9dd47e281f0c500c971b59c9dcdcd82e")
.unchecked_into(),
// 5FYk11kNtB4178wLKJ2RNoUzzcjgRUciFe3SJDVZXhqX4dzG
array_bytes::hex2array_unchecked("02da1ab255ed888ee3e19b73d335fc13160b3eb10456c2d17c6a8ea7de403d2445")
.unchecked_into(),
),
(
// 5DyVtKWPidondEu8iHZgi6Ffv9yrJJ1NDNLom3X9cTDi98qp
Expand All @@ -162,6 +184,9 @@ fn configure_accounts_for_staging_testnet() -> (
// 5DhKqkHRkndJu8vq7pi2Q5S3DfftWJHGxbEUNH43b46qNspH
array_bytes::hex2array_unchecked("482a3389a6cf42d8ed83888cfd920fec738ea30f97e44699ada7323f08c3380a")
.unchecked_into(),
// 5GQx4FToRBPqfani6o7owFJE1UstiviqbPP7HPWyvtXWWukn
array_bytes::hex2array_unchecked("036a818b3f59579c5fbbe4fede64f49dbf090ba883eb2a175d5ca90e5adb5f0b3e")
.unchecked_into(),
),
(
// 5HYZnKWe5FVZQ33ZRJK1rG3WaLMztxWrrNDb1JRwaHHVWyP9
Expand All @@ -183,6 +208,9 @@ fn configure_accounts_for_staging_testnet() -> (
// 5C4vDQxA8LTck2xJEy4Yg1hM9qjDt4LvTQaMo4Y8ne43aU6x
array_bytes::hex2array_unchecked("00299981a2b92f878baaf5dbeba5c18d4e70f2a1fcd9c61b32ea18daf38f4378")
.unchecked_into(),
// 5FCu2pY928VVHPgnNVJssvxFJZECyNe1CyH3WTG79Wisx58B
array_bytes::hex2array_unchecked("020ce02b963548f9f8ade8765f7a4a06638c17819c78422a1cc35b647873583eef")
.unchecked_into(),
),
];

Expand Down Expand Up @@ -234,7 +262,8 @@ where
/// Helper function to generate stash, controller and session key from seed.
pub fn authority_keys_from_seed(
seed: &str,
) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId, MixnetId) {
) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId, MixnetId, BeefyId)
{
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
Expand All @@ -243,6 +272,7 @@ pub fn authority_keys_from_seed(
get_from_seed::<ImOnlineId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
get_from_seed::<MixnetId>(seed),
get_from_seed::<BeefyId>(seed),
)
}

Expand All @@ -255,12 +285,22 @@ fn configure_accounts(
ImOnlineId,
AuthorityDiscoveryId,
MixnetId,
BeefyId,
)>,
initial_nominators: Vec<AccountId>,
endowed_accounts: Option<Vec<AccountId>>,
stash: Balance,
) -> (
Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId, MixnetId)>,
Vec<(
AccountId,
AccountId,
GrandpaId,
BabeId,
ImOnlineId,
AuthorityDiscoveryId,
MixnetId,
BeefyId,
)>,
Vec<AccountId>,
usize,
Vec<(AccountId, AccountId, Balance, StakerStatus<AccountId>)>,
Expand Down Expand Up @@ -326,6 +366,7 @@ pub fn testnet_genesis(
ImOnlineId,
AuthorityDiscoveryId,
MixnetId,
BeefyId,
)>,
initial_nominators: Vec<AccountId>,
root_key: AccountId,
Expand All @@ -351,6 +392,7 @@ pub fn testnet_genesis(
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
),
)
})
Expand Down Expand Up @@ -471,7 +513,7 @@ pub(crate) mod tests {

sc_service_test::connectivity(integration_test_config_with_two_authorities(), |config| {
let NewFullBase { task_manager, client, network, sync, transaction_pool, .. } =
new_full_base(config, None, false, |_, _| ())?;
new_full_base(config, None, false, false, |_, _| ())?;
Ok(sc_service_test::TestNetComponents::new(
task_manager,
client,
Expand Down
6 changes: 6 additions & 0 deletions substrate/bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ pub struct Cli {
#[arg(long)]
pub no_hardware_benchmarks: bool,

/// Disable the BEEFY gadget.
///
/// Currently enabled by default.
#[arg(long)]
pub no_beefy: bool,
serban300 marked this conversation as resolved.
Show resolved Hide resolved

#[allow(missing_docs)]
#[clap(flatten)]
pub storage_monitor: sc_storage_monitor::StorageMonitorParams,
Expand Down
Loading