Skip to content

withdrawals tracking#625

Merged
pk910 merged 9 commits intomasterfrom
pk910/withdrawals-tracking
Apr 9, 2026
Merged

withdrawals tracking#625
pk910 merged 9 commits intomasterfrom
pk910/withdrawals-tracking

Conversation

@pk910
Copy link
Copy Markdown
Member

@pk910 pk910 commented Apr 2, 2026

Proper Withdrawals Indexing

Summary

Replaces the lightweight el_withdrawals table (written exclusively by the EL tx indexer) with a first-class withdrawals table indexed from the beacon chain, with granular withdrawal type classification. Fee recipient rewards are moved out of the withdrawals system entirely and stored as fields on el_blocks.

Changes

Schema & Data Model

  • New withdrawals table with block_uid, block_idx, type, orphaned, fork_id, validator (NOT NULL), account_id, amount (Gwei). Primary key (block_uid, block_idx).
  • New fee columns on el_blocks: fee_amount, fee_amount_raw, fee_account_id — fee recipient rewards are no longer tracked as withdrawals.
  • Migration (20260402000000_withdrawals-index.sql): Creates new table, seeds CL withdrawals from el_withdrawals, migrates fee data to el_blocks, drops old table. Both SQLite and PostgreSQL.
  • Deleted db/el_withdrawals.go and all ElWithdrawal/ElWithdrawalFilter types.

Withdrawal Type Classification

Four withdrawal types, classified during beacon block indexing:

Type Value Detection
Full Withdrawal 1 Validator exited + withdrawable, amount >= EJECTION_BALANCE - 0.5 ETH
Sweep Withdrawal 2 Regular scheduled sweep (excess balance), or small dust after exit
Requested Withdrawal 3 EIP-7002 partial withdrawal (from pending_partial_withdrawals in state)

Type detection uses the state simulator to count pending partial withdrawals per block (they appear first in the execution payload per spec), then checks validator exit status and amount threshold for full vs sweep classification.

Beacon Indexer

  • buildDbWithdrawals extracts withdrawals from execution payload, classifies types using sim state, resolves account IDs (persist path creates missing accounts using the existing transaction; read path only looks up existing ones).
  • persistBlockWithdrawals wired into persistBlockChildObjects, also calls UpdateWithdrawalsForkId to keep fee recipient entries (written by EL indexer) in sync during reorgs/finalization.
  • GetDbWithdrawals on Block for chain service cache access, reconstructs sim from epoch stats on the read path.

EL Tx Indexer

  • No longer writes to withdrawals table at all.
  • Fee recipient data written directly to el_blocks record (fee_amount, fee_amount_raw, fee_account_id).
  • processBlockRewards simplified to only collect fee data.

Chain Service

  • GetWithdrawalsByFilter in new services/chainservice_withdrawals.go — cache + DB pagination pattern (same as voluntary exits/slashings). No fee recipient merging needed.
  • WithdrawalFilter supports multi-type filtering (Types []uint8), validator name search, account ID with address fallback for cached blocks.
  • GetWithdrawalRequestsByFilter now properly passes MinAmount/MaxAmount to both pending tx and cached request operation filters.

UI — Withdrawals Overview (/validators/withdrawals)

  • Default tab changed to "Recent Withdrawals" (beacon chain withdrawals).
  • Stats boxes: Withdrawn (24h) | Requests / Queued | Queued Amount | Queue Duration Est.
  • 3 tabs: Recent Withdrawals, Withdrawal Requests (excludes exits), Withdrawal Queue.
  • Withdrawal Requests tab links to /validators/el_withdrawals?f=&f.type=1&f.orphaned=1.
image

UI — Withdrawals Filtered List (/validators/withdrawals/filtered)

  • Filterable, paginated list of all beacon chain withdrawals.
  • Filters: Validator (index/name), Address, Type (multi-select: Full/Sweep/Requested), Amount range (ETH), Orphaned.
  • Type badges: Full (blue), Sweep (green), Requested (yellow).
image

UI — Exits Overview (/validators/exits)

  • New "Recent Exit Requests" tab for EL-triggered exits (EIP-7002 with amount=0).
  • Links to /validators/el_withdrawals?f=&f.type=2&f.orphaned=1 for full list.

UI — Validator Detail Page

  • New "Withdrawals" tab showing beacon chain withdrawals for the validator.
  • Links to filtered list for viewing all withdrawals.
image

UI — Address Detail Page

  • "System Deposits" tab split into "Beacon Withdrawals" and "Block Fees".
  • Withdrawal tab visibility uses the combined chain service accessor (cache + DB) to detect withdrawals for addresses that are used as withdrawal credentials.
  • Block fees tab queries el_blocks by fee_account_id.
image

UI — Breadcrumbs

  • All action pages (Deposits, Withdrawals, Consolidations, Exits, Slashings) now have consistent breadcrumb hierarchy: Home / Validators / <Action> with child pages under Home / Validators / <Action> / <Page>.
  • "Consolidation Requests" renamed to "Consolidations" in breadcrumbs and page titles.

Other

  • formatEthFromGweiP template function added for configurable decimal precision (withdrawals use 6 decimals).
  • Slot detail page withdrawals updated to 6 decimal places.
  • EL data retention cleanup no longer touches withdrawals (beacon-indexed data, not subject to EL data retention).

@pk910 pk910 mentioned this pull request Apr 2, 2026
@pk910 pk910 merged commit d2df3ec into master Apr 9, 2026
4 checks passed
@pk910 pk910 deleted the pk910/withdrawals-tracking branch April 9, 2026 23:18
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.

2 participants