diff --git a/Cargo.lock b/Cargo.lock index 046ad7d8e..32dcde7d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,66 @@ dependencies = [ "regex", ] +[[package]] +name = "ac-compose-macros" +version = "0.4.2" +source = "git+https://github.com/webb-tools/substrate-api-client#6653a8d12d9ddfa2cd0301ab6c2aa50262da73e1" +dependencies = [ + "ac-primitives", + "log", + "maybe-async", +] + +[[package]] +name = "ac-node-api" +version = "0.5.1" +source = "git+https://github.com/webb-tools/substrate-api-client#6653a8d12d9ddfa2cd0301ab6c2aa50262da73e1" +dependencies = [ + "ac-primitives", + "bitvec 1.0.1", + "derive_more", + "either", + "frame-metadata 15.1.0", + "hex", + "log", + "parity-scale-codec", + "scale-bits 0.4.0", + "scale-decode 0.8.0", + "scale-encode 0.4.0", + "scale-info", + "serde", + "serde_json", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", +] + +[[package]] +name = "ac-primitives" +version = "0.9.0" +source = "git+https://github.com/webb-tools/substrate-api-client#6653a8d12d9ddfa2cd0301ab6c2aa50262da73e1" +dependencies = [ + "frame-system", + "impl-serde", + "pallet-assets", + "pallet-balances", + "parity-scale-codec", + "primitive-types", + "scale-info", + "serde", + "serde_json", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-core-hashing 9.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-staking", + "sp-version", + "sp-weights 20.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", +] + [[package]] name = "addr2line" version = "0.19.0" @@ -2455,6 +2515,18 @@ dependencies = [ "webb-proposals 0.6.0", ] +[[package]] +name = "dkg-integration-tests" +version = "0.1.0" +dependencies = [ + "ac-primitives", + "dkg-logging", + "dkg-standalone-runtime", + "substrate-api-client", + "tokio", + "tokio-websockets", +] + [[package]] name = "dkg-logging" version = "0.1.0" @@ -5686,6 +5758,17 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "maybe-async" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f1b8c13cb1f814b634a96b2c725449fe7ed464a7b8781de8688be5ffbd3f305" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "md-5" version = "0.10.5" @@ -6439,6 +6522,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "pallet-assets" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", +] + [[package]] name = "pallet-aura" version = "4.0.0-dev" @@ -9568,6 +9666,17 @@ dependencies = [ "serde", ] +[[package]] +name = "scale-bits" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "036575c29af9b6e4866ffb7fa055dbf623fe7a9cc159b33786de6013a6969d89" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", +] + [[package]] name = "scale-decode" version = "0.7.0" @@ -9576,13 +9685,27 @@ checksum = "f0459d00b0dbd2e765009924a78ef36b2ff7ba116292d732f00eb0ed8e465d15" dependencies = [ "parity-scale-codec", "primitive-types", - "scale-bits", - "scale-decode-derive", + "scale-bits 0.3.0", + "scale-decode-derive 0.7.0", "scale-info", "smallvec", "thiserror", ] +[[package]] +name = "scale-decode" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea509715113edab351e1f4d51fba6b186653259049a1155b52e2e994dd2f0e6d" +dependencies = [ + "parity-scale-codec", + "primitive-types", + "scale-bits 0.4.0", + "scale-decode-derive 0.8.0", + "scale-info", + "smallvec", +] + [[package]] name = "scale-decode-derive" version = "0.7.0" @@ -9596,6 +9719,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scale-decode-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c9d7a1341497e9d016722144310de3dc6c933909c0376017c88f65092fff37" +dependencies = [ + "darling 0.14.4", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "scale-encode" version = "0.3.0" @@ -9604,13 +9740,27 @@ checksum = "b0401b7cdae8b8aa33725f3611a051358d5b32887ecaa0fda5953a775b2d4d76" dependencies = [ "parity-scale-codec", "primitive-types", - "scale-bits", - "scale-encode-derive", + "scale-bits 0.3.0", + "scale-encode-derive 0.3.0", "scale-info", "smallvec", "thiserror", ] +[[package]] +name = "scale-encode" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6f51bc8cd927dab2f4567b1a8a8e9d7fd5d0866f2dbc7c84fc97cfa9383a26" +dependencies = [ + "parity-scale-codec", + "primitive-types", + "scale-bits 0.4.0", + "scale-encode-derive 0.4.0", + "scale-info", + "smallvec", +] + [[package]] name = "scale-encode-derive" version = "0.3.0" @@ -9624,6 +9774,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scale-encode-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28be1877787156a2df01be3c029b92bdffa6b6a9748d4996e383fff218c88f3" +dependencies = [ + "darling 0.14.4", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "scale-info" version = "2.9.0" @@ -9661,9 +9824,9 @@ dependencies = [ "either", "frame-metadata 15.1.0", "parity-scale-codec", - "scale-bits", - "scale-decode", - "scale-encode", + "scale-bits 0.3.0", + "scale-decode 0.7.0", + "scale-encode 0.3.0", "scale-info", "serde", "thiserror", @@ -10055,6 +10218,12 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha1_smol" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" + [[package]] name = "sha2" version = "0.8.2" @@ -11503,6 +11672,34 @@ dependencies = [ "webrtc-util", ] +[[package]] +name = "substrate-api-client" +version = "0.14.0" +source = "git+https://github.com/webb-tools/substrate-api-client#6653a8d12d9ddfa2cd0301ab6c2aa50262da73e1" +dependencies = [ + "ac-compose-macros", + "ac-node-api", + "ac-primitives", + "async-trait", + "derive_more", + "frame-metadata 15.1.0", + "frame-support", + "futures", + "hex", + "jsonrpsee", + "log", + "maybe-async", + "parity-scale-codec", + "serde", + "serde_json", + "sp-core 21.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-version", + "url", +] + [[package]] name = "substrate-bip39" version = "0.4.4" @@ -11687,9 +11884,9 @@ dependencies = [ "jsonrpsee", "parity-scale-codec", "primitive-types", - "scale-bits", - "scale-decode", - "scale-encode", + "scale-bits 0.3.0", + "scale-decode 0.7.0", + "scale-encode 0.3.0", "scale-info", "scale-value", "serde", @@ -12157,6 +12354,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "tokio-websockets" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd056b4095b3ec42b9a13d6985f3b1f7d2ee1a216440a9b25e122c15edfdce3" +dependencies = [ + "base64 0.21.2", + "bytes", + "fastrand 2.0.0", + "futures-util", + "http", + "httparse", + "sha1_smol", + "tokio", + "tokio-util", +] + [[package]] name = "toml" version = "0.5.11" @@ -12552,7 +12766,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.4.6", "static_assertions", ] diff --git a/Cargo.toml b/Cargo.toml index cc8d8128f..af93812fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ members = [ 'dkg-test-orchestrator', 'relayer-gadget', 'relayer-gadget/cli', + 'dkg-integration-tests' ] resolver = "2" @@ -32,7 +33,7 @@ pallet-bridge-registry = { path = "pallets/bridge-registry", default-features = dkg-gadget = { path = "dkg-gadget", default-features = false } dkg-primitives = { path = "dkg-primitives", default-features = false } dkg-standalone-runtime = { version = "3.0.0", path = "standalone/runtime" } -dkg-logging = { path = "dkg-logging" } +dkg-logging = { path = "dkg-logging", default-features = false } dkg-rococo-runtime = { default-features = false, path = "parachain/runtime/rococo" } dkg-mock-blockchain = { path = "dkg-mock-blockchain", default-features = false } dkg-test-orchestrator = { path = "dkg-test-orchestrator", default-features = false } @@ -75,6 +76,9 @@ tracing-subscriber = "0.3.5" sync_wrapper = "0.1.2" async-stream = "0.3.5" lazy_static = "1.4.0" +substrate-api-client = { git = "https://github.com/webb-tools/substrate-api-client" } +ac-primitives = { git = "https://github.com/webb-tools/substrate-api-client" } +tokio-websockets = "0.3.3" scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/Makefile.toml b/Makefile.toml index eab7b3a28..5ba8afada 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -16,32 +16,37 @@ command = "cargo" args = ["build", "-rp", "dkg-standalone-node", "--features=integration-tests,testing"] [tasks.alice] -dependencies = ["build-test"] +condition = { files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/target/release/dkg-standalone-node"] } description = "Run Alice node (the bootnode)" command = "./target/release/dkg-standalone-node" args = ["--tmp", "--chain", "local", "--validator", "-lerror", "--alice", "--output-path=./tmp/alice/output.log", "--rpc-cors", "all", "--rpc-external", "--rpc-methods=unsafe", "--port", "30333", "--rpc-port", "9944", "--node-key", "0000000000000000000000000000000000000000000000000000000000000001"] [tasks.bob] -dependencies = ["build-test"] description = "Run Bob node" +condition = { files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/target/release/dkg-standalone-node"] } command = "./target/release/dkg-standalone-node" args = ["--tmp", "--chain", "local", "--validator", "-lerror", "--bob", "--output-path=./tmp/bob/output.log", "--rpc-cors", "all", "--rpc-external", "--rpc-methods=unsafe", "--port", "30305", "--rpc-port", "9945", "--bootnodes", "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"] [tasks.charlie] -dependencies = ["build-test"] description = "Run Charlie node" +condition = { files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/target/release/dkg-standalone-node"] } command = "./target/release/dkg-standalone-node" args = ["--tmp", "--chain", "local", "--validator", "-lerror", "--charlie", "--output-path=./tmp/charlie/output.log", "--rpc-cors", "all", "--rpc-external", "--rpc-methods=unsafe", "--port", "30306", "--rpc-port", "9946", "--bootnodes", "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"] [tasks.dave] -dependencies = ["build-test"] description = "Run Dave node" +condition = { files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/target/release/dkg-standalone-node"] } command = "./target/release/dkg-standalone-node" args = ["--tmp", "--chain", "local", "--validator", "-lerror", "--dave", "--output-path=./tmp/dave/output.log", "--rpc-cors", "all", "--rpc-external", "--rpc-methods=unsafe", "--port", "30307", "--rpc-port", "9947", "--bootnodes", "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"] [tasks.eve] -dependencies = ["build-test"] description = "Run Eve node" +condition = { files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/target/release/dkg-standalone-node"] } command = "./target/release/dkg-standalone-node" args = ["--tmp", "--chain", "local", "--validator", "-lerror", "--eve", "--output-path=./tmp/eve/output.log", "--rpc-cors", "all", "--rpc-external", "--rpc-methods=unsafe", "--port", "30308", "--rpc-port", "9948", "--bootnodes", "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"] +[tasks.ferdie] +description = "Run Ferdie node" +condition = { files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/target/release/dkg-standalone-node"] } +command = "./target/release/dkg-standalone-node" +args = ["--tmp", "--chain", "local", "--validator", "-lerror", "--ferdie", "--output-path=./tmp/ferdie/output.log", "--rpc-cors", "all", "--rpc-external", "--rpc-methods=unsafe", "--port", "30309", "--rpc-port", "9949", "--bootnodes", "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"] diff --git a/dkg-gadget/Cargo.toml b/dkg-gadget/Cargo.toml index bd9acb4c4..70e44ca5e 100644 --- a/dkg-gadget/Cargo.toml +++ b/dkg-gadget/Cargo.toml @@ -64,7 +64,7 @@ webb-proposals = { workspace = true } # Local dependencies dkg-runtime-primitives = { workspace = true } dkg-primitives = { workspace = true } -dkg-logging = { workspace = true } +dkg-logging = { workspace = true, features = ["full"] } dkg-mock-blockchain = { workspace = true } tracing = { workspace = true, optional = true } diff --git a/dkg-integration-tests/Cargo.toml b/dkg-integration-tests/Cargo.toml new file mode 100644 index 000000000..1aefc73b6 --- /dev/null +++ b/dkg-integration-tests/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "dkg-integration-tests" +version = "0.1.0" +description.workspace = true +authors.workspace = true +license.workspace = true +publish.workspace = true +homepage.workspace = true +repository.workspace = true +edition.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tokio = { workspace = true, features = ["full"] } +dkg-logging = { workspace = true, default-features = false } +dkg-standalone-runtime = { workspace = true } +substrate-api-client = { workspace = true, features = ["std"] } +ac-primitives = { workspace = true } +tokio-websockets = { workspace = true } diff --git a/dkg-integration-tests/src/main.rs b/dkg-integration-tests/src/main.rs new file mode 100644 index 000000000..d092a4c25 --- /dev/null +++ b/dkg-integration-tests/src/main.rs @@ -0,0 +1,204 @@ +use ac_primitives::{AssetRuntimeConfig, H256}; +use std::{collections::HashSet, error::Error, time::Duration}; +use substrate_api_client::{rpc::JsonrpseeClient, Api, SubscribeEvents}; +use tokio::{net::TcpStream, process::Child}; +use tokio_websockets::{ClientBuilder, MaybeTlsStream, WebsocketStream}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let mut shutdown = Shutdown { members: vec![] }; + let res = main_inner(&mut shutdown).await; + + for member in shutdown.members.iter_mut() { + if let Some(pid) = member.id() { + dkg_logging::info!(target: "dkg", "Killing member {pid}"); + let _exit = tokio::process::Command::new("kill") + .arg("-9") + .arg(pid.to_string()) + .stderr(std::process::Stdio::inherit()) + .stdout(std::process::Stdio::inherit()) + .spawn() + .expect("Should spawn") + .wait() + .await + .unwrap(); + } + + member.kill().await.expect("Should kill member"); + } + + res +} + +async fn main_inner(shutdown: &mut Shutdown) -> Result<(), Box> { + dkg_logging::setup_log(); + dkg_logging::info!(target: "dkg", "Will test getting to session 3"); + + let alice = generate_process("alice", false)?; + dkg_logging::info!(target: "dkg", "Spawned Bootnode, now awaiting for initialization"); + // With alice spawned, we now must wait for her to be ready to accept connections + wait_for_bootnode_to_init().await?; + + // with the bootnode ready, load the rest of the nodes + let bob = generate_process("bob", false)?; + let charlie = generate_process("charlie", false)?; + let dave = generate_process("dave", false)?; + let eve = generate_process("eve", false)?; + + shutdown.members = vec![alice, bob, charlie, dave, eve]; + + // Setup API + let client = JsonrpseeClient::with_default_url().unwrap(); + let mut api = Api::::new(client).unwrap(); + + // Wait for the bootnode to get to session 5 + wait_for_session_3(&mut api).await; + Ok(()) +} + +async fn wait_for_bootnode_to_init() -> Result<(), Box> { + loop { + match tokio::time::timeout( + Duration::from_millis(10000), + generate_websocket_connection_to_bootnode(), + ) + .await + { + Ok(Ok(_ws)) => { + dkg_logging::info!(target: "dkg", "Obtained websocket connection to bootnode"); + return Ok(()) + }, + + Ok(Err(_err)) => {}, + + Err(_err) => { + dkg_logging::info!(target: "dkg", "Still waiting for bootnode to init ..."); + }, + } + } +} + +async fn generate_websocket_connection_to_bootnode( +) -> Result>, Box> { + Ok(ClientBuilder::new() + .uri("ws://127.0.0.1:9944")? // connect to the bootnode's WS port to listen to events + .connect() + .await?) +} + +async fn wait_for_session_3(api: &mut Api) { + let mut has_seen = HashSet::new(); + let mut listener = DKGEventListener::new(); + loop { + let mut subscription = api.subscribe_events().unwrap(); + let records = tokio::task::spawn_blocking(move || { + let events = subscription.next_events::(); + if let Some(events) = events { + events.unwrap_or_default() + } else { + vec![] + } + }) + .await + .expect("JoinError"); + + for record in records { + let record_str = format!("{record:?}"); + if has_seen.insert(record_str.clone()) { + dkg_logging::info!(target: "dkg", "decoded: {:?}", record.event); + let session = listener.on_event_received(&record_str); + dkg_logging::info!(target: "dkg", "State: {listener:?}"); + if session == 3 { + return + } + } + } + } +} + +fn generate_process(node: &str, inherit: bool) -> Result> { + let mut command = tokio::process::Command::new("cargo"); + + if inherit { + command.stdout(std::process::Stdio::inherit()); + command.stderr(std::process::Stdio::inherit()); + } else { + command.stdout(std::process::Stdio::piped()); + command.stderr(std::process::Stdio::piped()); + } + + Ok(command + .arg("make") + .arg(node) + .env("RUST_LOG", "dkg=info") + .kill_on_drop(true) + .spawn()?) +} + +struct Shutdown { + members: Vec, +} + +const EVENT_DKG_PUBLIC_KEY_SUBMITTED: &str = "Event::PublicKeySubmitted"; +const EVENT_NEXT_DKG_PUBLIC_KEY_SUBMITTED: &str = "Event::NextPublicKeySubmitted"; +const EVENT_DKG_PROPOSAL_ADDED: &str = "Event::ProposalAdded"; +const EVENT_DKG_PROPOSAL_BATCH_SIGNED: &str = "Event::ProposalBatchSigned"; +const EVENT_NEXT_DKG_PUBLIC_KEY_SIGNATURE_SUBMITTED: &str = + "Event::NextPublicKeySignatureSubmitted"; +const EVENT_NEW_SESSION: &str = "Event::NewSession"; +const EVENT_PUBLIC_KEY_CHANGED: &str = "Event::PublicKeyChanged"; +const EVENT_PUBLIC_KEY_SIGNATURE_CHANGED: &str = "Event::PublicKeySignatureChanged"; + +#[derive(Debug)] +struct DKGEventListener { + current_session: u64, + current_session_events_required: HashSet<&'static str>, +} + +impl DKGEventListener { + fn new() -> Self { + Self { + current_session: 0, + current_session_events_required: [ + EVENT_DKG_PUBLIC_KEY_SUBMITTED, + EVENT_NEXT_DKG_PUBLIC_KEY_SUBMITTED, + EVENT_DKG_PROPOSAL_ADDED, + EVENT_DKG_PROPOSAL_BATCH_SIGNED, + EVENT_NEXT_DKG_PUBLIC_KEY_SIGNATURE_SUBMITTED, + EVENT_NEW_SESSION, + EVENT_PUBLIC_KEY_CHANGED, + EVENT_PUBLIC_KEY_SIGNATURE_CHANGED, + ] + .into_iter() + .collect(), + } + } + // Returns the current session + fn on_event_received(&mut self, event: &str) -> u64 { + let maybe_matched_event = self + .current_session_events_required + .iter() + .find(|exact| event.contains(**exact)); + if let Some(matched_event) = maybe_matched_event { + self.current_session_events_required.remove(*matched_event); + if self.current_session_events_required.is_empty() { + self.current_session += 1; + self.current_session_events_required = [ + // EVENT_DKG_PUBLIC_KEY_SUBMITTED, omit this since this is only needed in the + // zeroth session (genesis) + EVENT_NEXT_DKG_PUBLIC_KEY_SUBMITTED, + EVENT_DKG_PROPOSAL_ADDED, + EVENT_DKG_PROPOSAL_BATCH_SIGNED, + EVENT_NEXT_DKG_PUBLIC_KEY_SIGNATURE_SUBMITTED, + EVENT_NEW_SESSION, + EVENT_PUBLIC_KEY_CHANGED, + EVENT_PUBLIC_KEY_SIGNATURE_CHANGED, + ] + .into_iter() + .collect(); + } + } + + self.current_session + } +} diff --git a/dkg-logging/Cargo.toml b/dkg-logging/Cargo.toml index b34394070..d6a86ab83 100644 --- a/dkg-logging/Cargo.toml +++ b/dkg-logging/Cargo.toml @@ -9,14 +9,18 @@ edition = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = ["full"] +full = ["parking_lot", "serde", "sp-core", "lazy_static", "tokio", "serde_json", "hex"] + [dependencies] tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter", "json"] } tracing-filter = "0.1.0-alpha.2" -parking_lot = { workspace = true } -serde = { workspace = true } -sp-core = { workspace = true } -lazy_static = { workspace = true } -tokio = { workspace = true } -serde_json = { workspace = true } -hex = { workspace = true } +parking_lot = { workspace = true, optional = true } +serde = { workspace = true, optional = true } +sp-core = { workspace = true, optional = true } +lazy_static = { workspace = true, optional = true } +tokio = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true } +hex = { workspace = true, optional = true } diff --git a/dkg-logging/src/lib.rs b/dkg-logging/src/lib.rs index f7213b876..18905dcf8 100644 --- a/dkg-logging/src/lib.rs +++ b/dkg-logging/src/lib.rs @@ -5,6 +5,7 @@ use tracing_subscriber::{ EnvFilter, }; +#[cfg(feature = "full")] pub mod debug_logger; pub fn setup_log() { diff --git a/dkg-mock-blockchain/Cargo.toml b/dkg-mock-blockchain/Cargo.toml index 6c330678c..5ce87a04d 100644 --- a/dkg-mock-blockchain/Cargo.toml +++ b/dkg-mock-blockchain/Cargo.toml @@ -23,4 +23,4 @@ sc-network = { workspace = true } sc-utils = { workspace = true } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } dkg-runtime-primitives = { workspace = true, features = ["testing", "std"] } -dkg-logging = { workspace = true } +dkg-logging = { workspace = true, features = ["full"] } diff --git a/dkg-test-orchestrator/Cargo.toml b/dkg-test-orchestrator/Cargo.toml index abfaf7066..aeca6fc47 100644 --- a/dkg-test-orchestrator/Cargo.toml +++ b/dkg-test-orchestrator/Cargo.toml @@ -12,7 +12,7 @@ debug-tracing = ["dkg-gadget/debug-tracing"] tokio = { workspace = true, features = ["rt-multi-thread", "fs", "macros", "process"] } toml = { workspace = true, features = ["parse"] } dkg-mock-blockchain = { workspace = true } -dkg-logging = { workspace = true } +dkg-logging = { workspace = true, features = ["full"] } dkg-gadget = { workspace = true, features = ["testing"] } structopt = { workspace = true } log = { workspace = true } @@ -34,4 +34,4 @@ sp-core = { workspace = true } sp-keystore = { workspace = true } uuid = { workspace = true, features = ["v4"] } frame-support = { workspace = true } -rand = "0.8.5" \ No newline at end of file +rand = "0.8.5" diff --git a/standalone/node/Cargo.toml b/standalone/node/Cargo.toml index 3214cdef9..d88c23267 100644 --- a/standalone/node/Cargo.toml +++ b/standalone/node/Cargo.toml @@ -65,7 +65,7 @@ dkg-gadget = { workspace = true } dkg-runtime-primitives = { workspace = true } dkg-primitives = { workspace = true } dkg-standalone-runtime = { workspace = true } -dkg-logging = { workspace = true } +dkg-logging = { workspace = true, features = ["full"] } webb-relayer-gadget = { workspace = true } webb-relayer-gadget-cli = { workspace = true } tokio = { workspace = true, features = ["rt"] }