Skip to content

fix: stabilize MPB bridge transaction history reads - #271

Merged
L03TJ3 merged 5 commits into
GoodDollar:copilot/fix-mpb-bridge-transaction-historyfrom
edehvictor:fix/finalize-mpb-history-270
Jul 14, 2026
Merged

fix: stabilize MPB bridge transaction history reads#271
L03TJ3 merged 5 commits into
GoodDollar:copilot/fix-mpb-bridge-transaction-historyfrom
edehvictor:fix/finalize-mpb-history-270

Conversation

@edehvictor

@edehvictor edehvictor commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Closes #270
Addresses #268
Finalizes #269

Changes

  • Finalized the MPB bridge transaction history implementation from the AI-generated PR.
  • Replaced broad/fragile history reads with direct provider.getLogs calls using max 500-block chunks.
  • Added account-indexed event filters for BridgeRequest and ExecutedTransfer to reduce RPC load.
  • Added log deduplication for events where the connected wallet can match both indexed filters.
  • Added cursor-based cache refresh so warm loads fetch only from the last synced block forward.
  • Preserved the 30-day cold-cache backfill behavior.
  • Added per-chain partial error handling so one failing RPC does not block successful chains from rendering cached or refreshed history.
  • Added optional bridge-specific bridgeReadOnlyUrls support for MPB history reads, while preserving fallback to the existing app-level read-only provider setup.
  • Scoped GoodDesign history reads to the currently selected source/target chains to avoid unnecessary RPC traffic.
  • Switched read-only JSON RPC providers to StaticJsonRpcProvider for more stable network detection.
  • Added helper tests for chunking, account topics, log dedupe, and cache merge behavior.

Implementation Notes

The original issue expected independent per-chain reads. During local testing, public RPCs rate-limited heavily when too many requests were fired quickly, especially Celo public endpoints. The final implementation keeps chains isolated, but runs history RPC requests sequentially with a small delay and only for the active source/target route. This follows the later review guidance about slowing requests down and testing what public RPCs allow.

Each eth_getLogs request remains capped at 500 blocks.

Manual Verification

Validated locally in GoodProtocolUI using yalc/manual local package linking.

Environment used:

  • REACT_APP_NETWORK=production-celo
  • Celo RPCs tested/configured locally: https://forno.celo.org, https://rpc.ankr.com/celo, https://celo.drpc.org
  • Excluded unstable/rate-limited RPCs locally: tatum,onfinality,1rpc,alchemy

Bridge flow tested:

  • Connected wallet on Celo.
  • Bridged 10 G$ from Celo to XDC via LayerZero.
  • Transaction hash: 0x866075b684c5c9babd57501a99a25d60a36bb3072d054b2b9f53299417c0cc76
  • The bridge transaction completed successfully.
  • Recent Transactions rendered the completed history row:
    • Bridged via LayerZero
    • Celo -> XDC
    • +10.00 G$

Demo video: TODO - add video link here.

Testing

Passed:

node .yarn\releases\yarn-3.2.1.cjs workspace @gooddollar/web3sdk-v2 exec tsc --noEmit
node .yarn\releases\yarn-3.2.1.cjs workspace @gooddollar/good-design exec tsc --noEmit
..\..\node_modules\.bin\jest.cmd src/sdk/mpbridge/hooks/useMPBBridgeHistory.helpers.test.ts --runInBand
node_modules\.bin\eslint.cmd --quiet <changed MPB history/design files>

The helper test result was:

Test Suites: 1 passed
Tests: 5 passed

Could not complete in this Windows PowerShell environment:

node .yarn\releases\yarn-3.2.1.cjs lint

Reason: repo-wide CRLF/prettier warnings across many existing files in this Windows checkout. A targeted lint pass against the changed source files passed with --quiet.

node .yarn\releases\yarn-3.2.1.cjs workspace @gooddollar/web3sdk-v2 build
node .yarn\releases\yarn-3.2.1.cjs workspace @gooddollar/good-design build

Reason: both package build scripts fail before compiling because dev:clean calls Unix rm, which is not available in this PowerShell shell:

'rm' is not recognized as an internal or external command
command not found: rm

The TypeScript compile steps from those packages were run directly and passed.

Remaining Risks

  • Full package build should be rerun in Git Bash, WSL, or CI where rm and yalc are available.
  • Approval behavior was not deeply changed in this patch; the tested bridge flow completed successfully, but stale allowance edge cases may need a separate focused pass if reviewers still suspect an approval-state bug.

Summary by Sourcery

Stabilize MPB bridge transaction history by switching to targeted log-based RPC reads, introducing per-chain error isolation, and wiring configurable read-only endpoints and chain scoping into the GoodDesign bridge UI.

New Features:

  • Expose configurable MPB bridge history options, including per-chain read-only RPC URLs and selectable chain IDs, through the history hook and GoodDesign bridge props.
  • Add account-indexed log filters, log deduplication, and cursor-based cache syncing for bridge history to reduce RPC load while preserving a rolling 30-day backfill.

Bug Fixes:

  • Prevent MPB bridge history loading from being blocked by a single failing RPC by handling per-chain partial errors and surfacing them in the UI.
  • Reduce RPC rate-limit issues and unstable network detection by capping log ranges, running history requests sequentially with delays, and using StaticJsonRpcProvider for read-only providers.

Enhancements:

  • Normalize and simplify RPC error messages stored in bridge history state for clearer user-facing feedback.
  • Scope bridge history reads in GoodDesign to the currently selected source and target chains to avoid unnecessary RPC traffic.
  • Export MPB bridge history helpers and extend tests to cover chunking, account topic generation, log deduplication, and cache merge behavior.

