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

[Don't merge] Update the solochain template to stable2412 #16

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
10,969 changes: 0 additions & 10,969 deletions Cargo.lock

This file was deleted.

104 changes: 52 additions & 52 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,59 @@ resolver = "2"
[workspace.dependencies]
solochain-template-runtime = { path = "./runtime", default-features = false }
pallet-template = { path = "./pallets/template", default-features = false }
clap = { version = "4.5.10" }
frame-benchmarking-cli = { version = "43.0.0", default-features = false }
frame-metadata-hash-extension = { version = "0.6.0", default-features = false }
frame-system = { version = "38.0.0", default-features = false }
futures = { version = "0.3.30" }
clap = { version = "4.5.13" }
frame-benchmarking-cli = { version = "32.0.0", default-features = false }
frame-metadata-hash-extension = { version = "0.1.0", default-features = false }
frame-system = { version = "28.0.0", default-features = false }
futures = { version = "0.3.31" }
jsonrpsee = { version = "0.24.3" }
pallet-transaction-payment = { version = "38.0.0", default-features = false }
pallet-transaction-payment-rpc = { version = "41.0.0", default-features = false }
sc-basic-authorship = { version = "0.45.0", default-features = false }
sc-cli = { version = "0.47.0", default-features = false }
sc-client-api = { version = "37.0.0", default-features = false }
sc-consensus = { version = "0.44.0", default-features = false }
sc-consensus-aura = { version = "0.45.0", default-features = false }
sc-consensus-grandpa = { version = "0.30.0", default-features = false }
sc-executor = { version = "0.40.1", default-features = false }
sc-network = { version = "0.45.0", default-features = false }
sc-offchain = { version = "40.0.0", default-features = false }
sc-service = { version = "0.46.0", default-features = false }
sc-telemetry = { version = "25.0.0", default-features = false }
sc-transaction-pool = { version = "37.0.0", default-features = false }
sc-transaction-pool-api = { version = "37.0.0", default-features = false }
serde_json = { version = "1.0.127", default-features = false }
sp-api = { version = "34.0.0", default-features = false }
sp-block-builder = { version = "34.0.0", default-features = false }
sp-blockchain = { version = "37.0.1", default-features = false }
sp-consensus-aura = { version = "0.40.0", default-features = false }
sp-consensus-grandpa = { version = "21.0.0", default-features = false }
sp-core = { version = "34.0.0", default-features = false }
sp-inherents = { version = "34.0.0", default-features = false }
sp-io = { version = "38.0.0", default-features = false }
sp-keyring = { version = "39.0.0", default-features = false }
sp-runtime = { version = "39.0.1", default-features = false }
sp-timestamp = { version = "34.0.0", default-features = false }
substrate-frame-rpc-system = { version = "39.0.0", default-features = false }
pallet-transaction-payment = { version = "28.0.0", default-features = false }
pallet-transaction-payment-rpc = { version = "30.0.0", default-features = false }
sc-basic-authorship = { version = "0.34.0", default-features = false }
sc-cli = { version = "0.36.0", default-features = false }
sc-client-api = { version = "28.0.0", default-features = false }
sc-consensus = { version = "0.33.0", default-features = false }
sc-consensus-aura = { version = "0.34.0", default-features = false }
sc-consensus-grandpa = { version = "0.19.0", default-features = false }
sc-executor = { version = "0.32.0", default-features = false }
sc-network = { version = "0.34.0", default-features = false }
sc-offchain = { version = "29.0.0", default-features = false }
sc-service = { version = "0.35.0", default-features = false }
sc-telemetry = { version = "15.0.0", default-features = false }
sc-transaction-pool = { version = "28.0.0", default-features = false }
sc-transaction-pool-api = { version = "28.0.0", default-features = false }
serde_json = { version = "1.0.132", default-features = false }
sp-api = { version = "26.0.0", default-features = false }
sp-block-builder = { version = "26.0.0", default-features = false }
sp-blockchain = { version = "28.0.0", default-features = false }
sp-consensus-aura = { version = "0.32.0", default-features = false }
sp-consensus-grandpa = { version = "13.0.0", default-features = false }
sp-core = { version = "28.0.0", default-features = false }
sp-genesis-builder = { version = "0.8.0", default-features = false }
sp-inherents = { version = "26.0.0", default-features = false }
sp-io = { version = "30.0.0", default-features = false }
sp-keyring = { version = "31.0.0", default-features = false }
sp-runtime = { version = "31.0.1", default-features = false }
sp-timestamp = { version = "26.0.0", default-features = false }
substrate-frame-rpc-system = { version = "28.0.0", default-features = false }
substrate-build-script-utils = { version = "11.0.0", default-features = false }
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
frame-benchmarking = { version = "38.0.0", default-features = false }
frame-executive = { version = "38.0.0", default-features = false }
frame-support = { version = "38.0.0", default-features = false }
frame-system-benchmarking = { version = "38.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "34.0.0", default-features = false }
frame-try-runtime = { version = "0.44.0", default-features = false }
pallet-aura = { version = "37.0.0", default-features = false }
pallet-balances = { version = "39.0.0", default-features = false }
pallet-grandpa = { version = "38.0.0", default-features = false }
pallet-sudo = { version = "38.0.0", default-features = false }
pallet-timestamp = { version = "37.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "38.0.0", default-features = false }
frame-benchmarking = { version = "28.0.0", default-features = false }
frame-executive = { version = "28.0.0", default-features = false }
frame-support = { version = "28.0.0", default-features = false }
frame-system-benchmarking = { version = "28.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "26.0.0", default-features = false }
frame-try-runtime = { version = "0.34.0", default-features = false }
pallet-aura = { version = "27.0.0", default-features = false }
pallet-balances = { version = "28.0.0", default-features = false }
pallet-grandpa = { version = "28.0.0", default-features = false }
pallet-sudo = { version = "28.0.0", default-features = false }
pallet-timestamp = { version = "27.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "28.0.0", default-features = false }
scale-info = { version = "2.11.1", default-features = false }
sp-genesis-builder = { version = "0.15.1", default-features = false }
sp-offchain = { version = "34.0.0", default-features = false }
sp-session = { version = "36.0.0", default-features = false }
sp-storage = { version = "21.0.0", default-features = false }
sp-transaction-pool = { version = "34.0.0", default-features = false }
sp-version = { version = "37.0.0", default-features = false }
substrate-wasm-builder = { version = "24.0.1", default-features = false }
sp-offchain = { version = "26.0.0", default-features = false }
sp-session = { version = "27.0.0", default-features = false }
sp-storage = { version = "19.0.0", default-features = false }
sp-transaction-pool = { version = "26.0.0", default-features = false }
sp-version = { version = "29.0.0", default-features = false }
substrate-wasm-builder = { version = "17.0.0", default-features = false }
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ packages required to compile this template. Check the
the most common dependencies. Alternatively, you can use one of the [alternative
installation](#alternatives-installations) options.

Fetch solochain template code:

```sh
git clone https://github.com/paritytech/polkadot-sdk-solochain-template.git solochain-template

cd solochain-template
```

### Build

Use the following command to build the node without launching it:
🔨 Use the following command to build the node without launching it:

```sh
cargo build --release
Expand Down Expand Up @@ -177,7 +185,7 @@ template and note the following:
configuration is defined by a code block that begins with `impl
$PALLET_NAME::Config for Runtime`.
- The pallets are composed into a single runtime by way of the
[`construct_runtime!`](https://paritytech.github.io/substrate/master/frame_support/macro.construct_runtime.html)
[#[runtime]](https://paritytech.github.io/polkadot-sdk/master/frame_support/attr.runtime.html)
macro, which is part of the [core FRAME pallet
library](https://docs.substrate.io/reference/frame-pallets/#system-pallets).

Expand Down
11 changes: 6 additions & 5 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ sc-transaction-pool-api.workspace = true
sc-transaction-pool-api.default-features = true
sc-offchain.workspace = true
sc-offchain.default-features = true
sc-consensus.workspace = true
sc-consensus.default-features = true
sc-consensus-aura.workspace = true
sc-consensus-aura.default-features = true
sp-consensus-aura.workspace = true
sp-consensus-aura.default-features = true
sc-consensus.workspace = true
sc-consensus.default-features = true
sc-consensus-grandpa.workspace = true
sc-consensus-grandpa.default-features = true
sp-consensus-grandpa.workspace = true
sp-consensus-grandpa.default-features = true
sp-genesis-builder.workspace = true
sp-genesis-builder.default-features = true
sc-client-api.workspace = true
sc-client-api.default-features = true
sc-basic-authorship.workspace = true
Expand Down Expand Up @@ -87,13 +89,12 @@ substrate-build-script-utils.default-features = true

[features]
default = ["std"]
std = [
"solochain-template-runtime/std",
]
std = ["solochain-template-runtime/std"]
# Dependencies that are only required if runtime benchmarking should be build.
runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"solochain-template-runtime/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
Expand Down
2 changes: 1 addition & 1 deletion node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Release

Polkadot SDK stable2409
Polkadot SDK Stable 2412
6 changes: 3 additions & 3 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub fn create_benchmark_extrinsic(
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let extra: runtime::SignedExtra = (
let tx_ext: runtime::TxExtension = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
Expand All @@ -126,7 +126,7 @@ pub fn create_benchmark_extrinsic(

let raw_payload = runtime::SignedPayload::from_raw(
call.clone(),
extra.clone(),
tx_ext.clone(),
(
(),
runtime::VERSION.spec_version,
Expand All @@ -145,7 +145,7 @@ pub fn create_benchmark_extrinsic(
call,
sp_runtime::AccountId32::from(sender.public()).into(),
runtime::Signature::Sr25519(signature),
extra,
tx_ext,
)
}

Expand Down
98 changes: 5 additions & 93 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,117 +1,29 @@
use sc_service::ChainType;
use solochain_template_runtime::{AccountId, Signature, WASM_BINARY};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};

// The URL for the telemetry server.
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
use solochain_template_runtime::WASM_BINARY;

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

/// Generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}

type AccountPublic = <Signature as Verify>::Signer;

/// Generate an account ID from seed.
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}

/// Generate an Aura authority key.
pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
(get_from_seed::<AuraId>(s), get_from_seed::<GrandpaId>(s))
}

pub fn development_config() -> Result<ChainSpec, String> {
pub fn development_chain_spec() -> Result<ChainSpec, String> {
Ok(ChainSpec::builder(
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
None,
)
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(testnet_genesis(
// Initial PoA authorities
vec![authority_keys_from_seed("Alice")],
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
// Pre-funded accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
true,
))
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.build())
}

pub fn local_testnet_config() -> Result<ChainSpec, String> {
pub fn local_chain_spec() -> Result<ChainSpec, String> {
Ok(ChainSpec::builder(
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
None,
)
.with_name("Local Testnet")
.with_id("local_testnet")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(testnet_genesis(
// Initial PoA authorities
vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
// Pre-funded accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
true,
))
.with_genesis_config_preset_name(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
.build())
}

/// Configure initial storage state for FRAME modules.
fn testnet_genesis(
initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
) -> serde_json::Value {
serde_json::json!({
"balances": {
// Configure endowed accounts with initial balance of 1 << 60.
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
"aura": {
"authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::<Vec<_>>(),
},
"grandpa": {
"authorities": initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect::<Vec<_>>(),
},
"sudo": {
// Assign network admin rights.
"key": Some(root_key),
},
})
}
7 changes: 4 additions & 3 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ impl SubstrateCli for Cli {

fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()?),
"" | "local" => Box::new(chain_spec::local_testnet_config()?),
"dev" => Box::new(chain_spec::development_chain_spec()?),
"" | "local" => Box::new(chain_spec::local_chain_spec()?),
path =>
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
Expand Down Expand Up @@ -144,11 +144,12 @@ pub fn run() -> sc_cli::Result<()> {
let ext_builder = RemarkBuilder::new(client.clone());

cmd.run(
config,
config.chain_spec.name().into(),
client,
inherent_benchmark_data()?,
Vec::new(),
&ext_builder,
false,
)
},
BenchmarkCmd::Extrinsic(cmd) => {
Expand Down
Loading
Loading