Skip to content
Snippets Groups Projects
Commit 4d34e6c2 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

fix(#132): feat: use `gdev_client-specs.json` for raw specs

parent 91d3c092
No related branches found
No related tags found
1 merge request!182Resolve "Industrialize Releases production"
Pipeline #34146 waiting for manual action
{
"name": "ĞDev",
"id": "gdev",
"chainType": "Live",
"bootNodes": [],
"telemetryEndpoints": [
[
"/dns/telemetry.polkadot.io/tcp/443/x-parity-wss/%2Fsubmit%2F",
0
]
],
"properties": {
"tokenDecimals": 2,
"tokenSymbol": "ĞD"
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -27,7 +27,11 @@ use gdev_runtime::{
SessionConfig, SmithCertConfig, SmithMembershipConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, UniversalDividendConfig, WASM_BINARY,
};
use jsonrpsee::core::JsonValue;
use sc_network::config::MultiaddrWithPeerId;
use sc_service::ChainType;
use sc_telemetry::TelemetryEndpoints;
use serde::Deserialize;
use sp_core::sr25519;
use sp_runtime::Perbill;
use std::{env, fs};
......@@ -123,15 +127,36 @@ pub fn gdev_development_chain_spec(json_file_path: String) -> Result<ChainSpec,
))
}
// === client specifications ===
/// emulate client specifications to get them from json
#[derive(Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct ClientSpec {
name: String,
id: String,
chain_type: ChainType,
boot_nodes: Vec<MultiaddrWithPeerId>,
telemetry_endpoints: Option<TelemetryEndpoints>,
// protocol_id: Option<String>,
// #[serde(default = "Default::default", skip_serializing_if = "Option::is_none")]
// fork_id: Option<String>,
properties: Option<serde_json::Map<std::string::String, JsonValue>>,
// #[serde(default)]
// code_substitutes: BTreeMap<String, Bytes>,
}
/// generate live network chainspecs
pub fn gen_live_conf(json_file_path: String) -> Result<ChainSpec, String> {
pub fn gen_live_conf(client_spec: ClientSpec, json_file_path: String) -> Result<ChainSpec, String> {
let wasm_binary = get_wasm_binary().ok_or_else(|| "wasm not available".to_string())?;
Ok(ChainSpec::from_genesis(
// Name
"Ğdev",
client_spec.name.as_str(),
// ID
"gdev",
sc_service::ChainType::Live,
client_spec.id.as_str(),
// chain type
client_spec.chain_type,
move || {
let genesis_data =
gen_genesis_data::generate_genesis_data::<_, _, SessionKeys, GDevSKP>(
......@@ -143,29 +168,15 @@ pub fn gen_live_conf(json_file_path: String) -> Result<ChainSpec, String> {
genesis_data_to_gdev_genesis_conf(genesis_data, wasm_binary.to_vec())
},
// Bootnodes
vec![],
// Telemetry
Some(
sc_service::config::TelemetryEndpoints::new(vec![(
"wss://telemetry.polkadot.io/submit/".to_owned(),
0,
)])
.expect("invalid telemetry endpoints"),
),
client_spec.boot_nodes,
// Telemetry (by default, enable telemetry, can be disabled with argument)
client_spec.telemetry_endpoints,
// Protocol ID
Some("gdev2"),
//Fork ID
None,
// Properties
Some(
serde_json::json!({
"tokenDecimals": TOKEN_DECIMALS,
"tokenSymbol": TOKEN_SYMBOL,
})
.as_object()
.expect("must be a map")
.clone(),
),
client_spec.properties,
// Extensions
None,
))
......
......@@ -105,9 +105,22 @@ impl SubstrateCli for Cli {
// but must have a smith with declared session keys
// > optionally from DUNITER_GENESIS_CONFIG file to override default gdev configuration
#[cfg(feature = "gdev")]
"gdev_live" => Box::new(chain_spec::gdev::gen_live_conf(
"resources/gdev.json".to_string(),
)?),
"gdev_live" => {
const JSON_CLIENT_SPEC: &str = "./node/specs/gdev_client-specs.json";
let client_spec: chain_spec::gdev::ClientSpec = serde_json::from_slice(
&std::fs::read(
std::env::var("DUNITER_GTEST_CLIENT_SPEC")
.unwrap_or_else(|_| JSON_CLIENT_SPEC.to_string()),
)
.map_err(|e| format!("failed to read {JSON_CLIENT_SPEC} {e}"))?[..],
)
.map_err(|e| format!("failed to parse {e}"))?;
// rebuild chainspecs from these files
Box::new(chain_spec::gdev::gen_live_conf(
client_spec,
"resources/gdev.json".to_string(),
)?)
}
// hardcoded previously generated raw chainspecs
// yields a pointlessly heavy binary because of hexadecimal-text-encoded values
#[cfg(all(feature = "gdev", feature = "embed"))]
......
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