Skip to content

0xmovses/sec signing integration #1023

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

Draft
wants to merge 10 commits into
base: l-monninger/secure-signing-e2e-integration
Choose a base branch
from
Draft
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
375 changes: 195 additions & 180 deletions Cargo.lock

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,40 +155,40 @@ serde_yaml = "0.9.34"
## Aptos dependencies
### We use a forked version so that we can override dependency versions. This is required
### to be avoid dependency conflicts with other Sovereign Labs crates.
aptos-api = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-api-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-bitvec = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-block-executor = { git = "https://github.com/movementlabsxyz/aptos-core.git", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-cached-packages = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-config = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-consensus-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-crypto = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41", features = [
aptos-api = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-api-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-bitvec = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-block-executor = { git = "https://github.com/movementlabsxyz/aptos-core.git", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-cached-packages = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-config = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-consensus-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-crypto = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4", features = [
"cloneable-private-keys",
] }
aptos-db = { git = "https://github.com/movementlabsxyz/aptos-core.git", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-executor = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-executor-test-helpers = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-executor-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-faucet-core = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-framework = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-language-e2e-tests = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-mempool = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-proptest-helpers = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-sdk = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-state-view = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-storage-interface = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-temppath = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-vm = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-vm-genesis = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-vm-logging = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-vm-validator = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-logger = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-vm-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-indexer = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-indexer-grpc-fullnode = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-indexer-grpc-table-info = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-protos = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "9dfc8e7a3d622597dfd81cc4ba480a5377f87a41" }
aptos-db = { git = "https://github.com/movementlabsxyz/aptos-core.git", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-executor = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-executor-test-helpers = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-executor-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-faucet-core = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-framework = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-language-e2e-tests = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-mempool = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-proptest-helpers = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-sdk = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-state-view = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-storage-interface = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-temppath = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-vm = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-vm-genesis = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-vm-logging = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-vm-validator = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-logger = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-vm-types = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-indexer = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-indexer-grpc-fullnode = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-indexer-grpc-table-info = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }
aptos-protos = { git = "https://github.com/movementlabsxyz/aptos-core", rev = "fb1d8c5b884da9758813e59fa2a7b8d0d372ddc4" }

# Indexer
processor = { git = "https://github.com/movementlabsxyz/aptos-indexer-processors", rev = "7658338eb9224abd9698c1e02dbc6ca526c268ce" }
Expand Down
7 changes: 6 additions & 1 deletion networks/movement/movement-full-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ rust-version = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
buildtime-helpers = { workspace = true }
anyhow = { workspace = true }
aptos-sdk = { workspace = true }
maptos-dof-execution = { workspace = true }
prost = { workspace = true }
movement-da-light-node-proto = { workspace = true, features = ["client"] }
movement-da-util = { workspace = true }
mcr-settlement-client = { workspace = true, features = ["eth"] }
mcr-settlement-manager = { workspace = true }
serde_json = { workspace = true }
anyhow = { workspace = true }
aptos-language-e2e-tests = { workspace = true }
futures = { workspace = true }
tokio = { workspace = true }
once_cell = { workspace = true }
tokio-stream = { workspace = true }
sha2 = { workspace = true }
tonic = { workspace = true }
Expand All @@ -42,6 +46,7 @@ hex = { workspace = true }
mcr-settlement-config = { workspace = true }
clap = { workspace = true }
movement-da-light-node-client = { workspace = true}
url = { workspace = true }

[features]
default = []
Expand Down
144 changes: 144 additions & 0 deletions networks/movement/movement-full-node/src/admin/ops/burn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#[allow(unused_imports)]
use crate::common_args::MovementArgs;
use anyhow::Context;
use aptos_sdk::{
move_types::language_storage::StructTag,
move_types::identifier::Identifier,
rest_client::{Client},
transaction_builder::TransactionBuilder,
types::{
chain_id::ChainId,
transaction::{ Script, TransactionArgument},
LocalAccount,
},
};
use aptos_sdk::{
types::{account_address::AccountAddress, transaction::TransactionPayload},
};
use clap::Parser;
use once_cell::sync::Lazy;
use std::{
fs,
str::FromStr,
time::{SystemTime, UNIX_EPOCH},
};
use tokio::process::Command;
use url::Url;

static SUZUKA_CONFIG: Lazy<movement_config::Config> = Lazy::new(|| {
let dot_movement = dot_movement::DotMovement::try_from_env().unwrap();
let config = dot_movement.try_get_config_from_json::<movement_config::Config>().unwrap();
config
});

// :!:>section_1c
static NODE_URL: Lazy<Url> = Lazy::new(|| {
let node_connection_address = SUZUKA_CONFIG
.execution_config
.maptos_config
.client
.maptos_rest_connection_hostname
.clone();
let node_connection_port = SUZUKA_CONFIG
.execution_config
.maptos_config
.client
.maptos_rest_connection_port
.clone();

let node_connection_url =
format!("http://{}:{}", node_connection_address, node_connection_port);

Url::from_str(node_connection_url.as_str()).unwrap()
});

const DEAD_ADDRESS: &str = "000000000000000000000000000000000000000000000000000000000000dead";

#[derive(Debug, Parser, Clone)]
#[clap(rename_all = "kebab-case", about = "Burns tokens 🔥.")]
pub struct Burn {
#[clap(flatten)]
pub movement_args: MovementArgs,
}

impl Burn {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
let rest_client = Client::new(NODE_URL.clone());
let dead_address = AccountAddress::from_str(DEAD_ADDRESS)?;
let chain_id = rest_client
.get_index()
.await
.context("failed to get chain ID")?
.inner()
.chain_id;

let private_key = SUZUKA_CONFIG
.execution_config
.maptos_config
.chain
.maptos_private_key
.to_string();

let core_resources_account: LocalAccount =
LocalAccount::from_private_key(&private_key.clone(), 0)?;

tracing::info!("Created core resources account");
tracing::debug!("core_resources_account address: {}", core_resources_account.address());

// Create account for transactions and gas collection

// I know that we shouldn't compile on cmd execution, but we can optimise this later.
let _compile_status = Command::new("movement")
.args([
"move",
"compile",
"--package-dir",
"networks/movement/movement-full-node/ops/move-modules",
])
.status()
.await
.expect("Failed to execute `movement compile` command");

let code =
fs::read("networks/movement/movement-full-node/ops/move-modules/burn_from.move")?;

let args = vec![
TransactionArgument::Address(dead_address),
TransactionArgument::U64(1),
TransactionArgument::U8Vector(
StructTag {
address: AccountAddress::from_hex_literal("0x1")?,
module: Identifier::new("coin")?,
name: Identifier::new("BurnCapability")?,
type_args: vec![StructTag {
address: AccountAddress::from_hex_literal("0x1")?,
module: Identifier::new("aptos_coin")?,
name: Identifier::new("AptosCoin")?,
type_args: vec![],
}
.into()],
}
.access_vector(),
),
];

let script_payload = TransactionPayload::Script(Script::new(code, vec![], args));

let tx_response = rest_client
.submit_and_wait(
&core_resources_account.sign_with_transaction_builder(
TransactionBuilder::new(
script_payload,
SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() + 60,
ChainId::new(chain_id),
)
.sequence_number(core_resources_account.sequence_number()),
),
)
.await?;

tracing::info!("Transaction submitted: {:?}", tx_response);

Ok(())
}
}
Loading
Loading