Skip to content

refactor: replace full-node flag with explicit node-mode config - #5431

Open
martinconic wants to merge 12 commits into
masterfrom
refactor/node-mode-config
Open

refactor: replace full-node flag with explicit node-mode config#5431
martinconic wants to merge 12 commits into
masterfrom
refactor/node-mode-config

Conversation

@martinconic

@martinconic martinconic commented Apr 9, 2026

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

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-endpoint was non-empty, which
diverged from the documented definition of modes and allowed silent
misconfigurations.

This PR introduces a single explicit --node-mode option with three
valid values: full, light, and ultra-light.

Key changes:

  • NodeMode string type added to pkg/node with constants FullMode,
    LightMode, UltraLightMode; replaces FullNodeMode bool in Options
  • --node-mode flag added; --full-node deprecated with a warning
    pointing to --node-mode=full (see Backward compatibility below)
  • resolveNodeMode() in start.go enforces mode requirements at startup:
    Mode Requires
    full blockchain-rpc-endpoint + swap-enable: true + chequebook-enable: true + storage-incentives-enable: true
    light blockchain-rpc-endpoint (swap-enable optional; chequebook-enable requires swap-enable)
    ultra-light swap-enable must be false (blockchain-rpc-endpoint ignored if set)
  • isChainEnabled rewritten: no longer infers chain state from the RPC
    endpoint string — now reads directly from NodeMode
  • storage-incentives-enable default corrected to false (full node only)
  • chequebook-enable default corrected to false (requires swap-enable)
  • All packaging yamls (bee.yaml, scoop, homebrew-amd64, homebrew-arm64)
    restructured into labelled mode-based sections

Backward compatibility

chequebook-enable and storage-incentives-enable previously defaulted to
true, and --full-node implied them. With the corrected false defaults, an
existing --full-node config that relied on those implicit values would now
fail strict full-mode validation and the node would not start after upgrade.

To keep upgrades smooth, a legacy --full-node: true config (when node-mode
is not set) still starts: swap-enable, chequebook-enable and
storage-incentives-enable are auto-enabled for any the operator did not set
explicitly, 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:

  • explicitly setting any of those options to false while requesting a full
    node still fails validation;
  • a full node still requires blockchain-rpc-endpoint — that cannot be
    inferred;
  • the explicit --node-mode=full path is unaffected and remains strict (no
    auto-enable), since it is the new, intentional model.

Test plan

  • Start with node-mode: ultra-light and no RPC — node starts cleanly
  • Start with node-mode: light, no RPC — rejected with clear error
  • Start with node-mode: light + RPC — node starts in light mode
  • Start with node-mode: full, no RPC — rejected with clear error
  • Start with node-mode: full + RPC + swap-enable: false — rejected
  • Start with node-mode: full + RPC + swap-enable: true + cb/incentives — full node
  • Start with legacy full-node: true — deprecation warning, behaves as node-mode: full
  • Start with legacy full-node: true + only blockchain-rpc-endpoint (no swap/chequebook/incentives) — swap/chequebook/incentives auto-enabled with warnings, starts as full node
  • Start with legacy full-node: true + chequebook-enable: false — still rejected (explicit disable not masked)
  • Start with legacy full-node: true + no blockchain-rpc-endpoint — still rejected
  • Start with node-mode: ultra-light + swap-enable: true — rejected
  • --node-mode takes precedence over legacy --full-node with warning
  • node-mode: ultra-light with RPC endpoint ignores RPC and starts cleanly
  • node-mode: light with RPC + swap + chequebook starts cleanly
  • Invalid string formats ("", uppercase, whitespace) rejected

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.

@martinconic martinconic added this to the 2026 milestone Apr 9, 2026
@martinconic martinconic added enhancement enhancement of existing functionality user-experience issue affecting user experience labels Apr 9, 2026
@martinconic martinconic self-assigned this Apr 9, 2026
@martinconic

Copy link
Copy Markdown
Contributor Author

Beekeeper changes are also needed

Comment thread .github/workflows/beekeeper.yml
@acud

acud commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

needs a rebase

@martinconic
martinconic force-pushed the refactor/node-mode-config branch from b374fd7 to b58c43a Compare April 16, 2026 09:12

@akrem-chabchoub akrem-chabchoub 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.

Thanks @martinconic, Glad to see this change, It will simplify and enhance the UX 🚀

Comment thread cmd/bee/cmd/cmd.go
@Cafe137

Cafe137 commented Apr 23, 2026

Copy link
Copy Markdown

What's the actual difference between swap-enable and chequebook-enable? Do we really need both?

@martinconic

Copy link
Copy Markdown
Contributor Author

What's the actual difference between swap-enable and chequebook-enable? Do we really need both?

The actual semantics are:

  • swap-enable = "participate in the swap settlement protocol at all" (peer cheque protocol + factory + cashout).
  • chequebook-enable = "I have funded my own chequebook and want to pay peers with cheques."

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 akrem-chabchoub 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.

Just there are some git conflicts

@martinconic

Copy link
Copy Markdown
Contributor Author

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.
Comment thread cmd/bee/cmd/start.go
Comment thread cmd/bee/cmd/start.go
} {
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)

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.

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 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@gacevicljubisa gacevicljubisa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@martinconic martinconic mentioned this pull request Sep 3, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement enhancement of existing functionality user-experience issue affecting user experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate and refactor Bee node modes in node.go

7 participants