Skip to content

fix: stabilize MPB bridge transaction history reads#271

Open
edehvictor wants to merge 2 commits into
GoodDollar:copilot/fix-mpb-bridge-transaction-historyfrom
edehvictor:fix/finalize-mpb-history-270
Open

fix: stabilize MPB bridge transaction history reads#271
edehvictor wants to merge 2 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

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
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

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