Skip to content

feat(consensus): integrate kona as an in-process consensus engine#686

Open
0xOsiris wants to merge 54 commits into
mainfrom
osiris/kona-consensus-engine
Open

feat(consensus): integrate kona as an in-process consensus engine#686
0xOsiris wants to merge 54 commits into
mainfrom
osiris/kona-consensus-engine

Conversation

@0xOsiris

@0xOsiris 0xOsiris commented May 28, 2026

Copy link
Copy Markdown
Contributor

Note

High Risk
Touches consensus/sequencing, engine forkchoice/payload handling, and HA devnet wiring; misconfiguration or engine/IPC integration bugs could stall or fork the chain.

Overview
This PR makes the world-chain binary a monolithic execution + consensus client: when --kona.enabled is set, the Optimism Kona stack runs in-process instead of a separate op-node, and Engine API work on the hot path goes through WorldChainKonaEngineClient into reth’s ConsensusEngineHandle / PayloadStore (no HTTP/JWT for FCU, newPayload, getPayload).

A new world-chain-kona crate wires KonaService, config, and CLI (KonaArgs, P2P, sequencer, L1/beacon, conductor, node RPC). Workspace Cargo.lock pulls in kona-* from ethereum-optimism/optimism (op-reth/v2.2.0) plus libp2p and related networking deps. Node add-ons spawn Kona after launch and require reth IPC for slower L2 reads.

The full-stack devnet drops containerized op-nodes: native sequencers start with in-process Kona (P2P bootstore, conductor RPC, admin sequencer bootstrap). op-conductor and HA flows now talk to each sequencer’s kona RPC (optimism_syncStatus, admin_startSequencer, etc.).

Reviewed by Cursor Bugbot for commit 54a3f03. Configure here.

Otto and others added 8 commits March 18, 2026 09:07
Add a new `world-chain-kona` crate that integrates the Kona OP Stack
consensus/derivation node into World Chain as a single binary with reth.

Key components:

- `InProcessEngineClient`: Implements Kona's `EngineClient` trait
  (which extends `OpEngineApi`) by dispatching Engine API calls directly
  to reth's `ConsensusEngineHandle` and reading chain data from reth's
  provider. This eliminates HTTP/IPC overhead for all engine interactions.

- `KonaServiceHandle`: Manages Kona's actor lifecycle (L1 watcher,
  derivation pipeline, engine actor, network) under the same tokio
  runtime as reth, with cancellation token for graceful shutdown.

- `KonaConfig`: Bridges World Chain's configuration to Kona's builder
  requirements (L1 RPC, beacon URL, P2P settings, rollup config).

The crate is excluded from the default workspace build due to a known
op-alloy version mismatch (kona uses 0.22.x, world-chain uses 0.23.x).
Engine API method implementations are stubbed with descriptive TODOs
documenting the exact conversion steps needed.

Architecture:
  world-chain binary
  ├── Kona Node (consensus/derivation) ──► Rust fn calls
  └── Reth Engine (execution)          ◄── (no HTTP/IPC)

Ref: https://github.com/anton-rs/kona (rev 2586fc56)
@socket-security

socket-security Bot commented May 28, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
License policy violation: cargo openssl-src under Artistic-1.0

License: Artistic-1.0 - The applicable license policy does not permit this license (5) (openssl-src-300.6.1+3.6.3/openssl/external/perl/Text-Template-1.56/LICENSE)

License: GPL-1.0+ - The applicable license policy does not permit this license (5) (openssl-src-300.6.1+3.6.3/openssl/external/perl/Text-Template-1.56/LICENSE)

From: ?cargo/alloy-transport-http@2.0.5cargo/openssl-src@300.6.1%2B3.6.3

ℹ Read more on: This package | This alert | What is a license policy violation?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Find a package that does not violate your license policy or adjust your policy to allow this package's license.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/openssl-src@300.6.1%2B3.6.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 54a3f03. Configure here.

Comment thread crates/node/src/context.rs Outdated
Comment thread crates/cli/src/cli/kona.rs
@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Compared on the same runner in the same workflow run.

group                                                                                              base                                   pr
-----                                                                                              ----                                   --
flashblock_validation_launch_flashblock_sequence_eth_transfers/stream/4fb_x_125tx                  1.00     28.2±0.11ms        ? ?/sec    1.03     29.2±0.16ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_eth_transfers/stream/4fb_x_250tx                  1.00     56.0±0.19ms        ? ?/sec    1.03     57.4±0.30ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_eth_transfers/stream/4fb_x_50tx                   1.00     11.8±0.09ms        ? ?/sec    1.04     12.2±0.21ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_eth_transfers_with_bal/stream/4fb_x_125tx         1.02     37.6±0.34ms        ? ?/sec    1.00     37.1±0.37ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_eth_transfers_with_bal/stream/4fb_x_250tx         1.02     68.9±0.50ms        ? ?/sec    1.00     67.6±0.43ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_eth_transfers_with_bal/stream/4fb_x_50tx          1.00     16.8±0.53ms        ? ?/sec    1.04     17.5±0.37ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_fib/stream/4fb_x_125tx                            1.00     26.7±0.20ms        ? ?/sec    1.01     27.1±0.15ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_fib/stream/4fb_x_250tx                            1.00     53.1±0.49ms        ? ?/sec    1.00     52.8±0.07ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_fib/stream/4fb_x_50tx                             1.03     11.3±0.19ms        ? ?/sec    1.00     11.1±0.05ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_fib_with_bal/stream/4fb_x_125tx                   1.00     34.1±0.33ms        ? ?/sec    1.01     34.6±0.36ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_fib_with_bal/stream/4fb_x_250tx                   1.00     62.6±0.26ms        ? ?/sec    1.01     63.4±0.37ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_fib_with_bal/stream/4fb_x_50tx                    1.02     16.3±0.26ms        ? ?/sec    1.00     15.9±0.22ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_world_id_like_bn254/stream/4fb_x_10tx             1.00    135.2±0.10ms        ? ?/sec    1.00    134.8±0.21ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_world_id_like_bn254/stream/4fb_x_12tx             1.00    162.1±0.21ms        ? ?/sec    1.00    161.5±0.10ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_world_id_like_bn254/stream/4fb_x_5tx              1.01     68.4±0.18ms        ? ?/sec    1.00     67.9±0.05ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_world_id_like_bn254_with_bal/stream/4fb_x_10tx    1.00     22.4±1.33ms        ? ?/sec    1.06     23.8±1.16ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_world_id_like_bn254_with_bal/stream/4fb_x_12tx    1.00     24.1±1.74ms        ? ?/sec    1.01     24.3±1.63ms        ? ?/sec
flashblock_validation_launch_flashblock_sequence_world_id_like_bn254_with_bal/stream/4fb_x_5tx     1.00     18.7±0.17ms        ? ?/sec    1.02     19.0±0.23ms        ? ?/sec
flashblock_validation_process_flashblock_eth_transfers/txs/1000                                    1.00     48.6±0.15ms        ? ?/sec    1.00     48.6±0.18ms        ? ?/sec
flashblock_validation_process_flashblock_eth_transfers/txs/50                                      1.01      2.7±0.03ms        ? ?/sec    1.00      2.6±0.02ms        ? ?/sec
flashblock_validation_process_flashblock_eth_transfers/txs/500                                     1.00     24.3±0.04ms        ? ?/sec    1.00     24.4±0.05ms        ? ?/sec
flashblock_validation_process_flashblock_eth_transfers_with_bal/txs/1000                           1.00     58.7±0.19ms        ? ?/sec    1.01     59.3±0.29ms        ? ?/sec
flashblock_validation_process_flashblock_eth_transfers_with_bal/txs/50                             1.00      3.8±0.06ms        ? ?/sec    1.02      3.9±0.05ms        ? ?/sec
flashblock_validation_process_flashblock_eth_transfers_with_bal/txs/500                            1.00     29.4±0.10ms        ? ?/sec    1.02     30.0±0.30ms        ? ?/sec
flashblock_validation_process_flashblock_fib/txs/1000                                              1.00     47.7±0.05ms        ? ?/sec    1.00     47.7±0.06ms        ? ?/sec
flashblock_validation_process_flashblock_fib/txs/50                                                1.03      2.6±0.02ms        ? ?/sec    1.00      2.6±0.02ms        ? ?/sec
flashblock_validation_process_flashblock_fib/txs/500                                               1.00     24.0±0.04ms        ? ?/sec    1.00     23.9±0.03ms        ? ?/sec
flashblock_validation_process_flashblock_fib_with_bal/txs/1000                                     1.00     56.1±0.30ms        ? ?/sec    1.02     57.2±0.71ms        ? ?/sec
flashblock_validation_process_flashblock_fib_with_bal/txs/50                                       1.00      3.7±0.05ms        ? ?/sec    1.02      3.7±0.04ms        ? ?/sec
flashblock_validation_process_flashblock_fib_with_bal/txs/500                                      1.00     28.5±0.09ms        ? ?/sec    1.02     29.0±0.39ms        ? ?/sec
flashblock_validation_process_flashblock_world_id_like_bn254/txs/10                                1.00     33.6±0.08ms        ? ?/sec    1.01     33.9±0.13ms        ? ?/sec
flashblock_validation_process_flashblock_world_id_like_bn254/txs/25                                1.00     83.8±0.05ms        ? ?/sec    1.01     84.4±1.94ms        ? ?/sec
flashblock_validation_process_flashblock_world_id_like_bn254/txs/50                                1.00    167.2±0.10ms        ? ?/sec    1.00    167.8±0.30ms        ? ?/sec
flashblock_validation_process_flashblock_world_id_like_bn254_with_bal/txs/10                       1.03      5.4±0.26ms        ? ?/sec    1.00      5.2±0.19ms        ? ?/sec
flashblock_validation_process_flashblock_world_id_like_bn254_with_bal/txs/25                       1.04      8.3±0.06ms        ? ?/sec    1.00      8.0±0.39ms        ? ?/sec
flashblock_validation_process_flashblock_world_id_like_bn254_with_bal/txs/50                       1.04     12.0±0.99ms        ? ?/sec    1.00     11.5±0.36ms        ? ?/sec

