Skip to content

refactor: node mode two regimes - #5596

Open
martinconic wants to merge 15 commits into
masterfrom
refactor/node-mode-two-regimes
Open

refactor: node mode two regimes#5596
martinconic wants to merge 15 commits into
masterfrom
refactor/node-mode-two-regimes

Conversation

@martinconic

Copy link
Copy Markdown
Contributor

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Follow-up to #5431, addressing the upgrade-path review from @gacevicljubisa. Stacked on refactor/node-mode-config.

The legacy branch in resolveNodeMode applied some of the new semantics (strict validation, swap forced on) but not all (no defaults restored for light nodes), so existing configs broke in both directions. This PR replaces it with two regimes selected by one switch: whether node-mode is set.

node-mode unset (legacy): behaves exactly as releases before node-mode existed.

  • chequebook-enable and storage-incentives-enable fall back to their former default of true when not set. Both remain gated in NewBee (chequebook on swap, incentives on full mode), so nothing starts that the previous release would not have started.
  • Mode is inferred as before: full-node: true gives full, otherwise an RPC endpoint gives light, otherwise ultra-light.
  • No new validation. The only check kept is that a full node has an RPC endpoint; previous releases enabled the chain backend for every full node and failed at chain init without one, so this changes the message, not the outcome.
  • One deprecation warning names the inferred mode and the removal release (v2.11.0, a constant in start.go).

node-mode set: the mode owns the config.

  • full requires an RPC endpoint and implies swap-enable, chequebook-enable and storage-incentives-enable unless explicitly disabled. An explicit opt-out is honoured and logged as a warning. Bootnodes are exempt from the implied options because NewBee never starts swap, push-sync or the incentives agent for them.
  • light requires an RPC endpoint. Swap and chequebook stay off unless set. storage-incentives-enable: true is rejected.
  • ultra-light rejects swap-enable: true and storage-incentives-enable: true. An RPC endpoint is ignored.
  • chequebook-enable: true with swap-enable: false is rejected in every mode. Implied values never produce this combination, so it is always an explicit contradiction.

node-mode: full is now sufficient on its own. validateFullMode and the --full-node restore loop are gone.

The node-mode flag default is now empty instead of ultra-light, so an unset value selects the legacy regime without relying on viper's IsSet semantics for pflag defaults, and --help no longer shows a default that does not describe what happens.

Packaging: BEE_NODE_MODE added to the docker-compose passthrough and the env template, BEE_FULL_NODE marked deprecated, stale true defaults for BEE_CHEQUEBOOK_ENABLE and BEE_STORAGE_INCENTIVES_ENABLE corrected, bee.yaml variants document the implied options and the deprecated inference.

Behaviour matrix

Config Regime Result
RPC + swap-enable: true, nothing else legacy light, chequebook true (was silently lost)
chequebook-enable: true, swap unset legacy starts, ultra-light (was hard exit)
full-node: true + bootnode-mode: true + incentives false legacy full, starts (was hard exit)
full-node: true + RPC only legacy full, swap false, chequebook true, incentives true (master verbatim)
full-node: true, no RPC legacy error, as before but earlier
node-mode: full + RPC only new full, swap/chequebook/incentives all true
node-mode: full + storage-incentives-enable: false new full, incentives false, warning
node-mode: full + swap-enable: false new full, swap and chequebook false, incentives true
node-mode: full + bootnode-mode: true + RPC new full, nothing implied
node-mode: light + RPC new light, swap false
node-mode: light + chequebook-enable: true, swap unset new error
node-mode: ultra-light + swap-enable: true new error
node-mode: full, no RPC new error

Test plan

  • TestResolveNodeMode covers every row above through viper.New().
  • TestResolveNodeModeWithBoundFlags runs the resolver against the real bound start flags, so the empty node-mode default selects the legacy regime and the sub-option flag defaults do not count as set.
  • make lint (0 issues), go vet, full go test ./... pass.
  • Binary smoke tests with dist/bee start against an unreachable RPC endpoint (reaching chain init proves resolution passed):
    • legacy, no flags: starts as ultra-light, one deprecation warning naming the mode and v2.11.0
    • legacy, chequebook-enable: true without swap: starts as ultra-light (was a hard exit)
    • legacy, RPC + swap-enable: true: light, chequebook restored, reaches chain init
    • legacy, full-node + bootnode-mode + storage-incentives-enable: false: full, reaches chain init (was a hard exit)
    • legacy, full-node without RPC: clear error
    • node-mode: full + RPC only: swap, chequebook, incentives implied (debug log), reaches chain init
    • node-mode: full + storage-incentives-enable: false: opt-out honoured with a warning
    • node-mode: full without RPC, light + chequebook without swap, ultra-light + swap: rejected with clear errors
  • Beekeeper local.yaml still uses full-node; it keeps working via the legacy regime and migrates to node-mode in a follow-up beekeeper PR.

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

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.
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.
Split resolveNodeMode into a legacy regime (node-mode unset) that
reproduces the behaviour of releases before node-mode existed, and a
mode-owned regime (node-mode set) where the mode supplies defaults for
swap-enable, chequebook-enable and storage-incentives-enable.

Legacy regime: restore the former true defaults of chequebook-enable and
storage-incentives-enable when unset, infer the mode from full-node and
blockchain-rpc-endpoint as before, apply no new validation, and log a
deprecation warning naming the inferred mode and the removal release.
This fixes upgraded configs that were broken in both directions: a light
node with swap-enable only silently lost cheque settlement, and a config
carrying the old chequebook-enable default without swap, or a bootnode
with storage-incentives-enable false, refused to start.

Mode-owned regime: full implies swap, chequebook and incentives unless
explicitly disabled (bootnodes exempt, NewBee never starts them there),
light and full require blockchain-rpc-endpoint, and options a mode
cannot support are rejected only when explicitly enabled. node-mode=full
is now sufficient on its own; validateFullMode and the full-node restore
loop are removed.

The node-mode flag default becomes empty so an unset value selects the
legacy regime without relying on viper's IsSet semantics for pflag
defaults. Tests cover both regimes, including a run against the real
bound start flags.
… defaults

Add BEE_NODE_MODE to the docker-compose environment passthrough and the
env template, mark BEE_FULL_NODE deprecated, and correct the stale true
defaults documented for BEE_CHEQUEBOOK_ENABLE and
BEE_STORAGE_INCENTIVES_ENABLE. Document in the bee.yaml variants that
full mode implies the swap, chequebook and incentives options and that
an unset node-mode falls back to deprecated inference.
@martinconic martinconic changed the title Refactor/node mode two regimes refactor: node mode two regimes Sep 3, 2026
@martinconic
martinconic marked this pull request as ready for review September 3, 2026 13:02

@sbackend123 sbackend123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread cmd/bee/cmd/start.go
}
}
modeStr := c.config.GetString(optionNameNodeMode)
if modeStr == "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems, this differs from the documented distinction based on whether node-mode is set. Should we use IsSet to distinguish an omitted value from an explicitly empty one?

Comment thread packaging/docker/env
# BEE_CACHE_RETRIEVAL=true
## enable chequebook (default true)
# BEE_CHEQUEBOOK_ENABLE=true
## enable chequebook; requires swap; implied by BEE_NODE_MODE=full (default false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When BEE_NODE_MODE is unset, the legacy resolver restores chequebook-enable to true. Could we clarify that false applies only when BEE_NODE_MODE is explicitly set?

@martinconic
martinconic changed the base branch from refactor/node-mode-config to master September 4, 2026 12:11
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.

3 participants