Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signing e2e tests #981

Open
wants to merge 5 commits into
base: musitdev/alloy-integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -123,6 +125,9 @@ 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" }
movement-signer-e2e-test = { path = "util/signing/setup" }

## vault
vaultrs = { version = "0.7.3" }
Expand Down
13 changes: 13 additions & 0 deletions process-compose/signing/process-compose.e2etest.yml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions process-compose/signing/process-compose.setup_awskms.yml
Original file line number Diff line number Diff line change
@@ -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"
38 changes: 38 additions & 0 deletions process-compose/signing/process-compose.setup_local.yml
Original file line number Diff line number Diff line change
@@ -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"
65 changes: 65 additions & 0 deletions process-compose/signing/process-compose.yml
Original file line number Diff line number Diff line change
@@ -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

16 changes: 16 additions & 0 deletions util/signing/config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions util/signing/config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought it was UpperCamelCase when the variant contains fields and all upper case when it's a constant. I'll update.

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<KeyDefinition>,
}
34 changes: 34 additions & 0 deletions util/signing/e2e-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "movement-signer-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 }

anyhow = { workspace = true }
tokio = { workspace = true }


[dev-dependencies]


[lints]
workspace = true
15 changes: 15 additions & 0 deletions util/signing/e2e-test/bin/setup_awskms_eth_key.rs
Original file line number Diff line number Diff line change
@@ -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.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really show me a lot to do with how you integrate this with the mcr_settlement_client crate which is where the e2e testing would take place. That's what I would like to see earlier than later in this next sprint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mcr_settlement_client/test_client_settlement test is more an integration test because it doesn't need all the node setup process. It only uses an anvil process. It can be updated the same way it's done here: https://github.com/movementlabsxyz/movement/blob/musitdev/alloy-integration/util/signing/integrations/eth/tests/aws_test.rs
In this PR, I propose a way to manage how the setup/config process can be handled to integrate the signing API in the node execution process (setup->config->execution). To do that, we need a way to define the key during the setup and a way to get the key when the node is executed. For example, the setup key definition need to handle when the execution connects to AWS KMS with auth token (local on a PC for example) or a local signer provider when use in the github CI. The why I define 2 setup and one test.
If we agree on this conception, the integration in the Suzuka node / bridge will be only to update the corresponding setup to define the key the same way as the setup example and update how the Alloy provider is loaded, as done in the test.

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();
}
12 changes: 12 additions & 0 deletions util/signing/e2e-test/bin/setup_local_eth_key.rs
Original file line number Diff line number Diff line change
@@ -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();
}
10 changes: 10 additions & 0 deletions util/signing/e2e-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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..
#[tokio::test]
async fn e2e_eth_signing() -> Result<(), anyhow::Error> {
//use the ETH_TEST_KEY1 name to get the key from the Key Manager.
todo!()
}
Loading
Loading