From d09f6c3c9f55af7f32b2dd9601aee1cbedbb040a Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Fri, 20 Oct 2023 15:43:26 -0700 Subject: [PATCH 1/6] Added flamegraph --- .github/workflows/integrations.yml | 4 -- Cargo.lock | 1 + Cargo.toml | 4 ++ integration-tests/Cargo.toml | 8 ++- integration-tests/README.md | 6 -- integration-tests/src/env/local.rs | 25 ++++---- integration-tests/src/util.rs | 92 ++++++++++++++++++++++-------- mpc-recovery/Cargo.toml | 4 ++ mpc-recovery/src/lib.rs | 15 ++--- mpc-recovery/src/logging.rs | 23 ++++++++ mpc-recovery/src/oauth.rs | 5 +- 11 files changed, 123 insertions(+), 64 deletions(-) diff --git a/.github/workflows/integrations.yml b/.github/workflows/integrations.yml index c23e3e67a..115fd353b 100644 --- a/.github/workflows/integrations.yml +++ b/.github/workflows/integrations.yml @@ -60,10 +60,6 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Build MPC Recovery Binary Locally - run: | - cargo build -p mpc-recovery --release - - name: Test run: cargo test -p mpc-recovery-integration-tests --jobs 1 -- --test-threads 1 env: diff --git a/Cargo.lock b/Cargo.lock index 5fb9c5292..47a9c6a47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2948,6 +2948,7 @@ dependencies = [ "near-primitives 0.17.0", "near-units", "near-workspaces", + "nix", "once_cell", "rand 0.7.3", "rand 0.8.5", diff --git a/Cargo.toml b/Cargo.toml index d63f66d51..102cd14a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,7 @@ members = [ "load-tests", "test-oidc-provider", ] + +[profile.flamegraph] +inherits = "release" +debug = true diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 5e81bc4c6..d5ed12d5d 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -10,25 +10,26 @@ anyhow = { version = "1.0", features = ["backtrace"] } async-process = "1" bollard = "0.11" clap = { version = "4.2", features = ["derive", "env"] } -curv = { package = "curv-kzen", version = "0.9", default-features = false } +curv = { package = "curv-kzen", version = "0.9" } ed25519-dalek = { version = "1.0.1", features = ["serde"] } futures = "0.3" hex = "0.4.3" hyper = { version = "0.14", features = ["full"] } -mpc-recovery = { path = "../mpc-recovery" } +mpc-recovery = { path = "../mpc-recovery", default-features = false } multi-party-eddsa = { git = "https://github.com/DavidM-D/multi-party-eddsa.git", rev = "25ae4fdc5ff7819ae70e73ab4afacf1c24fc4da1" } tracing = "0.1" near-crypto = "0.17" near-jsonrpc-client = "0.6" near-primitives = "0.17" near-units = "0.2.0" +nix = { version = "0.27", features = ["signal"] } once_cell = "1" serde = "1" serde_json = "1" testcontainers = { version = "0.14", features = ["experimental"] } tokio = { version = "1.28", features = ["full"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } -near-workspaces = "0.8.0" +near-workspaces = "0.8.0" toml = "0.8.1" [dev-dependencies] @@ -43,3 +44,4 @@ reqwest = "0.11.16" [features] default = [] docker-test = [] +flamegraph = ["mpc-recovery/disable-open-telemetry"] diff --git a/integration-tests/README.md b/integration-tests/README.md index 4ed6d1611..0f7dae656 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -16,12 +16,6 @@ Build OIDC Provider test image docker build -t near/test-oidc-provider ./test-oidc-provider ``` -Now, build mpc-recovery from the project's root: - -```BASH -cargo build --release -``` - Then run the integration tests: ```BASH diff --git a/integration-tests/src/env/local.rs b/integration-tests/src/env/local.rs index 66a74b6d7..08a33beb6 100644 --- a/integration-tests/src/env/local.rs +++ b/integration-tests/src/env/local.rs @@ -1,12 +1,11 @@ use aes_gcm::aead::consts::U32; use aes_gcm::aead::generic_array::GenericArray; -use async_process::Child; use mpc_recovery::firewall::allowed::DelegateActionRelayer; use mpc_recovery::relayer::NearRpcAndRelayerClient; use multi_party_eddsa::protocols::ExpandedKeyPair; use crate::env::{LeaderNodeApi, SignerNodeApi}; -use crate::util; +use crate::util::{self, NodeProcess}; use mpc_recovery::logging; pub struct SignerNode { @@ -19,8 +18,7 @@ pub struct SignerNode { gcp_datastore_url: String, // process held so it's not dropped. Once dropped, process will be killed. - #[allow(unused)] - process: Child, + _process: NodeProcess, } impl SignerNode { @@ -51,11 +49,10 @@ impl SignerNode { gcp_datastore_url: Some(ctx.datastore.local_address.clone()), jwt_signature_pk_url: ctx.oidc_provider.jwt_pk_local_url.clone(), logging_options: logging::Options::default(), - } - .into_str_args(); + }; - let sign_node_id = format!("sign/{node_id}"); - let process = util::spawn_mpc(ctx.release, &sign_node_id, &args)?; + let sign_node_id = format!("sign-{node_id}"); + let process = util::spawn_mpc(ctx.release, &sign_node_id, args).await?; let address = format!("http://127.0.0.1:{web_port}"); tracing::info!("Signer node is starting at {}", address); util::ping_until_ok(&address, 60).await?; @@ -69,7 +66,7 @@ impl SignerNode { cipher_key: *cipher_key, gcp_project_id: ctx.gcp_project_id.clone(), gcp_datastore_url: ctx.datastore.local_address.clone(), - process, + _process: process, }) } @@ -92,8 +89,7 @@ pub struct LeaderNode { relayer_url: String, // process held so it's not dropped. Once dropped, process will be killed. - #[allow(unused)] - process: Child, + _process: NodeProcess, } impl LeaderNode { @@ -129,10 +125,9 @@ impl LeaderNode { gcp_datastore_url: Some(ctx.datastore.local_address.clone()), jwt_signature_pk_url: ctx.oidc_provider.jwt_pk_local_url.clone(), logging_options: logging::Options::default(), - } - .into_str_args(); + }; - let process = util::spawn_mpc(ctx.release, "leader", &args)?; + let process = util::spawn_mpc(ctx.release, "leader", args).await?; let address = format!("http://127.0.0.1:{web_port}"); tracing::info!("Leader node container is starting at {}", address); util::ping_until_ok(&address, 60).await?; @@ -142,7 +137,7 @@ impl LeaderNode { address, near_rpc: ctx.relayer_ctx.sandbox.local_address.clone(), relayer_url: ctx.relayer_ctx.relayer.local_address.clone(), - process, + _process: process, }) } diff --git a/integration-tests/src/util.rs b/integration-tests/src/util.rs index c96bafde1..3aa79d0ca 100644 --- a/integration-tests/src/util.rs +++ b/integration-tests/src/util.rs @@ -5,15 +5,17 @@ use std::{ }; use anyhow::Context; -use async_process::{Child, Command, Stdio}; +use async_process::{Child, Command, ExitStatus, Stdio}; use hyper::{Body, Client, Method, Request, StatusCode, Uri}; +use mpc_recovery::Cli; use near_workspaces::{types::SecretKey, AccountId}; use serde::{Deserialize, Serialize}; +use tokio::runtime::Runtime; use toml::Value; use crate::containers::RelayerConfig; -const EXECUTABLE: &str = "mpc-recovery"; +const PACKAGE: &str = "mpc-recovery"; pub async fn post( uri: U, @@ -223,38 +225,80 @@ pub async fn ping_until_ok(addr: &str, timeout: u64) -> anyhow::Result<()> { Ok(()) } -pub fn target_dir() -> Option { - let mut out_dir = Path::new(std::env!("OUT_DIR")); - loop { - if out_dir.ends_with("target") { - break Some(out_dir.to_path_buf()); - } +/// NodeProcess holds onto the respective handles such that on drop, it will clean +/// the running process, task, or thread. +pub enum NodeProcess { + Subprocess(Child), + Threaded(std::thread::JoinHandle>), +} - match out_dir.parent() { - Some(parent) => out_dir = parent, - None => break None, // We've reached the root directory and didn't find "target" - } +pub async fn spawn_mpc(release: bool, node: &str, cli: Cli) -> anyhow::Result { + if cfg!(feature = "flamegraph") { + let handle: std::thread::JoinHandle> = std::thread::spawn(|| { + let rt = Runtime::new()?; + rt.block_on(async move { + mpc_recovery::run(cli).await?; + anyhow::Result::<(), anyhow::Error>::Ok(()) + }) + .unwrap(); + Ok(()) + }); + + return Ok(NodeProcess::Threaded(handle)); } -} -pub fn executable(release: bool) -> Option { - let executable = target_dir()? - .join(if release { "release" } else { "debug" }) - .join(EXECUTABLE); - Some(executable) -} + if !prebuild_mpc(release).await?.success() { + anyhow::bail!("failed to prebuild MPC service for {node} node"); + } -pub fn spawn_mpc(release: bool, node: &str, args: &[String]) -> anyhow::Result { let executable = executable(release) .with_context(|| format!("could not find target dir while starting {node} node"))?; - - Command::new(&executable) - .args(args) + let child = Command::new(executable) + .args(cli.into_str_args()) .env("RUST_LOG", "mpc_recovery=INFO") .envs(std::env::vars()) .stdout(Stdio::inherit()) .stderr(Stdio::inherit()) .kill_on_drop(true) .spawn() - .with_context(|| format!("failed to run {node} node: {}", executable.display())) + .with_context(|| format!("failed to execute {node} node"))?; + + Ok(NodeProcess::Subprocess(child)) +} + +pub async fn prebuild_mpc(release: bool) -> anyhow::Result { + let mut cmd = Command::new("cargo"); + cmd.arg("build") + .arg("--package") + .arg(PACKAGE) + .envs(std::env::vars()) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()); + + if release { + cmd.arg("--release"); + } + + Ok(cmd.spawn()?.status().await?) +} + +fn executable(release: bool) -> Option { + let executable = target_dir()? + .join(if release { "release" } else { "debug" }) + .join(PACKAGE); + Some(executable) +} + +fn target_dir() -> Option { + let mut out_dir = Path::new(std::env!("OUT_DIR")); + loop { + if out_dir.ends_with("target") { + break Some(out_dir.to_path_buf()); + } + + match out_dir.parent() { + Some(parent) => out_dir = parent, + None => break None, // We've reached the root directory and didn't find "target" + } + } } diff --git a/mpc-recovery/Cargo.toml b/mpc-recovery/Cargo.toml index a2a215f25..b4f04b694 100644 --- a/mpc-recovery/Cargo.toml +++ b/mpc-recovery/Cargo.toml @@ -58,3 +58,7 @@ sha2 = "0.9.9" [dev-dependencies] rsa = "0.8.2" + +[features] +default = [] +disable-open-telemetry = [] diff --git a/mpc-recovery/src/lib.rs b/mpc-recovery/src/lib.rs index fdc5a255c..8a598f60b 100644 --- a/mpc-recovery/src/lib.rs +++ b/mpc-recovery/src/lib.rs @@ -205,14 +205,13 @@ pub async fn run(cmd: Cli) -> anyhow::Result<()> { jwt_signature_pk_url, logging_options, } => { - let _subscriber_guard = logging::default_subscriber_with_opentelemetry( + let _subscriber_guard = logging::subscribe_global( EnvFilter::from_default_env(), &logging_options, env.clone(), "leader".to_string(), ) - .await - .global(); + .await; let gcp_service = GcpService::new(env.clone(), gcp_project_id, gcp_datastore_url).await?; let account_creator_sk = @@ -252,14 +251,13 @@ pub async fn run(cmd: Cli) -> anyhow::Result<()> { jwt_signature_pk_url, logging_options, } => { - let _subscriber_guard = logging::default_subscriber_with_opentelemetry( + let _subscriber_guard = logging::subscribe_global( EnvFilter::from_default_env(), &logging_options, env.clone(), node_id.to_string(), ) - .await - .global(); + .await; let gcp_service = GcpService::new(env.clone(), gcp_project_id, gcp_datastore_url).await?; let oidc_providers = OidcProviderList { @@ -303,14 +301,13 @@ pub async fn run(cmd: Cli) -> anyhow::Result<()> { gcp_datastore_url, logging_options, } => { - let _subscriber_guard = logging::default_subscriber_with_opentelemetry( + let _subscriber_guard = logging::subscribe_global( EnvFilter::from_default_env(), &logging_options, env.clone(), node_id.to_string(), ) - .await - .global(); + .await; let gcp_service = GcpService::new( env.clone(), gcp_project_id.clone(), diff --git a/mpc-recovery/src/logging.rs b/mpc-recovery/src/logging.rs index 7da744f38..87ea39563 100644 --- a/mpc-recovery/src/logging.rs +++ b/mpc-recovery/src/logging.rs @@ -304,3 +304,26 @@ pub async fn default_subscriber_with_opentelemetry( writer_guard: Some(writer_guard), } } + +pub enum FeatureGuard { + Noop, + Default(DefaultSubscriberGuard), +} + +pub async fn subscribe_global( + env_filter: EnvFilter, + options: &Options, + env: String, + node_id: String, +) -> FeatureGuard { + if cfg!(feature = "disable-open-telemetry") { + FeatureGuard::Noop + } else { + let subscriber_guard = + default_subscriber_with_opentelemetry(env_filter, options, env, node_id) + .await + .global(); + + FeatureGuard::Default(subscriber_guard) + } +} diff --git a/mpc-recovery/src/oauth.rs b/mpc-recovery/src/oauth.rs index d1854c84f..35cffa352 100644 --- a/mpc-recovery/src/oauth.rs +++ b/mpc-recovery/src/oauth.rs @@ -18,6 +18,7 @@ pub async fn verify_oidc_token( let public_keys = get_pagoda_firebase_public_keys(client, jwt_signature_pk_url) .await .map_err(|e| anyhow::anyhow!("failed to get Firebase public key: {e}"))?; + tracing::info!("verify_oidc_token firebase public keys: {public_keys:?}"); let mut last_occured_error = anyhow::anyhow!("Unexpected error. Firebase public keys not found"); @@ -101,9 +102,7 @@ pub async fn get_pagoda_firebase_public_keys( ) -> anyhow::Result> { let response = client.get(jwt_signature_pk_url).send().await?; let json: HashMap = response.json().await?; - let keys: Vec = json.values().cloned().collect(); - tracing::info!("get_pagoda_firebase_public_keys keys: {:?}", keys); - Ok(keys) + Ok(json.into_values().collect()) } #[cfg(test)] From 81d17baee0d7f11d60a2ccc1c1511069a18b83d7 Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Fri, 20 Oct 2023 15:53:11 -0700 Subject: [PATCH 2/6] Moved mpc related stuff in util.rs to mpc.rs --- integration-tests/src/env/local.rs | 7 +-- integration-tests/src/lib.rs | 1 + integration-tests/src/mpc.rs | 87 ++++++++++++++++++++++++++++++ integration-tests/src/util.rs | 84 ----------------------------- 4 files changed, 92 insertions(+), 87 deletions(-) create mode 100644 integration-tests/src/mpc.rs diff --git a/integration-tests/src/env/local.rs b/integration-tests/src/env/local.rs index 08a33beb6..a3588e15e 100644 --- a/integration-tests/src/env/local.rs +++ b/integration-tests/src/env/local.rs @@ -5,7 +5,8 @@ use mpc_recovery::relayer::NearRpcAndRelayerClient; use multi_party_eddsa::protocols::ExpandedKeyPair; use crate::env::{LeaderNodeApi, SignerNodeApi}; -use crate::util::{self, NodeProcess}; +use crate::mpc::{self, NodeProcess}; +use crate::util; use mpc_recovery::logging; pub struct SignerNode { @@ -52,7 +53,7 @@ impl SignerNode { }; let sign_node_id = format!("sign-{node_id}"); - let process = util::spawn_mpc(ctx.release, &sign_node_id, args).await?; + let process = mpc::spawn(ctx.release, &sign_node_id, args).await?; let address = format!("http://127.0.0.1:{web_port}"); tracing::info!("Signer node is starting at {}", address); util::ping_until_ok(&address, 60).await?; @@ -127,7 +128,7 @@ impl LeaderNode { logging_options: logging::Options::default(), }; - let process = util::spawn_mpc(ctx.release, "leader", args).await?; + let process = mpc::spawn(ctx.release, "leader", args).await?; let address = format!("http://127.0.0.1:{web_port}"); tracing::info!("Leader node container is starting at {}", address); util::ping_until_ok(&address, 60).await?; diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 0375684a0..928e90ef5 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -10,6 +10,7 @@ use near_workspaces::{ use crate::env::containers; pub mod env; +pub mod mpc; pub mod sandbox; pub mod util; diff --git a/integration-tests/src/mpc.rs b/integration-tests/src/mpc.rs new file mode 100644 index 000000000..f5855fbf2 --- /dev/null +++ b/integration-tests/src/mpc.rs @@ -0,0 +1,87 @@ +use std::path::{Path, PathBuf}; + +use anyhow::Context; +use async_process::{Command, ExitStatus, Stdio}; +use tokio::runtime::Runtime; + +use mpc_recovery::Cli; + +const PACKAGE: &str = "mpc-recovery"; + +/// NodeProcess holds onto the respective handles such that on drop, it will clean +/// the running process, task, or thread. +pub enum NodeProcess { + Subprocess(async_process::Child), + Threaded(std::thread::JoinHandle>), +} + +fn executable(release: bool) -> Option { + let executable = target_dir()? + .join(if release { "release" } else { "debug" }) + .join(PACKAGE); + Some(executable) +} + +fn target_dir() -> Option { + let mut out_dir = Path::new(std::env!("OUT_DIR")); + loop { + if out_dir.ends_with("target") { + break Some(out_dir.to_path_buf()); + } + + match out_dir.parent() { + Some(parent) => out_dir = parent, + None => break None, // We've reached the root directory and didn't find "target" + } + } +} + +async fn build(release: bool) -> anyhow::Result { + let mut cmd = Command::new("cargo"); + cmd.arg("build") + .arg("--package") + .arg(PACKAGE) + .envs(std::env::vars()) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()); + + if release { + cmd.arg("--release"); + } + + Ok(cmd.spawn()?.status().await?) +} + +pub async fn spawn(release: bool, node: &str, cli: Cli) -> anyhow::Result { + if cfg!(feature = "flamegraph") { + let handle: std::thread::JoinHandle> = std::thread::spawn(|| { + let rt = Runtime::new()?; + rt.block_on(async move { + mpc_recovery::run(cli).await?; + anyhow::Result::<(), anyhow::Error>::Ok(()) + }) + .unwrap(); + Ok(()) + }); + + return Ok(NodeProcess::Threaded(handle)); + } + + if !build(release).await?.success() { + anyhow::bail!("failed to prebuild MPC service for {node} node"); + } + + let executable = executable(release) + .with_context(|| format!("could not find target dir while starting {node} node"))?; + let child = Command::new(executable) + .args(cli.into_str_args()) + .env("RUST_LOG", "mpc_recovery=INFO") + .envs(std::env::vars()) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .kill_on_drop(true) + .spawn() + .with_context(|| format!("failed to execute {node} node"))?; + + Ok(NodeProcess::Subprocess(child)) +} diff --git a/integration-tests/src/util.rs b/integration-tests/src/util.rs index 3aa79d0ca..0a0d3be2c 100644 --- a/integration-tests/src/util.rs +++ b/integration-tests/src/util.rs @@ -1,22 +1,16 @@ use std::{ fs::{self, File}, io::Write, - path::{Path, PathBuf}, }; use anyhow::Context; -use async_process::{Child, Command, ExitStatus, Stdio}; use hyper::{Body, Client, Method, Request, StatusCode, Uri}; -use mpc_recovery::Cli; use near_workspaces::{types::SecretKey, AccountId}; use serde::{Deserialize, Serialize}; -use tokio::runtime::Runtime; use toml::Value; use crate::containers::RelayerConfig; -const PACKAGE: &str = "mpc-recovery"; - pub async fn post( uri: U, request: Req, @@ -224,81 +218,3 @@ pub async fn ping_until_ok(addr: &str, timeout: u64) -> anyhow::Result<()> { .await?; Ok(()) } - -/// NodeProcess holds onto the respective handles such that on drop, it will clean -/// the running process, task, or thread. -pub enum NodeProcess { - Subprocess(Child), - Threaded(std::thread::JoinHandle>), -} - -pub async fn spawn_mpc(release: bool, node: &str, cli: Cli) -> anyhow::Result { - if cfg!(feature = "flamegraph") { - let handle: std::thread::JoinHandle> = std::thread::spawn(|| { - let rt = Runtime::new()?; - rt.block_on(async move { - mpc_recovery::run(cli).await?; - anyhow::Result::<(), anyhow::Error>::Ok(()) - }) - .unwrap(); - Ok(()) - }); - - return Ok(NodeProcess::Threaded(handle)); - } - - if !prebuild_mpc(release).await?.success() { - anyhow::bail!("failed to prebuild MPC service for {node} node"); - } - - let executable = executable(release) - .with_context(|| format!("could not find target dir while starting {node} node"))?; - let child = Command::new(executable) - .args(cli.into_str_args()) - .env("RUST_LOG", "mpc_recovery=INFO") - .envs(std::env::vars()) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) - .kill_on_drop(true) - .spawn() - .with_context(|| format!("failed to execute {node} node"))?; - - Ok(NodeProcess::Subprocess(child)) -} - -pub async fn prebuild_mpc(release: bool) -> anyhow::Result { - let mut cmd = Command::new("cargo"); - cmd.arg("build") - .arg("--package") - .arg(PACKAGE) - .envs(std::env::vars()) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()); - - if release { - cmd.arg("--release"); - } - - Ok(cmd.spawn()?.status().await?) -} - -fn executable(release: bool) -> Option { - let executable = target_dir()? - .join(if release { "release" } else { "debug" }) - .join(PACKAGE); - Some(executable) -} - -fn target_dir() -> Option { - let mut out_dir = Path::new(std::env!("OUT_DIR")); - loop { - if out_dir.ends_with("target") { - break Some(out_dir.to_path_buf()); - } - - match out_dir.parent() { - Some(parent) => out_dir = parent, - None => break None, // We've reached the root directory and didn't find "target" - } - } -} From 29f0c673b2ab9b2f3ff1d2975a25786c7750f96c Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Fri, 20 Oct 2023 16:06:14 -0700 Subject: [PATCH 3/6] Added README on profiling --- integration-tests/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/integration-tests/README.md b/integration-tests/README.md index 0f7dae656..412ccc010 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -38,6 +38,22 @@ Finally, run the integration tests with the built docker image: cargo test -p mpc-recovery-integration-tests --features docker-test ``` +## Profiling: Flamegraphs + +To profile code and get a flamegraph, run the following: + +```sh +cargo flamegraph --root --profile flamegraph --test lib +``` + +Or for a singular test like `test_basic_action`: + +```sh +cargo flamegraph --root --profile flamegraph --test lib -- test_basic_action +``` + +This will generate a `flamegraph.svg`. Open this on a browser and inspect each of the callstacks. + ## FAQ ### I want to run a test, but keep the docker containers from being destroyed From dbef323c0fed78c2c5776269c5e31c3fa45c9206 Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Fri, 20 Oct 2023 16:09:15 -0700 Subject: [PATCH 4/6] Fix incorrect default-features --- integration-tests/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 70f0c77a8..199835ded 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -10,12 +10,12 @@ anyhow = { version = "1.0", features = ["backtrace"] } async-process = "1" bollard = "0.11" clap = { version = "4.2", features = ["derive", "env"] } -curv = { package = "curv-kzen", version = "0.9" } +curv = { package = "curv-kzen", version = "0.9", default-features = false } ed25519-dalek = { version = "1.0.1", features = ["serde"] } futures = "0.3" hex = "0.4.3" hyper = { version = "0.14", features = ["full"] } -mpc-recovery = { path = "../mpc-recovery", default-features = false } +mpc-recovery = { path = "../mpc-recovery" } multi-party-eddsa = { git = "https://github.com/DavidM-D/multi-party-eddsa.git", rev = "25ae4fdc5ff7819ae70e73ab4afacf1c24fc4da1" } tracing = "0.1" near-crypto = "0.17" From 01a631715b916b785490806d0d3b4058bc06feaa Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Mon, 23 Oct 2023 14:15:46 -0700 Subject: [PATCH 5/6] Git ignore flamegraph files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b00bc8dd7..5a0427d44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target .direnv .DS_Store + +flamegraph*.svg \ No newline at end of file From 91c148da968c22f206a3f735e121eb36b726c611 Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Thu, 26 Oct 2023 17:53:11 -0500 Subject: [PATCH 6/6] Made building MPC service earlier in tests --- .github/workflows/integrations.yml | 4 ---- integration-tests/src/env/mod.rs | 8 +++++++- integration-tests/src/mpc.rs | 6 +----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integrations.yml b/.github/workflows/integrations.yml index 4359e135f..658e004e1 100644 --- a/.github/workflows/integrations.yml +++ b/.github/workflows/integrations.yml @@ -64,10 +64,6 @@ jobs: - name: Compile Contract run: cargo build -p mpc-contract --target wasm32-unknown-unknown --release - - name: Build MPC Recovery Binary Locally - run: | - cargo build -p mpc-recovery --release - - name: Test run: cargo test -p mpc-recovery-integration-tests mpc --jobs 1 -- --test-threads 1 env: diff --git a/integration-tests/src/env/mod.rs b/integration-tests/src/env/mod.rs index 91cb9f651..01526deff 100644 --- a/integration-tests/src/env/mod.rs +++ b/integration-tests/src/env/mod.rs @@ -101,6 +101,12 @@ pub struct Context<'a> { } pub async fn setup(docker_client: &DockerClient) -> anyhow::Result> { + let release = true; + #[cfg(not(feature = "flamegraph"))] + if !crate::mpc::build(release).await?.success() { + anyhow::bail!("failed to prebuild MPC service"); + } + let gcp_project_id = GCP_PROJECT_ID; let docker_network = NETWORK; docker_client.create_network(docker_network).await?; @@ -124,7 +130,7 @@ pub async fn setup(docker_client: &DockerClient) -> anyhow::Result> gcp_project_id: gcp_project_id.to_string(), audience_id: FIREBASE_AUDIENCE_ID.to_string(), issuer: ISSUER.to_string(), - release: true, + release, relayer_ctx, datastore, oidc_provider, diff --git a/integration-tests/src/mpc.rs b/integration-tests/src/mpc.rs index 87e7a8904..259f1c629 100644 --- a/integration-tests/src/mpc.rs +++ b/integration-tests/src/mpc.rs @@ -37,7 +37,7 @@ fn target_dir() -> Option { } } -async fn build(release: bool) -> anyhow::Result { +pub async fn build(release: bool) -> anyhow::Result { let mut cmd = Command::new("cargo"); cmd.arg("build") .arg("--package") @@ -68,10 +68,6 @@ pub async fn spawn(release: bool, node: &str, cli: Cli) -> anyhow::Result