Skip to content

fix(txm): not process the same block multiple times#577

Merged
GabrielMartinezRodriguez merged 1 commit intomasterfrom
gabriel/fix-repeated-blocks
Apr 13, 2025
Merged

fix(txm): not process the same block multiple times#577
GabrielMartinezRodriguez merged 1 commit intomasterfrom
gabriel/fix-repeated-blocks

Conversation

@GabrielMartinezRodriguez
Copy link
Contributor

@GabrielMartinezRodriguez GabrielMartinezRodriguez commented Apr 1, 2025

Description

While monitoring the service, I noticed that when we experience network issues, the viem onError callback is triggered multiple times per block, not just once per network error. This was causing the resetBlockSubscription function to be called multiple times, leading to race conditions such as processing the same block more than once

I removed the onError callback to address this since it's unreliable. Additionally, I implemented a mechanism to ensure that already processed blocks are never processed again.

Toggle Checklist

Checklist

Basics

  • B1. I have applied the proper label & proper branch name (e.g. norswap/build-system-caching).
  • B2. This PR is not so big that it should be split & addresses only one concern.
  • B3. The PR targets the lowest branch it can (ideally master).

Reminder: PR review guidelines

Correctness

  • C1. Builds and passes tests.
  • C2. The code is properly parameterized & compatible with different environments (e.g. local,
    testnet, mainnet, standalone wallet, ...).
  • C3. I have manually tested my changes & connected features.

< INDICATE BROWSER, DEMO APP & OTHER ENV DETAILS USED FOR TESTING HERE >

< INDICATE TESTED SCENARIOS (USER INTERFACE INTERACTION, CODE FLOWS) HERE >

  • C4. I have performed a thorough self-review of my code after submitting the PR,
    and have updated the code & comments accordingly.

Architecture & Documentation

  • D1. I made it easy to reason locally about the code, by (1) using proper abstraction boundaries,
    (2) commenting these boundaries correctly, (3) adding inline comments for context when needed.
  • D2. All public-facing APIs & meaningful (non-local) internal APIs are properly documented in code
    comments.
  • D3. If appropriate, the general architecture of the code is documented in a code comment or
    in a Markdown document.
  • D4. An appropriate Changeset has been generated (and committed) for changes that touch npm published packages (currently packages/core and packages/react), see here for more info.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 1, 2025

Deploying happychain with  Cloudflare Pages  Cloudflare Pages

Latest commit: f46fab6
Status:⚡️  Build in progress...

View logs

@GabrielMartinezRodriguez GabrielMartinezRodriguez marked this pull request as ready for review April 1, 2025 09:29
@GabrielMartinezRodriguez GabrielMartinezRodriguez added the reviewing-1 Ready for, or undergoing first-line review label Apr 1, 2025
@aodhgan aodhgan added rethink A different approach is needed and removed reviewing-1 Ready for, or undergoing first-line review labels Apr 1, 2025
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/fix-block-undefined branch from 0cfc909 to 357ffc8 Compare April 3, 2025 11:18
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/fix-repeated-blocks branch from 295778e to 2493832 Compare April 3, 2025 11:18
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/fix-block-undefined branch from 357ffc8 to 7776719 Compare April 3, 2025 11:37
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/fix-repeated-blocks branch from 2493832 to 1b2d737 Compare April 3, 2025 11:37
@GabrielMartinezRodriguez GabrielMartinezRodriguez added the reviewing-1 Ready for, or undergoing first-line review label Apr 3, 2025
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/fix-block-undefined branch from 7776719 to e914fb7 Compare April 3, 2025 13:08
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/fix-repeated-blocks branch from 1b2d737 to 38e19fa Compare April 3, 2025 13:08
@aodhgan aodhgan added merge-blocked Ready to merge, waiting for downstack and removed reviewing-1 Ready for, or undergoing first-line review rethink A different approach is needed labels Apr 3, 2025
Base automatically changed from gabriel/fix-block-undefined to master April 13, 2025 21:39
@GabrielMartinezRodriguez GabrielMartinezRodriguez merged commit 3337949 into master Apr 13, 2025
2 of 4 checks passed
@GabrielMartinezRodriguez GabrielMartinezRodriguez deleted the gabriel/fix-repeated-blocks branch April 13, 2025 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-blocked Ready to merge, waiting for downstack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants