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

chore: update deps in staking-miner-playground #773

Merged
merged 17 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5,566 changes: 2,746 additions & 2,820 deletions staking-miner-playground/Cargo.lock

Large diffs are not rendered by default.

79 changes: 39 additions & 40 deletions staking-miner-playground/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,61 @@ name = "staking-miner-playground"

[dependencies]
clap = { version = "4.0.9", features = ["derive"] }
futures = "0.3"
serde_json = "1"

frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-staking = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-consensus-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-telemetry = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
# polkadot-sdk
frame-system = { git = "https://github.com/paritytech/polkadot-sdk" }
pallet-staking = { git = "https://github.com/paritytech/polkadot-sdk" }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-cli = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-network = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-service = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk" }

# These dependencies are used for the node template's RPCs
jsonrpsee = { version = "0.16.2", features = ["server"] }
sc-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk" }
sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk" }
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk" }

# These dependencies are used for runtime benchmarking
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk" }

# Local Dependencies
node-template-runtime = { version = "4.0.0-dev", path = "../runtime" }

runtime = { version = "4.0.0-dev", path = "../runtime" }
lazy_static = "1.4.0"
rand = "0.8.5"

# CLI-specific dependencies
try-runtime-cli = { version = "0.10.0-dev", optional = true, git = "https://github.com/paritytech/substrate.git", branch = "master" }
try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", optional = true }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk" }

[features]
default = []
runtime-benchmarks = ["node-template-runtime/runtime-benchmarks"]
runtime-benchmarks = ["runtime/runtime-benchmarks"]
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
# in the near future.
try-runtime = ["node-template-runtime/try-runtime", "try-runtime-cli"]

try-runtime = ["runtime/try-runtime", "try-runtime-cli"]
49 changes: 21 additions & 28 deletions staking-miner-playground/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use node_template_runtime::{
opaque::SessionKeys, AccountId, AuraConfig, Balance, BalancesConfig, GenesisConfig,
GrandpaConfig, MaxNominations, SessionConfig, Signature, StakingConfig, SudoConfig,
SystemConfig, WASM_BINARY,
};
use pallet_staking::StakerStatus;
use rand::{distributions::Alphanumeric, rngs::OsRng, seq::SliceRandom, Rng};
use runtime::{
opaque::SessionKeys, AccountId, AuraConfig, Balance, BalancesConfig, GrandpaConfig,
MaxNominations, RuntimeGenesisConfig, SessionConfig, Signature, StakingConfig, SudoConfig,
SystemConfig, WASM_BINARY,
};
use sc_service::ChainType;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
Expand All @@ -18,7 +18,7 @@ lazy_static::lazy_static! {
}

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;

/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
Expand Down Expand Up @@ -50,38 +50,30 @@ pub fn authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) {
pub fn development_config() -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;

Ok(ChainSpec::from_genesis(
// Name
"Development",
// ID
"dev",
ChainType::Development,
move || testnet_genesis(wasm_binary, true),
vec![],
None,
None,
None,
None,
None,
))
let chain_spec = ChainSpec::builder(wasm_binary, Default::default())
.with_genesis_config_patch(testnet_genesis())
.with_chain_type(ChainType::Development)
.build();

Ok(chain_spec)
}

fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys {
SessionKeys { grandpa, aura }
}

/// Configure initial storage state for FRAME modules.
fn testnet_genesis(wasm_binary: &[u8], _enable_println: bool) -> GenesisConfig {
fn testnet_genesis() -> serde_json::Value {
let rand_str =
|| -> String { OsRng.sample_iter(&Alphanumeric).take(32).map(char::from).collect() };

let nominators: u32 = *NOMINATORS;
let validators: u32 = *VALIDATORS;
let candidates: u32 = *CANDIDATES;

let min_balance = node_template_runtime::voter_bags::EXISTENTIAL_WEIGHT as Balance;
let min_balance = runtime::voter_bags::EXISTENTIAL_WEIGHT as Balance;
let stash_min: Balance = min_balance;
let stash_max: Balance = **node_template_runtime::voter_bags::THRESHOLDS
let stash_max: Balance = **runtime::voter_bags::THRESHOLDS
.iter()
.skip(100)
.take(1)
Expand Down Expand Up @@ -151,8 +143,8 @@ fn testnet_genesis(wasm_binary: &[u8], _enable_println: bool) -> GenesisConfig {
}))
.collect::<Vec<_>>();

GenesisConfig {
system: SystemConfig { code: wasm_binary.to_vec() },
let genesis = RuntimeGenesisConfig {
system: SystemConfig::default(),
balances: BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, endowment)).collect(),
},
Expand All @@ -169,9 +161,10 @@ fn testnet_genesis(wasm_binary: &[u8], _enable_println: bool) -> GenesisConfig {
..Default::default()
},
aura: AuraConfig { authorities: vec![] },
grandpa: GrandpaConfig { authorities: vec![] },
grandpa: GrandpaConfig::default(),
sudo: SudoConfig { key: Some(root_key) },
transaction_payment: Default::default(),
config_block: Default::default(),
}
};

serde_json::to_value(&genesis).expect("Valid ChainSpec; qed")
}
8 changes: 2 additions & 6 deletions staking-miner-playground/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use node_template_runtime::Block;
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
use runtime::Block;
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;

impl SubstrateCli for Cli {
Expand Down Expand Up @@ -39,10 +39,6 @@ impl SubstrateCli for Cli {
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
&node_template_runtime::VERSION
}
}

/// Parse and run command line arguments
Expand Down
2 changes: 1 addition & 1 deletion staking-miner-playground/node/src/command_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use crate::service::FullClient;

use node_template_runtime as runtime;
use runtime;
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
use runtime::SystemCall;
use sc_cli::Result;
use sc_client_api::BlockBackend;
Expand Down
9 changes: 2 additions & 7 deletions staking-miner-playground/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use std::sync::Arc;

use jsonrpsee::RpcModule;
use node_template_runtime::{opaque::Block, AccountId, Balance, Index};
use runtime::{opaque::Block, AccountId, Balance, Nonce};
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
Expand All @@ -34,7 +34,7 @@ where
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
C: Send + Sync + 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
Expand All @@ -48,10 +48,5 @@ where
module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;

// Extend this RPC with a custom API by using the following syntax.
// `YourRpcStruct` should have a reference to a client, which is needed
// to call into the runtime.
// `module.merge(YourRpcTrait::into_rpc(YourRpcStruct::new(ReferenceToClient, ...)))?;`

Ok(module)
}
Loading