Skip to content

fix debug tab cache #1727

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

Open
wants to merge 8 commits into
base: 2025-04-07-deployment-debug-tab
Choose a base branch
from

Conversation

rouzwelt
Copy link
Contributor

@rouzwelt rouzwelt commented May 4, 2025

Motivation

Fixes the cache issue mentioned in #1599
There were several bugs and issues with the logic/implementation of the debug tab to correctly use and hit foundry cache, this PR fixes that.

⚠️ Merge this to #1599 first and then merge that into main.

Solution

  • There was a shared state in tauri source that kept a hash map of detrain + settings string paired with FuzzRunner instances, and since FuzzRunner has a fresh instance of Forker, we never actually reused any forks as a result never using any cache, it now keeps a single FuzzRunner instance which is alive during program.
  • There was only one single block numbers coming from GUI for all the networks, rather than a map of them for each network and the inner logic used that to debug the detrain for all of the available deployments in the settings which is clearly wrong, so the provided block number was not at all related to the different networks, causing issues and bug, we now pass on a map of block numbers for each network chain id and a column on the GUI debug tab to show block height for each debug row, keeping block numbers against chain id is preferred option as it guarantees that for many deployments on a given network even if those deployments use different rpcs, they all still get debugged on unified block height.
  • inside make_debug_data() method of FuzzRunner, the forker property was getting cloned for each debug loop iteration, and those forker instances that cache the calls all go out of scope once the method execution ends, We needed to operate on &mut self so only one Forker instance is used and caches everything for all the networks and block numbers and never goes out of scope during the program since on tauri it is kept under Arc<Mutex> shared state.
  • There was incorrect attempt at parallel exec for fork calls, awaiting a tokio spawn right after which has no effect, however since now we only have one instance of Forker that manages all the forks, and we wanna keep the cache during the program execution, we can't do parallel execution because Forker only works on one active fork at a time. (make_chart_data() method still operates in parallel because it doesn't need the cache and clones the forker instance for each fuzz run)
  • There are some modifications to the FuzzRunner abstraction, which are removing the dotrain, settings and seed from its properties and moving them on to a new struct called FuzzRunnerContext with a new() method and FuzzRunnerContext is now a context argument for all the methods of FuzzRunner, this way a single FuzzRunner instance is able to operate on many FuzzRunnerContext instances (i.e. many detrains, settings and seeds).
  • Updated existing tests to work with changes

GUI Test

debug-test.mov

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

@rouzwelt rouzwelt self-assigned this May 4, 2025
Copy link
Contributor

coderabbitai bot commented May 4, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rouzwelt rouzwelt requested a review from hardyjosh May 4, 2025 04:08
rouzwelt added 2 commits May 4, 2025 21:11
- added `FuzzRunnerContext`
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.

1 participant