Skip to content

Conversation

@awelc
Copy link
Contributor

@awelc awelc commented Nov 6, 2025

Description

This PR implements a fix to local variable lifetime approximation algorithm which was causing an exception being thrown when variable containing the actual value (that was referenced in the subsequent frames by another variable) went out of scope due to it's lifetime ending. Lifetimes should be extended by additional events in the trace beyond reads and writes.

Additionally, extended debug printing to catch these types of errors in the unit tests rather than when actually debugging code...

Test plan

Added a new test that was failing under old implementation but passes under the new one. All tests must pass

@awelc awelc temporarily deployed to sui-typescript-aws-kms-test-env November 6, 2025 18:16 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Nov 6, 2025

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

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
multisig-toolkit Ignored Ignored Nov 6, 2025 6:16pm
sui-kiosk Ignored Ignored Nov 6, 2025 6:16pm

@awelc awelc requested a review from dariorussi November 6, 2025 18:16
@awelc awelc self-assigned this Nov 6, 2025
root_value_read: JSONTraceValue;
}

interface JSONTracePushEffect {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were actually not necessary as they are subsumed by JSONTraceValue interface

frame_id: number;
gas_left: number;
return_: JSONTraceRuntimeValueContent[];
return_: JSONTraceValue[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated fix (spotted when looking at trace format code...)

// Read as Buffer then view it as a Uint8Array for fzstd which expects Uint8Array
const buf = fs.readFileSync(traceFilePath);
const decompressed = await decompress(buf);
const u8 = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another unrelated fix (for some reason the code was actually working even though TS compiler didn't like the types - now compilation is clean again)

Copy link
Contributor Author

@awelc awelc left a comment

Choose a reason for hiding this comment

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

Left some additional comments

@awelc awelc merged commit 98219e9 into main Nov 12, 2025
55 of 56 checks passed
@awelc awelc deleted the aw/trace-view-ref-lifetime-fix branch November 12, 2025 22:06
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.

3 participants