From b27692d7b9b58759780c7df8e34b066904c85790 Mon Sep 17 00:00:00 2001 From: musitdev Date: Thu, 2 Jan 2025 14:54:00 +0100 Subject: [PATCH 1/5] Add config and setup to e2e test --- Cargo.lock | 26 ++++ Cargo.toml | 6 +- util/signing/config/Cargo.toml | 16 +++ util/signing/config/src/lib.rs | 27 ++++ util/signing/e2e-test/Cargo.toml | 33 +++++ .../e2e-test/bin/setup_awskms_eth_key.rs | 15 +++ .../e2e-test/bin/setup_local_eth_key.rs | 12 ++ util/signing/e2e-test/src/main.rs | 14 ++ util/signing/{signer.old => setup}/Cargo.toml | 9 +- util/signing/setup/src/lib.rs | 7 + .../signer.old/src/cryptography/ed25519.rs | 34 ----- .../signer.old/src/cryptography/mod.rs | 5 - .../signer.old/src/cryptography/secp256k1.rs | 39 ------ util/signing/signer.old/src/lib.rs | 124 ------------------ 14 files changed, 157 insertions(+), 210 deletions(-) create mode 100644 util/signing/config/Cargo.toml create mode 100644 util/signing/config/src/lib.rs create mode 100644 util/signing/e2e-test/Cargo.toml create mode 100644 util/signing/e2e-test/bin/setup_awskms_eth_key.rs create mode 100644 util/signing/e2e-test/bin/setup_local_eth_key.rs create mode 100644 util/signing/e2e-test/src/main.rs rename util/signing/{signer.old => setup}/Cargo.toml (58%) create mode 100644 util/signing/setup/src/lib.rs delete mode 100644 util/signing/signer.old/src/cryptography/ed25519.rs delete mode 100644 util/signing/signer.old/src/cryptography/mod.rs delete mode 100644 util/signing/signer.old/src/cryptography/secp256k1.rs delete mode 100644 util/signing/signer.old/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d4b01f3fc..55f7c6d4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6139,6 +6139,17 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +[[package]] +name = "e2e-test" +version = "0.0.2" +dependencies = [ + "anyhow", + "godfig", + "movement-signer-config", + "movement-signer-setup", + "tokio", +] + [[package]] name = "ecdsa" version = "0.14.8" @@ -10580,6 +10591,13 @@ dependencies = [ "spki 0.7.3", ] +[[package]] +name = "movement-signer-config" +version = "0.0.2" +dependencies = [ + "serde", +] + [[package]] name = "movement-signer-hashicorp-vault" version = "0.0.2" @@ -10590,6 +10608,14 @@ dependencies = [ "vaultrs", ] +[[package]] +name = "movement-signer-setup" +version = "0.0.2" +dependencies = [ + "anyhow", + "movement-signer-config", +] + [[package]] name = "movement-signing-aptos" version = "0.0.2" diff --git a/Cargo.toml b/Cargo.toml index db7ddec7d..56f6e9d6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,8 +46,10 @@ members = [ "util/signing/integrations/aptos", "util/signing/providers/aws-kms", "util/signing/providers/hashicorp-vault", + "util/signing/config", + "util/signing/setup", "demo/hsm" -] +, "util/signing/setup", "util/signing/config", "util/signing/e2e-test"] [workspace.package] version = "0.0.2" @@ -123,6 +125,8 @@ aptos-account-whitelist = { path = "protocol-units/access-control/aptos/account- movement-signer = { path = "util/signing/interface" } movement-signer-aws-kms = { path = "util/signing/providers/aws-kms" } movement-signer-hashicorp-vault = { path = "util/signing/providers/hashicorp-vault" } +movement-signer-config = { path = "util/signing/config" } +movement-signer-setup = { path = "util/signing/setup" } ## vault vaultrs = { version = "0.7.3" } diff --git a/util/signing/config/Cargo.toml b/util/signing/config/Cargo.toml new file mode 100644 index 000000000..00183fe96 --- /dev/null +++ b/util/signing/config/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "movement-signer-config" +version.workspace = true +edition.workspace = true +license.workspace = true +authors.workspace = true +repository.workspace = true +homepage.workspace = true +publish.workspace = true +rust-version.workspace = true + +[dependencies] +serde = { workspace = true , features = ["derive"] } + +[lints] +workspace = true diff --git a/util/signing/config/src/lib.rs b/util/signing/config/src/lib.rs new file mode 100644 index 000000000..b9dd8399c --- /dev/null +++ b/util/signing/config/src/lib.rs @@ -0,0 +1,27 @@ +//! This crate provides configuration parameters for signing KeyManager +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub enum KeyProvider { + #[default] + LOCALETH, + LOCALMVT, + AWSKMS, + VAULT, +} + +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct KeyDefinition { + #[serde(default)] + pub name: String, + #[serde(default)] + pub provider: KeyProvider, + #[serde(default)] + pub id: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct Config { + #[serde(default)] + pub key_list: Vec, +} diff --git a/util/signing/e2e-test/Cargo.toml b/util/signing/e2e-test/Cargo.toml new file mode 100644 index 000000000..fccf2874a --- /dev/null +++ b/util/signing/e2e-test/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "e2e-test" +version.workspace = true +edition.workspace = true +license.workspace = true +authors.workspace = true +repository.workspace = true +homepage.workspace = true +publish.workspace = true +rust-version.workspace = true + +[[bin]] +name = "setup_local_eth_key" +path = "bin/setup_local_eth_key.rs" + +[[bin]] +name = "setup_awskms_eth_key" +path = "bin/setup_awskms_eth_key.rs" + + +[dependencies] +movement-signer-setup = { workspace = true } +movement-signer-config = { workspace = true } + +godfig = { workspace = true } + +[dev-dependencies] +anyhow = { workspace = true } +tokio = { workspace = true } + + +[lints] +workspace = true diff --git a/util/signing/e2e-test/bin/setup_awskms_eth_key.rs b/util/signing/e2e-test/bin/setup_awskms_eth_key.rs new file mode 100644 index 000000000..08697a42c --- /dev/null +++ b/util/signing/e2e-test/bin/setup_awskms_eth_key.rs @@ -0,0 +1,15 @@ +// Create the config that contains one Eth key that sign using AWS KMS. +use godfig::env_default; +use movement_signer_config::KeyDefinition; +use movement_signer_config::KeyProvider; + +fn main() { + env_default!(get_aws_key_id, "AWS_KEY_ID", String); + let awskms_key_id = get_aws_key_id().expect("AWS_KEY_ID not defined in env."); + let key = KeyDefinition { + name: "ETH_TEST_KEY1".to_string(), + provider: KeyProvider::LOCALETH, + id: awskms_key_id, + }; + movement_signer_setup::setup_sign_config(vec![key]).unwrap(); +} diff --git a/util/signing/e2e-test/bin/setup_local_eth_key.rs b/util/signing/e2e-test/bin/setup_local_eth_key.rs new file mode 100644 index 000000000..2658e16a0 --- /dev/null +++ b/util/signing/e2e-test/bin/setup_local_eth_key.rs @@ -0,0 +1,12 @@ +// Create the config that contains one Eth key that sign in local. +use movement_signer_config::KeyDefinition; +use movement_signer_config::KeyProvider; + +fn main() { + let key = KeyDefinition { + name: "ETH_TEST_KEY1".to_string(), + provider: KeyProvider::AWSKMS, + id: String::new(), + }; + movement_signer_setup::setup_sign_config(vec![key]).unwrap(); +} diff --git a/util/signing/e2e-test/src/main.rs b/util/signing/e2e-test/src/main.rs new file mode 100644 index 000000000..09cd1b7bb --- /dev/null +++ b/util/signing/e2e-test/src/main.rs @@ -0,0 +1,14 @@ +// Run the e2e signing Test. +// e2e signing test are run using real node: 'ex Anvil and Suzuka node). + +// Use the local signer to sign Eth Tx. Can be run in the CI. +#[tokio::test] +async fn e2e_eth_signing_local() -> Result<(), anyhow::Error> { + todo!() +} + +// Use the AWS KMS signer to sign Eth Tx. AWS auth env var must be set to run the test. +#[tokio::test] +async fn e2e_eth_signing_awskms() -> Result<(), anyhow::Error> { + todo!() +} diff --git a/util/signing/signer.old/Cargo.toml b/util/signing/setup/Cargo.toml similarity index 58% rename from util/signing/signer.old/Cargo.toml rename to util/signing/setup/Cargo.toml index fa855726d..89b4a7490 100644 --- a/util/signing/signer.old/Cargo.toml +++ b/util/signing/setup/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "signer" +name = "movement-signer-setup" version.workspace = true edition.workspace = true license.workspace = true @@ -10,13 +10,8 @@ publish.workspace = true rust-version.workspace = true [dependencies] -thiserror = { workspace = true } -async-trait = { workspace = true } -ed25519 = { workspace = true } -ring-compat = { workspace = true } -k256 = { workspace = true, features = ["ecdsa", "pkcs8"] } anyhow = { workspace = true } - +movement-signer-config = { workspace = true } [lints] workspace = true diff --git a/util/signing/setup/src/lib.rs b/util/signing/setup/src/lib.rs new file mode 100644 index 000000000..15d579216 --- /dev/null +++ b/util/signing/setup/src/lib.rs @@ -0,0 +1,7 @@ +use movement_signer_config::KeyDefinition; + +/// Save the provided Key definition in the signing KeyManager Config. +/// Call be each signing user during setup. +pub fn setup_sign_config(key_list: Vec) -> Result<(), anyhow::Error> { + todo!(); +} diff --git a/util/signing/signer.old/src/cryptography/ed25519.rs b/util/signing/signer.old/src/cryptography/ed25519.rs deleted file mode 100644 index aa34725e4..000000000 --- a/util/signing/signer.old/src/cryptography/ed25519.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::cryptography::Curve; -use crate::{Bytes, PublicKey, Signature, VerifierError, VerifierOperations}; -use anyhow::Context; -use ring_compat::signature::{ - ed25519::{self, VerifyingKey}, - Verifier, -}; - -/// The Ed25519 curve. -#[derive(Debug, Clone)] -pub struct Ed25519; - -impl Curve for Ed25519 {} - -/// Built-in verifier for Ed25519. -#[async_trait::async_trait] -impl VerifierOperations for Ed25519 { - async fn verify( - &self, - message: Bytes, - signature: Signature, - public_key: PublicKey, - ) -> Result { - let verifying_key = VerifyingKey::from_slice(public_key.0 .0.as_slice()) - .context("Failed to create verifying key") - .map_err(|e| VerifierError::Verify(e.to_string()))?; - - let signature = ed25519::Signature::from_slice(signature.0 .0.as_slice()) - .context("Failed to create signature") - .map_err(|e| VerifierError::Verify(e.to_string()))?; - - Ok(verifying_key.verify(message.0.as_slice(), &signature).is_ok()) - } -} diff --git a/util/signing/signer.old/src/cryptography/mod.rs b/util/signing/signer.old/src/cryptography/mod.rs deleted file mode 100644 index 8681cce3d..000000000 --- a/util/signing/signer.old/src/cryptography/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod ed25519; -pub mod secp256k1; -/// A curve. -/// Currently this has no methods, but it is used to bound the `Signer` trait. -pub trait Curve {} diff --git a/util/signing/signer.old/src/cryptography/secp256k1.rs b/util/signing/signer.old/src/cryptography/secp256k1.rs deleted file mode 100644 index d9db5f062..000000000 --- a/util/signing/signer.old/src/cryptography/secp256k1.rs +++ /dev/null @@ -1,39 +0,0 @@ -use crate::cryptography::Curve; -use crate::{Bytes, PublicKey, Signature, VerifierError, VerifierOperations}; -use anyhow::Context; -use k256::ecdsa::{self, VerifyingKey}; -use k256::pkcs8::DecodePublicKey; -use ring_compat::signature::Verifier; - -/// The secp256k1 elliptic curve. -#[derive(Debug, Clone)] -pub struct Secp256k1; - -impl Curve for Secp256k1 {} - -/// Built-in verifier for secp256k1. -#[async_trait::async_trait] -impl VerifierOperations for Secp256k1 { - async fn verify( - &self, - message: Bytes, - signature: Signature, - public_key: PublicKey, - ) -> Result { - let verifying_key = VerifyingKey::from_public_key_der(&public_key.0 .0) - .context("Failed to create verifying key") - .map_err(|e| VerifierError::Verify(e.to_string()))?; - - let signature = ecdsa::Signature::from_der(&signature.0 .0) - .context("Failed to create signature") - .map_err(|e| VerifierError::Verify(e.to_string()))?; - - match verifying_key.verify(message.0.as_slice(), &signature) { - Ok(_) => Ok(true), - Err(e) => { - println!("Error verifying signature: {:?}", e); - Ok(false) - } - } - } -} diff --git a/util/signing/signer.old/src/lib.rs b/util/signing/signer.old/src/lib.rs deleted file mode 100644 index 49d3196c5..000000000 --- a/util/signing/signer.old/src/lib.rs +++ /dev/null @@ -1,124 +0,0 @@ -pub mod cryptography; - -/// A collection of bytes. -#[derive(Debug, Clone)] -pub struct Bytes(pub Vec); - -/// A signature. -#[derive(Debug, Clone)] -pub struct Signature(pub Bytes); - -/// A public key. -#[derive(Debug, Clone)] -pub struct PublicKey(pub Bytes); - -/// Version of a key. -/// Default mean the current key. -#[derive(Debug, Clone, Default)] -pub struct KeyVersion(pub String); - -/// Id that identify a Key. -#[derive(Debug, Clone)] -pub struct KeyId(pub String); - -/// Errors thrown by Signer -#[derive(Debug, thiserror::Error)] -pub enum SignerError { - #[error("Error during signing : {0}")] - Sign(String), - #[error("Error during public key retrieval : {0}")] - PublicKey(String), - #[error("Error can't decode provided hex data : {0}")] - Hex(String), - #[error("Signature not found.")] - SignatureNotFound, - #[error("public key not found.")] - PublicKeyNotFound, -} - -#[async_trait::async_trait] -pub trait SignerOperations { - /// Signs some bytes. - async fn sign(&self, message: Bytes) -> Result; - - /// Gets the public key. - async fn public_key(&self) -> Result; -} - -pub struct Signer -where - O: SignerOperations, - C: cryptography::Curve, -{ - operations: O, - _curve_marker: std::marker::PhantomData, -} - -/// Signer wraps an implementation of [SignerOperations] and provides a simple API for signing and getting the public key. -impl Signer -where - O: SignerOperations, - C: cryptography::Curve, -{ - pub fn new(operations: O) -> Self { - Self { operations, _curve_marker: std::marker::PhantomData } - } - - /// Signs some bytes. - pub async fn sign(&self, message: Bytes) -> Result { - self.operations.sign(message).await - } - - /// Gets the public key. - pub async fn public_key(&self) -> Result { - self.operations.public_key().await - } -} - -/// Errors thrown by the verifier. -#[derive(Debug, thiserror::Error)] -pub enum VerifierError { - #[error("Error during verification : {0}")] - Verify(String), -} - -#[async_trait::async_trait] -pub trait VerifierOperations { - /// Verifies a signature. - async fn verify( - &self, - message: Bytes, - signature: Signature, - public_key: PublicKey, - ) -> Result; -} - -pub struct Verifier -where - O: VerifierOperations, - C: cryptography::Curve, -{ - operations: O, - _curve_marker: std::marker::PhantomData, -} - -/// Verifier wraps an implementation of [VerifierOperations] and provides a simple API for verifying signatures. -impl Verifier -where - O: VerifierOperations, - C: cryptography::Curve, -{ - pub fn new(operations: O) -> Self { - Self { operations, _curve_marker: std::marker::PhantomData } - } - - /// Verifies a signature. - pub async fn verify( - &self, - message: Bytes, - signature: Signature, - public_key: PublicKey, - ) -> Result { - self.operations.verify(message, signature, public_key).await - } -} From 155ef99d9ae7a7da6dad5f4ea464b439443c4ca1 Mon Sep 17 00:00:00 2001 From: musitdev Date: Thu, 2 Jan 2025 15:11:10 +0100 Subject: [PATCH 2/5] define on test for both setup --- util/signing/e2e-test/Cargo.toml | 2 +- util/signing/e2e-test/src/main.rs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/util/signing/e2e-test/Cargo.toml b/util/signing/e2e-test/Cargo.toml index fccf2874a..5a97d84c2 100644 --- a/util/signing/e2e-test/Cargo.toml +++ b/util/signing/e2e-test/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "e2e-test" +name = "movement-signer-e2e-test" version.workspace = true edition.workspace = true license.workspace = true diff --git a/util/signing/e2e-test/src/main.rs b/util/signing/e2e-test/src/main.rs index 09cd1b7bb..384c01fae 100644 --- a/util/signing/e2e-test/src/main.rs +++ b/util/signing/e2e-test/src/main.rs @@ -1,14 +1,8 @@ // Run the e2e signing Test. // e2e signing test are run using real node: 'ex Anvil and Suzuka node). - -// Use the local signer to sign Eth Tx. Can be run in the CI. +// Depending on the executed setup it doesn't use the same key/provided.. #[tokio::test] -async fn e2e_eth_signing_local() -> Result<(), anyhow::Error> { - todo!() -} - -// Use the AWS KMS signer to sign Eth Tx. AWS auth env var must be set to run the test. -#[tokio::test] -async fn e2e_eth_signing_awskms() -> Result<(), anyhow::Error> { +async fn e2e_eth_signing() -> Result<(), anyhow::Error> { + //use the ETH_TEST_KEY1 name to get the key from the Key Manager. todo!() } From 2fc958137c59df9a7a014e92117372083d02c675 Mon Sep 17 00:00:00 2001 From: musitdev Date: Thu, 2 Jan 2025 15:35:31 +0100 Subject: [PATCH 3/5] correct build --- Cargo.lock | 22 +++++++++++----------- util/signing/e2e-test/Cargo.toml | 5 +++-- util/signing/e2e-test/src/main.rs | 2 ++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55f7c6d4e..fa5c26125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6139,17 +6139,6 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" -[[package]] -name = "e2e-test" -version = "0.0.2" -dependencies = [ - "anyhow", - "godfig", - "movement-signer-config", - "movement-signer-setup", - "tokio", -] - [[package]] name = "ecdsa" version = "0.14.8" @@ -10598,6 +10587,17 @@ dependencies = [ "serde", ] +[[package]] +name = "movement-signer-e2e-test" +version = "0.0.2" +dependencies = [ + "anyhow", + "godfig", + "movement-signer-config", + "movement-signer-setup", + "tokio", +] + [[package]] name = "movement-signer-hashicorp-vault" version = "0.0.2" diff --git a/util/signing/e2e-test/Cargo.toml b/util/signing/e2e-test/Cargo.toml index 5a97d84c2..919d46a0e 100644 --- a/util/signing/e2e-test/Cargo.toml +++ b/util/signing/e2e-test/Cargo.toml @@ -21,13 +21,14 @@ path = "bin/setup_awskms_eth_key.rs" [dependencies] movement-signer-setup = { workspace = true } movement-signer-config = { workspace = true } - godfig = { workspace = true } -[dev-dependencies] anyhow = { workspace = true } tokio = { workspace = true } +[dev-dependencies] + + [lints] workspace = true diff --git a/util/signing/e2e-test/src/main.rs b/util/signing/e2e-test/src/main.rs index 384c01fae..b9c0d6d57 100644 --- a/util/signing/e2e-test/src/main.rs +++ b/util/signing/e2e-test/src/main.rs @@ -1,3 +1,5 @@ +fn main() {} + // Run the e2e signing Test. // e2e signing test are run using real node: 'ex Anvil and Suzuka node). // Depending on the executed setup it doesn't use the same key/provided.. From 8e7bea0d1c9e4167a66279ccacbb399bfcf6e2d3 Mon Sep 17 00:00:00 2001 From: musitdev Date: Thu, 2 Jan 2025 16:06:13 +0100 Subject: [PATCH 4/5] add process compose scripts --- Cargo.toml | 1 + .../signing/process-compose.e2etest.yml | 13 ++++ .../signing/process-compose.setup_awskms.yml | 38 +++++++++++ .../signing/process-compose.setup_local.yml | 38 +++++++++++ process-compose/signing/process-compose.yml | 65 +++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 process-compose/signing/process-compose.e2etest.yml create mode 100644 process-compose/signing/process-compose.setup_awskms.yml create mode 100644 process-compose/signing/process-compose.setup_local.yml create mode 100644 process-compose/signing/process-compose.yml diff --git a/Cargo.toml b/Cargo.toml index 56f6e9d6a..5ece15f3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,6 +127,7 @@ movement-signer-aws-kms = { path = "util/signing/providers/aws-kms" } movement-signer-hashicorp-vault = { path = "util/signing/providers/hashicorp-vault" } movement-signer-config = { path = "util/signing/config" } movement-signer-setup = { path = "util/signing/setup" } +movement-signer-e2e-test = { path = "util/signing/setup" } ## vault vaultrs = { version = "0.7.3" } diff --git a/process-compose/signing/process-compose.e2etest.yml b/process-compose/signing/process-compose.e2etest.yml new file mode 100644 index 000000000..8ededf02c --- /dev/null +++ b/process-compose/signing/process-compose.e2etest.yml @@ -0,0 +1,13 @@ +version: "3" + +environment: + +processes: + bridge_e2e-tests: + command: | + cargo test -p movement-signer-e2e-test e2e_eth_signing -- --nocapture --test-threads=1 + depends_on: + signing_local_setup: + condition: process_healthy + availability: + exit_on_end: true \ No newline at end of file diff --git a/process-compose/signing/process-compose.setup_awskms.yml b/process-compose/signing/process-compose.setup_awskms.yml new file mode 100644 index 000000000..5cfb32683 --- /dev/null +++ b/process-compose/signing/process-compose.setup_awskms.yml @@ -0,0 +1,38 @@ +version: "3" + +processes: + + setup: + environment: + - "ETH_RPC_CONNECTION_PROTOCOL=http" + - "ETH_RPC_CONNECTION_HOSTNAME=0.0.0.0" + - "ETH_RPC_CONNECTION_PORT=8090" + - "ETH_WS_CONNECTION_PROTOCOL=ws" + - "ETH_WS_CONNECTION_HOSTNAME=0.0.0.0" + - "ETH_WS_CONNECTION_PORT=8090" + - "MAYBE_RUN_LOCAL=true" + - "MAYBE_TESTING_MCR=true" + - "MAYBE_DEPLOY_MCR=true" + + command: | + movement-full-node-setup + depends_on: + build: + condition: process_completed_successfully + readiness_probe: + initial_delay_seconds: 10 + exec: + command: echo "true" + + signing_local_setup: + command: | + cargo run -p movement-signer-e2e-test --bin setup_awskms_eth_key + availability: + restart: exit_on_failure + depends_on: + movement-faucet: + condition: process_healthy + readiness_probe: + initial_delay_seconds: 20 + exec: + command: echo "true" diff --git a/process-compose/signing/process-compose.setup_local.yml b/process-compose/signing/process-compose.setup_local.yml new file mode 100644 index 000000000..94a613f59 --- /dev/null +++ b/process-compose/signing/process-compose.setup_local.yml @@ -0,0 +1,38 @@ +version: "3" + +processes: + + setup: + environment: + - "ETH_RPC_CONNECTION_PROTOCOL=http" + - "ETH_RPC_CONNECTION_HOSTNAME=0.0.0.0" + - "ETH_RPC_CONNECTION_PORT=8090" + - "ETH_WS_CONNECTION_PROTOCOL=ws" + - "ETH_WS_CONNECTION_HOSTNAME=0.0.0.0" + - "ETH_WS_CONNECTION_PORT=8090" + - "MAYBE_RUN_LOCAL=true" + - "MAYBE_TESTING_MCR=true" + - "MAYBE_DEPLOY_MCR=true" + + command: | + movement-full-node-setup + depends_on: + build: + condition: process_completed_successfully + readiness_probe: + initial_delay_seconds: 10 + exec: + command: echo "true" + + signing_local_setup: + command: | + cargo run -p movement-signer-e2e-test --bin setup_local_eth_key + availability: + restart: exit_on_failure + depends_on: + movement-faucet: + condition: process_healthy + readiness_probe: + initial_delay_seconds: 20 + exec: + command: echo "true" diff --git a/process-compose/signing/process-compose.yml b/process-compose/signing/process-compose.yml new file mode 100644 index 000000000..585c75ede --- /dev/null +++ b/process-compose/signing/process-compose.yml @@ -0,0 +1,65 @@ +version: "3" + +processes: + + build: + command: | + exit 0 + + setup: + command: | + # sleep forever + sleep 999999999d + depends_on: + build: + condition: process_completed_successfully + + celestia-light-node: + command: | + exit 1 + depends_on: + setup: + condition: process_healthy + + celestia-light-node-synced: + command: | + wait-for-celestia-light-node + depends_on: + celestia-light-node: + condition: process_healthy + + movement-celestia-da-light-node: + command: | + movement-celestia-da-light-node + depends_on: + celestia-light-node: + condition: process_healthy + celestia-light-node-synced: + condition: process_completed_successfully + readiness_probe: + initial_delay_seconds: 3 + exec: + command: grpcurl -plaintext 0.0.0.0:30730 list + + movement-full-node: + command: | + movement-full-node + depends_on: + movement-celestia-da-light-node: + condition: process_healthy + readiness_probe: + initial_delay_seconds: 10 + exec: + command: curl http://0.0.0.0:30731 + + movement-faucet: + command : | + movement-faucet-service run-simple + depends_on: + movement-full-node: + condition: process_healthy + readiness_probe: + initial_delay_seconds: 30 + exec: + command: curl http://0.0.0.0:30732 + From 062f21ec97465175ba523b8005919cff83ca01a0 Mon Sep 17 00:00:00 2001 From: musitdev Date: Wed, 8 Jan 2025 18:22:07 +0100 Subject: [PATCH 5/5] correct Eth signing test --- .../integrations/eth/tests/aws_test.rs | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/util/signing/integrations/eth/tests/aws_test.rs b/util/signing/integrations/eth/tests/aws_test.rs index a75ae2bfb..0db3a3d97 100644 --- a/util/signing/integrations/eth/tests/aws_test.rs +++ b/util/signing/integrations/eth/tests/aws_test.rs @@ -39,12 +39,9 @@ async fn test_aws_kms_send_tx() -> Result<(), anyhow::Error> { let _secret_key = env::var("AWS_SECRET_KEY").expect("AWS_SECRET_KEY not set"); let key_id = env::var("AWS_KEY_ID").expect("AWS_KEY_ID not set"); - println!("key_id:{key_id}"); - let aws = AwsKmsSigner::new(key_id).await; let signer = HsmSigner::try_new(aws, Some(chain_id)).await?; let address = signer.address(); - println!("DEEEEB Key address:{}", address); let key_provider = ProviderBuilder::new() .with_recommended_fillers() @@ -63,39 +60,26 @@ async fn test_aws_kms_send_tx() -> Result<(), anyhow::Error> { //transfer some eth to the key. let tx = TransactionRequest::default() .with_to(address) - .with_value(U256::from(1000000000)); + .with_value(U256::from(10_000_000_000_000_000u64)); let receipt = admin_provider.send_transaction(tx).await?.get_receipt().await?; - println!("Admin -> Key receipt: {receipt:?}",); - let account = key_provider.get_accounts().await; - println!("Account: {:?}", account); - let balance = key_provider.get_balance(address).await; - println!("Balance: {:?}", balance); + let balance = key_provider.get_balance(address).await?; //transfer back some eth. let tx = TransactionRequest::default() .with_from(address) .with_to(admin_address) - .with_value(U256::from(5)) - .gas_limit(3000000); - println!("Tx from {:?}", tx.from); - - let receipt = key_provider.send_transaction(tx).await; //.get_receipt().await?; - println!("Key -> Admin receipt: {receipt:?}",); + .with_value(U256::from(500)) + .with_chain_id(chain_id) + .gas_limit(3_000_000); - // // Print ANvil output. - // use std::io; - // use std::io::BufRead; - // use std::io::BufReader; - // use std::io::Write; + key_provider.send_transaction(tx).await?.get_receipt().await?; - // let anvil_out = anvil.child_mut().stdout.take().unwrap(); - // let mut stdout_writer = io::stdout(); - // let mut reader = BufReader::new(anvil_out).lines(); - // while let Some(Ok(line)) = reader.next() { - // stdout_writer.write_all(line.as_bytes())?; - // stdout_writer.write_all(b"\n")?; - // } + let new_balance = key_provider.get_balance(address).await?; + assert!( + balance != new_balance, + "AWS account didn't change. Last transfer doesn't execute correctly." + ); Ok(()) }