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: request missing on chain events on error #2298

Merged

Conversation

aditiharini
Copy link
Contributor

@aditiharini aditiharini commented Sep 6, 2024

Why is this change needed?

Our hubs regularly fail to get into sync because some of them are missing onchain events. This feature will have us request missing onchain events if there are errors related to missing on chain events when messages are submitted.

Deployed to hoyt for testing: Logs

Merge Checklist

Choose all relevant options below by adding an x now or at any time before submitting for review


PR-Codex overview

The focus of this PR is to enhance error handling and retry mechanisms for on-chain events in the Hubble application.

Detailed summary

  • Added feature to request missing on-chain events on related submit message errors
  • Improved error code handling for validation failures and unknown signers
  • Implemented retry mechanism for on-chain events by fid
  • Enhanced error messages and error handling logic

The following files were skipped due to too many changes: apps/hubble/src/storage/engine/index.ts, apps/hubble/src/eth/l2EventsProvider.ts

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Sep 6, 2024

🦋 Changeset detected

Latest commit: cebffb7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@farcaster/core Patch
@farcaster/hubble Patch
@farcaster/hub-nodejs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hub-monorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 16, 2024 0:24am

apps/hubble/src/eth/l2EventsProvider.ts Show resolved Hide resolved
apps/hubble/src/storage/engine/index.ts Outdated Show resolved Hide resolved
packages/core/src/errors.ts Outdated Show resolved Hide resolved
apps/hubble/src/eth/l2EventsProvider.test.ts Outdated Show resolved Hide resolved
apps/hubble/src/eth/l2EventsProvider.ts Outdated Show resolved Hide resolved
apps/hubble/src/eth/l2EventsProvider.ts Outdated Show resolved Hide resolved
};
}

// TODO(aditi): Make sure we don't make multiple requests for a single fid
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this is not a problem now, but when you remove the await when calling the retry function, it will become an issue. You might need to add a lock around the duplicate check. I would add a test case when submitting 10 messages via mergeMessages for the same fid, it only calls retry once.

Copy link
Contributor Author

@aditiharini aditiharini Sep 13, 2024

Choose a reason for hiding this comment

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

This is currently pretty hard to test. We mock the l2 events provider in most tests -- which I think is a good practice. The l2 events tests are slow and the setup for each test is really complicated. It's hard to test the logic that checks for duplicates via mergeMessage

I don't think I understand the failure mode here though. All this code is in JS-land so we don't need to worry about concurrency issues right? Are you worried about the JS runtime switching to a new task between the has and set calls? I also don't think it's the biggest issue if we end up with multiple concurrent calls.

apps/hubble/src/storage/engine/index.ts Outdated Show resolved Hide resolved
apps/hubble/src/storage/engine/index.ts Outdated Show resolved Hide resolved
apps/hubble/src/eth/l2EventsProvider.ts Show resolved Hide resolved
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 84.94624% with 14 lines in your changes missing coverage. Please review.

Project coverage is 44.44%. Comparing base (1880070) to head (cebffb7).
Report is 349 commits behind head on main.

Files with missing lines Patch % Lines
apps/hubble/src/eth/l2EventsProvider.ts 83.87% 10 Missing ⚠️
apps/hubble/src/storage/engine/index.ts 87.09% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2298       +/-   ##
===========================================
- Coverage   74.05%   44.44%   -29.62%     
===========================================
  Files          99      146       +47     
  Lines        9425    25563    +16138     
  Branches     2097     9063     +6966     
===========================================
+ Hits         6980    11362     +4382     
- Misses       2327    12481    +10154     
- Partials      118     1720     +1602     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

apps/hubble/src/eth/l2EventsProvider.ts Outdated Show resolved Hide resolved
apps/hubble/src/eth/l2EventsProvider.ts Outdated Show resolved Hide resolved
apps/hubble/src/eth/l2EventsProvider.ts Outdated Show resolved Hide resolved
@aditiharini aditiharini merged commit f084daa into farcasterxyz:main Sep 16, 2024
9 of 10 checks passed
if (
result.error.errCode === "bad_request.no_storage" ||
"bad_request.unknown_signer" ||
"bad_request.missing_fid"

Choose a reason for hiding this comment

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

Q: Should that be bad_request.unknown_fid as the name suggested in line 1237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-feat Add a new feature or protocol improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants