Sitelet https://github.com/starkware-libs/cairo/pull/10173
Skip to content

bugfix(starknet-plugin): Fixed test deployment hygiene issues. - #10173

Merged
orizi merged 1 commit into
mainfrom
orizi/06-29-bugfix_starknet-plugin_fixed_test_deployment_hygiene_issues
Jun 29, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-29-bugfix_starknet-plugin_fixed_test_deployment_hygiene_issues

Conversation

@orizi

@orizi orizi commented Jun 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The internal bindings generated by deploy_for_test (class_hash, deployment_params, calldata) are renamed to __deploy_class_hash__, __deploy_params__, and __deploy_calldata__ to avoid collisions with constructor parameter names that happen to share those identifiers.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

When a contract's constructor declared parameters named class_hash, deployment_params, or calldata, the generated deploy_for_test function would either fail to compile with a parameter redefinition error (E2054) or silently drop the user's argument (e.g. the calldata array was overwritten by the internally declared let mut calldata binding, causing serialization to operate on an empty array instead of the user-supplied one).


What was the behavior or documentation before?

A constructor with parameters named class_hash, deployment_params, or calldata caused the generated deploy_for_test to either produce a compile error due to duplicate parameter names, or silently ignore the user-supplied calldata argument because the internal let mut calldata binding shadowed it.


What is the behavior or documentation after?

The generated deploy_for_test uses mangled names (__deploy_class_hash__, __deploy_params__, __deploy_calldata__) for its internal bindings, so constructor parameters with any of those names are passed through correctly without collision or shadowing. A new test contract (reserved_ctor_arg_names) and accompanying test (test_deploy_for_test_reserved_ctor_arg_names) verify this behavior end-to-end.


Related issue or discussion (if any)


Additional context

The fix is purely in the code generation template inside generate_deploy_function. The double-underscore prefix/suffix convention is chosen to minimize the chance of a real constructor parameter ever colliding with the generated names.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi
orizi marked this pull request as ready for review June 29, 2026 06:03
@cursor

cursor Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Scoped to #[cfg(target: 'test')] codegen in the Starknet plugin; production contract deployment paths are unchanged.

Overview
Fixes test-only deploy_for_test codegen so constructor parameters named class_hash, deployment_params, or calldata no longer clash with the helper’s own parameters and locals.

generate_deploy_function now uses __deploy_class_hash__, __deploy_params__, and __deploy_calldata__ for the syscall inputs and serialization buffer instead of the old names. That removes E2054 redefinition errors and stops an internal calldata binding from shadowing a user calldata constructor arg (which previously serialized into an empty array).

Adds the reserved_ctor_arg_names contract and test_deploy_for_test_reserved_ctor_arg_names in deployment.cairo, plus an updated plugin diagnostics snapshot.

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

@eytan-starkware eytan-starkware 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.

:lgtm:

@eytan-starkware reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).

@orizi
orizi added this pull request to the merge queue Jun 29, 2026
Merged via the queue into main with commit 0a2f39e Jun 29, 2026
55 checks passed

Copy link
Copy Markdown

Security scan complete — no issues detected.


Generated by Claude Code

@orizi
orizi deleted the orizi/06-29-bugfix_starknet-plugin_fixed_test_deployment_hygiene_issues branch June 29, 2026 13:25
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.

4 participants