Skip to content

Commit

Permalink
[create-pull-request] automated change
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianbarbu authored and github-actions[bot] committed Oct 23, 2024
1 parent ce64339 commit 3ff0a5d
Show file tree
Hide file tree
Showing 20 changed files with 289 additions and 10,811 deletions.
10,521 changes: 0 additions & 10,521 deletions Cargo.lock

This file was deleted.

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

[workspace]
"default-members" = ["pallets/template", "runtime"]
# add to the build command to build all members
members = [
"node",
"pallets/template",
Expand All @@ -16,41 +18,12 @@ 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.13" }
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.121", 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-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 = { path = "umbrella", default-features = false }
serde_json = { version = "1.0.132", 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.1", 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 Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /polkadot
COPY . /polkadot

RUN cargo fetch
RUN cargo build --locked --release
RUN cargo build --workspace --locked --release

FROM docker.io/parity/base-bin:latest

Expand Down
71 changes: 66 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,74 @@ A Polkadot SDK based project such as this one consists of:
* 🛠️ Depending on your operating system and Rust version, there might be additional
packages required to compile this template - please take note of the Rust compiler output.

Fetch minimal template code:

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

cd minimal-template
```

### Build

🔨 Use the following command to build the node without launching it:
🔨 Use the following command to build the template, which by default
compiles just the runtime. There is also a `node` crate that is able
to run and load the runtime but the recommended way of starting the
template is based on Omni Node (TODO: add link to docs).

```sh
cargo build --release
```

### Single-node Development Chain with Omni Node

⬇️ Omni Node can be run by using the `polkadot-omni-node` binary, which can be
downloaded from [Polkadot SDK releases](https://github.com/paritytech/polkadot-sdk/releases/latest).

* 🔗 Once downloaded, it must be added to the `PATH` environment variable like so:

```sh
cargo build --package minimal-template-node --release
export PATH="<path-to-binary>:$PATH"
```

🐳 Alternatively, build the docker image:
↩️ The Omni Node needs a runtime chainspec which can be generated based on
the `minimal-runtime`.

```sh
docker build . -t polkadot-sdk-minimal-template
# Build the minimal runtime.
cargo build -p minimal-template-runtime --release
# Install chain-spec-builder if not installed already.
cargo install staging-chain-spec-builder
# Use chain-spec-builder to generate the chain_spec.json file based on the development preset.
chain-spec-builder create --relay-chain "dev" --para-id 1000 --runtime \
<target/release/wbuild/path/to/minimal-template-runtime.wasm> named-preset development
```

### Single-Node Development Chain
⚙️ The `relay-chain` and `para-id` flags are extra bits of information to configure the node
for the case of representing a parachain that is connected to a relay chain. They are not relevant
to minimal template business logic, but they are mandatory information for Omni Node, nonetheless.

🚀 Start Omni Node with manual seal (3 seconds block times) and minimal template runtime based
chain spec.

```sh
polkadot-omni-node --chain <path/to/chain_spec.json> --dev-block-time 3000 --tmp
```

### Single-Node Development Chain with Minimal Template Node

⚙️ Use the following command to build the node as well:

```sh
cargo build --workspace --release
```

🐳 Alternatively, build the docker image which builds all the workspace members,
and has as entry point the node binary:

```sh
docker build . -t polkadot-sdk-minimal-template
```

👤 The following command starts a single-node development chain:

Expand All @@ -68,6 +121,14 @@ Development chains:
* 💰 Are pre-configured with a genesis state that includes several pre-funded development accounts.
* 🧑‍⚖️ One development account (`ALICE`) is used as `sudo` accounts.

**Note**: running multiple nodes with the same command used for the single node setup is also possible and
it can work up to a certain moment. The nodes will be peers, taking their turn in block production if manual
seal is configured to allow nodes to produce blocks at certain intervals and in the meantime to
import the blocks produced by peers. However, there is a big chance that at some point in time at least two nodes
will overlap with the block production at a certain height, at which point they will fork and will not consider
each others blocks anymore (stopping from being peers). They will continue to participate in blocks production
of their own fork and possibly of other nodes too.

### Connect with the Polkadot-JS Apps Front-End

* 🌐 You can interact with your local node using the
Expand Down
60 changes: 11 additions & 49 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "minimal-template-node"
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.15.0)"
version = "0.1.0"
description = "A minimal Substrate-based Substrate node, ready for hacking."
version = "0.0.0"
license = "Unlicense"
authors.workspace = true
homepage.workspace = true
Expand All @@ -20,54 +20,16 @@ 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 }
minimal-template-runtime.workspace = 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 = []
default = ["std"]
std = [
"minimal-template-runtime/std",
"polkadot-sdk/std",
]
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
27 changes: 7 additions & 20 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

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

/// This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec;
Expand All @@ -30,26 +31,12 @@ fn props() -> Properties {
properties
}

pub fn development_config() -> Result<ChainSpec, String> {
pub fn development_chain_spec() -> Result<ChainSpec, String> {
Ok(ChainSpec::builder(WASM_BINARY.expect("Development wasm not available"), Default::default())
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(testnet_genesis())
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.with_properties(props())
.build())
}

/// Configure initial storage state for FRAME pallets.
fn testnet_genesis() -> Value {
use frame::traits::Get;
use minimal_template_runtime::interface::{Balance, MinimumBalance};
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
let balances = AccountKeyring::iter()
.map(|a| (a.to_account_id(), endowment))
.collect::<Vec<_>>();
json!({
"balances": BalancesConfig { balances },
"sudo": SudoConfig { key: Some(AccountKeyring::Alice.to_account_id()) },
})
}
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
8 changes: 2 additions & 6 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 Expand Up @@ -53,7 +49,7 @@ 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()?),
"dev" => Box::new(chain_spec::development_chain_spec()?),
path =>
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
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)
}
Loading

0 comments on commit 3ff0a5d

Please sign in to comment.