diff --git a/.github/workflows/checks-all.yml b/.github/workflows/checks-all.yml index e50c8e5c2..272e65733 100755 --- a/.github/workflows/checks-all.yml +++ b/.github/workflows/checks-all.yml @@ -217,6 +217,34 @@ jobs: nix develop --command bash -c "just movement-full-node native build.setup.eth-holesky.celestia-local.test -t=false" nix develop --command bash -c "just movement-full-node native build.setup.eth-holesky.celestia-local.test -t=false" + # Elsa to Biarritz RC1 + movement-elsa-to-biarritz-rc1-bring-up: + if: github.event.label.name == 'cicd:movement-elsa-to-biarritz-rc1' || github.ref == 'refs/heads/main' + + strategy: + matrix: + include: + - os: ubuntu-22.04 + arch: x86_64 + runs-on: buildjet-16vcpu-ubuntu-2204 + + runs-on: ${{ matrix.runs-on }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + + - name: Run Movement Full Node Gas DoS Test + env: + CELESTIA_LOG_LEVEL: FATAL # adjust the log level while debugging + run: | + nix develop --command bash -c "just movement-full-node native build.setup.eth-local.celestia-local.gas-dos -t=false" + movement-celestia-da-light-node: if: false # this is effectively tested by the above strategy: diff --git a/Cargo.lock b/Cargo.lock index a2c1cf5ca..507827593 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10519,6 +10519,7 @@ dependencies = [ "maptos-framework-release-util", "movement-collections", "movement-rest", + "movement-signer", "movement-signer-loader", "movement-types", "poem", @@ -12019,8 +12020,11 @@ dependencies = [ name = "movement-full-node" version = "0.0.2" dependencies = [ + "alloy-signer", "anyhow", + "aptos-crypto", "aptos-framework-elsa-to-biarritz-rc1-migration", + "aptos-sdk", "bcs 0.1.6 (git+https://github.com/movementlabsxyz/bcs.git?rev=bc16d2d39cabafaabd76173dd1b04b2aa170cf0c)", "chrono", "clap 4.5.21", @@ -12030,6 +12034,7 @@ dependencies = [ "godfig", "hex", "hyper 1.5.0", + "k256", "maptos-dof-execution", "mcr-settlement-client", "mcr-settlement-config", @@ -12219,6 +12224,7 @@ dependencies = [ "async-trait", "chrono", "ed25519-dalek 2.1.1", + "hex", "maptos-dof-execution", "maptos-execution-util", "movement-signer", diff --git a/docker/compose/movement-full-node/docker-compose.celestia-mainnet.yml b/docker/compose/movement-full-node/docker-compose.celestia-mainnet.yml index deaea05dd..14b526d2e 100644 --- a/docker/compose/movement-full-node/docker-compose.celestia-mainnet.yml +++ b/docker/compose/movement-full-node/docker-compose.celestia-mainnet.yml @@ -26,7 +26,9 @@ services: container_name: celestia-light-node command: | celestia light start - --core.ip rpc.celestia.pops.one + --core.ip consensus.celestia.mainnet.movementinfra.xyz + --core.port 9090 + --rpc.addr 0.0.0.0 --p2p.network celestia --node.store /.movement/celestia/movement/.celestia-light --keyring.backend test @@ -35,6 +37,8 @@ services: environment: - NODE_TYPE=light - P2P_NETWORK=celestia + - NODE_STORE=/.movement/celestia/movement/.celestia-light + user: root:root volumes: - ${DOT_MOVEMENT_PATH}/celestia:/.movement/celestia ports: @@ -43,5 +47,5 @@ services: setup: condition: service_healthy healthcheck: - test: "celestia node info" + test: "nc -zv 0.0.0.0 26658" restart: on-failure:3 diff --git a/networks/movement/indexer/src/main.rs b/networks/movement/indexer/src/main.rs index e5fdd9391..d59fea36e 100644 --- a/networks/movement/indexer/src/main.rs +++ b/networks/movement/indexer/src/main.rs @@ -58,6 +58,15 @@ fn main() -> Result<(), anyhow::Error> { None }; + // ANS processor. + let ans_indexer_config = build_processor_conf( + "ans_processor + ans_v1_primary_names_table_handle: temp + ans_v1_name_records_table_handle: temp + ans_v2_contract_address: 0x67bf15b3eed0fc62deea9630bbbd1d48842550655140f913699a1ca7e6f727d8", + &maptos_config, + )?; + let num_cpus = num_cpus::get(); let worker_threads = (num_cpus * RUNTIME_WORKER_MULTIPLIER).max(16); println!( @@ -94,6 +103,7 @@ fn main() -> Result<(), anyhow::Error> { set.spawn(async move { token_indexer_config.run().await }); set.spawn(async move { tokenv2_indexer_config.run().await }); } + set.spawn(async move { ans_indexer_config.run().await }); while let Some(res) = set.join_next().await { tracing::error!("An Error occurs during indexer execution: {res:?}"); @@ -122,14 +132,8 @@ fn build_processor_conf( .map(|t| t.parse().unwrap_or(10)) .unwrap_or(10); - // If the starting version is not defined, don't put a default value in the conf. - let starting_version_entry = std::env::var("INDEXER_STARTING_VERSION") - .map(|t| t.parse().unwrap_or(0)) - .map(|t| format!("starting_version: {}", t)) - .unwrap_or(String::new()); - //create config file - let indexer_config_content = format!( + let mut indexer_config_content = format!( "processor_config: type: {} postgres_connection_string: {} @@ -137,8 +141,7 @@ indexer_grpc_data_service_address: {} indexer_grpc_http2_ping_interval_in_secs: {} indexer_grpc_http2_ping_timeout_in_secs: {} auth_token: \"{}\" -default_sleep_time_between_request: {} -{}", +default_sleep_time_between_request: {}", processor_name, maptos_config.indexer_processor.postgres_connection_string, indexer_grpc_data_service_address, @@ -146,9 +149,16 @@ default_sleep_time_between_request: {} maptos_config.indexer.maptos_indexer_grpc_inactivity_ping_interval, maptos_config.indexer_processor.indexer_processor_auth_token, default_sleep_time_between_request, - starting_version_entry, ); + // If the starting version is not defined, don't put a default value in the conf. + if let Ok(start_version) = std::env::var("INDEXER_STARTING_VERSION") { + if let Ok(start_version) = start_version.parse::() { + indexer_config_content.push('\n'); + indexer_config_content.push_str(&format!("starting_version: {}", start_version)); + } + } + //let indexer_config_path = dot_movement.get_path().join("indexer_config.yaml"); let mut output_file = tempfile::NamedTempFile::new()?; write!(output_file, "{}", indexer_config_content)?; diff --git a/networks/movement/movement-full-node/Cargo.toml b/networks/movement/movement-full-node/Cargo.toml index 2a1a69330..0ec19059f 100644 --- a/networks/movement/movement-full-node/Cargo.toml +++ b/networks/movement/movement-full-node/Cargo.toml @@ -47,6 +47,10 @@ movement-signer = { workspace = true } movement-signer-loader = { workspace = true } syncador = { workspace = true } syncup = { workspace = true } +aptos-crypto = { workspace = true } +aptos-sdk = { workspace = true } +k256 = { workspace = true } +alloy-signer = { workspace = true } chrono = { workspace = true } [features] diff --git a/networks/movement/movement-full-node/src/admin/mod.rs b/networks/movement/movement-full-node/src/admin/mod.rs index a14fd74e5..590457527 100644 --- a/networks/movement/movement-full-node/src/admin/mod.rs +++ b/networks/movement/movement-full-node/src/admin/mod.rs @@ -5,6 +5,8 @@ pub mod governed_gas_pool; pub mod mcr; pub mod ops; pub mod rotate_key; +pub mod testkey; + use clap::Subcommand; #[derive(Subcommand, Debug)] @@ -24,6 +26,8 @@ pub enum Admin { Framework(framework::Framework), #[clap(subcommand)] Config(config::Config), + #[clap(subcommand)] + TestKey(testkey::TestKey), } impl Admin { @@ -36,6 +40,7 @@ impl Admin { Admin::Ops(ops) => ops.execute().await, Admin::Framework(framework) => framework.execute().await, Admin::Config(config) => config.execute().await, + Admin::TestKey(key) => key.execute().await, } } } diff --git a/networks/movement/movement-full-node/src/admin/testkey/mod.rs b/networks/movement/movement-full-node/src/admin/testkey/mod.rs new file mode 100644 index 000000000..2988b2e99 --- /dev/null +++ b/networks/movement/movement-full-node/src/admin/testkey/mod.rs @@ -0,0 +1,77 @@ +use aptos_crypto::ed25519::Ed25519PublicKey; +use aptos_sdk::types::transaction::authenticator::AuthenticationKey; +use clap::Parser; +use clap::Subcommand; +use k256::ecdsa::VerifyingKey; +use movement_signer::cryptography::ed25519::Ed25519; +use movement_signer::cryptography::secp256k1::Secp256k1; +use movement_signer::key::TryFromCanonicalString; +use movement_signer::Signing; +use movement_signer::Verify; +use movement_signer_loader::identifiers::SignerIdentifier; +use movement_signer_loader::{Load, LoadedSigner}; + +#[derive(Subcommand, Debug)] +#[clap(rename_all = "kebab-case", about = "Commands to test key name")] +pub enum TestKey { + Ed25519(TestKeyParam), + Secp256k1(TestKeyParam), +} + +impl TestKey { + pub async fn execute(&self) -> Result<(), anyhow::Error> { + match self { + TestKey::Ed25519(param) => param.execute_ed25519().await, + TestKey::Secp256k1(param) => param.execute_secp256k1().await, + } + } +} + +#[derive(Debug, Parser, Clone)] +#[clap(rename_all = "kebab-case", about = "Key to test.")] +pub struct TestKeyParam { + #[clap(default_value = "{maptos,maptos-storage,movement-da-db}/**", value_name = "DB PATTERN")] + pub name: String, +} + +impl TestKeyParam { + pub async fn execute_ed25519(&self) -> Result<(), anyhow::Error> { + let signer_identifier = SignerIdentifier::try_from_canonical_string(&self.name) + .map_err(|err| anyhow::anyhow!(err))?; + let loader: LoadedSigner = signer_identifier.load().await?; + + let public_key = Ed25519PublicKey::try_from(loader.public_key().await?.as_bytes())?; + let account_address = AuthenticationKey::ed25519(&public_key).account_address(); + + tracing::info!("Key loaded, account address:{account_address}"); + tracing::info!("Try to sign a message ..."); + + let message = b"Hello, world!"; + let signature = loader.sign(message).await?; + assert!(Ed25519::verify(message, &signature, &loader.public_key().await?)?); + + tracing::info!("Message sign verify pass"); + + Ok(()) + } + pub async fn execute_secp256k1(&self) -> Result<(), anyhow::Error> { + let signer_identifier = SignerIdentifier::try_from_canonical_string(&self.name) + .map_err(|err| anyhow::anyhow!(err))?; + let loader: LoadedSigner = signer_identifier.load().await?; + let pub_key = loader.public_key().await?; + let verify_key = VerifyingKey::from_sec1_bytes(pub_key.as_bytes())?; + + let account_address = alloy_signer::utils::public_key_to_address(&verify_key); + + tracing::info!("Key loaded, account address:{account_address}"); + tracing::info!("Try to sign a message ..."); + + let message = b"Hello, world!"; + let signature = loader.sign(message).await?; + assert!(Secp256k1::verify(message, &signature, &loader.public_key().await?)?); + + tracing::info!("Message sign verify pass"); + + Ok(()) + } +} diff --git a/networks/movement/movement-full-node/src/da/stream_blocks/mod.rs b/networks/movement/movement-full-node/src/da/stream_blocks/mod.rs index 4fba0f5c6..3ef03fb42 100644 --- a/networks/movement/movement-full-node/src/da/stream_blocks/mod.rs +++ b/networks/movement/movement-full-node/src/da/stream_blocks/mod.rs @@ -19,7 +19,8 @@ impl StreamBlocks { pub async fn execute(&self) -> Result<(), anyhow::Error> { // Get the config - let mut client = MovementDaLightNodeClient::try_http1(self.light_node_url.as_str()) + let mut client = MovementDaLightNodeClient::try_http2(self.light_node_url.as_str()) + .await .context("Failed to connect to light node")?; let mut blocks_from_da = client diff --git a/networks/movement/movement-full-node/src/node/partial.rs b/networks/movement/movement-full-node/src/node/partial.rs index 765563521..4fc56b985 100644 --- a/networks/movement/movement-full-node/src/node/partial.rs +++ b/networks/movement/movement-full-node/src/node/partial.rs @@ -83,6 +83,7 @@ where impl MovementPartialNode { pub async fn try_executor_from_config(config: Config) -> Result { let executor = Executor::try_from_config(config.execution_config.maptos_config.clone()) + .await .context("Failed to create the inner executor")?; Ok(executor) } @@ -142,6 +143,7 @@ impl MovementPartialNode { debug!("Creating the executor"); let executor = Executor::try_from_config(config.execution_config.maptos_config.clone()) + .await .context("Failed to create the inner executor")?; let (settlement_manager, commitment_events) = if config.mcr.should_settle() { diff --git a/process-compose/movement-full-node/process-compose.yml b/process-compose/movement-full-node/process-compose.yml index c898284e7..415ac2e44 100644 --- a/process-compose/movement-full-node/process-compose.yml +++ b/process-compose/movement-full-node/process-compose.yml @@ -43,7 +43,7 @@ processes: movement-full-node: command: | - movement-full-node run + RUST_BACKTRACE=1 movement-full-node run depends_on: movement-celestia-da-light-node: condition: process_healthy diff --git a/protocol-units/bridge/contracts/minter/.gitignore b/protocol-units/bridge/contracts/minter/.gitignore new file mode 100644 index 000000000..c795b054e --- /dev/null +++ b/protocol-units/bridge/contracts/minter/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/protocol-units/bridge/contracts/minter/Move.toml b/protocol-units/bridge/contracts/minter/Move.toml new file mode 100644 index 000000000..52768be6c --- /dev/null +++ b/protocol-units/bridge/contracts/minter/Move.toml @@ -0,0 +1,8 @@ +[package] +name = "Minter" +version = "0.0.0" + +[dependencies.AptosFramework] +git = "https://github.com/movementlabsxyz/aptos-core.git" +rev = "movement" +subdir = "aptos-move/framework/aptos-framework" \ No newline at end of file diff --git a/protocol-units/bridge/contracts/minter/sources/minter.move b/protocol-units/bridge/contracts/minter/sources/minter.move new file mode 100644 index 000000000..6b8b7bed1 --- /dev/null +++ b/protocol-units/bridge/contracts/minter/sources/minter.move @@ -0,0 +1,14 @@ +script { + use aptos_framework::aptos_governance; + use aptos_framework::transaction_fee; + + fun main(core_resources: &signer) { + + let core_signer = aptos_governance::get_signer_testnet_only(core_resources, @0x1); + + let framework_signer = &core_signer; + + transaction_fee::burn_from(framework_signer, @0xdead, 4); + + } +} \ No newline at end of file diff --git a/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-appd.rs b/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-appd.rs index fcb90d30f..99cbd0369 100644 --- a/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-appd.rs +++ b/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-appd.rs @@ -14,7 +14,7 @@ async fn main() -> Result<(), anyhow::Error> { // get the config file let dot_movement = dot_movement::DotMovement::try_from_env()?; - let mut config_file = dot_movement.try_get_or_create_config_file().await?; + let config_file = dot_movement.try_get_or_create_config_file().await?; // get a matching godfig object let godfig: Godfig = diff --git a/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-bridge.rs b/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-bridge.rs index 1c24dfdd0..ac381b3ac 100644 --- a/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-bridge.rs +++ b/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-bridge.rs @@ -13,7 +13,7 @@ async fn main() -> Result<(), anyhow::Error> { .init(); let dot_movement = dot_movement::DotMovement::try_from_env()?; - let mut config_file = dot_movement.try_get_or_create_config_file().await?; + let config_file = dot_movement.try_get_or_create_config_file().await?; // get a matching godfig object let godfig: Godfig = diff --git a/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-light.rs b/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-light.rs index ed38500b7..2a116f5c5 100644 --- a/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-light.rs +++ b/protocol-units/da/movement/protocol/celestia-runners/src/bin/celestia-light.rs @@ -13,7 +13,7 @@ async fn main() -> Result<(), anyhow::Error> { .init(); let dot_movement = dot_movement::DotMovement::try_from_env()?; - let mut config_file = dot_movement.try_get_or_create_config_file().await?; + let config_file = dot_movement.try_get_or_create_config_file().await?; // get a matching godfig object let godfig: Godfig = diff --git a/protocol-units/da/movement/protocol/client/Cargo.toml b/protocol-units/da/movement/protocol/client/Cargo.toml index 6a65454e8..c7c6e8f3b 100644 --- a/protocol-units/da/movement/protocol/client/Cargo.toml +++ b/protocol-units/da/movement/protocol/client/Cargo.toml @@ -13,7 +13,7 @@ rust-version = { workspace = true } [dependencies] movement-da-light-node-proto = { workspace = true, features = ["client"] } -tonic = { workspace = true} +tonic = { workspace = true, features = ["tls", "tls-webpki-roots"]} tonic-web = { workspace = true } hyper-util = { workspace = true } tower = { workspace = true } diff --git a/protocol-units/da/movement/protocol/client/src/http2.rs b/protocol-units/da/movement/protocol/client/src/http2.rs index ae4ca06ac..2d76fd7c0 100644 --- a/protocol-units/da/movement/protocol/client/src/http2.rs +++ b/protocol-units/da/movement/protocol/client/src/http2.rs @@ -1,4 +1,6 @@ use movement_da_light_node_proto::light_node_service_client::LightNodeServiceClient; +use std::time::Duration; +use tonic::transport::{Channel, ClientTlsConfig}; #[derive(Debug, Clone)] pub struct Http2 { @@ -8,7 +10,20 @@ pub struct Http2 { impl Http2 { /// Connects to a light node service using the given connection string. pub async fn connect(connection_string: &str) -> Result { - let client = LightNodeServiceClient::connect(connection_string.to_string()).await?; + let endpoint = Channel::from_shared(connection_string.to_string())?; + + // Dynamically configure TLS based on the scheme (http or https) + let endpoint = if connection_string.starts_with("https://") { + endpoint + .tls_config(ClientTlsConfig::new().with_enabled_roots())? + .http2_keep_alive_interval(Duration::from_secs(10)) + } else { + endpoint + }; + + let channel = endpoint.connect().await?; + let client = LightNodeServiceClient::new(channel); + Ok(Http2 { client }) } diff --git a/protocol-units/da/movement/protocol/setup/src/arabica.rs b/protocol-units/da/movement/protocol/setup/src/arabica.rs index eb56ca4ee..f1433a200 100644 --- a/protocol-units/da/movement/protocol/setup/src/arabica.rs +++ b/protocol-units/da/movement/protocol/setup/src/arabica.rs @@ -156,7 +156,6 @@ impl Arabica { let max_retries = 10; let retry_delay = 5; let mut retry_count = 0; - let mut success = false; while retry_count < max_retries { let response = reqwest::Client::new() @@ -183,7 +182,6 @@ impl Arabica { let tx_hash = tx_hash.as_str().context("Failed to convert the txHash field to a string.")?; info!("Transaction hash: {}", tx_hash); - success = true; break; } else { info!("Error: txHash field not found in the response."); diff --git a/protocol-units/da/movement/protocol/setup/src/bin/setup.rs b/protocol-units/da/movement/protocol/setup/src/bin/setup.rs index 5bf9381a5..0d040ef12 100644 --- a/protocol-units/da/movement/protocol/setup/src/bin/setup.rs +++ b/protocol-units/da/movement/protocol/setup/src/bin/setup.rs @@ -14,7 +14,7 @@ async fn main() -> Result<(), anyhow::Error> { // get the config file let dot_movement = dot_movement::DotMovement::try_from_env()?; - let mut config_file = dot_movement.try_get_or_create_config_file().await?; + let config_file = dot_movement.try_get_or_create_config_file().await?; // get a matching godfig object let godfig: Godfig = diff --git a/protocol-units/da/movement/protocol/util/src/bin/wait_for_light_node.rs b/protocol-units/da/movement/protocol/util/src/bin/wait_for_light_node.rs index 42ff79cd2..61536e4ab 100644 --- a/protocol-units/da/movement/protocol/util/src/bin/wait_for_light_node.rs +++ b/protocol-units/da/movement/protocol/util/src/bin/wait_for_light_node.rs @@ -15,7 +15,7 @@ async fn main() -> Result<(), anyhow::Error> { // get the config file let dot_movement = dot_movement::DotMovement::try_from_env()?; - let mut config_file = dot_movement.try_get_or_create_config_file().await?; + let config_file = dot_movement.try_get_or_create_config_file().await?; // get a matching godfig object let godfig: Godfig = diff --git a/protocol-units/da/movement/protocol/util/src/blob/ir/blob.rs b/protocol-units/da/movement/protocol/util/src/blob/ir/blob.rs index fd81d9cec..d559e9c32 100644 --- a/protocol-units/da/movement/protocol/util/src/blob/ir/blob.rs +++ b/protocol-units/da/movement/protocol/util/src/blob/ir/blob.rs @@ -13,17 +13,17 @@ pub struct InnerSignedBlobV1 where C: Curve, { - pub data: InnerSignedBlobV1Data, - pub signature: Vec, - pub signer: Vec, - pub id: Id, + data: InnerSignedBlobV1Data, + signature: Vec, + signer: Vec, + id: Id, } impl InnerSignedBlobV1 where C: Curve + Verify + Digester, { - pub fn new( + pub(crate) fn new( data: InnerSignedBlobV1Data, signature: Vec, signer: Vec, @@ -165,29 +165,6 @@ where } } -#[cfg(test)] -pub mod test { - - use super::*; - use movement_da_light_node_signer::Signer; - use movement_signer::cryptography::secp256k1::Secp256k1; - use movement_signer_local::signer::LocalSigner; - - #[tokio::test] - async fn test_cannot_change_id_and_verify() -> Result<(), anyhow::Error> { - let blob = InnerSignedBlobV1Data::new(vec![1, 2, 3], 123); - let signer = Signer::new(LocalSigner::::random()); - let signed_blob = blob.try_to_sign(&signer).await?; - - let mut changed_blob = signed_blob.clone(); - changed_blob.id = Id::new(vec![1, 2, 3, 4]); - - assert!(changed_blob.try_verify().is_err()); - - Ok(()) - } -} - pub mod stream_read_response { use movement_da_light_node_proto::*; diff --git a/protocol-units/da/movement/protocol/util/src/blob/ir/data.rs b/protocol-units/da/movement/protocol/util/src/blob/ir/data.rs index 414a77e9b..80dfa95db 100644 --- a/protocol-units/da/movement/protocol/util/src/blob/ir/data.rs +++ b/protocol-units/da/movement/protocol/util/src/blob/ir/data.rs @@ -80,4 +80,28 @@ pub mod block { Ok(Self::now(blob)) } } + + impl TryFrom for InnerSignedBlobV1Data + where + C: Curve + Verify + Digester, + { + type Error = anyhow::Error; + + fn try_from(id: block::Id) -> Result { + let blob = id.as_bytes().to_vec(); + Ok(Self::now(blob)) + } + } + + impl TryFrom> for InnerSignedBlobV1Data + where + C: Curve + Verify + Digester, + { + type Error = anyhow::Error; + + fn try_from(ids: Vec) -> Result { + let blob = bcs::to_bytes(&ids)?; + Ok(Self::now(blob)) + } + } } diff --git a/protocol-units/execution/maptos/dof/src/v1.rs b/protocol-units/execution/maptos/dof/src/v1.rs index b8d92b63f..c3779eb68 100644 --- a/protocol-units/execution/maptos/dof/src/v1.rs +++ b/protocol-units/execution/maptos/dof/src/v1.rs @@ -32,8 +32,8 @@ impl Executor { Self { executor, finality_view } } - pub fn try_from_config(config: Config) -> Result { - let executor = OptExecutor::try_from_config(config)?; + pub async fn try_from_config(config: Config) -> Result { + let executor = OptExecutor::try_from_config(config).await?; Ok(Self::new(executor)) } } @@ -174,11 +174,11 @@ mod tests { use std::collections::HashMap; - fn setup(mut maptos_config: Config) -> Result<(Executor, TempDir), anyhow::Error> { + async fn setup(mut maptos_config: Config) -> Result<(Executor, TempDir), anyhow::Error> { let tempdir = tempfile::tempdir()?; // replace the db path with the temporary directory maptos_config.chain.maptos_db_path.replace(tempdir.path().to_path_buf()); - let executor = Executor::try_from_config(maptos_config)?; + let executor = Executor::try_from_config(maptos_config).await?; Ok((executor, tempdir)) } @@ -205,7 +205,7 @@ mod tests { config.chain.maptos_private_key_signer_identifier = SignerIdentifier::Local(Local { private_key_hex_bytes: private_key.to_encoded_string()?.to_string(), }); - let (executor, _tempdir) = setup(config)?; + let (executor, _tempdir) = setup(config).await?; let block_id = HashValue::random(); let block_metadata = executor .build_block_metadata(block_id.clone(), chrono::Utc::now().timestamp_micros() as u64) @@ -231,7 +231,7 @@ mod tests { config.chain.maptos_private_key_signer_identifier = SignerIdentifier::Local(Local { private_key_hex_bytes: private_key.to_encoded_string()?.to_string(), }); - let (executor, _tempdir) = setup(config.clone())?; + let (executor, _tempdir) = setup(config.clone()).await?; let (tx_sender, mut tx_receiver) = mpsc::channel(16); let (context, background) = executor.background(tx_sender, &config)?; let services = context.services(); @@ -265,7 +265,7 @@ mod tests { }); config.chain.maptos_read_only = true; let (tx_sender, _tx_receiver) = mpsc::channel(16); - let (executor, _tempdir) = setup(config.clone())?; + let (executor, _tempdir) = setup(config.clone()).await?; let (context, background) = executor.background(tx_sender, &config)?; let services = context.services(); let api = services.get_opt_apis(); @@ -295,7 +295,7 @@ mod tests { config.chain.maptos_private_key_signer_identifier = SignerIdentifier::Local(Local { private_key_hex_bytes: private_key.to_encoded_string()?.to_string(), }); - let (executor, _tempdir) = setup(config.clone())?; + let (executor, _tempdir) = setup(config.clone()).await?; let (tx_sender, mut tx_receiver) = mpsc::channel(16); let (context, background) = executor.background(tx_sender, &config)?; let services = context.services(); @@ -356,7 +356,7 @@ mod tests { config.chain.maptos_private_key_signer_identifier = SignerIdentifier::Local(Local { private_key_hex_bytes: private_key.to_encoded_string()?.to_string(), }); - let (executor, _tempdir) = setup(config.clone())?; + let (executor, _tempdir) = setup(config.clone()).await?; let (tx_sender, mut tx_receiver) = mpsc::channel(16); let (context, background) = executor.background(tx_sender, &config)?; let services = context.services(); @@ -438,7 +438,7 @@ mod tests { // Create an executor instance from the environment configuration. let config = Config::default(); let (tx_sender, _tx_receiver) = mpsc::channel(16); - let executor = Executor::try_from_config(config.clone())?; + let executor = Executor::try_from_config(config.clone()).await?; let (context, background) = executor.background(tx_sender, &config)?; let config = executor.config(); let services = context.services(); @@ -511,7 +511,7 @@ mod tests { // Create an executor instance from the environment configuration. let config = Config::default(); let (tx_sender, _tx_receiver) = mpsc::channel(16); - let executor = Executor::try_from_config(config.clone())?; + let executor = Executor::try_from_config(config.clone()).await?; let (context, background) = executor.background(tx_sender, &config)?; let config = executor.config(); let services = context.services(); diff --git a/protocol-units/execution/maptos/fin-view/src/fin_view.rs b/protocol-units/execution/maptos/fin-view/src/fin_view.rs index 7afaacff1..97570c01a 100644 --- a/protocol-units/execution/maptos/fin-view/src/fin_view.rs +++ b/protocol-units/execution/maptos/fin-view/src/fin_view.rs @@ -79,7 +79,7 @@ mod tests { // Create an Executor and a FinalityView instance from the environment configuration. let config = Config::default(); let (tx_sender, _tx_receiver) = mpsc::channel(16); - let executor = Executor::try_from_config(config)?; + let executor = Executor::try_from_config(config).await?; let (context, _transaction_pipe) = executor.background(tx_sender)?; let finality_view = FinalityView::new(context.db_reader()); let service = finality_view.service( diff --git a/protocol-units/execution/maptos/framework/migrations/elsa-to-biarritz-rc1/src/lib.rs b/protocol-units/execution/maptos/framework/migrations/elsa-to-biarritz-rc1/src/lib.rs index 1c3654787..1ce06cef4 100644 --- a/protocol-units/execution/maptos/framework/migrations/elsa-to-biarritz-rc1/src/lib.rs +++ b/protocol-units/execution/maptos/framework/migrations/elsa-to-biarritz-rc1/src/lib.rs @@ -1,6 +1,6 @@ pub mod dot_movement; -use aptos_framework_biarritz_rc1_release::cached::gas_upgrade::BiarritzRc1; +use aptos_framework_biarritz_rc1_release::cached::full::feature_upgrade::BiarritzRc1; use maptos_framework_release_util::{Release, ReleaseSigner}; use std::future::Future; @@ -21,7 +21,7 @@ impl ElsaToBiarritzRc1 { // upgrade to Biarritz RC1 with the gas upgrade let biarritz_rc1 = BiarritzRc1::new(); biarritz_rc1 - .release(signer, 2_000_000, 100, 60, client) + .release(signer, 2_000_000, 100, 60_000, client) .await .map_err(|e| ElsaToBiarritzRc1Error::MigrationFailed(e.into()))?; diff --git a/protocol-units/execution/maptos/framework/releases/biarritz-rc1/build.rs b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/build.rs index 9b765682d..441396908 100644 --- a/protocol-units/execution/maptos/framework/releases/biarritz-rc1/build.rs +++ b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/build.rs @@ -5,7 +5,7 @@ use maptos_framework_release_util::commit_hash_with_script; commit_hash_with_script!( BiarritzRc1, // Struct name "https://github.com/movementlabsxyz/aptos-core.git", // Repository URL - "d86339c130c3a9afd9413db95412b7586b78c905", // Commit hash + "aa45303216be96ea30d361ab7eb2e95fb08c2dcb", // Commit hash 6, // Bytecode version "biarritz-rc1.mrb", // MRB file name "CACHE_BIARRITZ_RC1_FRAMEWORK_RELEASE" // Cache environment variable for Elsa diff --git a/protocol-units/execution/maptos/framework/releases/biarritz-rc1/mrb_cache/aa45303216be96ea30d361ab7eb2e95fb08c2dcb-biarritz-rc1.mrb b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/mrb_cache/aa45303216be96ea30d361ab7eb2e95fb08c2dcb-biarritz-rc1.mrb new file mode 100644 index 000000000..51cc61e95 Binary files /dev/null and b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/mrb_cache/aa45303216be96ea30d361ab7eb2e95fb08c2dcb-biarritz-rc1.mrb differ diff --git a/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/cached.rs b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/cached.rs index ad711be14..e6971eda3 100644 --- a/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/cached.rs +++ b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/cached.rs @@ -4,7 +4,7 @@ use maptos_framework_release_util::mrb_release; mrb_release!( BiarritzRc1, BIARRTIZ_RC1, - "d86339c130c3a9afd9413db95412b7586b78c905-biarritz-rc1.mrb" + "aa45303216be96ea30d361ab7eb2e95fb08c2dcb-biarritz-rc1.mrb" ); generate_gas_upgrade_module!(gas_upgrade, BiarritzRc1, { diff --git a/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/lib.rs b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/lib.rs index b32dc43c3..6bf69cb77 100644 --- a/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/lib.rs +++ b/protocol-units/execution/maptos/framework/releases/biarritz-rc1/src/lib.rs @@ -7,7 +7,7 @@ use maptos_framework_release_util::commit_hash_with_script; commit_hash_with_script!( BiarritzRc1, // Struct name "https://github.com/movementlabsxyz/aptos-core.git", // Repository URL - "d86339c130c3a9afd9413db95412b7586b78c905", // Commit hash + "aa45303216be96ea30d361ab7eb2e95fb08c2dcb", // Commit hash 6, // Bytecode version "biarritz-rc1.mrb", // MRB file name "CACHE_BIARRITZ_RC1_FRAMEWORK_RELEASE" // Cache environment variable for Elsa diff --git a/protocol-units/execution/maptos/framework/releases/feature-flags/src/lib.rs b/protocol-units/execution/maptos/framework/releases/feature-flags/src/lib.rs index 814793023..c422fd9e0 100644 --- a/protocol-units/execution/maptos/framework/releases/feature-flags/src/lib.rs +++ b/protocol-units/execution/maptos/framework/releases/feature-flags/src/lib.rs @@ -162,7 +162,7 @@ where let now_u64 = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .map_err(|e| ReleaseBundleError::Build(e.into()))? - .as_secs(); + .as_micros() as u64; let expiration_timestamp_secs = now_u64 + expiration_timestamp_sec_offset; self.set_feature_flags( signer, diff --git a/protocol-units/execution/maptos/framework/releases/release-script/src/lib.rs b/protocol-units/execution/maptos/framework/releases/release-script/src/lib.rs index a0d302990..22a0ecd11 100644 --- a/protocol-units/execution/maptos/framework/releases/release-script/src/lib.rs +++ b/protocol-units/execution/maptos/framework/releases/release-script/src/lib.rs @@ -154,7 +154,7 @@ where let now_u64 = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .map_err(|e| ReleaseBundleError::Build(e.into()))? - .as_secs(); + .as_micros() as u64; let expiration_timestamp_secs = now_u64 + expiration_timestamp_sec_offset; self.set_release_script( signer, diff --git a/protocol-units/execution/maptos/framework/releases/upgrade-gas/src/lib.rs b/protocol-units/execution/maptos/framework/releases/upgrade-gas/src/lib.rs index 95bb3fada..8b879895a 100644 --- a/protocol-units/execution/maptos/framework/releases/upgrade-gas/src/lib.rs +++ b/protocol-units/execution/maptos/framework/releases/upgrade-gas/src/lib.rs @@ -156,7 +156,7 @@ where let now_u64 = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .map_err(|e| ReleaseBundleError::Build(e.into()))? - .as_secs(); + .as_micros() as u64; let expiration_timestamp_secs = now_u64 + expiration_timestamp_sec_offset; info!("Upgrading gas parameters"); diff --git a/protocol-units/execution/maptos/framework/releases/util/src/lib.rs b/protocol-units/execution/maptos/framework/releases/util/src/lib.rs index 4f29b37cc..222ed694d 100644 --- a/protocol-units/execution/maptos/framework/releases/util/src/lib.rs +++ b/protocol-units/execution/maptos/framework/releases/util/src/lib.rs @@ -383,7 +383,7 @@ pub trait Release { let now_u64 = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .map_err(|e| ReleaseBundleError::Build(e.into()))? - .as_secs(); + .as_micros() as u64; let expiration_timestamp = now_u64 + expiration_timestamp_sec_offset as u64; let _completed_votes = self .vote(signer, max_gas_amount, gas_unit_price, expiration_timestamp, client) @@ -412,7 +412,7 @@ fn build_release_bundles_raw_transactions( let now_u64 = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .map_err(|e| ReleaseBundleError::Build(e.into()))? - .as_secs(); + .as_micros() as u64; let expiration_timestamp = now_u64 + (expiration_timestamp_sec_offset * i) as u64; let raw_transaction = RawTransaction::new( diff --git a/protocol-units/execution/maptos/opt-executor/Cargo.toml b/protocol-units/execution/maptos/opt-executor/Cargo.toml index 59177a71f..e076854ce 100644 --- a/protocol-units/execution/maptos/opt-executor/Cargo.toml +++ b/protocol-units/execution/maptos/opt-executor/Cargo.toml @@ -76,6 +76,7 @@ aptos-gas-schedule = { workspace = true } aptos-sdk = { workspace = true } tempfile = { workspace = true } movement-signer-loader = { workspace = true } +movement-signer = { workspace = true } [dev-dependencies] dirs = { workspace = true } diff --git a/protocol-units/execution/maptos/opt-executor/src/background/transaction_pipe.rs b/protocol-units/execution/maptos/opt-executor/src/background/transaction_pipe.rs index 875377486..415abf4d4 100644 --- a/protocol-units/execution/maptos/opt-executor/src/background/transaction_pipe.rs +++ b/protocol-units/execution/maptos/opt-executor/src/background/transaction_pipe.rs @@ -344,9 +344,12 @@ mod tests { use maptos_execution_util::config::chain::Config; use tempfile::TempDir; - fn setup() -> (Context, TransactionPipe, mpsc::Receiver<(u64, SignedTransaction)>, TempDir) { + async fn setup() -> (Context, TransactionPipe, mpsc::Receiver<(u64, SignedTransaction)>, TempDir) + { let (tx_sender, tx_receiver) = mpsc::channel(16); - let (executor, tempdir) = Executor::try_test_default(GENESIS_KEYPAIR.0.clone()).unwrap(); + let (executor, tempdir) = Executor::try_test_default(GENESIS_KEYPAIR.0.clone()) + .await + .expect("Transaction pipe test can't create executor with private key."); let (context, background) = executor.background(tx_sender).unwrap(); let transaction_pipe = background.into_transaction_pipe(); (context, transaction_pipe, tx_receiver, tempdir) @@ -367,7 +370,7 @@ mod tests { async fn test_pipe_mempool() -> Result<(), anyhow::Error> { // set up let maptos_config = Config::default(); - let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup(); + let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup().await; let user_transaction = create_signed_transaction(1, &maptos_config); // send transaction to mempool @@ -395,7 +398,7 @@ mod tests { async fn test_pipe_mempool_cancellation() -> Result<(), anyhow::Error> { // set up let maptos_config = Config::default(); - let (context, mut transaction_pipe, _tx_receiver, _tempdir) = setup(); + let (context, mut transaction_pipe, _tx_receiver, _tempdir) = setup().await; let user_transaction = create_signed_transaction(1, &maptos_config); // send transaction to mempool @@ -418,7 +421,7 @@ mod tests { async fn test_pipe_mempool_with_duplicate_transaction() -> Result<(), anyhow::Error> { // set up let maptos_config = Config::default(); - let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup(); + let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup().await; let mut mempool_client_sender = context.mempool_client_sender(); let user_transaction = create_signed_transaction(1, &maptos_config); @@ -459,7 +462,7 @@ mod tests { #[tokio::test] async fn test_pipe_mempool_from_api() -> Result<(), anyhow::Error> { - let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup(); + let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup().await; let service = Service::new(&context); #[allow(unreachable_code)] @@ -486,7 +489,7 @@ mod tests { #[tokio::test] async fn test_repeated_pipe_mempool_from_api() -> Result<(), anyhow::Error> { - let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup(); + let (context, mut transaction_pipe, mut tx_receiver, _tempdir) = setup().await; let service = Service::new(&context); #[allow(unreachable_code)] @@ -526,7 +529,7 @@ mod tests { async fn test_cannot_submit_too_new() -> Result<(), anyhow::Error> { // set up let maptos_config = Config::default(); - let (_context, mut transaction_pipe, _tx_receiver, _tempdir) = setup(); + let (_context, mut transaction_pipe, _tx_receiver, _tempdir) = setup().await; // submit a transaction with a valid sequence number let user_transaction = create_signed_transaction(0, &maptos_config); @@ -554,7 +557,7 @@ mod tests { #[tokio::test] async fn test_sequence_number_too_old() -> Result<(), anyhow::Error> { let (tx_sender, _tx_receiver) = mpsc::channel(16); - let (executor, _tempdir) = Executor::try_test_default(GENESIS_KEYPAIR.0.clone())?; + let (executor, _tempdir) = Executor::try_test_default(GENESIS_KEYPAIR.0.clone()).await?; let (context, background) = executor.background(tx_sender)?; let mut transaction_pipe = background.into_transaction_pipe(); diff --git a/protocol-units/execution/maptos/opt-executor/src/bootstrap.rs b/protocol-units/execution/maptos/opt-executor/src/bootstrap.rs index a1b7685d4..de08a988c 100644 --- a/protocol-units/execution/maptos/opt-executor/src/bootstrap.rs +++ b/protocol-units/execution/maptos/opt-executor/src/bootstrap.rs @@ -4,7 +4,6 @@ use aptos_crypto::ed25519::Ed25519PublicKey; use aptos_db::AptosDB; use aptos_executor::db_bootstrapper; use aptos_gas_schedule::{AptosGasParameters, InitialGasSchedule, ToOnChainGasSchedule}; -use aptos_sdk::move_types::gas_algebra::GasQuantity; use aptos_storage_interface::DbReaderWriter; use aptos_types::{ chain_id::ChainId, diff --git a/protocol-units/execution/maptos/opt-executor/src/executor/execution.rs b/protocol-units/execution/maptos/opt-executor/src/executor/execution.rs index 77c3ea200..6a2962e41 100644 --- a/protocol-units/execution/maptos/opt-executor/src/executor/execution.rs +++ b/protocol-units/execution/maptos/opt-executor/src/executor/execution.rs @@ -212,11 +212,14 @@ mod tests { ed25519::{Ed25519PrivateKey, Ed25519Signature}, HashValue, PrivateKey, Uniform, }; - use aptos_sdk::{transaction_builder::TransactionFactory, types::LocalAccount}; + use aptos_sdk::{ + transaction_builder::TransactionFactory, + types::{AccountKey, LocalAccount}, + }; use aptos_storage_interface::state_view::DbStateViewAtVersion; use aptos_types::{ account_address::AccountAddress, - account_config::AccountResource, + account_config::{aptos_test_root_address, AccountResource}, block_executor::partitioner::ExecutableTransactions, block_metadata::BlockMetadata, chain_id::ChainId, @@ -250,7 +253,7 @@ mod tests { async fn test_execute_block() -> Result<(), anyhow::Error> { let private_key = Ed25519PrivateKey::generate_for_testing(); let (tx_sender, _tx_receiver) = mpsc::channel(1); - let (executor, _tempdir) = Executor::try_test_default(private_key)?; + let (executor, _tempdir) = Executor::try_test_default(private_key).await?; let (context, _transaction_pipe) = executor.background(tx_sender)?; let block_id = HashValue::random(); let block_metadata = Transaction::BlockMetadata(BlockMetadata::new( @@ -284,7 +287,7 @@ mod tests { // Create an executor instance from the environment configuration. let private_key = Ed25519PrivateKey::generate_for_testing(); let (tx_sender, _tx_receiver) = mpsc::channel(1); - let (executor, _tempdir) = Executor::try_test_default(private_key)?; + let (executor, _tempdir) = Executor::try_test_default(private_key).await?; let (context, _transaction_pipe) = executor.background(tx_sender)?; // Initialize a root account using a predefined keypair and the test root address. @@ -295,8 +298,11 @@ mod tests { .maptos_private_key_signer_identifier .try_raw_private_key()?; let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?; - let root_account = - LocalAccount::from_private_key(private_key.to_encoded_string()?.as_str(), 0)?; + let root_account = LocalAccount::new( + aptos_test_root_address(), + AccountKey::from_private_key(private_key), + 0, + ); // Seed for random number generator, used here to generate predictable results in a test environment. let seed = [3u8; 32]; @@ -392,7 +398,7 @@ mod tests { // Create an executor instance from the environment configuration. let private_key = Ed25519PrivateKey::generate_for_testing(); let (tx_sender, _tx_receiver) = mpsc::channel(16); - let (executor, _tempdir) = Executor::try_test_default(private_key)?; + let (executor, _tempdir) = Executor::try_test_default(private_key).await?; let (context, _transaction_pipe) = executor.background(tx_sender)?; let service = Service::new(&context); @@ -403,8 +409,11 @@ mod tests { .maptos_private_key_signer_identifier .try_raw_private_key()?; let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?; - let root_account = - LocalAccount::from_private_key(private_key.to_encoded_string()?.as_str(), 0)?; + let root_account = LocalAccount::new( + aptos_test_root_address(), + AccountKey::from_private_key(private_key), + 0, + ); // Seed for random number generator, used here to generate predictable results in a test environment. let seed = [3u8; 32]; diff --git a/protocol-units/execution/maptos/opt-executor/src/executor/initialization.rs b/protocol-units/execution/maptos/opt-executor/src/executor/initialization.rs index 2cf149ba6..915159add 100644 --- a/protocol-units/execution/maptos/opt-executor/src/executor/initialization.rs +++ b/protocol-units/execution/maptos/opt-executor/src/executor/initialization.rs @@ -1,11 +1,14 @@ use super::Executor; use crate::background::BackgroundTask; use crate::{bootstrap, Context}; -use aptos_crypto::ed25519::Ed25519PrivateKey; +use movement_signer::cryptography::ed25519::Ed25519; +use movement_signer::Signing; +use movement_signer_loader::{Load, LoadedSigner}; use aptos_config::config::NodeConfig; +#[cfg(test)] +use aptos_crypto::ed25519::Ed25519PrivateKey; use aptos_crypto::ed25519::Ed25519PublicKey; -use aptos_crypto::PrivateKey; #[cfg(test)] use aptos_crypto::ValidCryptoMaterialStringExt; use aptos_executor::block_executor::BlockExecutor; @@ -128,16 +131,21 @@ impl Executor { }) } - pub fn bootstrap(maptos_config: &Config) -> Result { - let raw_private_key = - maptos_config.chain.maptos_private_key_signer_identifier.try_raw_private_key()?; - let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?; - let public_key = private_key.public_key(); + pub async fn bootstrap(maptos_config: &Config) -> Result { + // let raw_private_key = + // maptos_config.chain.maptos_private_key_signer_identifier.try_raw_private_key()?; + // let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?; + // let public_key = private_key.public_key(); + + let loader: LoadedSigner = + maptos_config.chain.maptos_private_key_signer_identifier.load().await?; + let public_key = Ed25519PublicKey::try_from(loader.public_key().await?.as_bytes())?; + Self::bootstrap_with_public_key(maptos_config, public_key) } - pub fn try_from_config(maptos_config: Config) -> Result { - Self::bootstrap(&maptos_config) + pub async fn try_from_config(maptos_config: Config) -> Result { + Self::bootstrap(&maptos_config).await } #[cfg(test)] @@ -163,7 +171,7 @@ impl Executor { } #[cfg(test)] - pub fn try_test_default( + pub async fn try_test_default( private_key: Ed25519PrivateKey, ) -> Result<(Self, TempDir), anyhow::Error> { let tempdir = tempfile::tempdir()?; @@ -177,7 +185,7 @@ impl Executor { // replace the db path with the temporary directory maptos_config.chain.maptos_db_path.replace(tempdir.path().to_path_buf()); - let executor = Self::try_from_config(maptos_config)?; + let executor = Self::try_from_config(maptos_config).await?; Ok((executor, tempdir)) } diff --git a/protocol-units/execution/maptos/opt-executor/src/service.rs b/protocol-units/execution/maptos/opt-executor/src/service.rs index 45ed519a6..670df6877 100644 --- a/protocol-units/execution/maptos/opt-executor/src/service.rs +++ b/protocol-units/execution/maptos/opt-executor/src/service.rs @@ -115,7 +115,7 @@ mod tests { #[tokio::test] async fn test_pipe_mempool_while_server_running() -> Result<(), anyhow::Error> { let (tx_sender, mut tx_receiver) = mpsc::channel(16); - let (executor, _tempdir) = Executor::try_test_default(GENESIS_KEYPAIR.0.clone())?; + let (executor, _tempdir) = Executor::try_test_default(GENESIS_KEYPAIR.0.clone()).await?; let (context, background) = executor.background(tx_sender)?; let mut transaction_pipe = background.into_transaction_pipe(); let service = Service::new(&context); diff --git a/protocol-units/settlement/mcr/contracts/minter/Move.toml b/protocol-units/settlement/mcr/contracts/minter/Move.toml new file mode 100644 index 000000000..52768be6c --- /dev/null +++ b/protocol-units/settlement/mcr/contracts/minter/Move.toml @@ -0,0 +1,8 @@ +[package] +name = "Minter" +version = "0.0.0" + +[dependencies.AptosFramework] +git = "https://github.com/movementlabsxyz/aptos-core.git" +rev = "movement" +subdir = "aptos-move/framework/aptos-framework" \ No newline at end of file diff --git a/protocol-units/settlement/mcr/contracts/minter/sources/minter.move b/protocol-units/settlement/mcr/contracts/minter/sources/minter.move new file mode 100644 index 000000000..363f2a765 --- /dev/null +++ b/protocol-units/settlement/mcr/contracts/minter/sources/minter.move @@ -0,0 +1,22 @@ +script { + use std::signer; + use aptos_framework::aptos_account; + use aptos_framework::aptos_coin; + use aptos_framework::coin; + + // Tune this parameter based upon the actual gas costs + const GAS_BUFFER: u64 = 100000; + const U64_MAX: u64 = 18446744073709551615; + + fun main(minter: &signer, dst_addr: address, amount: u64) { + let minter_addr = signer::address_of(minter); + + // Do not mint if it would exceed U64_MAX + let balance = coin::balance(minter_addr); + if (balance < U64_MAX - amount - GAS_BUFFER) { + aptos_coin::mint(minter, minter_addr, amount + GAS_BUFFER); + }; + + aptos_account::transfer(minter, dst_addr, amount); + } +} \ No newline at end of file diff --git a/util/signing/testing/Cargo.toml b/util/signing/testing/Cargo.toml index d139b4e8e..239c35f85 100644 --- a/util/signing/testing/Cargo.toml +++ b/util/signing/testing/Cargo.toml @@ -19,7 +19,7 @@ async-trait = { workspace = true } maptos-dof-execution = { workspace = true } maptos-execution-util = { workspace = true } movement-signing-aptos = { workspace = true } -movement-signer-loader = { workspace = true } +movement-signer-loader = { workspace = true } movement-signer-local = { workspace = true } movement-signer-aws-kms = { workspace = true } movement-signing-eth = { workspace = true } @@ -28,6 +28,7 @@ aptos-types = { workspace = true } anyhow = { workspace = true } chrono = { workspace = true } ed25519-dalek = { workspace = true, features = ["rand_core"] } +hex = { workspace = true } # Workspace is on rand 0.7 due largely to aptos-core rand = "0.8" sha3 = "0.10.8" diff --git a/util/signing/testing/tests/execute.rs b/util/signing/testing/tests/execute.rs index b62ac9f06..35a51bc77 100644 --- a/util/signing/testing/tests/execute.rs +++ b/util/signing/testing/tests/execute.rs @@ -12,15 +12,14 @@ use aptos_types::transaction::{ }; use anyhow::Context; -use aptos_crypto::ValidCryptoMaterialStringExt; use movement_signer_loader::identifiers::{local::Local, SignerIdentifier}; use tempfile::TempDir; -fn setup(mut maptos_config: Config) -> Result<(Executor, TempDir), anyhow::Error> { +async fn setup(mut maptos_config: Config) -> Result<(Executor, TempDir), anyhow::Error> { let tempdir = tempfile::tempdir()?; // replace the db path with the temporary directory maptos_config.chain.maptos_db_path.replace(tempdir.path().to_path_buf()); - let executor = Executor::try_from_config(maptos_config)?; + let executor = Executor::try_from_config(maptos_config).await?; Ok((executor, tempdir)) } @@ -45,11 +44,11 @@ async fn execute_signed_transaction() -> Result<(), anyhow::Error> { let private_key = Ed25519PrivateKey::generate_for_testing(); let mut config = Config::default(); let signing_key = ed25519_dalek::SigningKey::from_bytes(&private_key.to_bytes()); - config.chain.maptos_private_key_signer_identifier = SignerIdentifier::Local(Local { - private_key_hex_bytes: private_key.to_encoded_string()?.to_string(), - }); + let private_key_hex_bytes = hex::encode(&private_key.to_bytes()); + config.chain.maptos_private_key_signer_identifier = + SignerIdentifier::Local(Local { private_key_hex_bytes }); let signer = TestSigner::new(signing_key); - let (executor, _tempdir) = setup(config)?; + let (executor, _tempdir) = setup(config).await?; let transaction = create_signed_transaction(&signer).await?; let block_id = HashValue::random(); let block_metadata = executor