Skip to content

Commit e407f64

Browse files
musitdevnicholasflintwillow
authored andcommitted
fix: Update executor block validator signer to use LoadedSigner, add test key admin command (#1063)
1 parent 8d89aac commit e407f64

File tree

22 files changed

+150
-48
lines changed

22 files changed

+150
-48
lines changed

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

networks/movement/movement-full-node/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ movement-signer = { workspace = true }
4747
movement-signer-loader = { workspace = true }
4848
syncador = { workspace = true }
4949
syncup = { workspace = true }
50+
aptos-crypto = { workspace = true }
51+
aptos-sdk = { workspace = true }
52+
k256 = { workspace = true }
53+
alloy-signer = { workspace = true }
5054
chrono = { workspace = true }
5155

5256
[features]

networks/movement/movement-full-node/src/admin/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ pub mod governed_gas_pool;
55
pub mod mcr;
66
pub mod ops;
77
pub mod rotate_key;
8+
pub mod testkey;
9+
810
use clap::Subcommand;
911

1012
#[derive(Subcommand, Debug)]
@@ -24,6 +26,8 @@ pub enum Admin {
2426
Framework(framework::Framework),
2527
#[clap(subcommand)]
2628
Config(config::Config),
29+
#[clap(subcommand)]
30+
TestKey(testkey::TestKey),
2731
}
2832

2933
impl Admin {
@@ -36,6 +40,7 @@ impl Admin {
3640
Admin::Ops(ops) => ops.execute().await,
3741
Admin::Framework(framework) => framework.execute().await,
3842
Admin::Config(config) => config.execute().await,
43+
Admin::TestKey(key) => key.execute().await,
3944
}
4045
}
4146
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
use aptos_crypto::ed25519::Ed25519PublicKey;
2+
use aptos_sdk::types::transaction::authenticator::AuthenticationKey;
3+
use clap::Parser;
4+
use clap::Subcommand;
5+
use k256::ecdsa::VerifyingKey;
6+
use movement_signer::cryptography::ed25519::Ed25519;
7+
use movement_signer::cryptography::secp256k1::Secp256k1;
8+
use movement_signer::key::TryFromCanonicalString;
9+
use movement_signer::Signing;
10+
use movement_signer::Verify;
11+
use movement_signer_loader::identifiers::SignerIdentifier;
12+
use movement_signer_loader::{Load, LoadedSigner};
13+
14+
#[derive(Subcommand, Debug)]
15+
#[clap(rename_all = "kebab-case", about = "Commands to test key name")]
16+
pub enum TestKey {
17+
Ed25519(TestKeyParam),
18+
Secp256k1(TestKeyParam),
19+
}
20+
21+
impl TestKey {
22+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
23+
match self {
24+
TestKey::Ed25519(param) => param.execute_ed25519().await,
25+
TestKey::Secp256k1(param) => param.execute_secp256k1().await,
26+
}
27+
}
28+
}
29+
30+
#[derive(Debug, Parser, Clone)]
31+
#[clap(rename_all = "kebab-case", about = "Key to test.")]
32+
pub struct TestKeyParam {
33+
#[clap(default_value = "{maptos,maptos-storage,movement-da-db}/**", value_name = "DB PATTERN")]
34+
pub name: String,
35+
}
36+
37+
impl TestKeyParam {
38+
pub async fn execute_ed25519(&self) -> Result<(), anyhow::Error> {
39+
let signer_identifier = SignerIdentifier::try_from_canonical_string(&self.name)
40+
.map_err(|err| anyhow::anyhow!(err))?;
41+
let loader: LoadedSigner<Ed25519> = signer_identifier.load().await?;
42+
43+
let public_key = Ed25519PublicKey::try_from(loader.public_key().await?.as_bytes())?;
44+
let account_address = AuthenticationKey::ed25519(&public_key).account_address();
45+
46+
tracing::info!("Key loaded, account address:{account_address}");
47+
tracing::info!("Try to sign a message ...");
48+
49+
let message = b"Hello, world!";
50+
let signature = loader.sign(message).await?;
51+
assert!(Ed25519::verify(message, &signature, &loader.public_key().await?)?);
52+
53+
tracing::info!("Message sign verify pass");
54+
55+
Ok(())
56+
}
57+
pub async fn execute_secp256k1(&self) -> Result<(), anyhow::Error> {
58+
let signer_identifier = SignerIdentifier::try_from_canonical_string(&self.name)
59+
.map_err(|err| anyhow::anyhow!(err))?;
60+
let loader: LoadedSigner<Secp256k1> = signer_identifier.load().await?;
61+
let pub_key = loader.public_key().await?;
62+
let verify_key = VerifyingKey::from_sec1_bytes(pub_key.as_bytes())?;
63+
64+
let account_address = alloy_signer::utils::public_key_to_address(&verify_key);
65+
66+
tracing::info!("Key loaded, account address:{account_address}");
67+
tracing::info!("Try to sign a message ...");
68+
69+
let message = b"Hello, world!";
70+
let signature = loader.sign(message).await?;
71+
assert!(Secp256k1::verify(message, &signature, &loader.public_key().await?)?);
72+
73+
tracing::info!("Message sign verify pass");
74+
75+
Ok(())
76+
}
77+
}

