Skip to content

Add admin-toggled block_merging_enabled kill switch - #502

Open
0w3n-d wants to merge 1 commit into
developfrom
od/merged_block_sim
Open

Add admin-toggled block_merging_enabled kill switch#502
0w3n-d wants to merge 1 commit 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

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>
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