Skip to content

starknet_transaction_prover: make RPC error spec test exhaustive via enum - #14051

Open
avi-starkware wants to merge 1 commit into
avi/privacy/tls-tests-v2from
avi/privacy/exhaustive-error-spec-test-v2
Open

starknet_transaction_prover: make RPC error spec test exhaustive via enum#14051
avi-starkware wants to merge 1 commit into
avi/privacy/tls-tests-v2from
avi/privacy/exhaustive-error-spec-test-v2

Conversation

@avi-starkware

@avi-starkware avi-starkware commented May 17, 2026

Copy link
Copy Markdown
Collaborator

Replaces the ad-hoc test_cases vec in test_error_responses_match_spec with a
ServiceErrorCode enum whose spec_key and sample_error_object matches are
exhaustive: adding a variant fails to compile until both are updated, and the
bidirectional set-equality check between the enum and the spec's
components/errors keys fails until the OpenRPC spec documents it.

Each error's code and canonical message now live in one place, with the
constructor functions as thin wrappers.

strum is a dev-dependency and EnumIter is derived under #[cfg(test)]: the
iteration exists only for the test, so it does not belong in the shipped
binary's dependency graph.

Drops the pre-existing TODO(Avi): Add an error enum to make this test exhaustive.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@cursor

cursor Bot commented May 17, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Refactors error construction and test wiring without changing RPC behavior; risk is limited to accidental code/message drift, which the new exhaustive checks are meant to catch.

Overview
Introduces ServiceErrorCode so each proving-service JSON-RPC error has a single source of truth for its code and canonical message; existing helpers like block_not_found() and service_busy() now only build ErrorObjectOwned through the enum.

The OpenRPC conformance test test_error_responses_match_spec no longer uses a hand-maintained list. It walks all enum variants (via strum::EnumIter, enabled only under cfg(test)), checks each against the spec through exhaustive spec_key / sample_error_object matches, and asserts set equality between enum keys and components/errors in the proving API spec. A new variant fails to compile until those matches and the spec are updated.

strum is added as a dev-dependency; Cargo.lock reflects that.

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

@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from b062874 to 1d6f06e Compare May 17, 2026 17:39
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch 2 times, most recently from 3457808 to ac2d30f Compare May 17, 2026 19:07
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from 1d6f06e to 6377a5b Compare May 17, 2026 19:07
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch from ac2d30f to cb3ebef Compare May 20, 2026 08:33
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from 6377a5b to 6a4087a Compare May 20, 2026 08:33
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch from cb3ebef to 93accf4 Compare May 31, 2026 10:39
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from 6a4087a to 44827d2 Compare May 31, 2026 10:39
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch from 93accf4 to dd1dfa1 Compare June 7, 2026 11:46
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale.
This PR will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch 2 times, most recently from 6cd4efd to affd486 Compare July 9, 2026 13:57
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from a1deacf to 53eac05 Compare July 9, 2026 13:57
@github-actions github-actions Bot removed the stale label Jul 10, 2026
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch 2 times, most recently from b3125c8 to 6883b3f Compare July 12, 2026 12:39
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from 380e332 to 3f1a1f0 Compare July 12, 2026 12:39
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from 3f1a1f0 to 7178327 Compare July 19, 2026 13:25
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch from 6883b3f to 366b359 Compare July 19, 2026 13:25
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from 7178327 to 51b6a7b Compare August 25, 2026 19:33
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch from 366b359 to 4bf0ce3 Compare August 25, 2026 19:33
…enum

Replaces the ad-hoc test_cases vec in test_error_responses_match_spec
with a KnownRpcError test-only enum whose spec_key and
sample_error_object matches are exhaustive — adding a new variant
forces both matches to be updated, and the bidirectional set-equality
check between KnownRpcError::ALL and the spec's components/errors
keys guarantees the enum and the OpenRPC spec stay in sync.

Drops the pre-existing 'TODO(Avi): Add an error enum to make this
test exhaustive' tag.
@avi-starkware
avi-starkware force-pushed the avi/privacy/tls-tests-v2 branch from 51b6a7b to f0d3ede Compare August 25, 2026 20:01
@avi-starkware
avi-starkware force-pushed the avi/privacy/exhaustive-error-spec-test-v2 branch from 4bf0ce3 to d3ef343 Compare August 25, 2026 20:01
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