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

Optimize Simnet usage accross the app #80

Merged
merged 2 commits into from
Jan 3, 2025

Conversation

BowTiedRadone
Copy link
Collaborator

@BowTiedRadone BowTiedRadone commented Jan 2, 2025

This PR aims to improve Simnet efficiency in Rendezvous, enhancing overall performance and pushing the tool closer to the limits of clarinet-sdk v2.12.0. While it does not fully solve #78, it represents a step forward in optimizing resource usage.

This commit improves the efficiency of Simnet usage in invariant testing by
querying account data only once at the start of the invariant testing setup.
The fetched accounts and their addresses are reused throughout the tests.
Copy link
Member

@moodmosaic moodmosaic left a comment

Choose a reason for hiding this comment

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

Those changes look reasonable to me as-is.

@BowTiedRadone
Copy link
Collaborator Author

BowTiedRadone commented Jan 2, 2025

The updates added via 8a2c270 to the invariant testing type also improve how errors are reported when a Node.JS process containing a long-running Simnet session exceeds the 4GB memory limit:

wallet_4 [PASS] counter invariant-counter-gt-zero 
wallet_3        counter increment 
wallet_2 [FAIL] counter invariant-counter-gt-zero 
wallet_6        counter decrement 
wallet_2 [FAIL] counter invariant-counter-gt-zero 
wallet_6        counter decrement 
wallet_6 [FAIL] counter invariant-counter-gt-zero 
wallet_6        counter add 900309476
wallet_6 [FAIL] counter invariant-counter-gt-zero 
wallet_6        counter add 0
wallet_6 [FAIL] counter invariant-counter-gt-zero 

Error: Property failed after 1,808,192 tests.
Seed : 217566923

Counterexample:
- Contract : counter
- Function : add (public)
- Arguments: [0]
- Caller   : wallet_6
- Outputs  : {"type":{"response":{"ok":"bool","error":"uint128"}}}
- Invariant: invariant-counter-gt-zero (read_only)
- Arguments: []
- Caller   : wallet_6

What happened? Rendezvous identified a weak spot:  

The invariant "invariant-counter-gt-zero" returned:  
    Error: recursive use of an object detected which would lead to unsafe aliasing in Rust

Previously, the crash described in #78 occurred at the generator level, preventing the custom reporter from logging the error details. This update ensures this type of known issue will not happen at the generator level.

@BowTiedRadone BowTiedRadone changed the title [DRAFT] Optimize Simnet usage accross the app Optimize Simnet usage accross the app Jan 2, 2025
@BowTiedRadone BowTiedRadone marked this pull request as ready for review January 2, 2025 20:53
@BowTiedRadone BowTiedRadone requested a review from a team as a code owner January 2, 2025 20:53
This commit improves the efficiency of Simnet usage in property testing by
querying account data only once at the start of the invariant testing setup.
The fetched accounts and their addresses are reused throughout the property
testing infrastructure.
Copy link
Member

@moodmosaic moodmosaic left a comment

Choose a reason for hiding this comment

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

Great catch 👍

@moodmosaic
Copy link
Member

This resolves #78. The rendezvous part of it.

@moodmosaic moodmosaic merged commit 3a5c7cb into master Jan 3, 2025
16 checks passed
@moodmosaic moodmosaic deleted the perf/simnet-session-optimizations branch January 3, 2025 10:46
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