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

Update the minimal template to stable2409 #19

Merged
merged 2 commits into from
Nov 5, 2024
Merged
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
17,011 changes: 12,509 additions & 4,502 deletions Cargo.lock

Large diffs are not rendered by default.

43 changes: 5 additions & 38 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,18 @@ repository = "https://github.com/paritytech/polkadot-sdk-minimal-template.git"
edition = "2021"

[workspace]
members = [
"node",
"pallets/template",
"runtime",
]
members = ["node", "pallets/template", "runtime"]
resolver = "2"

[workspace.dependencies]
minimal-template-runtime = { path = "./runtime", default-features = false }
pallet-minimal-template = { path = "./pallets/template", default-features = false }
clap = { version = "4.5.3" }
clap = { version = "4.5.10" }
docify = { version = "0.2.8" }
frame = { version = "0.6.0", default-features = false, package = "polkadot-sdk-frame" }
futures = { version = "0.3.30" }
futures-timer = { version = "3.0.2" }
jsonrpsee = { version = "0.23.2" }
sc-basic-authorship = { version = "0.44.0", default-features = false }
sc-cli = { version = "0.46.0", default-features = false }
sc-client-api = { version = "37.0.0", default-features = false }
sc-consensus = { version = "0.43.0", default-features = false }
sc-consensus-manual-seal = { version = "0.45.0", default-features = false }
sc-executor = { version = "0.40.0", default-features = false }
sc-network = { version = "0.44.0", default-features = false }
sc-offchain = { version = "39.0.0", default-features = false }
sc-rpc-api = { version = "0.43.0", default-features = false }
sc-service = { version = "0.45.0", default-features = false }
sc-telemetry = { version = "24.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.114", 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.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.0", default-features = false }
sp-timestamp = { version = "34.0.0", default-features = false }
substrate-frame-rpc-system = { version = "38.0.0", default-features = false }
substrate-build-script-utils = { version = "11.0.0", default-features = false }
jsonrpsee = { version = "0.24.3" }
polkadot-sdk = { version = "0.7.0", default-features = false }
serde_json = { version = "1.0.127", default-features = false }
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
pallet-balances = { version = "38.0.0", default-features = false }
pallet-sudo = { version = "37.0.0", default-features = false }
pallet-timestamp = { version = "36.0.0", default-features = false }
pallet-transaction-payment = { version = "37.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "37.0.0", default-features = false }
scale-info = { version = "2.11.1", default-features = false }
sp-genesis-builder = { version = "0.15.0", default-features = false }
substrate-wasm-builder = { version = "24.0.0", default-features = false }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages required to compile this template - please take note of the Rust compil
🔨 Use the following command to build the node without launching it:

```sh
cargo build --package minimal-template-node --release
cargo build --release
```

🐳 Alternatively, build the docker image:
Expand Down
50 changes: 4 additions & 46 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "minimal-template-node"
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.15.0)"
description = "A minimal Substrate-based Substrate node, ready for hacking."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
Expand All @@ -20,57 +20,15 @@ futures = { features = ["thread-pool"], workspace = true }
futures-timer = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
serde_json = { workspace = true, default-features = true }
sc-cli.workspace = true
sc-cli.default-features = true
sc-executor.workspace = true
sc-executor.default-features = true
sc-network.workspace = true
sc-network.default-features = true
sc-service.workspace = true
sc-service.default-features = true
sc-telemetry.workspace = true
sc-telemetry.default-features = true
sc-transaction-pool.workspace = true
sc-transaction-pool.default-features = true
sc-transaction-pool-api.workspace = true
sc-transaction-pool-api.default-features = true
sc-consensus.workspace = true
sc-consensus.default-features = true
sc-consensus-manual-seal.workspace = true
sc-consensus-manual-seal.default-features = true
sc-rpc-api.workspace = true
sc-rpc-api.default-features = true
sc-basic-authorship.workspace = true
sc-basic-authorship.default-features = true
sc-offchain.workspace = true
sc-offchain.default-features = true
sc-client-api.workspace = true
sc-client-api.default-features = true
sp-timestamp.workspace = true
sp-timestamp.default-features = true
sp-keyring.workspace = true
sp-keyring.default-features = true
sp-api.workspace = true
sp-api.default-features = true
sp-blockchain.workspace = true
sp-blockchain.default-features = true
sp-block-builder.workspace = true
sp-block-builder.default-features = true
sp-io.workspace = true
sp-io.default-features = true
sp-runtime.workspace = true
sp-runtime.default-features = true
substrate-frame-rpc-system.workspace = true
substrate-frame-rpc-system.default-features = true
frame = { features = ["experimental", "runtime"], workspace = true, default-features = true }
polkadot-sdk = { workspace = true, features = ["experimental", "node"] }
minimal-template-runtime.workspace = true

[build-dependencies]
substrate-build-script-utils.workspace = true
substrate-build-script-utils.default-features = true
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }

[features]
default = ["std"]
std = [
"minimal-template-runtime/std",
"polkadot-sdk/std",
]
5 changes: 5 additions & 0 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@
initial (genesis) state.
- [`service.rs`](./src/service.rs): This file defines the node implementation.
It's a place to configure consensus-related topics. In favor of minimalism, this template has no consensus configured.


## Release

Polkadot SDK stable2409
2 changes: 1 addition & 1 deletion node/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
use polkadot_sdk::substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
generate_cargo_keys();
Expand Down
9 changes: 6 additions & 3 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
// limitations under the License.

use minimal_template_runtime::{BalancesConfig, SudoConfig, WASM_BINARY};
use sc_service::{ChainType, Properties};
use polkadot_sdk::{
sc_service::{ChainType, Properties},
sp_keyring::AccountKeyring,
*,
};
use serde_json::{json, Value};
use sp_keyring::AccountKeyring;

