Skip to content

Commit

Permalink
add dev-omni-node
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma committed Jul 23, 2024
1 parent ac98bc3 commit be5e541
Show file tree
Hide file tree
Showing 11 changed files with 1,085 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ members = [
"substrate/bin/node/testing",
"substrate/bin/utils/chain-spec-builder",
"substrate/bin/utils/subkey",
"substrate/bin/utils/dev-omni-node",
"substrate/client/allocator",
"substrate/client/api",
"substrate/client/authority-discovery",
Expand Down
76 changes: 76 additions & 0 deletions substrate/bin/utils/dev-omni-node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[package]
name = "dev-omni-node"
description = "A minimal omni node capable of running runtimes without any consensus."
version = "1.0.0"
authors.workspace = true
edition.workspace = true
repository.workspace = true
publish = true
build = "build.rs"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "https://paritytech.github.io/polkadot-sdk"


[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
clap = { features = ["derive"], workspace = true }
futures = { features = ["thread-pool"], workspace = true }
futures-timer = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
serde_json = { workspace = true, default-features = true }
log = { worksapce = true }
docify = { workspace = true }

sc-cli = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-network = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
sc-telemetry = { workspace = true, default-features = true }
sc-transaction-pool = { workspace = true, default-features = true }
sc-transaction-pool-api = { workspace = true, default-features = true }
sc-consensus = { workspace = true, default-features = true }
sc-consensus-manual-seal = { workspace = true, default-features = true }
sc-rpc-api = { workspace = true, default-features = true }
sc-basic-authorship = { workspace = true, default-features = true }
sc-offchain = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }
sc-chain-spec = { workspace = true, default-features = true }

sp-timestamp = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-block-builder = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
sp-transaction-pool = { workspace = true, default-features = true }
sp-session = { workspace = true, default-features = true }
sp-offchain = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-inherents = { workspace = true, default-features = true }
sp-consensus-aura = { workspace = true, default-features = true }
sp-consensus-grandpa = { workspace = true, default-features = true }
sp-weights = { workspace = true, default-features = true }
sp-version = { workspace = true, default-features = true }

# cumulus-primitives-core = { workspace = true, default-features = true }

# frame and pallets
# pallet-transaction-payment-rpc = { workspace = true, default-features = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = true }
pallet-transaction-payment = { workspace = true, default-features = true }

substrate-frame-rpc-system = { workspace = true, default-features = true }
frame-system-rpc-runtime-api = { workspace = true, default-features = true }

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

[dev-dependencies]
assert_cmd = "2.0.14"
nix = { version = "0.28.0", features = ["signal"] }


[features]
default = []
23 changes: 23 additions & 0 deletions substrate/bin/utils/dev-omni-node/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 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};

fn main() {
generate_cargo_keys();
rerun_if_git_head_changed();
}
103 changes: 103 additions & 0 deletions substrate/bin/utils/dev-omni-node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! The CLI parameters of the dev omni-node.
use sc_cli::RunCmd;

/// The consensus algorithm to use.
#[derive(Debug, Clone)]
pub enum Consensus {
/// Manual seal, with the block time in milliseconds.
///
/// Should be provided as `manual-seal-3000` for a 3 seconds block time.
ManualSeal(u64),
/// Instant seal.
///
/// Authors a new block as soon as a transaction is received.
InstantSeal,
}

impl std::str::FromStr for Consensus {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(if s == "instant-seal" {
Consensus::InstantSeal
} else if let Some(block_time) = s.strip_prefix("manual-seal-") {
Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?)
} else {
return Err("incorrect consensus identifier".into())
})
}
}

/// You typically run this node with:
///
/// * Either of `--chain runtime.wasm` or `--chain spec.json`.
/// * `--tmp` to use a temporary database.
///
/// This binary goes hand in hand with:
///
/// * a `.wasm` file. You typically get this from your runtime template.
/// * `chain-spec-builder` to generate chain-spec. You might possibly edit this chain-spec manually,
/// or alter your runtime's `sp_genesis_builder` impl with specific presets.
///
/// * `frame-omni-bencher` to create benchmarking.
#[derive(Debug, clap::Parser)]
pub struct Cli {
/// The subcommand to use.
#[command(subcommand)]
pub subcommand: Option<Subcommand>,

/// The block authoring (aka. consensus) engine to use.
#[clap(long, default_value = "manual-seal-1000")]
pub consensus: Consensus,

/// The main run command
#[clap(flatten)]
pub run: RunCmd,
}

/// Possible sub-commands.
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
/// Key management cli utilities
#[command(subcommand)]
Key(sc_cli::KeySubcommand),

/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),

/// Export blocks.
ExportBlocks(sc_cli::ExportBlocksCmd),

/// Export the state of a given block into a chain spec.
ExportState(sc_cli::ExportStateCmd),

/// Import blocks.
ImportBlocks(sc_cli::ImportBlocksCmd),

/// Remove the whole chain.
PurgeChain(sc_cli::PurgeChainCmd),

/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),

/// Db meta columns information.
ChainInfo(sc_cli::ChainInfoCmd),
}
Loading

0 comments on commit be5e541

Please sign in to comment.