networks/movement/movement-full-node/src/node/partial.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ where
8383
impl MovementPartialNode<Executor> {
8484
pub async fn try_executor_from_config(config: Config) -> Result<Executor, anyhow::Error> {
8585
let executor = Executor::try_from_config(config.execution_config.maptos_config.clone())
86+
.await
8687
.context("Failed to create the inner executor")?;
8788
Ok(executor)
8889
}
@@ -142,6 +143,7 @@ impl MovementPartialNode<Executor> {
142143

143144
debug!("Creating the executor");
144145
let executor = Executor::try_from_config(config.execution_config.maptos_config.clone())
146+
.await
145147
.context("Failed to create the inner executor")?;
146148

147149
let (settlement_manager, commitment_events) = if config.mcr.should_settle() {

process-compose/movement-full-node/process-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ processes:
4343

4444
movement-full-node:
4545
command: |
46-
movement-full-node run
46+
RUST_BACKTRACE=1 movement-full-node run
4747
depends_on:
4848
movement-celestia-da-light-node:
4949
condition: process_healthy

protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-appd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async fn main() -> Result<(), anyhow::Error> {
1414

1515
// get the config file
1616
let dot_movement = dot_movement::DotMovement::try_from_env()?;
17-
let mut config_file = dot_movement.try_get_or_create_config_file().await?;
17+
let config_file = dot_movement.try_get_or_create_config_file().await?;
1818

1919
// get a matching godfig object
2020
let godfig: Godfig<CelestiaDaLightNodeConfig, ConfigFile> =

protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-bridge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async fn main() -> Result<(), anyhow::Error> {
1313
.init();
1414

1515
let dot_movement = dot_movement::DotMovement::try_from_env()?;
16-
let mut config_file = dot_movement.try_get_or_create_config_file().await?;
16+
let config_file = dot_movement.try_get_or_create_config_file().await?;
1717

1818
// get a matching godfig object
1919
let godfig: Godfig<CelestiaDaLightNodeConfig, ConfigFile> =

protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-light.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async fn main() -> Result<(), anyhow::Error> {
1313
.init();
1414

1515
let dot_movement = dot_movement::DotMovement::try_from_env()?;
16-
let mut config_file = dot_movement.try_get_or_create_config_file().await?;
16+
let config_file = dot_movement.try_get_or_create_config_file().await?;
1717

1818
// get a matching godfig object
1919
let godfig: Godfig<CelestiaDaLightNodeConfig, ConfigFile> =

protocol-units/da/movement/protocol/setup/src/arabica.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ impl Arabica {
156156
let max_retries = 10;
157157
let retry_delay = 5;
158158
let mut retry_count = 0;
159-
let mut success = false;
160159

161160
while retry_count < max_retries {
162161
let response = reqwest::Client::new()
@@ -183,7 +182,6 @@ impl Arabica {
183182
let tx_hash =
184183
tx_hash.as_str().context("Failed to convert the txHash field to a string.")?;
185184
info!("Transaction hash: {}", tx_hash);
186-
success = true;
187185
break;
188186
} else {
189187
info!("Error: txHash field not found in the response.");

0 commit comments

Comments
 (0)