Skip to content

Commit fd40b0f

Browse files
authored
Enable tracing in the execution layer (#21165)
## Description The main idea here is that we have a client (e.g., the upcoming replay tool) at some point calling the `execute_transaction_to_effects` from the `Executor` trait defined in `sui/sui-execution/src/executor.rs` to execute a PTB. We want execution of a PTB to be traced, the trace "returned" to the client which is responsible for delivering this trace to the user (e.g., by storing in to disk). In other words, we want the executor to be responsible for execution and tracing itself, and the client to be responsible for all the remaining handling of the generated trace (e.g., I/O operations). There are arguably many ways to accomplish this and this PR proposes one of them - passing optional `MoveTraceBuilder` as an additional argument to `execute_transaction_to_effects`. Ultimately, we want execution of the entire PTB to be traced, but in this PR we only trace execution of Move calls. Tracing of the remaining PTB commands will be added at a later time via external `TraceEvent`s, without further changing the interface being modified in this PR. `MoveTraceBuilder` creates an instance of `MoveTrace`, which contains a list of trace events including `TraceEvent::External`. This type of event can represent an arbitrary value, including arguments and return values of PTB commands.
1 parent 07ae422 commit fd40b0f

File tree

21 files changed

+104
-28
lines changed

21 files changed

+104
-28
lines changed

Cargo.lock

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ exclude = [
4343
"external-crates/move/crates/move-stdlib-natives",
4444
"external-crates/move/crates/move-symbol-pool",
4545
"external-crates/move/crates/move-transactional-test-runner",
46+
"external-crates/move/crates/move-trace-format",
4647
"external-crates/move/crates/move-unit-test",
4748
"external-crates/move/crates/move-vm-config",
4849
"external-crates/move/crates/move-vm-integration-tests",
@@ -584,6 +585,7 @@ move-symbol-pool = { path = "external-crates/move/crates/move-symbol-pool" }
584585
move-abstract-interpreter = { path = "external-crates/move/crates/move-abstract-interpreter" }
585586
move-abstract-stack = { path = "external-crates/move/crates/move-abstract-stack" }
586587
move-analyzer = { path = "external-crates/move/crates/move-analyzer" }
588+
move-trace-format = { path = "external-crates/move/crates/move-trace-format" }
587589

588590
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "69d496c71fb37e3d22fe85e5bbfd4256d61422b9" }
589591
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "69d496c71fb37e3d22fe85e5bbfd4256d61422b9" }

crates/simulacrum/src/epoch_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ impl EpochState {
150150
kind,
151151
signer,
152152
tx_digest,
153+
&mut None,
153154
);
154155
Ok((inner_temp_store, gas_status, effects, result))
155156
}

crates/sui-core/src/authority.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,7 @@ impl AuthorityState {
16881688
kind,
16891689
signer,
16901690
tx_digest,
1691+
&mut None,
16911692
);
16921693

16931694
fail_point_if!("cp_execution_nondeterminism", || {
@@ -1880,6 +1881,7 @@ impl AuthorityState {
18801881
kind,
18811882
signer,
18821883
transaction_digest,
1884+
&mut None,
18831885
);
18841886
let tx_digest = *effects.transaction_digest();
18851887

@@ -2070,6 +2072,7 @@ impl AuthorityState {
20702072
kind,
20712073
signer,
20722074
transaction.digest(),
2075+
&mut None,
20732076
);
20742077

20752078
Ok(SimulateTransactionResult {

crates/sui-genesis-builder/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ fn create_genesis_transaction(
940940
kind,
941941
signer,
942942
genesis_digest,
943+
&mut None,
943944
);
944945
assert!(inner_temp_store.input_objects.is_empty());
945946
assert!(inner_temp_store.mutable_inputs.is_empty());

crates/sui-replay/src/replay.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ impl LocalExec {
779779
transaction_kind.clone(),
780780
tx_info.sender,
781781
*tx_digest,
782+
&mut None,
782783
);
783784

784785
if let Err(err) = self.pretty_print_for_tracing(
@@ -939,6 +940,7 @@ impl LocalExec {
939940
kind,
940941
signer,
941942
*executable.digest(),
943+
&mut None,
942944
);
943945

944946
let effects =

crates/sui-single-node-benchmark/src/single_node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ impl SingleValidator {
220220
kind,
221221
signer,
222222
*executable.digest(),
223+
&mut None,
223224
);
224225
assert!(effects.status().is_ok());
225226
store.commit_objects(inner_temp_store);

crates/sui-swarm-config/src/network_config_builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ mod test {
617617
kind,
618618
signer,
619619
genesis_digest,
620+
&mut None,
620621
);
621622

622623
assert_eq!(&effects, genesis.effects());

external-crates/move/crates/move-trace-format/Cargo.toml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,15 @@ version = "0.0.1"
44
authors = ["Move Core Contributors"]
55
description = "Move Trace Format"
66
license = "Apache-2.0"
7+
publish = false
78
edition = "2021"
89

910
[dependencies]
10-
anyhow.workspace = true
11-
proptest = { workspace = true, optional = true }
12-
proptest-derive = { workspace = true, optional = true }
13-
ref-cast.workspace = true
14-
variant_count.workspace = true
1511
move-core-types.workspace = true
1612
serde.workspace = true
17-
enum-compat-util.workspace = true
18-
move-proc-macros.workspace = true
1913
move-binary-format.workspace = true
2014

21-
# wasm support (requires js feature of getrandom)
22-
getrandom = { workspace = true, features = ["js"], optional = true }
2315
serde_json = { workspace = true, features = ["arbitrary_precision"] }
2416

25-
[dev-dependencies]
26-
proptest.workspace = true
27-
proptest-derive.workspace = true
28-
move-core-types = { workspace = true, features = ["fuzzing" ] }
29-
3017
[features]
3118
default = []
32-
fuzzing = ["proptest", "proptest-derive", "move-core-types/fuzzing"]
33-
wasm = ["getrandom"]

external-crates/move/crates/move-trace-format/src/format.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ impl MoveTrace {
217217
}
218218
}
219219

220+
impl Default for MoveTrace {
221+
fn default() -> Self {
222+
Self::new()
223+
}
224+
}
225+
220226
impl MoveTraceBuilder {
221227
/// Create a new `MoveTraceBuilder` with no additional tracing.
222228
pub fn new() -> Self {
@@ -314,6 +320,12 @@ impl MoveTraceBuilder {
314320
}
315321
}
316322

323+
impl Default for MoveTraceBuilder {
324+
fn default() -> Self {
325+
Self::new()
326+
}
327+
}
328+
317329
impl Display for TraceValue {
318330
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
319331
match self {

0 commit comments

Comments
 (0)