/// This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec;
Expand All @@ -42,8 +45,8 @@ pub fn development_config() -> Result<ChainSpec, String> {

/// Configure initial storage state for FRAME pallets.
fn testnet_genesis() -> Value {
use frame::traits::Get;
use minimal_template_runtime::interface::{Balance, MinimumBalance};
use polkadot_sdk::polkadot_sdk_frame::traits::Get;
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
let balances = AccountKeyring::iter()
.map(|a| (a.to_account_id(), endowment))
Expand Down
2 changes: 1 addition & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use sc_cli::RunCmd;
use polkadot_sdk::{sc_cli::RunCmd, *};

#[derive(Debug, Clone)]
pub enum Consensus {
Expand Down
6 changes: 1 addition & 5 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;

#[cfg(feature = "try-runtime")]
use try_runtime_cli::block_building_info::timestamp_with_aura_info;
use polkadot_sdk::{sc_cli::SubstrateCli, sc_service::PartialComponents, *};

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down
2 changes: 1 addition & 1 deletion node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ mod command;
mod rpc;
mod service;

fn main() -> sc_cli::Result<()> {
fn main() -> polkadot_sdk::sc_cli::Result<()> {
command::run()
}
17 changes: 8 additions & 9 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@

use jsonrpsee::RpcModule;
use minimal_template_runtime::interface::{AccountId, Nonce, OpaqueBlock};
use sc_transaction_pool_api::TransactionPool;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use polkadot_sdk::{
sc_transaction_pool_api::TransactionPool,
sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata},
*,
};
use std::sync::Arc;

pub use sc_rpc_api::DenyUnsafe;

/// Full client dependencies.
pub struct FullDeps<C, P> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
}

#[docify::export]
Expand All @@ -57,11 +56,11 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
P: TransactionPool + 'static,
{
use substrate_frame_rpc_system::{System, SystemApiServer};
use polkadot_sdk::substrate_frame_rpc_system::{System, SystemApiServer};
let mut module = RpcModule::new(());
let FullDeps { client, pool, deny_unsafe } = deps;
let FullDeps { client, pool } = deps;

module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
module.merge(System::new(client.clone(), pool.clone()).into_rpc())?;

Ok(module)
}
34 changes: 17 additions & 17 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@

use futures::FutureExt;
use minimal_template_runtime::{interface::OpaqueBlock as Block, RuntimeApi};
use sc_client_api::backend::Backend;
use sc_executor::WasmExecutor;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_runtime::traits::Block as BlockT;
use polkadot_sdk::{
sc_client_api::backend::Backend,
sc_executor::WasmExecutor,
sc_service::{error::Error as ServiceError, Configuration, TaskManager},
sc_telemetry::{Telemetry, TelemetryWorker},
sc_transaction_pool_api::OffchainTransactionPoolFactory,
sp_runtime::traits::Block as BlockT,
*,
};
use std::sync::Arc;

use crate::cli::Consensus;

#[cfg(feature = "runtime-benchmarks")]
type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);

#[cfg(not(feature = "runtime-benchmarks"))]
type HostFunctions = sp_io::SubstrateHostFunctions;

#[docify::export]
Expand Down Expand Up @@ -63,7 +61,7 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
})
.transpose()?;

let executor = sc_service::new_wasm_executor(config);
let executor = sc_service::new_wasm_executor(&config.executor);

let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
Expand Down Expand Up @@ -126,7 +124,10 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
Block,
<Block as BlockT>::Hash,
Network,
>::new(&config.network);
>::new(
&config.network,
config.prometheus_config.as_ref().map(|cfg| cfg.registry.clone()),
);
let metrics = Network::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
);
Expand All @@ -140,7 +141,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
import_queue,
net_config,
block_announce_validator_builder: None,
warp_sync_params: None,
warp_sync_config: None,
block_relay: None,
metrics,
})?;
Expand Down Expand Up @@ -170,9 +171,8 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let client = client.clone();
let pool = transaction_pool.clone();

Box::new(move |deny_unsafe, _| {
let deps =
crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), deny_unsafe };
Box::new(move |_| {
let deps = crate::rpc::FullDeps { client: client.clone(), pool: pool.clone() };
crate::rpc::create_full(deps).map_err(Into::into)
})
};
Expand Down
14 changes: 5 additions & 9 deletions pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-minimal-template"
description = "A minimal pallet built with FRAME, part of Polkadot Sdk. (polkadot v1.15.0)"
description = "A minimal pallet built with FRAME, part of Polkadot Sdk."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
Expand All @@ -13,15 +13,11 @@ publish = false
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = [
"derive",
], workspace = true }
scale-info = { features = [
"derive",
], workspace = true }
frame = { features = ["experimental", "runtime"], workspace = true }
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
polkadot-sdk = { workspace = true, features = ["experimental", "runtime"], default-features = false }


[features]
default = ["std"]
std = ["codec/std", "frame/std", "scale-info/std"]
std = ["codec/std", "polkadot-sdk/std", "scale-info/std"]
5 changes: 5 additions & 0 deletions pallets/template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


## Release

Polkadot SDK stable2409
4 changes: 2 additions & 2 deletions pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

use frame::prelude::*;
use polkadot_sdk::polkadot_sdk_frame as frame;

// Re-export all pallet parts, this is needed to properly import the pallet into the runtime.
pub use pallet::*;
Expand All @@ -15,7 +15,7 @@ pub mod pallet {
use super::*;

#[pallet::config]
pub trait Config: frame_system::Config {}
pub trait Config: polkadot_sdk::frame_system::Config {}

#[pallet::pallet]
pub struct Pallet<T>(_);
Expand Down
Loading