Skip to content

slave (M3): add slave boot and lifecycle#38

Open
syntrust wants to merge 13 commits into
slave-m2from
slave-m3
Open

slave (M3): add slave boot and lifecycle#38
syntrust wants to merge 13 commits into
slave-m2from
slave-m3

Conversation

@syntrust

@syntrust syntrust commented Jul 14, 2026

Copy link
Copy Markdown

Milestone M3 of #17, stacked on #26 (base: slave-m2).

Boots a slave identity end to end: slave --cluster_config <file> --node_id S0 starts every owned shard, runs until SIGINT/SIGTERM, and shuts down cleanly. No network I/O.

What's included

  • qkc/slave: SlaveBackend with a branch-keyed shard registry (mirrors pyquarkchain SlaveServer); the slave process itself owns no database. Stop() is idempotent and blocks until every shard and chaindb is closed.
  • cmd/slave: default run action — a drop-in for how pyquarkchain's cluster.py launches a slave — with signal-driven shutdown; a second signal force-quits.

Test plan

  • go build ./cmd/slave && go test ./qkc/... ./cmd/slave/ — 131 tests / 12 packages green; gofmt/vet clean.
  • New tests: slave boot + reopen over the {mainnet, devnet} fixtures; rollback via a failing ChainService injected through Options.Chain (pebble's directory lock proves the DBs were closed); idempotent Stop; cmd-level bootSlave pipeline with DB_PATH_ROOT redirected to a temp dir.
  • Manual demo: boot S0 from the devnet fixture → per-shard shard started genesis=0x… head=0^C exits 0 → rerun on the same datadir logs existing genesis validated per shard (via qkc/shard.ReconcileGenesisRecord, slave (M2): add shard skeleton with ShardChain stub and genesis record #26).

🤖 Generated with Claude Code

@syntrust syntrust changed the title qkc/slave: add slave boot and lifecycle (M3) slave (M3): add slave boot and lifecycle Jul 14, 2026
@syntrust
syntrust marked this pull request as ready for review July 14, 2026 11:11
syntrust and others added 5 commits July 15, 2026 10:10
…boot

The slave performs no network I/O of any kind, but registering all of
geth's debug.Flags made --pprof start an HTTP listener and --pyroscope
push to a remote server. Register an allowlisted subset instead: logging
and file-based profiling only, fail-closed against upstream additions,
with a test pinning the boundary in both directions.

Install the SIGINT/SIGTERM handler before any resource opens, so a
signal that lands during config load or shard boot still funnels into
the blocking Stop() path instead of the OS default termination. A
watcher restores default signal handling the moment the first signal
lands, keeping the second-signal force-quit available even mid-boot.
Covered by a reexec subprocess test that signals at the 'slave booting'
line and asserts a clean exit plus a reopenable datadir.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The pattern was added with a leading space, which is significant in
gitignore syntax, so it never matched anything. Remove it rather than
fix it and restore the trailing newline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
syntrust and others added 5 commits July 16, 2026 16:18
Take the finalized cmd/slave CLI shape from slave-m2 and relocate the boot
tests it superseded: the fixture helpers, TestBootSlave, and
TestBootSlaveRejectsBadNodeID move from slave_test.go (owned by slave-m1) into
run_test.go, which also adopts its final goleak TestMain form; run.go and
qkc/slave pick up their follow-up TODO markers. main.go keeps only the
one-line app.Action wiring on top of slave-m2.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The README baseline now carries the final section structure; keep only the
'Running a slave' section on top (its milestone marker dropped with the rest).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 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