Tests:

  • Extend MPB bridge history helper tests to cover account topic creation, log deduplication, and cache merge behavior, ensuring the new history sync logic is validated.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@edehvictor

Copy link
Copy Markdown
Contributor Author

Local validation after latest push

Latest pushed commit: 7135957 (fix: finalize MPB bridge history recovery)

Demo video: https://www.loom.com/share/ca5ef9ad275245fea142ffee278f6f68

What I validated locally:

  • Reproduced the approval bug check flow: bridged 10 G$, refreshed, then submitted another bridge request for the same 10 G$ amount.
  • Confirmed the app requested a fresh approval again before the second bridge transaction.
  • Confirmed the second bridge completed from Celo to Fuse.
  • Confirmed Recent Transactions renders the bridged rows and keeps the previous Celo -> XDC row visible while refresh continues.
  • Confirmed GoodWallet shows the bridged balances, including 9.99 G$ on Fuse and the previous 9.99 G$ on XDC.

Implementation notes:

  • Removed the allowance shortcut that skipped approval on repeated same-amount bridge requests.
  • Made MPB history recover from empty or stale local cursors, prioritize recent source-chain BridgeRequest logs, stream rows into the UI during refresh, and keep valid rows visible even if another RPC returns a refresh warning.

Testing run:

  • yarn workspace @gooddollar/web3sdk-v2 exec tsc --noEmit
  • yarn workspace @gooddollar/good-design exec tsc --noEmit
  • node_modules/.bin/eslint.cmd --quiet packages/sdk-v2/src/sdk/mpbridge/hooks/useMPBBridgeHistory.ts packages/sdk-v2/src/sdk/mpbridge/hooks/useMPBBridge.ts packages/good-design/src/apps/bridge/mpbridge/TransactionHistory.tsx
  • jest src/sdk/mpbridge/hooks/useMPBBridgeHistory.helpers.test.ts --runInBand

Proof screenshots:

GoodBridge transaction history proof

GoodWallet bridged balances proof

@L03TJ3 L03TJ3 moved this to In Review in GoodBounties Jul 7, 2026
@edehvictor

edehvictor commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Update after final local test and push:

  • Pushed latest branch changes through c893e2b.
  • New demo video: https://www.loom.com/share/731d5a10775f44b48732acea01d6946c
  • Confirmed the previous Oops! Unknown block modal no longer appears after bridge submission.
  • Confirmed the “Track Transaction” flow opens the transaction details/progress modal instead of surfacing the transient block-read error.
  • Confirmation screenshot from local test shows Recent Transactions with the 07/07/2026 16:33 Celo -> XDC LayerZero bridge marked completed (+10.00 G$).
  • Also verified repeated bridge attempts request approval again after page refresh.

Verification run locally:

  • jest src/sdk/mpbridge/hooks/useMPBBridge.test.ts --runInBand
  • jest src/sdk/mpbridge/hooks/useMPBBridgeHistory.helpers.test.ts --runInBand
  • jest src/apps/bridge/mpbridge/utils/transactionHelpers.test.ts --runInBand
  • tsc --noEmit for @gooddollar/web3sdk-v2
  • tsc --noEmit for @gooddollar/good-design
  • eslint --quiet on touched SDK/good-design files

Confirmation screenshot:

GoodBridge completed 16:33 transaction confirmation

Note: after several real bridge tests the wallet started showing insufficient CELO for gas; that is unrelated to this fix and happened only after the successful bridge flows depleted the test wallet gas balance.

Comment thread packages/sdk-v2/src/hooks/useMulticallAtChain.tsx
Comment thread packages/good-design/src/apps/bridge/mpbridge/TransactionHistory.tsx Outdated
@github-project-automation github-project-automation Bot moved this from In Review to In Progress in GoodBounties Jul 13, 2026
@edehvictor

Copy link
Copy Markdown
Contributor Author

Addressed the latest review feedback in commit 39b91bc.

Changes:

  • Documented why the static read-only provider is used: the chain ID is already known, so this avoids an extra network-detection RPC request on rate-limited endpoints.
  • Kept per-chain RPC refresh errors visible even when cached transaction history exists; cached rows continue to render below the warning.
  • Replaced the dynamic chain-name mapping with an explicit list of the supported MPB bridge chains.

Verification completed successfully: SDK and good-design TypeScript checks, targeted ESLint, 8 SDK tests, and the good-design transaction helper test.

Thank you for the review.

@L03TJ3
L03TJ3 merged commit 6096f6d into GoodDollar:copilot/fix-mpb-bridge-transaction-history Jul 14, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Deploy and Verify in GoodBounties Jul 14, 2026
L03TJ3 added a commit that referenced this pull request Jul 15, 2026
* Initial plan

* chore: plan mp bridge history fix

* fix: make mp bridge history sync reliable

* chore: remove committed skills artifacts

* docs: add bridge history sync comments

* fix: stabilize MPB bridge transaction history reads (#271)

* fix: stabilize MPB bridge history reads

* fix: finalize MPB bridge history recovery

* fix: handle transient MPB bridge block read errors

* fix: polish MPB bridge transaction details

* fix: address MPB bridge review feedback

* simplify solution and shorten range

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Victor Edeh <edehvictor715@gmail.com>
Co-authored-by: LewisB <laurence@gooddollar.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Deploy and Verify

Development

Successfully merging this pull request may close these issues.

2 participants