Skip to content

Refactor MP bridge history to chunked per-chain log sync#269

Draft
Copilot wants to merge 5 commits into
masterfrom
copilot/fix-mpb-bridge-transaction-history
Draft

Refactor MP bridge history to chunked per-chain log sync#269
Copilot wants to merge 5 commits into
masterfrom
copilot/fix-mpb-bridge-transaction-history

Conversation

Copilot AI commented Jun 29, 2026

Copy link
Copy Markdown

MP bridge history was relying on useLogs over narrow rolling windows, which made refreshes unreliable on public RPCs and collapsed cached, loading, and failure states into a single UI outcome. This change moves history sync to direct per-chain getLogs fetching with persistent cursors so cached results render immediately while each chain refreshes independently.

  • SDK: replace useLogs history polling

    • swap the history flow to direct provider.getLogs(...)
    • fetch BridgeRequest and ExecutedTransfer in <=500 block chunks
    • backfill 30 days on empty cache, then resume from per-chain lastSyncedBlock
  • Cache model: persist real sync state

    • keep one wallet+deployment cache entry with:
      • merged normalized history rows
      • per-chain lastSyncedBlock
      • per-chain lastSuccessfulSyncAt
      • per-chain error state
    • prune cached rows outside the rolling 30-day window
    • merge successful chain results without blocking on failed chains
  • History behavior: make refresh explicit

    • hydrate cached rows first for fast first paint
    • run background sync per chain with Promise.allSettled
    • expose initialLoading, refreshing, errorsByChain, and refreshHistory()
    • refresh only fetches deltas from stored cursors
  • UI: show real history state

    • keep cached transactions visible during background sync
    • add a manual Refresh action
    • show inline refreshing state separately from initial loading
    • surface per-chain refresh failures instead of silently treating them as empty history
    • trigger refreshHistory() after a successful bridge action
  • History matching: preserve request/completion merge

    • continue normalizing and matching BridgeRequest with ExecutedTransfer after all fetched rows are merged into cache
const { historySorted, initialLoading, refreshing, errorsByChain, refreshHistory } = useMPBBridgeHistory();

// empty cache:
//   backfill 30 days per chain in 500-block chunks
// warm cache:
//   show cached rows immediately, then fetch cursor+1 -> latest

Copilot AI changed the title [WIP] Fix MPB Bridge transaction history loading reliability Refactor MP bridge history to chunked per-chain log sync Jun 29, 2026
Copilot AI requested a review from L03TJ3 June 29, 2026 11:22
@L03TJ3

L03TJ3 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot can you uncommit the skills folder

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Author

@copilot can you uncommit the skills folder

Removed in 3a372f7, and added ignore rules so the Copilot skills artifacts do not get recommitted.

Copilot finished work on behalf of L03TJ3 July 1, 2026 06:13
@L03TJ3

L03TJ3 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot please comment your suggested solution extensively

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Author

@copilot please comment your suggested solution extensively

Added extensive inline comments in ff95f8c covering the cache window, chunked log fetching, per-chain sync/error handling, cache persistence, and request/completion matching flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants