Skip to content

Commit

Permalink
review revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
lanvidr committed Jan 24, 2024
1 parent 28d790b commit bf7eb57
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 730 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

32 changes: 18 additions & 14 deletions crates/sui-replay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ pub enum ReplayToolCommand {
show_effects: bool,
#[arg(long, short)]
diag: bool,
/// Optional version of the executor to use, if not specified defaults to the one originally used for the transaction.
#[arg(long, short, allow_hyphen_values = true)]
executor_version_override: Option<i64>,
executor_version: Option<i64>,
/// Optional protocol version to use, if not specified defaults to the one originally used for the transaction.
#[arg(long, short, allow_hyphen_values = true)]
protocol_version_override: Option<i64>,
protocol_version: Option<i64>,
/// Optional output filepath for the profile generated by this run, if not specified defaults to `gas_profile_{tx_digest}_{unix_timestamp}.json in the working directory.
#[arg(long, short, allow_hyphen_values = true)]
profile_output_filepath_override: Option<PathBuf>,
profile_output: Option<PathBuf>,
},

/// Replay transaction
Expand All @@ -90,10 +93,12 @@ pub enum ReplayToolCommand {
show_effects: bool,
#[arg(long, short)]
diag: bool,
/// Optional version of the executor to use, if not specified defaults to the one originally used for the transaction.
#[arg(long, short, allow_hyphen_values = true)]
executor_version_override: Option<i64>,
executor_version: Option<i64>,
/// Optional protocol version to use, if not specified defaults to the one originally used for the transaction.
#[arg(long, short, allow_hyphen_values = true)]
protocol_version_override: Option<i64>,
protocol_version: Option<i64>,
},

/// Replay transactions listed in a file
Expand Down Expand Up @@ -368,9 +373,9 @@ pub async fn execute_replay_command(
tx_digest,
show_effects,
diag,
executor_version_override,
protocol_version_override,
profile_output_filepath_override,
executor_version,
protocol_version,
profile_output,
} => {
let tx_digest = TransactionDigest::from_str(&tx_digest)?;
info!("Executing tx: {}", tx_digest);
Expand All @@ -380,10 +385,9 @@ pub async fn execute_replay_command(
tx_digest,
safety,
use_authority,
executor_version_override,
protocol_version_override,
profile_output_filepath_override
.or(Some((*DEFAULT_PROFILE_OUTPUT_PATH.clone()).to_path_buf())),
executor_version,
protocol_version,
profile_output.or(Some((*DEFAULT_PROFILE_OUTPUT_PATH.clone()).to_path_buf())),
)
.await?;

Expand All @@ -404,8 +408,8 @@ pub async fn execute_replay_command(
tx_digest,
show_effects,
diag,
executor_version_override,
protocol_version_override,
executor_version: executor_version_override,
protocol_version: protocol_version_override,
} => {
let tx_digest = TransactionDigest::from_str(&tx_digest)?;
info!("Executing tx: {}", tx_digest);
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-replay/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ pub struct LocalExec {
// -1 implies use latest version
// None implies use the protocol version at the time of execution
pub protocol_version_override: Option<i64>,
// Whether or not to enable the gas profiler
// Whether or not to enable the gas profiler, the PathBuf contains either a user specified
// filepath or DEFAULT_PROFILE_OUTPUT_PATH for the profile output
pub enable_profiler: Option<PathBuf>,
// Retry policies due to RPC errors
pub num_retries_for_timeout: u32,
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ workspace-hack.workspace = true
git-version.workspace = true
const-str = "0.5.6"
move-vm-profiler = { workspace = true, features = ["gas-profiler"] }
move-vm-profiler.workspace = true

[[bin]]
name = "sui-tool"
path = "src/main.rs"

[features]
default = ["gas-profiler"]
#default = ["gas-profiler"]
4 changes: 0 additions & 4 deletions crates/sui-tool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ pub mod commands;
pub mod db_tool;
pub mod pkg_dump;

#[cfg(feature = "enable-gas-profiler")]
extern crate move-vm-profiler;


// This functions requires at least one of genesis or fullnode_rpc to be `Some`.
async fn make_clients(
genesis: Option<PathBuf>,
Expand Down
18 changes: 9 additions & 9 deletions crates/sui/src/client_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,16 +647,16 @@ pub enum SuiClientCommands {
address_override: Option<ObjectID>,
},

/// Profile the gas usage of a transaction. Outputs a file `gas_profile_{tx_digest}_{unix_timestamp}.json` which can be opened in a flamegraph tool such as speedscope.
/// Profile the gas usage of a transaction. If an output filepath is not specified, it will output a file `gas_profile_{tx_digest}_{unix_timestamp}.json` which can be opened in a flamegraph tool such as speedscope.
#[clap(name = "profile-transaction")]
ProfileTransaction {
/// The digest of the transaction to replay
#[arg(long, short)]
tx_digest: String,

/// If specified, overrides the filepath of the output profile, for example -- /temp/my_profile.json
#[clap(name = "profile_output_filepath")]
profile_output_filepath: Option<PathBuf>,
#[clap(name = "profile_output")]
profile_output: Option<PathBuf>,
},

/// Replay a given transaction to view transaction effects. Set environment variable MOVE_VM_STEP=1 to debug.
Expand Down Expand Up @@ -712,15 +712,15 @@ impl SuiClientCommands {
let ret = Ok(match self {
SuiClientCommands::ProfileTransaction {
tx_digest,
profile_output_filepath,
profile_output,
} => {
let cmd = ReplayToolCommand::ProfileTransaction {
tx_digest,
show_effects: false,
diag: false,
executor_version_override: None,
protocol_version_override: None,
profile_output_filepath_override: profile_output_filepath,
executor_version: None,
protocol_version: None,
profile_output,
};
let rpc = context.config.get_active_env()?.rpc.clone();
let _command_result =
Expand All @@ -737,8 +737,8 @@ impl SuiClientCommands {
tx_digest,
show_effects: true,
diag: false,
executor_version_override: None,
protocol_version_override: None,
executor_version: None,
protocol_version: None,
};

let rpc = context.config.get_active_env()?.rpc.clone();
Expand Down
Loading

0 comments on commit bf7eb57

Please sign in to comment.