Skip to content

Commit

Permalink
Update template triggered by workflow_dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
1 parent b218abb commit c908bb1
Show file tree
Hide file tree
Showing 9 changed files with 1,193 additions and 626 deletions.
1,676 changes: 1,110 additions & 566 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ default_constructed_unit_structs = { level = "allow", priority = 2 } # stylistic
polkavm = "0.9.3"
polkavm-linker = "0.9.2"
polkavm-derive = "0.9.1"
log = { version = "0.4.20", default-features = false }
log = { version = "0.4.21", default-features = false }
quote = { version = "1.0.33" }
serde = { version = "1.0.197", default-features = false }
serde-big-array = { version = "0.3.2" }
serde_derive = { version = "1.0.117" }
serde_json = { version = "1.0.114", default-features = false }
serde_yaml = { version = "0.9" }
syn = { version = "2.0.50" }
syn = { version = "2.0.53" }
thiserror = { version = "1.0.48" }
tracing-subscriber = { version = "0.3.18" }
50 changes: 25 additions & 25 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 miniaml Substrate-based Substrate node, ready for hacking. (polkadot v1.9.0)"
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.11.0)"
version = "0.1.0"
license = "MIT-0"
authors.workspace = true
Expand All @@ -17,36 +17,36 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
futures = { version = "0.3.21", features = ["thread-pool"] }
clap = { version = "4.5.3", features = ["derive"] }
futures = { version = "0.3.30", features = ["thread-pool"] }
futures-timer = "3.0.1"
jsonrpsee = { version = "0.22", features = ["server"] }
serde_json = { workspace = true, default-features = true }
sc-cli = { version = "0.39.0" }
sc-executor = { version = "0.35.0" }
sc-network = { version = "0.37.0" }
sc-service = { version = "0.38.0" }
sc-telemetry = { version = "17.0.0" }
sc-transaction-pool = { version = "31.0.0" }
sc-transaction-pool-api = { version = "31.0.0" }
sc-consensus = { version = "0.36.0" }
sc-consensus-manual-seal = { version = "0.38.0" }
sc-rpc-api = { version = "0.36.0" }
sc-basic-authorship = { version = "0.37.0" }
sc-offchain = { version = "32.0.0" }
sc-client-api = { version = "31.0.0" }
sp-timestamp = { version = "29.0.0" }
sp-keyring = { version = "34.0.0" }
sp-api = { version = "29.0.0" }
sp-blockchain = { version = "31.0.0" }
sp-block-builder = { version = "29.0.0" }
sp-io = { version = "33.0.0" }
sp-runtime = { version = "34.0.0" }
substrate-frame-rpc-system = { version = "31.0.0" }
sc-cli = { version = "0.41.0" }
sc-executor = { version = "0.37.0" }
sc-network = { version = "0.39.0" }
sc-service = { version = "0.40.0" }
sc-telemetry = { version = "19.0.0" }
sc-transaction-pool = { version = "33.0.0" }
sc-transaction-pool-api = { version = "33.0.0" }
sc-consensus = { version = "0.38.0" }
sc-consensus-manual-seal = { version = "0.40.0" }
sc-rpc-api = { version = "0.38.0" }
sc-basic-authorship = { version = "0.39.0" }
sc-offchain = { version = "34.0.0" }
sc-client-api = { version = "33.0.0" }
sp-timestamp = { version = "31.0.0" }
sp-keyring = { version = "36.0.0" }
sp-api = { version = "31.0.0" }
sp-blockchain = { version = "33.0.0" }
sp-block-builder = { version = "31.0.0" }
sp-io = { version = "35.0.0" }
sp-runtime = { version = "36.0.0" }
substrate-frame-rpc-system = { version = "33.0.0" }

# Once the native runtime is gone, there should be little to no dependency on FRAME here, and
# certainly no dependency on the runtime.
frame = { version = "0.1.1", package = "polkadot-sdk-frame", features = ["experimental", "runtime"] }
frame = { version = "0.2.0", package = "polkadot-sdk-frame", features = ["experimental", "runtime"] }
runtime = { package = "minimal-template-runtime", path = "../runtime", version = "0.1.0" }

[build-dependencies]
Expand Down
10 changes: 9 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ pub fn run() -> sc_cli::Result<()> {
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
service::new_full(config, cli.consensus).map_err(sc_cli::Error::Service)
match config.network.network_backend {
sc_network::config::NetworkBackendType::Libp2p =>
service::new_full::<sc_network::NetworkWorker<_, _>>(config, cli.consensus)
.map_err(sc_cli::Error::Service),
sc_network::config::NetworkBackendType::Litep2p => service::new_full::<
sc_network::Litep2pNetworkBackend,
>(config, cli.consensus)
.map_err(sc_cli::Error::Service),
}
})
},
}
Expand Down
18 changes: 15 additions & 3 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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 std::sync::Arc;

use crate::cli::Consensus;
Expand Down Expand Up @@ -104,7 +105,10 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
}

/// Builds a new service for a full client.
pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManager, ServiceError> {
pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Hash>>(
config: Configuration,
consensus: Consensus,
) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
client,
backend,
Expand All @@ -116,7 +120,14 @@ pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManag
other: mut telemetry,
} = new_partial(&config)?;

