Skip to content

Commit

Permalink
revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
lanvidr committed Jan 19, 2024
1 parent d3c94df commit 1607d72
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions crates/sui-replay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ move-binary-format.workspace = true
move-bytecode-utils.workspace = true
move-core-types.workspace = true
tokio.workspace = true
tabled.workspace = true

shared-crypto.workspace = true
sui-config.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions crates/sui-replay/src/displays/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

mod transaction_displays;

pub struct Pretty<'a, T>(pub &'a T);
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::transaction::CallArg::Pure;
use crate::transaction::{
use crate::displays::Pretty;
use std::fmt::{Display, Formatter};
use sui_types::transaction::CallArg::Pure;
use sui_types::transaction::{
write_sep, Argument, CallArg, Command, ObjectArg, ProgrammableMoveCall, ProgrammableTransaction,
};
use std::fmt::{Display, Formatter};
use tabled::{
builder::Builder as TableBuilder,
settings::{style::HorizontalLine, Panel as TablePanel, Style as TableStyle},
};

pub struct Pretty<'a, T>(pub &'a T);

/// These Display implementations provide alternate displays that are used to format info contained
/// in these Structs when calling the CLI replay command with an additional provided flag.
impl<'a> Display for Pretty<'a, ProgrammableTransaction> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut builder = TableBuilder::default();
Expand Down
1 change: 1 addition & 0 deletions crates/sui-replay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub mod types;
static DEFAULT_SANDBOX_BASE_PATH: &str =
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/sandbox_snapshots");

mod displays;
#[cfg(test)]
mod tests;

