Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rollback global context in error case #621

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

csgui
Copy link
Collaborator

@csgui csgui commented Mar 5, 2025

Fix #549

In case of an error, the function context needs to be cleaned up, rolling back to a pristine state.

@csgui csgui force-pushed the fix/global-context-rollback branch from a4a05ca to 7891268 Compare March 5, 2025 19:14
@csgui csgui marked this pull request as draft March 5, 2025 20:22
Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.67%. Comparing base (c4528e1) to head (cad1b1b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #621      +/-   ##
==========================================
- Coverage   85.67%   85.67%   -0.01%     
==========================================
  Files          46       46              
  Lines       24599    24609      +10     
  Branches    24599    24609      +10     
==========================================
+ Hits        21076    21084       +8     
  Misses       1672     1672              
- Partials     1851     1853       +2     

☔ 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.

@csgui csgui marked this pull request as ready for review March 6, 2025 11:27
@csgui csgui requested review from Acaccia, ureeves and BowTiedWoo March 6, 2025 11:27
Copy link
Collaborator

@Acaccia Acaccia left a comment

Choose a reason for hiding this comment

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

Is there any way we could have some tests to prove the efficiency of the change ?

@csgui
Copy link
Collaborator Author

csgui commented Mar 6, 2025

Is there any way we could have some tests to prove the efficiency of the change ?

I was thinking about that too. Actually, we do have tests to verify the error path, for instance:

https://github.com/stacks-network/clarity-wasm/blob/main/clar2wasm/tests/lib_tests.rs#L4091

and

https://github.com/stacks-network/clarity-wasm/blob/main/clar2wasm/tests/lib_tests.rs#L4103

among others.

Also, in this PR, I added the instantiation of the global context for tests, which is needed to validate the changes.

A more detailed test would require additional work to validate context management, state verification, and a more rigorous assessment of the integration with stacks-core. This is a task that can be addressed separately, imo, since we are already covering it with some tests and also relying the validation of the changes here on fuzzing tests.

@Acaccia
Copy link
Collaborator

Acaccia commented Mar 6, 2025

This is a task that can be addressed separately, imo, since we are already covering it with some tests and also relying the validation of the changes here on fuzzing tests.

Where are those tests actually? What are we covering?
To my knowledge, none of our existing tests fail due to this bug.

@csgui
Copy link
Collaborator Author

csgui commented Mar 6, 2025

The tests that I linked above are impacted by this PR. That means a context was not initialized before, but now it is initialized and rolled back in error cases. Without the change on https://github.com/stacks-network/clarity-wasm/pull/621/files#diff-88585f598b79cb14968cf2e11093aacaa49eb5f7553ded728347b3ffafc8c410R500 they will fail.

The changes are only visible during runtime errors. Normal conditions remain unaffected by this PR, but this issue is hindering the fuzzing tests. Therefore, I suggest merging this PR, deploying a new release, and validating it also with fuzzing tests.

@Acaccia
Copy link
Collaborator

Acaccia commented Mar 6, 2025

Fuzzing tests are not enough imho since they are out of our control.
What currently prevents another dev to come work on this project and reintroduce the bug?
We would notice it only after it’s merged into the main branch. And this is only if we run systematically the fuzzing tests after a merge to main. The fuzzing tests with the right conditions that trigger this specific bug.

@Acaccia
Copy link
Collaborator

Acaccia commented Mar 6, 2025

The tests that I linked above are impacted by this PR. That means a context was not initialized before, but now it is initialized and rolled back in error cases. Without the change on https://github.com/stacks-network/clarity-wasm/pull/621/files#diff-88585f598b79cb14968cf2e11093aacaa49eb5f7553ded728347b3ffafc8c410R500 they will fail.

I just checked this, and made the change only in tests/lib_tests.rs, the tests don't fail at all.

@csgui
Copy link
Collaborator Author

csgui commented Mar 6, 2025

Thinking about the things we can control, you're right. Let me take a stab at adding more tests for this PR.

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.

ArithmeticOverflow runtime error causing panic! on wasm testnet
2 participants