feat(flashblocks rpc): Full revamp of X Layer custom flashblocks RPC layer#176
Draft
feat(flashblocks rpc): Full revamp of X Layer custom flashblocks RPC layer#176
Conversation
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…to state cache 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a tertiary tx hash index (HashMap<TxHash, Arc<CachedTxInfo>>) to ConfirmCache, enabling O(1) lookups for transaction_by_hash, transaction_by_hash_with_meta, and receipt_by_hash from confirmed flashblocks that are ahead of the canonical chain. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add collect_cached_block_range_while helper that threads a predicate through both the provider prefix and cached suffix, enabling sealed_headers_while to serve confirmed flashblock headers instead of bypassing the cache entirely. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… rpc crate Consolidates flashblocks cache provider trait implementations (block, header, factory, receipt, transaction) into a single eth.rs override module in the rpc crate. Wires FlashblockStateCache into the node's RPC registration. Simplifies the cache layer to only manage state. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…an up cache interfaces 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Consolidate the previously split flashblocks service setup and state cache creation into one cohesive `if let Some` block. This fixes a subtle bug where using `.map()` with `?` operators would produce `Option<Result<T, E>>` instead of the intended `Option<T>`, causing `?` to not propagate errors to the outer closure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… access Restructure ConfirmCache to store ExecutedBlock directly instead of just BlockAndReceipts, enabling state provider overlay for flashblock state queries. - Add ConfirmedBlock struct wrapping ExecutedBlock + receipts - Update insert/remove signatures to accept ExecutedBlock - Make PendingSequence.tx_index pub for state access - Fix execution cache test assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cks state 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f8a26bf to
5d96010
Compare
5d96010 to
6666f70
Compare
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ate provider helpers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ution mod 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace associated-type-based `Eth` generic with explicit `N` (node) and `Rpc` (converter) generics on `XLayerEthApiExt` and helper functions. Use fully-qualified `EthApiServer::` calls instead of inherent method dispatch for clearer trait resolution. Simplify helper function bounds by parameterizing directly on `Rpc: RpcConvert` instead of `Eth: EthApiTypes`. Update storage slot type to `JsonStorageKey` and fix transaction body access to use direct field/method calls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rename `eth.rs` to `flashblocks.rs` and `xlayer_ext.rs` to `default.rs` to better reflect their responsibilities. Rename `XLayerEthApiExt` to `FlashblocksEthApiExt`, `XlayerRpcExt` to `DefaultRpcExt`, and `XlayerRpcExtApi` to `DefaultRpcExtApi`. Extract `FlashblocksRpcArgs` as a standalone struct with derive macros and update `main.rs` to use the new type names and module paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove unused `reth-rpc` and `async-trait` dependencies from `crates/rpc/Cargo.toml`. Remove stale comment on converter field, fix redundant parentheses in payload builder, and use associated `N::Primitives` type instead of concrete `OpPrimitives` in `get_flashblock_state_provider_by_id` return type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit 94e1d8a.
This reverts commit f2d3752.
…rst" This reverts commit 079ecb7.
…nto execution mod" This reverts commit 707f540.
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
This PR revamps the entire flashblocks rpc layer design, similar to the previous Realtime-feature (RTA) cache capabilities on the since discontinued xlayer-erigon (refer to: https://github.com/okx/xlayer-erigon/tree/dev/zk/realtime).
Essentially, this revamp implements the full solution 2 mentioned in the upstream reth's issue discussion thread: paradigmxyz/reth#20491, which is a more elegant design to the complex op-reth's flashblock rpc layer that is still dependent on the canonical chainstate.
Motivations
The best design for allowing minimal latencies is to allow a full state accumulation from incoming flashblocks that are ahead of the canonical chainstate, while allowing for a hybrid sync approach that:
latesttags) on flashblocks rpc tries to read from both the flashblocks state cache and underlying canon providerNew flashblocks rpc design
1. Flashblock cache layer
FlashblockStateCachelayer which includes both the pending state and confirm state caches2. Flashblocks eth rpc extension
3. Revamp worker
4. Remove sequence manager, revamp to RawCache
5. Add handlers for flashblocks state update logic
handle_flashblockshandler - handle receiving a raw flashblock, and updating the raw cachehandle_flashblocks_statehandler - handle spawning task execution for flashblocks sequence validation and updating the flashblocks state cachehandle_canonical_block- logic to handle canonical chainstate updates to flush flashblocks state cache layer, and also handle extreme cases like chain reorgs, etcSupported flashblocks eth APIs
Block apis
[✅]
eth_blockNumber[✅]
eth_getBlockByNumber[✅]
eth_getBlockByHash[✅]
eth_getBlockReceipts[✅]
eth_getBlockTransactionCountByNumber[✅]
eth_getBlockTransactionCountByHashTransaction apis
[✅]
eth_getTransactionByHash[✅]
eth_getRawTransactionByHash[✅]
eth_getTransactionReceipt[✅]
eth_getTransactionByBlockHashAndIndex[✅]
eth_getTransactionByBlockNumberAndIndex[✅]
eth_getRawTransactionByBlockHashAndIndex[✅]
eth_getRawTransactionByBlockNumberAndIndex[✅]
eth_sendRawTransactionSyncState apis
[✅]
eth_call[✅]
eth_estimateGas[✅]
eth_getBalance[✅]
eth_getTransactionCount[✅]
eth_getCode[✅]
eth_getStorageAtTODO:
Support eth_getLogs in the future
Design flaws on op-reth flashblocks rpc