From 1607d721801a7b8600f00aac52497c50c36efd45 Mon Sep 17 00:00:00 2001 From: laura Date: Fri, 19 Jan 2024 13:38:54 +0900 Subject: [PATCH] revisions --- Cargo.lock | 2 +- crates/sui-replay/Cargo.toml | 1 + crates/sui-replay/src/displays/mod.rs | 6 ++++++ .../src/displays}/transaction_displays.rs | 11 ++++++----- crates/sui-replay/src/lib.rs | 1 + crates/sui-replay/src/replay.rs | 11 +++++++++-- crates/sui-types/Cargo.toml | 1 - crates/sui-types/src/lib.rs | 1 - crates/sui-types/src/transaction.rs | 2 +- crates/sui/src/client_commands.rs | 4 ++-- .../src/programmable_transactions/execution.rs | 5 ----- .../src/programmable_transactions/execution.rs | 5 ----- .../src/programmable_transactions/execution.rs | 5 ----- .../src/programmable_transactions/execution.rs | 5 ----- 14 files changed, 27 insertions(+), 33 deletions(-) create mode 100644 crates/sui-replay/src/displays/mod.rs rename crates/{sui-types/src => sui-replay/src/displays}/transaction_displays.rs (95%) diff --git a/Cargo.lock b/Cargo.lock index a171517c376cb..0c0c2fe1feff1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12913,6 +12913,7 @@ dependencies = [ "sui-sdk", "sui-storage", "sui-types", + "tabled", "tempfile", "thiserror", "tokio", @@ -13580,7 +13581,6 @@ dependencies = [ "sui-enum-compat-util", "sui-macros", "sui-protocol-config", - "tabled", "tap", "thiserror", "tonic 0.10.0", diff --git a/crates/sui-replay/Cargo.toml b/crates/sui-replay/Cargo.toml index 6ee11d2200689..8c1bd7604eda1 100644 --- a/crates/sui-replay/Cargo.toml +++ b/crates/sui-replay/Cargo.toml @@ -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 diff --git a/crates/sui-replay/src/displays/mod.rs b/crates/sui-replay/src/displays/mod.rs new file mode 100644 index 0000000000000..1b5ad9e0e3d6d --- /dev/null +++ b/crates/sui-replay/src/displays/mod.rs @@ -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); diff --git a/crates/sui-types/src/transaction_displays.rs b/crates/sui-replay/src/displays/transaction_displays.rs similarity index 95% rename from crates/sui-types/src/transaction_displays.rs rename to crates/sui-replay/src/displays/transaction_displays.rs index 47e655b4d1a93..7c81afc36d640 100644 --- a/crates/sui-types/src/transaction_displays.rs +++ b/crates/sui-replay/src/displays/transaction_displays.rs @@ -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(); diff --git a/crates/sui-replay/src/lib.rs b/crates/sui-replay/src/lib.rs index 6ecc600f29e1f..af093933291df 100644 --- a/crates/sui-replay/src/lib.rs +++ b/crates/sui-replay/src/lib.rs @@ -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; diff --git a/crates/sui-replay/src/replay.rs b/crates/sui-replay/src/replay.rs index fd54ff918dce1..cdb9360126ac5 100644 --- a/crates/sui-replay/src/replay.rs +++ b/crates/sui-replay/src/replay.rs @@ -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::{ @@ -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, @@ -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. @@ -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) @@ -750,7 +753,7 @@ 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, ) @@ -758,6 +761,10 @@ impl LocalExec { 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)?; diff --git a/crates/sui-types/Cargo.toml b/crates/sui-types/Cargo.toml index 40e1645003017..a406ae5385481 100644 --- a/crates/sui-types/Cargo.toml +++ b/crates/sui-types/Cargo.toml @@ -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 diff --git a/crates/sui-types/src/lib.rs b/crates/sui-types/src/lib.rs index b7bbb02a8c12c..193a4dc876267 100644 --- a/crates/sui-types/src/lib.rs +++ b/crates/sui-types/src/lib.rs @@ -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; diff --git a/crates/sui-types/src/transaction.rs b/crates/sui-types/src/transaction.rs index 813044cfbe9eb..e907181e69d4c 100644 --- a/crates/sui-types/src/transaction.rs +++ b/crates/sui-types/src/transaction.rs @@ -863,7 +863,7 @@ impl Command { } } -pub(crate) fn write_sep( +pub fn write_sep( f: &mut Formatter<'_>, items: impl IntoIterator, sep: &str, diff --git a/crates/sui/src/client_commands.rs b/crates/sui/src/client_commands.rs index d134af589b389..32f2d710a6b65 100644 --- a/crates/sui/src/client_commands.rs +++ b/crates/sui/src/client_commands.rs @@ -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, }, diff --git a/sui-execution/latest/sui-adapter/src/programmable_transactions/execution.rs b/sui-execution/latest/sui-adapter/src/programmable_transactions/execution.rs index c72b47bf0b6e2..80b3dfd0fcb31 100644 --- a/sui-execution/latest/sui-adapter/src/programmable_transactions/execution.rs +++ b/sui-execution/latest/sui-adapter/src/programmable_transactions/execution.rs @@ -50,7 +50,6 @@ mod checked { UpgradeTicket, }, transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction}, - transaction_displays::Pretty, transfer::RESOLVED_RECEIVING_STRUCT, SUI_FRAMEWORK_ADDRESS, }; @@ -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::*; @@ -78,9 +76,6 @@ mod checked { gas_charger: &mut GasCharger, pt: ProgrammableTransaction, ) -> Result { - #[skip_checked_arithmetic] - trace!(target: "replay_ptb_info", "{}", Pretty(&pt)); - let ProgrammableTransaction { inputs, commands } = pt; let mut context = ExecutionContext::new( protocol_config, diff --git a/sui-execution/next-vm/sui-adapter/src/programmable_transactions/execution.rs b/sui-execution/next-vm/sui-adapter/src/programmable_transactions/execution.rs index e15664bec2da5..6fc32c5ec5197 100644 --- a/sui-execution/next-vm/sui-adapter/src/programmable_transactions/execution.rs +++ b/sui-execution/next-vm/sui-adapter/src/programmable_transactions/execution.rs @@ -50,7 +50,6 @@ mod checked { UpgradeTicket, }, transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction}, - transaction_displays::Pretty, transfer::RESOLVED_RECEIVING_STRUCT, SUI_FRAMEWORK_ADDRESS, }; @@ -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::*; @@ -77,9 +75,6 @@ mod checked { gas_charger: &mut GasCharger, pt: ProgrammableTransaction, ) -> Result { - #[skip_checked_arithmetic] - trace!(target: "replay_ptb_info", "{}", Pretty(&pt)); - let ProgrammableTransaction { inputs, commands } = pt; let mut context = ExecutionContext::new( protocol_config, diff --git a/sui-execution/v0/sui-adapter/src/programmable_transactions/execution.rs b/sui-execution/v0/sui-adapter/src/programmable_transactions/execution.rs index e66f111801d39..e3f97f383fb85 100644 --- a/sui-execution/v0/sui-adapter/src/programmable_transactions/execution.rs +++ b/sui-execution/v0/sui-adapter/src/programmable_transactions/execution.rs @@ -52,7 +52,6 @@ mod checked { UpgradeReceipt, UpgradeTicket, }, transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction}, - transaction_displays::Pretty, Identifier, SUI_FRAMEWORK_ADDRESS, }; use sui_types::{ @@ -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::*; @@ -77,9 +75,6 @@ mod checked { gas_charger: &mut GasCharger, pt: ProgrammableTransaction, ) -> Result { - #[skip_checked_arithmetic] - trace!(target: "replay_ptb_info", "{}", Pretty(&pt)); - let ProgrammableTransaction { inputs, commands } = pt; let mut context = ExecutionContext::new( protocol_config, diff --git a/sui-execution/v1/sui-adapter/src/programmable_transactions/execution.rs b/sui-execution/v1/sui-adapter/src/programmable_transactions/execution.rs index e15664bec2da5..6fc32c5ec5197 100644 --- a/sui-execution/v1/sui-adapter/src/programmable_transactions/execution.rs +++ b/sui-execution/v1/sui-adapter/src/programmable_transactions/execution.rs @@ -50,7 +50,6 @@ mod checked { UpgradeTicket, }, transaction::{Argument, Command, ProgrammableMoveCall, ProgrammableTransaction}, - transaction_displays::Pretty, transfer::RESOLVED_RECEIVING_STRUCT, SUI_FRAMEWORK_ADDRESS, }; @@ -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::*; @@ -77,9 +75,6 @@ mod checked { gas_charger: &mut GasCharger, pt: ProgrammableTransaction, ) -> Result { - #[skip_checked_arithmetic] - trace!(target: "replay_ptb_info", "{}", Pretty(&pt)); - let ProgrammableTransaction { inputs, commands } = pt; let mut context = ExecutionContext::new( protocol_config,