Skip to content

Commit

Permalink
[Tooling] Combine some tools to a single binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
grao1991 committed Oct 27, 2023
1 parent 94b9fbd commit 2f36971
Show file tree
Hide file tree
Showing 23 changed files with 313 additions and 334 deletions.
83 changes: 41 additions & 42 deletions Cargo.lock

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

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ members = [
"crates/aptos-compression",
"crates/aptos-crypto",
"crates/aptos-crypto-derive",
"crates/aptos-debugger",
"crates/aptos-drop-helper",
"crates/aptos-enum-conversion-derive",
"crates/aptos-faucet/cli",
Expand Down Expand Up @@ -115,7 +116,6 @@ members = [
"ecosystem/node-checker",
"ecosystem/node-checker/fn-check-client",
"execution/block-partitioner",
"execution/db-bootstrapper",
"execution/executor",
"execution/executor-benchmark",
"execution/executor-service",
Expand Down Expand Up @@ -242,13 +242,13 @@ default-members = [
"aptos-node",
"consensus/safety-rules",
"crates/aptos",
"crates/aptos-debugger",
"crates/aptos-faucet/service",
"crates/aptos-keygen",
"crates/aptos-rate-limiter",
"crates/aptos-rosetta",
"crates/transaction-emitter",
"aptos-move/framework",
"execution/db-bootstrapper",
"storage/backup/backup-cli",
"ecosystem/node-checker",
]
Expand Down Expand Up @@ -296,7 +296,7 @@ aptos-data-streaming-service = { path = "state-sync/data-streaming-service" }
aptos-db = { path = "storage/aptosdb" }
aptos-db-indexer = { path = "storage/indexer" }
aptos-db-tool = { path = "storage/db-tool" }
aptos-debugger = { path = "aptos-move/aptos-debugger" }
aptos-debugger = { path = "crates/aptos-debugger" }
aptos-drop-helper = { path = "crates/aptos-drop-helper" }
aptos-event-notifications = { path = "state-sync/inter-component/event-notifications" }
aptos-executable-store = { path = "storage/executable-store" }
Expand Down Expand Up @@ -350,6 +350,7 @@ aptos-mempool = { path = "mempool" }
aptos-mempool-notifications = { path = "state-sync/inter-component/mempool-notifications" }
aptos-memsocket = { path = "network/memsocket" }
aptos-metrics-core = { path = "crates/aptos-metrics-core" }
aptos-move-debugger = { path = "aptos-move/aptos-debugger" }
aptos-move-examples = { path = "aptos-move/move-examples" }
aptos-moving-average = { path = "crates/moving-average" }
aptos-mvhashmap = { path = "aptos-move/mvhashmap" }
Expand Down Expand Up @@ -740,10 +741,6 @@ debug-assertions = true
[profile.bench]
debug = true

# This is a temporary workaround to avoid multiple library
# definitions for LZ4 (caused by rust-rocksdb).
# This will be removed once our pull requests land.
# https://github.com/rust-rocksdb/rust-rocksdb/issues/666
[patch.crates-io]
serde-reflection = { git = "https://github.com/aptos-labs/serde-reflection", rev = "839aed62a20ddccf043c08961cfe74875741ccba" }
merlin = { git = "https://github.com/aptos-labs/merlin" }
Expand Down
20 changes: 11 additions & 9 deletions aptos-move/aptos-debugger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
[package]
name = "aptos-debugger"
name = "aptos-move-debugger"
version = "0.1.0"
authors = ["Aptos Labs <[email protected]>"]
description = "A tool to replay transactions on chain and to execute transactions locally with remote backend"
repository = "https://github.com/aptos-labs/aptos-core"
homepage = "https://aptoslabs.com"
license = "Apache-2.0"
publish = false
edition = "2021"
default-run = "aptos-debugger"
description = "A tool to replay transactions on chain and to execute transactions locally."

# Workspace inherited keys
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }

[dependencies]
anyhow = { workspace = true }
Expand Down
58 changes: 57 additions & 1 deletion aptos-move/aptos-debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,58 @@ use aptos_vm::{
};
use aptos_vm_logging::log_schema::AdapterLogSchema;
use aptos_vm_types::{change_set::VMChangeSet, output::VMOutput, storage::ChangeSetConfigs};
use clap::Parser;
use move_binary_format::errors::VMResult;
use std::{path::Path, sync::Arc};
use std::{
path::{Path, PathBuf},
sync::Arc,
};
use url::Url;

#[derive(Parser)]
#[clap(group(clap::ArgGroup::new("target")
.required(true)
.args(&["rest_endpoint", "db_path"]),
))]
pub struct Command {
/// Use full node's rest api as query endpoint.
#[clap(long, group = "target")]
rest_endpoint: Option<String>,

/// Use a local db instance to serve as query endpoint.
#[clap(long, group = "target")]
db_path: Option<PathBuf>,

#[clap(long)]
begin_version: u64,

#[clap(long)]
limit: u64,

#[clap(long, default_value_t = 1)]
concurrency_level: usize,
}

impl Command {
pub async fn run(self) -> Result<()> {
AptosVM::set_concurrency_level_once(self.concurrency_level);

let debugger = if let Some(rest_endpoint) = self.rest_endpoint {
AptosDebugger::rest_client(Client::new(Url::parse(&rest_endpoint)?))?
} else {
AptosDebugger::db(self.db_path.unwrap())?
};

println!(
"{:#?}",
debugger
.execute_past_transactions(self.begin_version, self.limit)
.await?
);

Ok(())
}
}

pub struct AptosDebugger {
debugger: Arc<dyn AptosValidatorInterface + Send>,
Expand Down Expand Up @@ -260,3 +310,9 @@ fn is_reconfiguration(vm_output: &TransactionOutput) -> bool {
.iter()
.any(|event| event.event_key() == Some(&new_epoch_event_key))
}

#[test]
fn verify_tool() {
use clap::CommandFactory;
Command::command().debug_assert()
}
61 changes: 0 additions & 61 deletions aptos-move/aptos-debugger/src/main.rs

This file was deleted.

22 changes: 22 additions & 0 deletions crates/aptos-debugger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "aptos-debugger"
version = "0.1.0"
description = "Debugging tools."

# Workspace inherited keys
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }

[dependencies]
anyhow = { workspace = true }
aptos-db-tool = { workspace = true }
aptos-logger = { workspace = true }
aptos-move-debugger = { workspace = true }
aptos-push-metrics = { workspace = true }
clap = { workspace = true }
tokio = { workspace = true }
Loading

0 comments on commit 2f36971

Please sign in to comment.