Expand Down
11 changes: 9 additions & 2 deletions crates/sui-replay/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::chain_from_chain_id;
use crate::displays::Pretty;
use crate::{
config::ReplayableNetworkConfigSet,
data_fetcher::{
Expand Down Expand Up @@ -44,6 +45,7 @@ use sui_json_rpc_types::{SuiTransactionBlockEffects, SuiTransactionBlockEffectsA
use sui_protocol_config::{Chain, ProtocolConfig};
use sui_sdk::{SuiClient, SuiClientBuilder};
use sui_types::storage::{get_module, PackageObject};
use sui_types::transaction::TransactionKind::ProgrammableTransaction;
use sui_types::{
base_types::{ObjectID, ObjectRef, SequenceNumber, SuiAddress, VersionNumber},
committee::EpochId,
Expand All @@ -64,7 +66,7 @@ use sui_types::{
},
DEEPBOOK_PACKAGE_ID,
};
use tracing::{error, info, warn};
use tracing::{error, info, trace, warn};

// TODO: add persistent cache. But perf is good enough already.

Expand Down Expand Up @@ -735,6 +737,7 @@ impl LocalExec {

// All prep done
let expensive_checks = true;
let transaction_kind = override_transaction_kind.unwrap_or(tx_info.kind.clone());
let certificate_deny_set = HashSet::new();
let res = if let Ok(gas_status) =
SuiGasStatus::new(tx_info.gas_budget, tx_info.gas_price, rgp, protocol_config)
Expand All @@ -750,14 +753,18 @@ impl LocalExec {
CheckedInputObjects::new_for_replay(input_objects),
tx_info.gas.clone(),
gas_status,
override_transaction_kind.unwrap_or(tx_info.kind.clone()),
transaction_kind.clone(),
tx_info.sender,
*tx_digest,
)
} else {
unreachable!("Transaction was valid so gas status must be valid");
};

if let ProgrammableTransaction(pt) = transaction_kind {
trace!(target: "replay_ptb_info", "{}", Pretty(&pt));
};

let all_required_objects = self.storage.all_objects();
let effects =
SuiTransactionBlockEffects::try_from(res.1).map_err(ReplayEngineError::from)?;
Expand Down
1 change: 0 additions & 1 deletion crates/sui-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ enum_dispatch.workspace = true
eyre.workspace = true
indexmap.workspace = true
derivative.workspace = true
tabled.workspace = true

move-binary-format.workspace = true
move-bytecode-utils.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/sui-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub mod storage;
pub mod sui_serde;
pub mod sui_system_state;
pub mod transaction;
pub mod transaction_displays;
pub mod transfer;
pub mod type_resolver;
pub mod versioned;
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ impl Command {
}
}

pub(crate) fn write_sep<T: Display>(
pub fn write_sep<T: Display>(
f: &mut Formatter<'_>,
items: impl IntoIterator<Item = T>,
sep: &str,
Expand Down
4 changes: 2 additions & 2 deletions crates/sui/src/client_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,11 @@ pub enum SuiClientCommands {
tx_digest: String,

/// Log extra gas-related information
#[arg(long, short)]
#[arg(long)]
gas_info: bool,

/// Log information about each programmable transaction command
#[arg(long, short)]
#[arg(long)]
ptb_info: bool,
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ mod checked {
UpgradeTicket,
},
transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction},
transaction_displays::Pretty,
transfer::RESOLVED_RECEIVING_STRUCT,
SUI_FRAMEWORK_ADDRESS,
};
Expand All @@ -64,7 +63,6 @@ mod checked {
INIT_FN_NAME,
};
use tracing::instrument;
use tracing::trace;

use crate::adapter::substitute_package_id;
use crate::programmable_transactions::context::*;
Expand All @@ -78,9 +76,6 @@ mod checked {
gas_charger: &mut GasCharger,
pt: ProgrammableTransaction,
) -> Result<Mode::ExecutionResults, ExecutionError> {
#[skip_checked_arithmetic]
trace!(target: "replay_ptb_info", "{}", Pretty(&pt));

let ProgrammableTransaction { inputs, commands } = pt;
let mut context = ExecutionContext::new(
protocol_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ mod checked {
UpgradeTicket,
},
transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction},
transaction_displays::Pretty,
transfer::RESOLVED_RECEIVING_STRUCT,
SUI_FRAMEWORK_ADDRESS,
};
Expand All @@ -63,7 +62,6 @@ mod checked {
INIT_FN_NAME,
};
use tracing::instrument;
use tracing::trace;

use crate::adapter::substitute_package_id;
use crate::programmable_transactions::context::*;
Expand All @@ -77,9 +75,6 @@ mod checked {
gas_charger: &mut GasCharger,
pt: ProgrammableTransaction,
) -> Result<Mode::ExecutionResults, ExecutionError> {
#[skip_checked_arithmetic]
trace!(target: "replay_ptb_info", "{}", Pretty(&pt));

let ProgrammableTransaction { inputs, commands } = pt;
let mut context = ExecutionContext::new(
protocol_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ mod checked {
UpgradeReceipt, UpgradeTicket,
},
transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction},
transaction_displays::Pretty,
Identifier, SUI_FRAMEWORK_ADDRESS,
};
use sui_types::{
Expand All @@ -63,7 +62,6 @@ mod checked {
private_generics::{EVENT_MODULE, PRIVATE_TRANSFER_FUNCTIONS, TRANSFER_MODULE},
INIT_FN_NAME,
};
use tracing::trace;

use crate::adapter::substitute_package_id;
use crate::programmable_transactions::context::*;
Expand All @@ -77,9 +75,6 @@ mod checked {
gas_charger: &mut GasCharger,
pt: ProgrammableTransaction,
) -> Result<Mode::ExecutionResults, ExecutionError> {
#[skip_checked_arithmetic]
trace!(target: "replay_ptb_info", "{}", Pretty(&pt));

let ProgrammableTransaction { inputs, commands } = pt;
let mut context = ExecutionContext::new(
protocol_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ mod checked {
UpgradeTicket,
},
transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction},
transaction_displays::Pretty,
transfer::RESOLVED_RECEIVING_STRUCT,
SUI_FRAMEWORK_ADDRESS,
};
Expand All @@ -63,7 +62,6 @@ mod checked {
INIT_FN_NAME,
};
use tracing::instrument;
use tracing::trace;

use crate::adapter::substitute_package_id;
use crate::programmable_transactions::context::*;
Expand All @@ -77,9 +75,6 @@ mod checked {
gas_charger: &mut GasCharger,
pt: ProgrammableTransaction,
) -> Result<Mode::ExecutionResults, ExecutionError> {
#[skip_checked_arithmetic]
trace!(target: "replay_ptb_info", "{}", Pretty(&pt));

let ProgrammableTransaction { inputs, commands } = pt;
let mut context = ExecutionContext::new(
protocol_config,
Expand Down

0 comments on commit 1607d72

Please sign in to comment.