feat(ol/rpc): add decoded RPC endpoints for blocks, txs, and accounts#1747
Draft
voidash wants to merge 4 commits into
Draft
feat(ol/rpc): add decoded RPC endpoints for blocks, txs, and accounts#1747voidash wants to merge 4 commits into
voidash wants to merge 4 commits into
Conversation
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.
Contributor
|
Commit: ec80012 SP1 Execution Results
|
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 Report❌ Patch coverage is
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 263 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OLFullNodeRpc:strata_getBlockBySlot,strata_getRecentBlocks,strata_getBlockTransactions,strata_listAccountsstrata-ol-rpc-types:RpcOLBlockDetail,RpcOLBlockSummary,RpcOLL1UpdateSummary,RpcOLTxDetail(plus effects/transfer/message/SAU summary types),RpcAccountEntry(plus type/snark summary)TsnlLedgerAccountsTable+OLState::ledger()so account listing reuses the existingget_toplevel_ol_stateprovider methodCloses STR-3097.
Out of scope
getBlockLogsis deferred. Per-block logs are not persisted today (onlylogs_rootis in the header), so the endpoint needs new storage infrastructure. Follow-up ticket coming.jsonrpsee+ tower middleware composition; tracked separately.Test plan
cargo nextest runon touched crates: 132 tests pass (7 new)just lint-check-wsclean