Skip to content

starknet_transaction_prover: global panic hook + graceful SIGTERM shutdown#14166

Open
avi-starkware wants to merge 1 commit into
avi/prover-v3/request-logsfrom
avi/prover-v3/panic-shutdown
Open

starknet_transaction_prover: global panic hook + graceful SIGTERM shutdown#14166
avi-starkware wants to merge 1 commit into
avi/prover-v3/request-logsfrom
avi/prover-v3/panic-shutdown

Conversation

@avi-starkware
Copy link
Copy Markdown
Collaborator

Installs a process-wide panic hook that emits one structured event=panic
tracing event with location and backtrace, and bridges SIGTERM/SIGINT into
ServerHandle::stop so container teardown becomes visible in logs and
in-flight proofs get to finish. A second signal forces exit(1) to work
around tokio-rs/tokio#7905.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

@cursor
Copy link
Copy Markdown

cursor Bot commented May 24, 2026

PR Summary

Low Risk
Changes are limited to process lifecycle, logging, and signal handling; proving and JSON-RPC request handling are unchanged.

Overview
Improves production operability of the transaction prover binary: panics and shutdowns become visible in structured logs instead of ad-hoc stderr output.

A new server/panic module installs a process-wide panic hook (after tracing init) that logs event=panic with message, source location, and a forced backtrace via tracing::error, without changing default abort-on-panic behavior. extract_payload is covered by a small unit test.

main now wires SIGTERM/SIGINT into jsonrpsee’s ServerHandle::stop, logs shutdown_started / shutdown_complete, and on a second signal logs force_exit and calls exit(1) so a stuck graceful shutdown is not swallowed (workaround for tokio signal behavior).

Dependencies: tokio gains the signal feature; tracing-subscriber gains json so the existing LogFormat::Json CLI path can emit JSON logs (including panic events).

Reviewed by Cursor Bugbot for commit c3950e4. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Collaborator Author

avi-starkware commented May 24, 2026

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c31ce65. Configure here.

return s.clone();
}
"<non-string panic payload>".to_string()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reimplements already-stable standard library method

Low Severity

The extract_payload function manually reimplements PanicHookInfo::payload_as_str(), which was stabilized in Rust 1.91.0. The project's rust-toolchain.toml specifies channel 1.95, so the standard library method is already available. The doc comment on extract_payload references a nightly-2025-07-14 toolchain that no longer matches the project's actual pinned toolchain, making the stated reason for the workaround stale.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c31ce65. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually, the crate starknet_transaction_prover uses the referenced nightly toolchain, so the doc comment is not stale

@avi-starkware avi-starkware force-pushed the avi/prover-v3/panic-shutdown branch from c31ce65 to 72a08b0 Compare May 26, 2026 12:16
@avi-starkware avi-starkware force-pushed the avi/prover-v3/request-logs branch 2 times, most recently from 2dcb716 to f83f30c Compare May 26, 2026 12:17
@avi-starkware avi-starkware force-pushed the avi/prover-v3/panic-shutdown branch from 72a08b0 to 17dbfd9 Compare May 26, 2026 12:17
@avi-starkware avi-starkware force-pushed the avi/prover-v3/request-logs branch from f83f30c to 53b6a1e Compare May 26, 2026 12:58
@avi-starkware avi-starkware force-pushed the avi/prover-v3/panic-shutdown branch from 17dbfd9 to 9845d29 Compare May 26, 2026 12:58
@avi-starkware avi-starkware force-pushed the avi/prover-v3/panic-shutdown branch from 9845d29 to 4d23115 Compare May 26, 2026 16:14
@avi-starkware avi-starkware force-pushed the avi/prover-v3/request-logs branch from 53b6a1e to 4645e9b Compare May 26, 2026 16:14
…tdown

Installs a process-wide panic hook that emits one structured `event=panic`
tracing event with location and backtrace, and bridges SIGTERM/SIGINT into
`ServerHandle::stop` so container teardown becomes visible in logs and
in-flight proofs get to finish. A second signal forces `exit(1)` to work
around tokio-rs/tokio#7905.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avi-starkware avi-starkware force-pushed the avi/prover-v3/panic-shutdown branch from 4d23115 to c3950e4 Compare May 26, 2026 16:59
@avi-starkware avi-starkware force-pushed the avi/prover-v3/request-logs branch from 4645e9b to 278ffaa Compare May 26, 2026 16:59
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