Block Production
Streaming Execution with Checkpoints
Kaizen uses streaming execution where transactions execute immediately upon arrival, with periodic checkpoints every 100ms for oracle updates.
Why Streaming?
| Approach | Latency | Complexity |
|---|---|---|
| Batch (old) | Up to 100ms wait | Mempool ordering |
| Streaming (current) | Instant execution | Simpler, lower latency |
Transactions no longer wait in a mempool. They execute immediately and are committed at the next checkpoint.
Checkpoint Operation
Every 100ms:
Important: Block N contains the oracle snapshot that was applied at the START of Block N, not the new one pulled for Block N+1.
Note: Settlement is handled by the Settler service via SystemSettle transactions, not during begin_block(). This keeps block production fast and decoupled from settlement logic.
Oracle Price Pulling
The Executor pulls prices from the Oracle Service, rather than receiving them as transactions:
Benefits:
- No nonce management for oracle data
- Deterministic sequencing - prices at block level, not tx level
- Lower latency - direct HTTP vs mempool processing
If oracle is unreachable, fallback to last known prices (up to 3s staleness).
Write → Read Synchronization
Read nodes receive blocks from Write node and execute the same STF to reconstruct state.
Normal Sync
- Receive new blocks via TCP streaming
- Apply oracle snapshot (from block) via
begin_block() - Execute all TXs with full verification
- Verify computed state_root matches block header (determinism check)
- Propagate events to WebSocket subscribers
Critical: The oracle snapshot in each block is the one that was applied BEFORE TX execution on the Write node, ensuring Read nodes produce identical state.
Catch-up (restart/recovery)
- Read node sends its last block height to Write node
- Write node sends subsequent blocks
- Read node re-executes STF for each block
- Switches to live stream after catching up
Snapshot Bootstrap
- Completely new Read node replaying from block 0 takes too long
- Load periodically saved State Snapshot and replay only subsequent blocks
Configuration
[block]
interval_ms = 100 # Checkpoint interval
max_txs_per_block = 1000 # Max txs per checkpoint
[oracle]
service_url = "http://oracle:8550" # Oracle service URL
timeout_ms = 10 # Oracle pull timeout
max_stale_ms = 3000 # Max oracle staleness
[settler]
enabled = true
address = "0x..." # Authorized settler addressRunning Nodes
Write Node (Sequencer)
./target/release/kaizen-node --config config.tomlRead Node
./target/release/kaizen-node --mode read --write-node ws://localhost:9000Settler
# All pairs
./target/release/settler --write-node 127.0.0.1:9000
# Per-pair deployment
./target/release/settler --pairs BTC/USDT
./target/release/settler --pairs ETH/USDT