Skip to content

feat(ol/rpc): add decoded RPC endpoints for blocks, txs, and accounts#1747

Draft
voidash wants to merge 4 commits into
mainfrom
ashish/str-3097-decoded-rpc-endpoints
Draft

feat(ol/rpc): add decoded RPC endpoints for blocks, txs, and accounts#1747
voidash wants to merge 4 commits into
mainfrom
ashish/str-3097-decoded-rpc-endpoints

Conversation

@voidash
Copy link
Copy Markdown
Contributor

@voidash voidash commented May 3, 2026

Summary

  • Adds 4 decoded JSON RPC endpoints to OLFullNodeRpc: strata_getBlockBySlot, strata_getRecentBlocks, strata_getBlockTransactions, strata_listAccounts
  • Defines new RPC response types in strata-ol-rpc-types: RpcOLBlockDetail, RpcOLBlockSummary, RpcOLL1UpdateSummary, RpcOLTxDetail (plus effects/transfer/message/SAU summary types), RpcAccountEntry (plus type/snark summary)
  • Exposes a public ledger iterator on TsnlLedgerAccountsTable + OLState::ledger() so account listing reuses the existing get_toplevel_ol_state provider method
  • 7 new unit tests covering happy paths, missing slots, count=0, count > tip, and ledger iteration

Closes STR-3097.

Out of scope

  • getBlockLogs is deferred. Per-block logs are not persisted today (only logs_root is in the header), so the endpoint needs new storage infrastructure. Follow-up ticket coming.
  • Static HTML serving for the explorer UI (STR-3098). Needs jsonrpsee + tower middleware composition; tracked separately.
  • E2E tests (STR-3099) — depends on STR-3098 landing first.

Test plan

  • cargo nextest run on touched crates: 132 tests pass (7 new)
  • just lint-check-ws clean
  • Manual smoke against a running strata node (recommend before merge)

Adds four endpoints to OLFullNodeRpc that return decoded JSON instead of
raw SSZ bytes:

- strata_getBlockBySlot(slot) -> Option<RpcOLBlockDetail>
- strata_getRecentBlocks(count) -> Vec<RpcOLBlockSummary>
- strata_getBlockTransactions(slot) -> Vec<RpcOLTxDetail>
- strata_listAccounts(block_or_tag) -> Vec<RpcAccountEntry>

New response types in strata-ol-rpc-types map SSZ block/tx/account
internals into JSON-friendly views with hex-encoded fields. Exposes a
public ledger iterator on TsnlLedgerAccountsTable + OLState so account
listing reuses the existing get_toplevel_ol_state provider method
without requiring a new one.

getBlockLogs is intentionally deferred to a follow-up ticket. Per-block
logs are not persisted today (only logs_root is); adding the endpoint
requires new storage infrastructure.

Refs STR-3097.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

Commit: ec80012

SP1 Execution Results

program cycles success
EVM EE STF 1,318,208
Checkpoint 1,930,632

Addresses two findings from a codex code review:

1. listAccounts was unbounded: a large ledger could return a massive
   single response. Add (start, count) pagination with a server-side cap
   of max_headers_range, and wrap the response in RpcAccountListPage so
   we can extend it with new fields without breaking the wire format.

2. resolve_block_or_tag for the Confirmed tag was using prev_epoch,
   which can lag behind confirmed_epoch when epochs complete locally
   before being observed on L1. Use confirmed_epoch directly from
   ChainSyncStatus. (The matching bug in get_snark_account_state still
   has a TODO referencing STR-2420; out of scope for this PR.)

Adds two tests for the new pagination bounds.

Refs STR-3097.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 66.20690% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.41%. Comparing base (14e54d8) to head (132af39).

Files with missing lines Patch % Lines
crates/ol/rpc/types/src/tx.rs 54.63% 44 Missing ⚠️
crates/ol/rpc/types/src/block.rs 68.83% 24 Missing ⚠️
bin/strata/src/rpc/node.rs 65.00% 14 Missing ⚠️
crates/ol/rpc/types/src/account_state.rs 77.58% 13 Missing ⚠️
crates/ol/state-types/src/ledger.rs 80.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (14e54d8) and HEAD (132af39). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (14e54d8) HEAD (132af39)
unit 2 1
functional 1 0
@@             Coverage Diff             @@
##             main    #1747       +/-   ##
===========================================
- Coverage   77.83%   64.41%   -13.42%     
===========================================
  Files         650      648        -2     
  Lines       68864    69059      +195     
===========================================
- Hits        53602    44487     -9115     
- Misses      15262    24572     +9310     
Flag Coverage Δ
functional ?
unit 64.41% <66.20%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
crates/ol/state-types/src/toplevel.rs 88.11% <100.00%> (-3.77%) ⬇️
crates/ol/state-types/src/ledger.rs 96.21% <80.00%> (-3.20%) ⬇️
crates/ol/rpc/types/src/account_state.rs 72.72% <77.58%> (-0.61%) ⬇️
bin/strata/src/rpc/node.rs 68.76% <65.00%> (-9.55%) ⬇️
crates/ol/rpc/types/src/block.rs 65.21% <68.83%> (+42.26%) ⬆️
crates/ol/rpc/types/src/tx.rs 47.61% <54.63%> (-23.04%) ⬇️

... and 263 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

voidash added 2 commits May 3, 2026 19:30
Three follow-up items from a self-review pass:

1. get_recent_blocks now walks from sync_status.tip.blkid directly
   instead of re-resolving the canonical block at tip_slot. Saves a DB
   call and reads a chain consistent with the tip we observed; if a
   reorg races the read, the canonical lookup could otherwise disagree
   with the sync_status snapshot.

2. New regression test for the Confirmed-tag fix from the prior commit.
   Sets up confirmed_epoch and prev_epoch at different blocks with
   different ledger contents and asserts listAccounts("confirmed")
   resolves to the confirmed_epoch (not prev_epoch).

3. New pagination test that walks listAccounts across three offsets
   (start=0, start=2, start=10) to exercise total/next_offset bookkeeping
   beyond the first page.

Refs STR-3097.
…d enums

- RpcOLTxDetail: drop type_id (u16) and type_name (String); replace the
  separate sau: Option<RpcSauTxSummary> field with a tagged kind enum
  RpcOLTxKind { GenericAccountMessage, SnarkAccountUpdate(RpcSauTxSummary) }.
  Mirrors the existing RpcTransactionPayload pattern in the same module.
  Also makes target Option<HexBytes32> instead of falling back to all-zero
  bytes when the underlying tx has no target.

- RpcAccountEntry: same treatment. Drop the standalone account_type and
  snark fields; replace with a tagged kind enum RpcAccountKind { Empty,
  Snark(RpcAccountSnarkSummary) }. Convenience snark() accessor preserved.

- New regression test get_block_transactions_decodes_gam_tx that
  constructs a real OLTransaction in a non-empty block and asserts the
  From<&OLTransaction> path round-trips kind, target, and effects.

Refs STR-3097.
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