let net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
let net_config = sc_network::config::FullNetworkConfiguration::<
Block,
<Block as BlockT>::Hash,
Network,
>::new(&config.network);
let metrics = Network::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
);

let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
Expand All @@ -129,6 +140,7 @@ pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManag
block_announce_validator_builder: None,
warp_sync_params: None,
block_relay: None,
metrics,
})?;

if config.offchain_worker.enabled {
Expand All @@ -143,7 +155,7 @@ pub fn new_full(config: Configuration, consensus: Consensus) -> Result<TaskManag
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: network.clone(),
network_provider: Arc::new(network.clone()),
enable_http_requests: true,
custom_extensions: |_| vec![],
})
Expand Down
6 changes: 3 additions & 3 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.9.0)"
description = "A minimal pallet built with FRAME, part of Polkadot Sdk. (polkadot v1.11.0)"
version = "0.1.0"
license = "MIT-0"
authors.workspace = true
Expand All @@ -19,10 +19,10 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
], default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = [
scale-info = { version = "2.11.1", default-features = false, features = [
"derive",
] }
frame = { version = "0.1.1", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
frame = { version = "0.2.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }


[features]
Expand Down
22 changes: 12 additions & 10 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "minimal-template-runtime"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.9.0)"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.11.0)"
version = "0.1.0"
license = "MIT-0"
authors.workspace = true
Expand All @@ -17,23 +17,24 @@ parity-scale-codec = { version = "3.0.0", default-features = false }
scale-info = { version = "2.6.0", default-features = false }

# this is a frame-based runtime, thus importing `frame` with runtime feature enabled.
frame = { version = "0.1.1", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
frame = { version = "0.2.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }

# pallets that we want to use
pallet-balances = { version = "31.0.0", default-features = false }
pallet-sudo = { version = "31.0.0", default-features = false }
pallet-timestamp = { version = "30.0.0", default-features = false }
pallet-transaction-payment = { version = "31.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "31.0.0", default-features = false }
pallet-balances = { version = "34.0.0", default-features = false }
pallet-sudo = { version = "33.0.0", default-features = false }
pallet-timestamp = { version = "32.0.0", default-features = false }
pallet-transaction-payment = { version = "33.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "33.0.0", default-features = false }

# genesis builder that allows us to interacto with runtime genesis config
sp-genesis-builder = { version = "0.10.0", default-features = false }
# genesis builder that allows us to interact with runtime genesis config
sp-genesis-builder = { version = "0.12.0", default-features = false }
sp-runtime = { version = "36.0.0", default-features = false, features = ["serde"] }

# local pallet templates
pallet-minimal-template = { path = "../pallets/template", default-features = false, version = "0.1.0" }

[build-dependencies]
substrate-wasm-builder = { version = "20.0.0", optional = true }
substrate-wasm-builder = { version = "22.0.0", optional = true }

[features]
default = ["std"]
Expand All @@ -52,5 +53,6 @@ std = [
"pallet-minimal-template/std",

"sp-genesis-builder/std",
"sp-runtime/std",
"substrate-wasm-builder",
]
6 changes: 1 addition & 5 deletions runtime/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
fn main() {
#[cfg(feature = "std")]
{
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build();
substrate_wasm_builder::WasmBuilder::build_using_defaults();
}
}
26 changes: 15 additions & 11 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use frame::{
deps::frame_support::{
genesis_builder_helper::{build_config, create_default_config},
genesis_builder_helper::{build_state, get_preset},
weights::{FixedFee, NoFee},
},
prelude::*,
Expand Down Expand Up @@ -83,28 +83,28 @@ parameter_types! {
pub const Version: RuntimeVersion = VERSION;
}

#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig as frame_system::DefaultConfig)]
#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
impl frame_system::Config for Runtime {
type Block = Block;
type Version = Version;
type BlockHashCount = ConstU32<1024>;
type AccountData = pallet_balances::AccountData<<Runtime as pallet_balances::Config>::Balance>;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)]
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Runtime {
type AccountStore = System;
}

#[derive_impl(pallet_sudo::config_preludes::TestDefaultConfig as pallet_sudo::DefaultConfig)]
#[derive_impl(pallet_sudo::config_preludes::TestDefaultConfig)]
impl pallet_sudo::Config for Runtime {}

#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig as pallet_timestamp::DefaultConfig)]
#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)]
impl pallet_timestamp::Config for Runtime {}

#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig as pallet_transaction_payment::DefaultConfig)]
#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig)]
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
type WeightToFee = NoFee<<Self as pallet_balances::Config>::Balance>;
type LengthToFee = FixedFee<1, <Self as pallet_balances::Config>::Balance>;
}
Expand Down Expand Up @@ -221,12 +221,16 @@ impl_runtime_apis! {
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn create_default_config() -> Vec<u8> {
create_default_config::<RuntimeGenesisConfig>()
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}

fn build_config(config: Vec<u8>) -> sp_genesis_builder::Result {
build_config::<RuntimeGenesisConfig>(config)
fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, |_| None)
}

fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
vec![]
}
}
}
Expand Down

0 comments on commit c908bb1

Please sign in to comment.