forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[aptos-debugger] Implement the CLI interface (aptos-labs#6289)
* [aptos-debugger] Implement the CLI interface * fixup! [aptos-debugger] Implement the CLI interface
- Loading branch information
1 parent
4d15b27
commit 291596e
Showing
8 changed files
with
144 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) Aptos | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::Result; | ||
use aptos_debugger::AptosDebugger; | ||
use aptos_rest_client::Client; | ||
use aptos_vm::AptosVM; | ||
use clap::{Parser, Subcommand}; | ||
use std::path::PathBuf; | ||
use url::Url; | ||
|
||
#[derive(Subcommand)] | ||
pub enum Target { | ||
/// Use full node's rest api as query endpoint. | ||
Rest { endpoint: String }, | ||
/// Use a local db instance to serve as query endpoint. | ||
DB { path: PathBuf }, | ||
} | ||
#[derive(Parser)] | ||
pub struct Argument { | ||
#[clap(subcommand)] | ||
target: Target, | ||
|
||
#[clap(long)] | ||
begin_version: u64, | ||
|
||
#[clap(long)] | ||
limit: u64, | ||
|
||
#[clap(long, default_value = "1")] | ||
concurrency_level: usize, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
aptos_logger::Logger::new().init(); | ||
let args = Argument::parse(); | ||
AptosVM::set_concurrency_level_once(args.concurrency_level); | ||
|
||
let debugger = match args.target { | ||
Target::Rest { endpoint } => { | ||
AptosDebugger::rest_client(Client::new(Url::parse(&endpoint)?))? | ||
}, | ||
Target::DB { path } => AptosDebugger::db(path)?, | ||
}; | ||
|
||
println!( | ||
"{:#?}", | ||
debugger | ||
.execute_past_transactions(args.begin_version, args.limit) | ||
.await? | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters