Skip to content

Commit 31d1baa

Browse files
committed
feat(cmd): add --light-node-limit CLI and config option
Backport of ethersphere#5559 onto the v2.8.1 tag, unchanged. v2.8.1 already carries LightNodeLimit in libp2p.Options and already honours it, so this adds only the CLI flag and the node.Options passthrough that were missing. The flag defaults to 100, which is defaultLightNodeLimit, so a node started without it behaves exactly as stock v2.8.1 does. Carried here because swarm-stream-loadlab measures the light-node connection ceiling against ethersphere#5556, and that needs the limit configurable on the version we actually run.
1 parent 7cf5319 commit 31d1baa

7 files changed

Lines changed: 13 additions & 0 deletions

File tree

cmd/bee/cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const (
5858
optionNameChequebookVerification = "chequebook-verification"
5959
optionNameChequebookMinBalance = "chequebook-min-balance"
6060
optionNameFullNode = "full-node"
61+
optionNameLightNodeLimit = "light-node-limit"
6162
optionNamePostageContractAddress = "postage-stamp-address"
6263
optionNamePostageContractStartBlock = "postage-stamp-start-block"
6364
optionNamePriceOracleAddress = "price-oracle-address"
@@ -309,6 +310,7 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
309310
cmd.Flags().Bool(optionNameChequebookVerification, false, "reject full-node hive/handshake records that carry no chequebook address")
310311
cmd.Flags().String(optionNameChequebookMinBalance, "110000000000000000", "minimum chequebook token balance required for verification, in token small units (default 11 BZZ)")
311312
cmd.Flags().Bool(optionNameFullNode, false, "cause the node to start in full mode")
313+
cmd.Flags().Int(optionNameLightNodeLimit, 100, "light node limit")
312314
cmd.Flags().String(optionNamePostageContractAddress, "", "postage stamp contract address")
313315
cmd.Flags().Uint64(optionNamePostageContractStartBlock, 0, "postage stamp contract start block number")
314316
cmd.Flags().String(optionNamePriceOracleAddress, "", "price oracle contract address")

cmd/bee/cmd/start.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo
329329
AutoTLSDomain: c.config.GetString(optionAutoTLSDomain),
330330
AutoTLSRegistrationEndpoint: c.config.GetString(optionAutoTLSRegistrationEndpoint),
331331
FullNodeMode: fullNode,
332+
LightNodeLimit: c.config.GetInt(optionNameLightNodeLimit),
332333
Logger: logger,
333334
MinimumGasTipCap: c.config.GetUint64(optionNameMinimumGasTipCap),
334335
GasLimitFallback: c.config.GetUint64(optionNameGasLimitFallback),

packaging/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ password-file: "/var/lib/bee/password"
145145
# autotls-ca-endpoint: ""
146146
## SIMD BMT hashing opt-in flag (only available on linux amd64)
147147
# use-simd-hashing: false
148+
## limit of possible connected light nodes (default: 100)
149+
# light-node-limit: 100

packaging/homebrew-amd64/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ password-file: "/usr/local/var/lib/swarm-bee/password"
145145
# autotls-ca-endpoint: ""
146146
## SIMD BMT hashing opt-in flag (only available on linux amd64)
147147
# use-simd-hashing: false
148+
## limit of possible connected light nodes (default: 100)
149+
# light-node-limit: 100

packaging/homebrew-arm64/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ password-file: "/opt/homebrew/var/lib/swarm-bee/password"
145145
# autotls-ca-endpoint: ""
146146
## SIMD BMT hashing opt-in flag (only available on linux amd64)
147147
# use-simd-hashing: false
148+
## limit of possible connected light nodes (default: 100)
149+
# light-node-limit: 100

packaging/scoop/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ password-file: "./password"
145145
# autotls-ca-endpoint: ""
146146
## SIMD BMT hashing opt-in flag (only available on linux amd64)
147147
# use-simd-hashing: false
148+
## limit of possible connected light nodes (default: 100)
149+
# light-node-limit: 100

pkg/node/node.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ type Options struct {
164164
AutoTLSDomain string
165165
AutoTLSRegistrationEndpoint string
166166
FullNodeMode bool
167+
LightNodeLimit int
167168
GasLimitFallback uint64
168169
Logger log.Logger
169170
MinimumGasTipCap uint64
@@ -707,6 +708,7 @@ func NewBee(
707708
AutoTLSCAEndpoint: o.AutoTLSCAEndpoint,
708709
WelcomeMessage: o.WelcomeMessage,
709710
FullNode: o.FullNodeMode,
711+
LightNodeLimit: o.LightNodeLimit,
710712
Nonce: nonce,
711713
AllowPrivateCIDRs: o.AllowPrivateCIDRs,
712714
Registry: registry,

0 commit comments

Comments
 (0)