Skip to content

Added replay-based support for tracing dry runs - #27749

Open
awelc wants to merge 10 commits into
mainfrom
aw/replay-dry-run-support-add
Open

Added replay-based support for tracing dry runs#27749
awelc wants to merge 10 commits into
mainfrom
aw/replay-dry-run-support-add

Conversation

@awelc

@awelc awelc commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds tracing support for sui client ptb --dry-run via an additional --trace flag. It produces artifacts similar to those created by the replay tool, most importantly the artifacts needed for trace debugging.

The traced dry-run executes locally, similarly to how the replay tool executes historical transactions, but instead of a historical transaction being replayed, it's a transaction dry-ran on a full-node.

The results of full-node dry-run remain the source of truth and are reported to the user. Traced dry-run uses state fetched via GraphQL and its result may diverge from the full-node execution results. This is mitigated by comparing transaction effects between local execution and full-node execution and reporting potential discrepancies

Test plan

New unit tests have been added. All tests must pass. Also tested manually

@awelc
awelc requested a review from tzakian August 19, 2026 00:53
@awelc awelc self-assigned this Aug 19, 2026
@awelc
awelc temporarily deployed to sui-typescript-aws-kms-test-env August 19, 2026 00:53 — with GitHub Actions Inactive
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sui-docs Ready Ready Preview Aug 20, 2026 8:15pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multisig-toolkit Ignored Ignored Preview Aug 20, 2026 8:15pm
sui-kiosk Ignored Ignored Preview Aug 20, 2026 8:15pm

Request Review

@awelc
awelc temporarily deployed to sui-typescript-aws-kms-test-env August 19, 2026 01:00 — with GitHub Actions Inactive

@tzakian tzakian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall liking it and much nicer than the checkpoint-pinned one!

Left some comments, but please ping on Slack with any questions or when you want me to take another pass.

}

/// Return the latest checkpoint sequence number indexed by the configured GraphQL endpoint.
pub fn latest_checkpoint_sequence_number(&self) -> Result<u64, Error> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this generally exposes an async interface, so I'm wondering if this should be async and the call and/or somewhere else should block on the async call rather than here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. It's not super elegant and, indirectly, also makes scheduling trace execution in ptb.rs a bit awkward as well. Re-worked a few things to be more idiomatic with how all this should work with tokio

Comment thread crates/sui/src/client_ptb/ptb.rs Outdated
);
ensure!(
!program_metadata.dev_inspect_set,
"--trace cannot be combined with --dev-inspect."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but..should it? what if anything prevents being able to use it with dev-inspect?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another artifact of this being a "child" of another implementation... In this on we can indeed trace dev-inspect as well!

Comment thread crates/sui/src/client_ptb/ptb.rs Outdated
Comment on lines +137 to +144
ensure!(
!program_metadata.tx_digest_set,
"--trace cannot be combined with --tx-digest."
);
ensure!(
!program_metadata.serialize_unsigned_set && !program_metadata.serialize_signed_set,
"--trace cannot be combined with transaction serialization."
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these "--trace cannot be combined with X" type of error messages, would it be better to just say "--trace can only be combined with XYZ" instead -- that way when we add another flag or the like we don't need to worry about adding that here as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

pub tx_digest_set: bool,
pub dry_run_set: bool,
/// Whether best-effort local tracing was requested for the fullnode dry-run.
pub trace_set: bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMo no need for the comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK!

Comment thread crates/sui-replay-2/src/replay_txn.rs Outdated
.try_remove_artifact()?;
}
Ok(())
Ok(effects == expected_effects)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd lift this up into an let tx_forked = ; and have the check on line 302 use that as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

};

// Keep this in sync with `DEV_INSPECT_GAS_COIN_VALUE` in `sui-core/src/authority.rs`.
const SIMULATION_GAS_COIN_VALUE: u64 = 1_000_000_000_000_000_000;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..we should just use that const then? It's public and we have access to sui-core in this crate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to pull the entire sui-core dependency to the replay tool's crate, but thinking about it more, the tool is largely used as part of Sui CLI anyway where this dependency is already pulled, and having the extra heft for the replay tool's dev builds should be OK. Changed!

/// For a request without gas payment, the fullnode executes with a deterministic synthetic gas
/// coin while returning the original payment-free transaction data. Insert the same coin locally
/// and require the resulting digest to match the effects; any other mismatch is rejected.
fn reconstruct_fullnode_transaction(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not have this call ensure_supported_transation? That way if this function passes than you're gtg as far as checks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. The way it's structured is a historical artifact from the "base" PR where it made more sense, but really does not make sense here. Fixed!

Comment thread crates/sui-replay-2/src/simulation.rs Outdated
})
}

fn clear_generated_artifacts(path: &Path) -> Result<()> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should this live on the artifact manager?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Moved!

}
}

#[cfg(test)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not entirely sure if we need these tests, but I guess it doesn't hurt to have them 🤷🏻

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say let's keep them as they indeed do no harm :-)

use sui_types::{effects::TransactionEffects, gas::GasUsageReport};
use sui_types::{base_types::ObjectID, effects::TransactionEffects, gas::GasUsageReport};

pub(crate) const BCODE_DIR: &str = "bytecode";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you moved it so it's fair game to comment on it! 🥳

Maybe rename this to a bit nicer name (looking at you BYTECODE_DIR 👀)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed!

Comment thread crates/sui-replay-2/Cargo.toml Outdated
serde.workspace = true
similar.workspace = true
sui-config.workspace = true
sui-core.workspace = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, wow, I thought we already pulled this for replay-2 in but I was wrong!

My bad, I think in that case, revert back to what you had for the const for the dev inspect gas and remove this dep as not having a dep on sui-core is actually quite nice 🙇🏻

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted!

@awelc
awelc temporarily deployed to sui-typescript-aws-kms-test-env August 20, 2026 20:09 — with GitHub Actions Inactive
@awelc
awelc requested a review from tzakian August 20, 2026 20:09
@awelc
awelc requested a review from a team August 21, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants