Skip to content
Snippets Groups Projects
Commit 9b5dc4bb authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

feat: embed distance oracle in duniter with subcommand

parent 23c25376
No related branches found
No related tags found
1 merge request!225embed distance oracle in duniter with subcommand
Pipeline #35214 passed
This commit is part of merge request !225. Comments created here will be created in the context of that merge request.
......@@ -18,7 +18,7 @@ name = 'duniter'
path = "node/src/main.rs"
[features]
default = ["gdev"]
default = ["gdev", "distance-oracle"]
gdev = ["gdev-runtime"] # gdev feature enables gdev runtime and gdev command line options
g1 = ["g1-runtime"]
gtest = ["gtest-runtime"]
......@@ -58,7 +58,7 @@ sp-trie = { git = "https://github.com/duniter/substrate", branch = "duniter-subs
# local dependencies
common-runtime = { path = 'runtime/common' }
dc-distance = { path = 'client/distance' }
distance-oracle = { path = 'distance-oracle', optional = true }
distance-oracle = { path = 'distance-oracle', default-features = false, optional = true }
g1-runtime = { path = 'runtime/g1', optional = true }
gdev-runtime = { path = 'runtime/gdev', optional = true }
gtest-runtime = { path = 'runtime/gtest', optional = true }
......
......@@ -9,7 +9,7 @@ edition = "2021"
[dependencies]
sp-distance = { path = "../primitives/distance" }
codec = { package = "parity-scale-codec", version = "3.1.5" }
codec = { package = "parity-scale-codec", version = "3.6.5" }
fnv = "1.0.7"
log = "0.4.17"
num-traits = "0.2.15"
......
......@@ -37,6 +37,10 @@ pub enum Subcommand {
/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),
/// Run distance oracle.
#[cfg(feature = "distance-oracle")]
DistanceOracle(DistanceOracle),
/// Export blocks.
ExportBlocks(sc_cli::ExportBlocksCmd),
......@@ -132,3 +136,14 @@ pub struct Completion {
#[clap(short, long, value_enum)]
pub generator: clap_complete::Shell,
}
#[derive(Debug, clap::Args)]
pub struct DistanceOracle {
#[clap(short = 'd', long, default_value = "/tmp/duniter/chains/gdev/distance")]
pub evaluation_result_dir: String,
/// Maximum depth to explore the WoT graph for referees
#[clap(short = 'D', long, default_value = "5")]
pub max_depth: u32,
#[clap(short = 'u', long, default_value = "ws://127.0.0.1:9944")]
pub rpc_url: String,
}
......@@ -304,6 +304,19 @@ pub fn run() -> sc_cli::Result<()> {
);
Ok(())
}
#[cfg(feature = "distance-oracle")]
Some(Subcommand::DistanceOracle(cmd)) => sc_cli::build_runtime()?.block_on(async move {
distance_oracle::run_and_save(
&distance_oracle::api::client(cmd.rpc_url.clone()).await,
distance_oracle::Settings {
evaluation_result_dir: cmd.evaluation_result_dir.clone().into(),
max_depth: cmd.max_depth,
rpc_url: cmd.rpc_url.clone(),
},
)
.await;
Ok(())
}),
#[cfg(feature = "runtime-benchmarks")]
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(&**cmd)?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment