Skip to content

Commit

Permalink
chore: update naming of env vars and binary (MPC_RECOVERY_* is now MP…
Browse files Browse the repository at this point in the history
…C_*) (#730)

* Renamed chain-signature MPC_RECOVERY_* env vars to MPC_*

* Rename mpc-recovery-node binary to mpc-node

* Rename some forgotten binary names

* Cargo fmt
  • Loading branch information
ChaoticTempest authored Jul 25, 2024
1 parent b1677a5 commit 2086c26
Show file tree
Hide file tree
Showing 32 changed files with 261 additions and 273 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/multichain-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:

- name: Build Chain-Signatures Node
working-directory: ./chain-signatures
run: cargo build -p mpc-recovery-node --release
run: cargo build -p mpc-node --release

# Build the tests before actually running them to see how long the tests take to run by itself
# instead of including the build time in the test time report on Github.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/multichain-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:

- name: Build Chain-Signatures Node
working-directory: ./chain-signatures
run: cargo build -p mpc-recovery-node --release
run: cargo build -p mpc-node --release

- name: Build Chain-Signatures Integration Tests
working-directory: ./integration-tests/chain-signatures
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.multichain
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ COPY chain-signatures/. .
RUN sed -i 's#"keys",##' Cargo.toml
RUN sed -i 's#"contract",##' Cargo.toml
RUN sed -i 's#target-dir = "../target"#target-dir = "target"#' .cargo/config.toml
RUN cargo build --release --package mpc-recovery-node
RUN cargo build --release --package mpc-node

FROM debian:stable-slim as runtime
RUN apt-get update && apt-get install --assume-yes libssl-dev ca-certificates curl
RUN update-ca-certificates
COPY --from=builder /usr/src/app/target/release/mpc-recovery-node /usr/local/bin/mpc-recovery-node
COPY --from=builder /usr/src/app/target/release/mpc-node /usr/local/bin/mpc-node
WORKDIR /usr/local/bin

ENTRYPOINT [ "mpc-recovery-node" ]
ENTRYPOINT [ "mpc-node" ]
2 changes: 1 addition & 1 deletion chain-signatures/Cargo.lock

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

4 changes: 2 additions & 2 deletions chain-signatures/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "mpc-recovery-node"
name = "mpc-node"
version = "1.0.0-rc.1"
edition = "2021"

[[bin]]
name = "mpc-recovery-node"
name = "mpc-node"
path = "src/main.rs"

[dependencies]
Expand Down
38 changes: 15 additions & 23 deletions chain-signatures/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,76 +22,68 @@ pub enum Cli {
/// NEAR RPC address
#[arg(
long,
env("MPC_RECOVERY_NEAR_RPC"),
env("MPC_NEAR_RPC"),
default_value("https://rpc.testnet.near.org")
)]
near_rpc: String,
/// MPC contract id
#[arg(
long,
env("MPC_RECOVERY_CONTRACT_ID"),
env("MPC_CONTRACT_ID"),
default_value("v5.multichain-mpc-dev.testnet")
)]
mpc_contract_id: AccountId,
/// This node's account id
#[arg(long, env("MPC_RECOVERY_ACCOUNT_ID"))]
#[arg(long, env("MPC_ACCOUNT_ID"))]
account_id: AccountId,
/// This node's account ed25519 secret key
#[arg(long, env("MPC_RECOVERY_ACCOUNT_SK"))]
#[arg(long, env("MPC_ACCOUNT_SK"))]
account_sk: SecretKey,
/// The web port for this server
#[arg(long, env("MPC_RECOVERY_WEB_PORT"))]
#[arg(long, env("MPC_WEB_PORT"))]
web_port: u16,
// TODO: need to add in CipherPK type for parsing.
/// The cipher public key used to encrypt messages between nodes.
#[arg(long, env("MPC_RECOVERY_CIPHER_PK"))]
#[arg(long, env("MPC_CIPHER_PK"))]
cipher_pk: String,
/// The cipher secret key used to decrypt messages between nodes.
#[arg(long, env("MPC_RECOVERY_CIPHER_SK"))]
#[arg(long, env("MPC_CIPHER_SK"))]
cipher_sk: String,
/// The secret key used to sign messages to be sent between nodes.
#[arg(long, env("MPC_RECOVERY_SIGN_SK"))]
#[arg(long, env("MPC_SIGN_SK"))]
sign_sk: Option<SecretKey>,
/// NEAR Lake Indexer options
#[clap(flatten)]
indexer_options: indexer::Options,
/// Local address that other peers can use to message this node.
#[arg(long, env("MPC_RECOVERY_LOCAL_ADDRESS"))]
#[arg(long, env("MPC_LOCAL_ADDRESS"))]
my_address: Option<Url>,
/// Storage options
#[clap(flatten)]
storage_options: storage::Options,
/// At minimum, how many triples to stockpile on this node.
#[arg(long, env("MPC_RECOVERY_MIN_TRIPLES"), default_value("20"))]
#[arg(long, env("MPC_MIN_TRIPLES"), default_value("20"))]
min_triples: usize,
/// At maximum, how many triples to stockpile on this node.
#[arg(long, env("MPC_RECOVERY_MAX_TRIPLES"), default_value("640"))]
#[arg(long, env("MPC_MAX_TRIPLES"), default_value("640"))]
max_triples: usize,

/// At maximum, how many triple protocols can this current node introduce
/// at the same time. This should be something like `max_concurrent_gen / num_nodes`
#[arg(
long,
env("MPC_RECOVERY_MAX_CONCURRENT_INTRODUCTION"),
default_value("2")
)]
#[arg(long, env("MPC_MAX_CONCURRENT_INTRODUCTION"), default_value("2"))]
max_concurrent_introduction: usize,

/// At maximum, how many ongoing protocols for triples to be running
/// at the same time. The rest will be queued up.
#[arg(
long,
env("MPC_RECOVERY_MAX_CONCURRENT_GENERATION"),
default_value("16")
)]
#[arg(long, env("MPC_MAX_CONCURRENT_GENERATION"), default_value("16"))]
max_concurrent_generation: usize,

/// At minimum, how many presignatures to stockpile on this node.
#[arg(long, env("MPC_RECOVERY_MIN_PRESIGNATURES"), default_value("10"))]
#[arg(long, env("MPC_MIN_PRESIGNATURES"), default_value("10"))]
min_presignatures: usize,

/// At maximum, how many presignatures to stockpile on the network.
#[arg(long, env("MPC_RECOVERY_MAX_PRESIGNATURES"), default_value("320"))]
#[arg(long, env("MPC_MAX_PRESIGNATURES"), default_value("320"))]
max_presignatures: usize,
},
}
Expand Down
12 changes: 4 additions & 8 deletions chain-signatures/node/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,24 @@ pub struct Options {
/// AWS S3 bucket name for NEAR Lake Indexer
#[clap(
long,
env("MPC_RECOVERY_INDEXER_S3_BUCKET"),
env("MPC_INDEXER_S3_BUCKET"),
default_value = "near-lake-data-testnet"
)]
pub s3_bucket: String,

/// AWS S3 region name for NEAR Lake Indexer
#[clap(
long,
env("MPC_RECOVERY_INDEXER_S3_REGION"),
default_value = "eu-central-1"
)]
#[clap(long, env("MPC_INDEXER_S3_REGION"), default_value = "eu-central-1")]
pub s3_region: String,

/// AWS S3 URL for NEAR Lake Indexer (can be used to point to LocalStack)
#[clap(long, env("MPC_RECOVERY_INDEXER_S3_URL"))]
#[clap(long, env("MPC_INDEXER_S3_URL"))]
pub s3_url: Option<String>,

/// The block height to start indexing from.
// Defaults to the latest block on 2023-11-14 07:40:22 AM UTC
#[clap(
long,
env("MPC_RECOVERY_INDEXER_START_BLOCK_HEIGHT"),
env("MPC_INDEXER_START_BLOCK_HEIGHT"),
default_value = "145964826"
)]
pub start_block_height: u64,
Expand Down
4 changes: 2 additions & 2 deletions chain-signatures/node/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use mpc_recovery_node::cli::Cli;
use mpc_node::cli::Cli;

fn main() -> anyhow::Result<()> {
mpc_recovery_node::cli::run(Cli::parse())
mpc_node::cli::run(Cli::parse())
}
10 changes: 5 additions & 5 deletions chain-signatures/node/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ pub mod triple_storage;
#[group(id = "storage_options")]
pub struct Options {
/// env used to suffix datastore table names to differentiate among environments.
#[clap(long, env("MPC_RECOVERY_ENV"))]
#[clap(long, env("MPC_ENV"))]
pub env: String,
/// GCP project ID.
#[clap(long, env("MPC_RECOVERY_GCP_PROJECT_ID"))]
#[clap(long, env("MPC_GCP_PROJECT_ID"))]
pub gcp_project_id: String,
/// GCP Secret Manager ID that will be used to load/store the node's secret key share.
#[clap(long, env("MPC_RECOVERY_SK_SHARE_SECRET_ID"), requires_all=["gcp_project_id"])]
#[clap(long, env("MPC_SK_SHARE_SECRET_ID"), requires_all=["gcp_project_id"])]
pub sk_share_secret_id: Option<String>,
/// Mostly for integration tests.
/// GCP Datastore URL that will be used to load/store the node's triples and presignatures.
#[arg(long, env("MPC_RECOVERY_GCP_DATASTORE_URL"))]
#[arg(long, env("MPC_GCP_DATASTORE_URL"))]
pub gcp_datastore_url: Option<String>,
#[arg(long, env("MPC_RECOVERY_SK_SHARE_LOCAL_PATH"))]
#[arg(long, env("MPC_SK_SHARE_LOCAL_PATH"))]
pub sk_share_local_path: Option<String>,
}

Expand Down
2 changes: 1 addition & 1 deletion chain-signatures/node/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl AffinePointExt for AffinePoint {
}

pub fn get_triple_timeout() -> Duration {
env::var("MPC_RECOVERY_TRIPLE_TIMEOUT_SEC")
env::var("MPC_TRIPLE_TIMEOUT_SEC")
.map(|val| val.parse::<u64>().ok().map(Duration::from_secs))
.unwrap_or_default()
.unwrap_or(crate::types::PROTOCOL_TRIPLE_TIMEOUT)
Expand Down
36 changes: 18 additions & 18 deletions infra/modules/multichain/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,51 @@ resource "google_cloud_run_v2_service" "node" {
args = ["start"]

env {
name = "MPC_RECOVERY_NODE_ID"
name = "MPC_NODE_ID"
value = var.node_id
}
env {
name = "MPC_RECOVERY_NEAR_RPC"
name = "MPC_NEAR_RPC"
value = var.near_rpc
}
env {
name = "MPC_RECOVERY_CONTRACT_ID"
name = "MPC_CONTRACT_ID"
value = var.mpc_contract_id
}
env {
name = "MPC_RECOVERY_ACCOUNT_ID"
name = "MPC_ACCOUNT_ID"
value = var.account_id
}
env {
name = "MPC_RECOVERY_CIPHER_PK"
name = "MPC_CIPHER_PK"
value = var.cipher_pk
}
env {
name = "MPC_RECOVERY_LOCAL_ADDRESS"
name = "MPC_LOCAL_ADDRESS"
value = var.my_address
}
env {
name = "MPC_RECOVERY_INDEXER_S3_BUCKET"
name = "MPC_INDEXER_S3_BUCKET"
value = var.indexer_options.s3_bucket
}
env {
name = "MPC_RECOVERY_INDEXER_S3_REGION"
name = "MPC_INDEXER_S3_REGION"
value = var.indexer_options.s3_region
}
// Conditional block in case s3_url is present. See https://stackoverflow.com/a/69891235
dynamic "env" {
for_each = var.indexer_options.s3_url == null ? [] : [1]
content {
name = "MPC_RECOVERY_INDEXER_S3_URL"
name = "MPC_INDEXER_S3_URL"
value = var.indexer_options.s3_url
}
}
env {
name = "MPC_RECOVERY_INDEXER_START_BLOCK_HEIGHT"
name = "MPC_INDEXER_START_BLOCK_HEIGHT"
value = var.indexer_options.start_block_height
}
env {
name = "MPC_RECOVERY_ACCOUNT_SK"
name = "MPC_ACCOUNT_SK"
value_source {
secret_key_ref {
secret = var.account_sk_secret_id
Expand All @@ -71,7 +71,7 @@ resource "google_cloud_run_v2_service" "node" {
}
}
env {
name = "MPC_RECOVERY_CIPHER_SK"
name = "MPC_CIPHER_SK"
value_source {
secret_key_ref {
secret = var.cipher_sk_secret_id
Expand All @@ -83,7 +83,7 @@ resource "google_cloud_run_v2_service" "node" {
dynamic "env" {
for_each = var.sign_sk_secret_id == null ? [] : [1]
content {
name = "MPC_RECOVERY_SIGN_SK"
name = "MPC_SIGN_SK"
value_source {
secret_key_ref {
secret = var.sign_sk_secret_id
Expand Down Expand Up @@ -115,24 +115,24 @@ resource "google_cloud_run_v2_service" "node" {
value = var.indexer_options.s3_region
}
env {
name = "MPC_RECOVERY_GCP_PROJECT_ID"
name = "MPC_GCP_PROJECT_ID"
value = var.project
}
env {
name = "MPC_RECOVERY_SK_SHARE_SECRET_ID"
name = "MPC_SK_SHARE_SECRET_ID"
value = var.sk_share_secret_id
}
env {
name = "MPC_RECOVERY_ENV"
name = "MPC_ENV"
value = var.env
}
env {
name = "MPC_RECOVERY_WEB_PORT"
name = "MPC_WEB_PORT"
value = "3000"
}
env {
name = "RUST_LOG"
value = "mpc_recovery_node=debug"
value = "mpc_node=debug"
}

ports {
Expand Down
18 changes: 9 additions & 9 deletions infra/multichain-dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ module "gce-container" {

env = concat(var.static_env, [
{
name = "MPC_RECOVERY_NODE_ID"
name = "MPC_NODE_ID"
value = "${count.index}"
},
{
name = "MPC_RECOVERY_ACCOUNT_ID"
name = "MPC_ACCOUNT_ID"
value = var.node_configs["${count.index}"].account
},
{
name = "MPC_RECOVERY_CIPHER_PK"
name = "MPC_CIPHER_PK"
value = var.node_configs["${count.index}"].cipher_pk
},
{
name = "MPC_RECOVERY_ACCOUNT_SK"
name = "MPC_ACCOUNT_SK"
value = data.google_secret_manager_secret_version.account_sk_secret_id[count.index].secret_data
},
{
name = "MPC_RECOVERY_CIPHER_SK"
name = "MPC_CIPHER_SK"
value = data.google_secret_manager_secret_version.cipher_sk_secret_id[count.index].secret_data
},
{
name = "MPC_RECOVERY_SIGN_SK"
name = "MPC_SIGN_SK"
value = data.google_secret_manager_secret_version.sign_sk_secret_id[count.index] != null ? data.google_secret_manager_secret_version.sign_sk_secret_id[count.index].secret_data : data.google_secret_manager_secret_version.account_sk_secret_id[count.index].secret_data
},
{
Expand All @@ -48,15 +48,15 @@ module "gce-container" {
value = data.google_secret_manager_secret_version.aws_secret_key_secret_id.secret_data
},
{
name = "MPC_RECOVERY_LOCAL_ADDRESS"
name = "MPC_LOCAL_ADDRESS"
value = "http://${google_compute_address.internal_ips[count.index].address}"
},
{
name = "MPC_RECOVERY_SK_SHARE_SECRET_ID"
name = "MPC_SK_SHARE_SECRET_ID"
value = var.node_configs["${count.index}"].sk_share_secret_id
},
{
name = "MPC_RECOVERY_ENV",
name = "MPC_ENV",
value = var.env
}
])
Expand Down
Loading

0 comments on commit 2086c26

Please sign in to comment.