Skip to content

Conversation

@Bilogweb3
Copy link
Contributor

The function computes x1 from point1.x and uses it in calculations, but never saves it to execution scope. This doesn't match the Python hint spec which explicitly defines x1 in scope, and breaks the pattern used in similar functions like ec_double_assign_new_x where all computed variables are saved.

Added exec_scopes.insert_value("x1", x1) to fix this oversight.

@gabrielbosio
Copy link
Collaborator

Hi, @Bilogweb3!

  • Can you link to the Python hint you mention in the description?
  • Do you have a Cairo program that causes the VM to fail in main but not in this branch? It would be nice to have it in a new test case.

@Bilogweb3
Copy link
Contributor Author

@gabrielbosio HI!

The Python hint is actually right in our test file here: https://github.com/lambdaclass/cairo-vm/blob/main/cairo_programs/fast_ec_add_v2.cairo#L41-L51

You can see it creates x1 in the scope along with x0 and y0.

About a failing test - honestly, I don't have one. The thing is, x1 isn't actually read from the scope afterwards, so programs run fine without this fix.

What bothered me was that we're computing x1 and using it in the calculation, but then not saving it to scope like the hint says we should. Every other similar function (like ec_double_assign_new_x) saves all the variables it computes, so this looked like someone just forgot to add that line when copying code.

I can write a test that verifies x1 exists in the scope after execution if you think that would be useful? It wouldn't catch a crash, but it would verify we're actually doing what the hint specification says.

Let me know what you think.

@gabrielbosio
Copy link
Collaborator

What bothered me was that we're computing x1 and using it in the calculation, but then not saving it to scope like the hint says we should. Every other similar function (like ec_double_assign_new_x) saves all the variables it computes, so this looked like someone just forgot to add that line when copying code.

I think it wasn't added to the execution scope because there are no other hints that use that variable so it wasn't necessary.

I can write a test that verifies x1 exists in the scope after execution if you think that would be useful? It wouldn't catch a crash, but it would verify we're actually doing what the hint specification says.

It might be useful since a crate that uses the BuiltinHintProcessor would expect the execution_scopes to include that variable, so yes I would go with that.

@Bilogweb3
Copy link
Contributor Author

Added a test for this. It checks that x0, x1, and y0 are in the scope after execution - same pattern as the other tests in the file.

Copy link
Collaborator

@gabrielbosio gabrielbosio left a comment

Choose a reason for hiding this comment

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

Nice job!

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

LGTM!

@gabrielbosio gabrielbosio added this pull request to the merge queue Nov 14, 2025
Merged via the queue into lambdaclass:main with commit 581c437 Nov 14, 2025
89 of 92 checks passed
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