Add opt-in headless staking (mine → fund → stake without the GUI) - #40
Add opt-in headless staking (mine → fund → stake without the GUI)#40br33zybail wants to merge 1 commit into
Conversation
Headless operators currently have no way to stake: the wallet's staking actions exist but are only reachable from GUI buttons. This wires them to the built-in headless wallet behind env flags, everything OFF by default: - CROSSLINK_AUTO_SEND=1: runtime switch for the existing (compile-time disabled) AUTO_SPEND miner->user forwarding path - CROSSLINK_AUTO_STAKE=1: bond spendable user funds to a finalizer during staking windows (every 150 blocks; acts only in the first 60 so the tx confirms in-window; at most one bond per window; first bond of any size registers the finalizer, afterwards only chunks >= 1 cTAZ to avoid dust) - CROSSLINK_STAKE_TARGET: optional 64-hex target key in the same display byte order the GUI stake box accepts; defaults to this node's own finalizer key (via TENDERLINK_PUBLIC_KEY, with an all-zero guard) Bonds go through the wallet's existing action queue (stake_to_finalizer), identical to the GUI path. Documented in README. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hfv59KmT627YnkA3BhhqgD
|
Hey @br33zybail, thanks for this effort towards addressing this user need. I unfortunately don't think this PR should be merged as-is. Concretely:
More subjective/design considerations: This may be just a subjective thing - I'm not personally a fan of environment variables for this kind of thing. As it's set-once persistent config, it should probably live in the config TOML. I think in principle that autostaking would be useful, but without the ability to at least redelegate, it seems like it doesn't let stakers make appropriate adjustments to account for finalizer behaviour - i.e. they can't fully carry out their role within Crosslink. A more basic single staking RPC (allowing for different staking action types) would probably be more useful. Autostaking could be either implemented in the alongside this, or as an external script that uses the RPC. Thanks again for taking a crack at this, it's genuinely appreciated. |
Motivation
Operators running headless builds (increasingly common — thanks to #33 the visualizer is now optional) currently have no way to stake: the wallet has
stake_to_finalizer()and friends, but they're only reachable from GUI buttons. This came up again in the Signal group today ("How can we stake in the current setup if we're running a node headless? … it looks like there are wallet functions for staking but not sure if they're connected to RPC calls").What this does
Wires the existing wallet staking actions to the built-in headless wallet, gated by environment variables. Everything is off by default — with no env vars set, behavior is unchanged.
CROSSLINK_AUTO_SEND=1AUTO_SPEND) miner→user forwarding pathCROSSLINK_AUTO_STAKE=1CROSSLINK_STAKE_TARGET=<64 hex>Guardrails on the auto-stake path:
TENDERLINK_PUBLIC_KEYat stake time with an all-zero guard (never bonds before the BFT service publishes the key)actions_in_flightqueue — the identical code path the GUI buttons use, including the in-flight dedup checkTesting
cargo build --release -p zebradclean (no new warnings)addr_from_str_bytessemantics mirrored)Notes for reviewers
CROSSLINK_AUTO_SENDgate deliberately reuses the dev-writtenAUTO_SPENDblock rather than duplicating it — the const staysfalse, the env var just makes it reachable at runtime.