Skip to content

Str 2540 explorer upgrade#36

Merged
purusang merged 3 commits into
mainfrom
STR-2540-explorer-upgrade
Apr 18, 2026
Merged

Str 2540 explorer upgrade#36
purusang merged 3 commits into
mainfrom
STR-2540-explorer-upgrade

Conversation

@purusang

@purusang purusang commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

STR-2540: Update explorer to new Strata RPC interface

Summary

Updates the checkpoint explorer backend to work with the revised Strata RPC interface and improves the block fetching algorithm.

RPC interface changes

Old New
strata_getLatestCheckpointIndex strata_getChainStatusconfirmed.epoch
strata_getHeadersAtIdx(slot) strata_getHeadersInRange(start, end)
  • RpcCheckpointInfo.confirmation_status is now a tagged enum (pending / confirmed { l1_reference } / finalized { l1_reference }).
  • Added RpcOLChainStatus / EpochCommitment wire types for strata_getChainStatus.
  • Replaced the generic fetch_data<T>(method, idx) helper with a dedicated fetch_checkpoint_info(idx) method.

Block fetch algorithm

Previously the block fetcher received one mpsc message per checkpoint and made a separate RPC call per block slot.

The new algorithm:

  1. A watch channel carries the L2 end slot of the latest checkpoint seen by the checkpoint fetcher (L2BlockFetchTarget).
  2. The block fetcher wakes only when the target changes (rx.changed()).
  3. On wake, it reads the last stored block height from the DB and resumes from last + 1.
  4. It fetches in batches of up to 5000 slots via strata_getHeadersInRange, advancing a cursor until it reaches the target.

This reduces RPC calls from O(n) per slot to O(n/5000) and avoids redundant fetching on restart.

Other changes

  • tokio::select! on all task JoinHandles in main and inside the status updater; any task exit calls std::process::exit(1) to bring down the whole process (TODO: replace with service framework in follow-up).
  • Removed redundant block_exists pre-check before INSERT; the DB unique constraint on block_hash/height rejects duplicates (MariaDB error 1062), logged at debug instead of error.
  • Updated the mock fullnode in functional tests to match the new RPC interface.

Local tests

I have run/observed the explorer locally.

- Replace `strata_getLatestCheckpointIndex` with `strata_getChainStatus`;
  use `confirmed.epoch` as the latest checkpoint index
- Replace per-block `strata_getHeadersAtIdx` with batch
  `strata_getHeadersInRange`; fetch up to 5000 headers per call
- Update `RpcCheckpointInfo` to use a private tagged `ConfStatus` enum
  (`pending`/`confirmed`/`finalized`) matching the new wire format
- Add `RpcOLChainStatus` / `EpochCommitment` wire types for chain status
- Switch checkpoint→block channel from `mpsc` to `watch`; block fetcher
  wakes on change and fetches up to the signalled L2 slot target
- Introduce `L2BlockFetchTarget` type alias for the watch channel value
- Collect task `JoinHandle`s and `tokio::select!` in `main` so any task
  panic exits the process; same pattern for status updater sub-tasks
- Remove redundant `block_exists` pre-check; rely on DB unique constraint
  (error 1062) and distinguish duplicate-key errors from real failures
- Update mock fullnode to match new RPC interface in functional tests

@krsnapaudel krsnapaudel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A nit and a question.

Comment thread backend/model/src/checkpoint.rs
Comment thread backend/fullnode-client/fetcher.rs
@purusang purusang requested a review from krsnapaudel April 17, 2026 16:21
@purusang purusang self-assigned this Apr 17, 2026
@purusang purusang added this pull request to the merge queue Apr 18, 2026
Merged via the queue into main with commit e587b63 Apr 18, 2026
3 checks passed
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.

3 participants