Skip to content

Add admin-toggled block_merging_enabled kill switch - #502

Merged
0w3n-d merged 2 commits into
developfrom
od/merged_block_sim
Aug 29, 2026
Merged

0w3n-d merged 2 commits into
developfrom
od/merged_block_sim

Conversation

@0w3n-d

@0w3n-d 0w3n-d commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Issue: #500 (step 1 of 4)

What this PR does

Adds a block_merging_enabled: Arc<AtomicBool> flag (seeded from config.block_merging_config.is_enabled), owned alongside BlockMergingTile and toggled via new POST/DELETE /admin/v1/block-merging admin routes, mirroring the existing /admin/v1/killswitch pattern. While disabled, the tile never dials the merge builder and force-disconnects any active connection (re-disconnecting on every subsequent reconnect attempt, since the underlying TcpConnector auto-reconnects outbound connections and has no permanent-remove API). /admin/v1/status now also reports block_merging_enabled.

What this PR deliberately does not do

No simulation wiring. This step only adds the admin-toggled kill switch and the tile's reaction to it — merged blocks still forward to the auctioneer exactly as before. Simulating merged blocks, attributing failures to the builder, and tripping this flag automatically are later steps (#500).

Tests

Written first, reviewed, then implemented against:

  • crates/relay/src/block_merging/tile.rs: unit tests over the extracted pure gating functions should_dial/should_force_disconnect, covering all four (enabled, has_token) combinations.
  • crates/relay/src/api/admin_service.rs: test_admin_service_block_merging, mirroring the existing test_admin_service/test_admin_service_merged_headers pattern.

just fmt-check, cargo clippy --all-features --no-deps -- -D warnings, and just test (full workspace) all pass. One unrelated pre-existing flaky test (helix-types::clock::test_duration_into_slot, a timing-sensitive test unrelated to this change) intermittently fails under parallel test-thread contention but passes in isolation.

Reviewer checklist

  • CI (lint, unit-test) is green
  • Matches the linked issue/step
  • No unexplained scope creep or unrelated files touched

0w3n-d and others added 2 commits August 28, 2026 13:44
Gates BlockMergingTile's dial/reconnect on a new admin-toggled flag,
mirroring the existing killswitch pattern. While disabled, the tile
never dials and force-disconnects any active merge builder connection.
No simulation wiring yet — that's a later step.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The connection isn't the problem: outbound TcpConnector auto-reconnects
with no permanent-remove API, so disconnecting on disable just made the
connection flap every ~2s (the connector's default reconnect interval)
for as long as the flag stayed off.

Instead, block_merging_enabled now gates the data flow, not the socket:
dial/handshake/ping-pong run unconditionally, forward_decoded and
on_top_bid no-op while disabled, and incoming MergedBlockV1 is silently
dropped. The merged-block handling is extracted into a standalone
handle_merged_block() so that gating (and the surrounding compute) is
unit-testable without a live connection.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@0w3n-d
0w3n-d force-pushed the od/merged_block_sim branch from 400bcdd to b03ab82 Compare August 28, 2026 12:44
@0w3n-d
0w3n-d merged commit a122a02 into develop Aug 29, 2026
2 checks passed
@0w3n-d
0w3n-d deleted the od/merged_block_sim branch August 29, 2026 13:19
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.

1 participant