Skip to content

feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder#162

Merged
louisliu2048 merged 8 commits intomainfrom
niven/write-fb-disk
Mar 4, 2026
Merged

feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder#162
louisliu2048 merged 8 commits intomainfrom
niven/write-fb-disk

Conversation

@sieniven
Copy link
Contributor

@sieniven sieniven commented Feb 28, 2026

Summary

This PR adds new logic on the flashblocks RPC nodes to persist the current pending flashblocks sequence to disk, and adds logic on our flashblocks sequencer startup to read from disk the pending flashblocks sequence to possible replay the sequences.

  1. Add serialization and deserialization logic of the flashblocks sequence cache
  2. Add unit tests coverage on flashblocks sequence cache
  3. Add persistence handle logic on flashblocks RPC service
  4. Add sequencer reading from disk to restore previously minted pending flashblocks sequence into the flashblocks sequence cache on start up
  5. Add new config flag flashblocks.replay-from-persistence-file to enable replay on flashblocks sequence on sequencer restart

sieniven and others added 7 commits February 28, 2026 14:58
Clone cached payloads instead of taking ownership, allowing the
flashblock payloads cache to persist across multiple retrievals
for the same parent hash.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add disk persistence for the pending flashblocks sequence received via
the flashblock broadcast channel. A dedicated `xlayer-flashblocks-persistence`
task writes each incoming flashblock to a JSON file using atomic
write-then-rename, ensuring crash-safe state on disk.

Key changes:
- Introduce `FlashblockPayloadsSequence` as a serializable struct with
  serde support for JSON persistence
- Add `persist()` and `load_from_file()` methods to `FlashblockPayloadsCache`
- Spawn a separate persistence task alongside the existing publish task
- Thread `datadir` from node config through to the flashblocks service
- Make `FlashblockPayloadsCache` public for cross-crate usage

🤖 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>
…m file

Add replay-from-persistence-file CLI flag and config to allow the
sequencer to load the pending flashblocks sequence from disk on startup.
This enables the builder to resume flashblocks streaming after a restart
without waiting for a new block build cycle.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tead

- Replace per-flashblock disk writes with tokio::select! loop using a
  5-second interval and dirty flag to reduce I/O from ~4/sec to ~0.2/sec
- Add final flush on shutdown to avoid losing latest cached state
- Remove redundant load_from_file method, migrate tests to try_load_from_filepath
- Fix doc comment spacing in FlashblocksArgs
- Use idiomatic flashblock.as_ref().clone() instead of FlashBlock::clone()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… exist

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@louisliu2048 louisliu2048 merged commit ac97855 into main Mar 4, 2026
Vui-Chee added a commit that referenced this pull request Mar 9, 2026
* main:
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
Vui-Chee added a commit that referenced this pull request Mar 13, 2026
* main: (25 commits)
  fix: bump quinn-proto to 0.11.14 to patch CVE-2026-31812 DoS vuln (#183)
  pre-job authorization (#193)
  fix: trigger review skill failed to ack (#192)
  feat: trigger skill review separately (#191)
  feat: add Claude skills and CLAUDE.md for AI-assisted development (#190)
  rename ext (#185)
  supply workflow for claude (#184)
  feat(builder): incremental trie cache optimization for flashblocks state root (#163)
  chore(flashblocks-rpc): migrate op-reth flashblocks into xlayer-reth (#175)
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
  fix: update testcontainers to v0.27.0 to remediate CVE-2025-62518 (#164)
  chore(builder): further clean up builder crate (#161)
  ...
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