Added replay-based support for tracing dry runs - #27749
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
2662a7d to
20d2df6
Compare
tzakian
left a comment
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
| ); | ||
| ensure!( | ||
| !program_metadata.dev_inspect_set, | ||
| "--trace cannot be combined with --dev-inspect." |
There was a problem hiding this comment.
but..should it? what if anything prevents being able to use it with dev-inspect?
There was a problem hiding this comment.
Another artifact of this being a "child" of another implementation... In this on we can indeed trace dev-inspect as well!
| 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." | ||
| ); |
There was a problem hiding this comment.
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.
| 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, |
There was a problem hiding this comment.
IMo no need for the comment.
| .try_remove_artifact()?; | ||
| } | ||
| Ok(()) | ||
| Ok(effects == expected_effects) |
There was a problem hiding this comment.
nit: I'd lift this up into an let tx_forked = ; and have the check on line 302 use that as well.
| }; | ||
|
|
||
| // 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; |
There was a problem hiding this comment.
..we should just use that const then? It's public and we have access to sui-core in this crate.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
why not have this call ensure_supported_transation? That way if this function passes than you're gtg as far as checks?
There was a problem hiding this comment.
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!
| }) | ||
| } | ||
|
|
||
| fn clear_generated_artifacts(path: &Path) -> Result<()> { |
There was a problem hiding this comment.
Can/should this live on the artifact manager?
| } | ||
| } | ||
|
|
||
| #[cfg(test)] |
There was a problem hiding this comment.
not entirely sure if we need these tests, but I guess it doesn't hurt to have them 🤷🏻
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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 👀)
| serde.workspace = true | ||
| similar.workspace = true | ||
| sui-config.workspace = true | ||
| sui-core.workspace = true |
There was a problem hiding this comment.
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 🙇🏻
Description
This PR adds tracing support for
sui client ptb --dry-runvia an additional--traceflag. 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