Threshold: 10% regression triggers failure

@alessandromazza98 alessandromazza98 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some non-blocking comments

// synced node the finalized L1 block already trails the safe head's origin by far more than
// this, so the clamp is a no-op; it only engages while the node replays history behind the
// finalized point (e.g. a restart bootstrapping derivation from L1 with no unsafe-block
// gossip), which is exactly the window where the unclamped feed crashes the node.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this comment a bit hard to understand. I understand it now but I'd suggest to add a small example that explains it very fast. Something like:

// Example:
//
//   safe head L2      = #1000
//   safe head origin  = L1 block 100
//
// The node is replaying history and receives:
//
//   finalized L1 = 150
//
// Kona will try to finalize the highest L2 block derived from finalized L1 data.
// That block may be beyond the current safe head:
//
//   safe head      = L2 #1000
//   finalize target= L2 #1200   <-- Critical error
//
// To avoid this, we cap the finalized L1 block to strictly before the safe head's
// L1 origin:
//
//   finalized L1 = min(150, 100 - 1) = 99
//
// Why "100 - 1" instead of "100"?
//
// Multiple L2 blocks can share the same L1 origin:
//
//   L1 origin 100
//     ├─ L2 #1000 (safe head)
//     ├─ L2 #1001
//     └─ L2 #1002
//
// The safe head only guarantees that L2 #1000 is safe. Later L2 blocks from the same
// epoch may still be unsafe. By clamping to origin 99, we only finalize epochs that
// are completely before the safe head's epoch, guaranteeing the derived finalize
// target can never be ahead of the current safe head.

}

#[cfg(test)]
mod tests {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this in the end of the file? Otherwise it may seem that from here forward everything is for tests, but right now this is not true

@0xOsiris

Copy link
Copy Markdown
Contributor Author

/deploy-alphanet

@github-actions

Copy link
Copy Markdown
Contributor

🛠️ Building sha-d22cdbc and dispatching an alphanet deploy. Track it in the deploy-alphanet-build runs.

@0xOsiris

Copy link
Copy Markdown
Contributor Author

/deploy-alphanet

@github-actions

Copy link
Copy Markdown
Contributor

Building ghcr.io/worldcoin/world-chain:alphanet and handing deployment to Argo CD Image Updater. Track it in the deploy-alphanet-build runs.

@0xOsiris

Copy link
Copy Markdown
Contributor Author

/deploy-alphanet

@github-actions

Copy link
Copy Markdown
Contributor

Building ghcr.io/worldcoin/world-chain:alphanet and handing deployment to Argo CD Image Updater. Track it in the deploy-alphanet-build runs.

@github-actions

Copy link
Copy Markdown
Contributor

Built ghcr.io/worldcoin/world-chain:alphanet. Argo CD Image Updater will detect the new digest and sync alphanet.

@0xOsiris

Copy link
Copy Markdown
Contributor Author

/deploy-alphanet

1 similar comment
@0xForerunner

Copy link
Copy Markdown
Contributor

/deploy-alphanet

@github-actions

Copy link
Copy Markdown
Contributor

Building ghcr.io/worldcoin/world-chain:alphanet from PR #686 at 342101d32092 and handing deployment to Argo CD Image Updater. Track it in the deploy-alphanet-build runs.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Building ghcr.io/worldcoin/world-chain:alphanet from PR #686 at 342101d32092 and handing deployment to Argo CD Image Updater. Track it in the deploy-alphanet-build runs.

@github-actions

Copy link
Copy Markdown
Contributor

Built ghcr.io/worldcoin/world-chain:alphanet from PR #686 at 342101d32092. Argo CD Image Updater will detect the new digest and sync alphanet.

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.

4 participants