Skip to content

Introduce semantic wrappers around Execute#3595

Closed
RafaelGranza wants to merge 3 commits intomainfrom
granza/hide-boolean-flags-on-cairo-vm-execute
Closed

Introduce semantic wrappers around Execute#3595
RafaelGranza wants to merge 3 commits intomainfrom
granza/hide-boolean-flags-on-cairo-vm-execute

Conversation

@RafaelGranza
Copy link
Copy Markdown
Contributor

@RafaelGranza RafaelGranza commented May 1, 2026

Summary

First of four incremental PRs refactoring vm.Execute (go) and cairo_vm_execute (rust) from a 7-positional-boolean signature into three semantic operations with typed options. This PR is purely additive. No call sites are migrated yet, and Execute remains fully functional.

Why

vm.Execute takes 7 positional bool parameters and is invoked from 8 production sites and ~38 test setups. The shape has caused real documentation drift:

  • The comments next to call args in rpc/v9/trace.go and rpc/v10/trace.go describe parameters that don't exist in the signature (// skipNonceCharge, // allowZeroMaxFee, // allowNoSignature — none are real Execute params).

Every existing call site falls into one of three semantic buckets:

  • Trace: replay an existing block (only returnInitialReads varies)
  • Simulate: RPC simulate_transactions / estimate_fee (5 flags vary)
  • BuildBlock: block production: builder + genesis (3 flags vary)

Roadmap

PR Scope
1 (this PR) Add Simulate/Trace/BuildBlock wrappers + options structs
2 Migrate 8 production call sites + ~38 test setups
3 Split Rust cairo_vm_execute into three dedicated entry points; wrappers call them directly
4 Remove Execute (Go interface, *vm, ThrottledVM, mock) and cairo_vm_execute (Rust + FFI header)

Changes in this PR

  • vm/vm.go: adds SimulateOptions, TraceOptions, BuildBlockOptions and the three corresponding methods on the VM interface and *vm implementation. The methods delegate to Execute for now.
  • node/throttled_vm.go: mirrors the three methods with throttle wrappers.
  • mocks/mock_vm.go: adds gomock implementations.

Out of scope (covered by follow-up PRs)

  • No call sites are migrated. Execute is still the method actually being invoked everywhere in production and tests.
  • No changes to Rust or the C FFI header.
  • The implementation-detail comments on the new methods (e.g. "errStack and allowBinarySearch are always on") describe the current delegation to Execute. These will be replaced in PR 3 when each method gets its own Rust entry point and those flags cease to exist as configuration.

@RafaelGranza RafaelGranza added Refactor go Pull requests that update Go code labels May 1, 2026
@RafaelGranza RafaelGranza self-assigned this May 1, 2026
Comment thread vm/vm.go
Comment on lines +48 to +50
// SimulateOptions carries the per-request flags relevant to RPC simulate /
// estimateFee. errStack and allowBinarySearch are constants for this path
// and are set internally.
Copy link
Copy Markdown
Contributor Author

@RafaelGranza RafaelGranza May 1, 2026

Choose a reason for hiding this comment

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

The documentation talking about flags that are constants or pre-defined will be removed after these methods stop depending on Execute

Comment thread vm/vm.go
Comment on lines +59 to +63
// TraceOptions carries the per-request flags relevant to replaying an
// existing block. All execution flags are off; only errStack is on.
type TraceOptions struct {
ReturnInitialReads bool
}
Copy link
Copy Markdown
Contributor Author

@RafaelGranza RafaelGranza May 1, 2026

Choose a reason for hiding this comment

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

I know it could be a single bollean, but I decided to keep this as a struct, for 2 reasons:

  • it keeps the same signature pattern as the other wrappers
  • if we ever need extra flags, adding a field to this struct is less conflicting than adding and extra argument to a method.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.94%. Comparing base (fead8f3) to head (a1aabf8).

Files with missing lines Patch % Lines
node/throttled_vm.go 0.00% 19 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3595      +/-   ##
==========================================
- Coverage   76.00%   75.94%   -0.07%     
==========================================
  Files         381      381              
  Lines       34275    34294      +19     
==========================================
- Hits        26052    26043       -9     
- Misses       6401     6430      +29     
+ Partials     1822     1821       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@rodrodros rodrodros left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@RafaelGranza
Copy link
Copy Markdown
Contributor Author

Move the changes to here: #3602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants