refactor: replace full-node flag with explicit node-mode config - #5431
refactor: replace full-node flag with explicit node-mode config#5431martinconic wants to merge 12 commits into
Conversation
|
Beekeeper changes are also needed |
|
needs a rebase |
b374fd7 to
b58c43a
Compare
akrem-chabchoub
left a comment
There was a problem hiding this comment.
Thanks @martinconic, Glad to see this change, It will simplify and enhance the UX 🚀
|
What's the actual difference between |
The actual semantics are:
Functionally yes, we need them both, because swap=on, chequebook=off (receive-only / cash-out-only) is a genuine state. It's useful for: a node booting before its chequebook is funded, an operator who wants to earn from serving content without depositing collateral yet, and any deferred-funding workflow. |
Resolves a conflict in pkg/node/node.go where master (#5460) added a startup block-height verification guard for the postage listener, while this branch replaced the o.FullNodeMode bool with o.NodeMode == FullMode. Resolution keeps master's new guard and applies the NodeMode predicate to the subsequent batch-service start branch.
akrem-chabchoub
left a comment
There was a problem hiding this comment.
Just there are some git conflicts
New things were merged until my last commit, so yes, will address the merge conflicts. |
Resolved packaging yaml conflicts (bee, scoop, homebrew-amd64, homebrew-arm64): kept the mode-based section layout from this branch and added the new 'use-simd-hashing' option from master. The p2p-wss, nat-wss, autotls, and withdrawal-addresses-whitelist options master appended already exist in the reorganized Network/Payments sections, so master's duplicates were dropped.
Resolve conflicts from v2.8.0 (#5477): - cmd.go: keep node-mode flag and deprecated full-node path while adding master's chequebook-verification and chequebook-min-balance flags; keep chequebook-enable default of false. - node.go: take master's chain-enabled chequebook factory init (wallet ERC20 resolution); adapt new chequebook-verification check to use NodeMode == FullMode instead of the removed FullNodeMode field. - packaging/*.yaml: keep the section-organized layout and add the new chequebook-verification option.
| } { | ||
| if !c.config.IsSet(key) { | ||
| logger.Warning("enabling option implied by legacy --full-node; set it explicitly or use --node-mode=full", "option", key) | ||
| c.config.Set(key, true) |
There was a problem hiding this comment.
For old users who ran a full node with swap-enable left at its default (false, never explicitly set), upgrading while still using the deprecated --full-node flag causes swap-enable,chequebook-enable and storage-incentives-enable to be silently forced to change on startup. This is only surfaced via a log, which is easy to miss maybe ?
Does this not risk misbehavior or misunderstanding for node operators ?
There was a problem hiding this comment.
Prior to this PR, chequebook-enable and storage-incentives-enable actually defaulted to true. So an existing full node was already running with chequebook and incentives active.
When we corrected those defaults to false in this PR to make the new configuration explicit, an existing --full-node config that relied on the old defaults would suddenly fail startup validation after an upgrade.
The auto-enable logic in the legacy fallback doesn't introduce unexpected behavior—it restores the previous implicit full-node stack so existing nodes don't crash on upgrade, while logging clear warnings advising operators to migrate to --node-mode=full. Crucially, it only applies to options left unset; an explicit false is never overridden and still fails validation as expected.
There was a problem hiding this comment.
Requesting changes on the upgrade path. The legacy branch currently gets some of the new semantics (strict validation, swap forced on) but not all (no defaults restored for light nodes), so existing configs break in both directions:
- light node with swap-enable: true, no chequebook-enable → chequebook-enable default flipped (cmd.go:363), nothing restores it, SetPayFunc never installed (node.go:1115) — starts clean, silently loses cheque settlement
- any config still carrying chequebook-enable: true without swap (the old shipped default, still in packaging/docker/env) → exits at start.go:417; master silently gated this under swap (node.go:595)
- bootnode with storage-incentives-enable: false → exits at start.go:472, though node.go:1295 never starts the agent for bootnodes anyway
- BEE_NODE_MODE missing from the compose passthrough (docker-compose.yml:33)
None of these are in the test plan, and the tests go through a bare viper.New() so the pflag default of ultra-light (which must not count as set) is never exercised.
Proposal: two regimes, one switch.
- node-mode unset → master's behavior verbatim: old defaults, old inference, no new validation. Log a deprecation warning with the equivalent node-mode: line and the release it will be removed in.
- node-mode set → the mode owns the config, no sub-flags: ultra-light = no chain/swap/incentives, light = chain + swap, full = chain + swap + incentives. full-node, swap-enable, chequebook-enable, storage-incentives-enable become deprecated and warn; explicit contradictions error. The cost is a chequebook deploy on light nodes, which only needs gas (swap-initial-deposit is 0) — and a light node that buys stamps needs gas anyway.
That removes the restore loop and validateFullMode entirely (only "chain required for light/full" remains), gives a clean cutover date, and makes node-mode: full sufficient on its own — today it's rejected without three more flags.
Checklist
Description
Fixes #5172. The previous approach to node mode was implicit and
inconsistent: the mode was inferred from a combination of
--full-node(bool) and whether
blockchain-rpc-endpointwas non-empty, whichdiverged from the documented definition of modes and allowed silent
misconfigurations.
This PR introduces a single explicit
--node-modeoption with threevalid values:
full,light, andultra-light.Key changes:
NodeModestring type added topkg/nodewith constantsFullMode,LightMode,UltraLightMode; replacesFullNodeMode boolinOptions--node-modeflag added;--full-nodedeprecated with a warningpointing to
--node-mode=full(see Backward compatibility below)resolveNodeMode()instart.goenforces mode requirements at startup:fullblockchain-rpc-endpoint+swap-enable: true+chequebook-enable: true+storage-incentives-enable: truelightblockchain-rpc-endpoint(swap-enableoptional;chequebook-enablerequiresswap-enable)ultra-lightswap-enablemust be false (blockchain-rpc-endpointignored if set)isChainEnabledrewritten: no longer infers chain state from the RPCendpoint string — now reads directly from
NodeModestorage-incentives-enabledefault corrected tofalse(full node only)chequebook-enabledefault corrected tofalse(requires swap-enable)bee.yaml, scoop, homebrew-amd64, homebrew-arm64)restructured into labelled mode-based sections
Backward compatibility
chequebook-enableandstorage-incentives-enablepreviously defaulted totrue, and--full-nodeimplied them. With the correctedfalsedefaults, anexisting
--full-nodeconfig that relied on those implicit values would nowfail strict full-mode validation and the node would not start after upgrade.
To keep upgrades smooth, a legacy
--full-node: trueconfig (whennode-modeis not set) still starts:
swap-enable,chequebook-enableandstorage-incentives-enableare auto-enabled for any the operator did not setexplicitly, a deprecation warning is logged for each, and the node comes up as a
fully-functional full node. This is a restoration of the previous implied
behavior — not silent degradation: the node runs full with chequebook and
incentives on, exactly as before.
The compatibility default only fills in values left unset. It does not mask
genuine misconfigurations:
falsewhile requesting a fullnode still fails validation;
blockchain-rpc-endpoint— that cannot beinferred;
--node-mode=fullpath is unaffected and remains strict (noauto-enable), since it is the new, intentional model.
Test plan
node-mode: ultra-lightand no RPC — node starts cleanlynode-mode: light, no RPC — rejected with clear errornode-mode: light+ RPC — node starts in light modenode-mode: full, no RPC — rejected with clear errornode-mode: full+ RPC +swap-enable: false— rejectednode-mode: full+ RPC +swap-enable: true+ cb/incentives — full nodefull-node: true— deprecation warning, behaves asnode-mode: fullfull-node: true+ onlyblockchain-rpc-endpoint(no swap/chequebook/incentives) — swap/chequebook/incentives auto-enabled with warnings, starts as full nodefull-node: true+chequebook-enable: false— still rejected (explicit disable not masked)full-node: true+ noblockchain-rpc-endpoint— still rejectednode-mode: ultra-light+swap-enable: true— rejected--node-modetakes precedence over legacy--full-nodewith warningnode-mode: ultra-lightwith RPC endpoint ignores RPC and starts cleanlynode-mode: lightwith RPC + swap + chequebook starts cleanly"", uppercase, whitespace) rejectedAI Disclosure