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

feat: getBytecodeByHash robustness #1000

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

Conversation

Karrq
Copy link
Contributor

@Karrq Karrq commented Mar 26, 2025

What 💻

  • Add error trace when bytecodeByHash RPC call fails
  • Properly propagate failure when bytecodeByHash RPC fails
  • [WIP] Add fixed-num retry mechanism to avoid spurious network errors

Why ✋

Evidence 📷

Screenshot 2025-03-27 at 22 10 47

Documentation 📚

Please ensure the following before submitting your PR:

  • Check if these changes affect any documented features or workflows.
  • Update the book if these changes affect any documented features or workflows.

Notes 📝

I originally tried to mock all requests to the server but it ended up being massive quickly (about the 6th request when it asked for the code of a system contract), so instead I added this MITM mode to our MockServer so we can override specific requests (in this case, zks_getBytecodeByHash) and forward all the rest to a target node.
I didn't change the other usages of MockServer to the new builder, just to avoid changing a bunch of files that are irrelevant, but we can do that here if we want to be consistent with usage.

@Karrq Karrq marked this pull request as ready for review March 31, 2025 12:11
@Karrq Karrq requested a review from a team as a code owner March 31, 2025 12:11

/// The delay (in seconds) betwen each retry to
/// retrieve code_by_hash from forked DB
const CODE_BY_HASH_RETRY_DELAY_SECS: u64 = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please make this a Duration

/// retrieve code_by_hash from forked DB
const CODE_BY_HASH_RETRIES: u32 = 3;

/// The delay (in seconds) betwen each retry to
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// The delay (in seconds) betwen each retry to
/// The delay (in seconds) between each retry to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants