Commit 3ff1214a authored by Anatol's avatar Anatol Committed by GitHub

refactor: remove standalone mode (#2331)

parent b90e92cd
...@@ -40,7 +40,6 @@ const ( ...@@ -40,7 +40,6 @@ const (
optionNameNetworkID = "network-id" optionNameNetworkID = "network-id"
optionWelcomeMessage = "welcome-message" optionWelcomeMessage = "welcome-message"
optionCORSAllowedOrigins = "cors-allowed-origins" optionCORSAllowedOrigins = "cors-allowed-origins"
optionNameStandalone = "standalone"
optionNameTracingEnabled = "tracing-enable" optionNameTracingEnabled = "tracing-enable"
optionNameTracingEndpoint = "tracing-endpoint" optionNameTracingEndpoint = "tracing-endpoint"
optionNameTracingHost = "tracing-host" optionNameTracingHost = "tracing-host"
...@@ -217,7 +216,6 @@ func (c *command) setAllFlags(cmd *cobra.Command) { ...@@ -217,7 +216,6 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
cmd.Flags().String(optionNameDebugAPIAddr, ":1635", "debug HTTP API listen address") cmd.Flags().String(optionNameDebugAPIAddr, ":1635", "debug HTTP API listen address")
cmd.Flags().Uint64(optionNameNetworkID, 10, "ID of the Swarm network") cmd.Flags().Uint64(optionNameNetworkID, 10, "ID of the Swarm network")
cmd.Flags().StringSlice(optionCORSAllowedOrigins, []string{}, "origins with CORS headers enabled") cmd.Flags().StringSlice(optionCORSAllowedOrigins, []string{}, "origins with CORS headers enabled")
cmd.Flags().Bool(optionNameStandalone, false, "whether we want the node to start with no listen addresses for p2p")
cmd.Flags().Bool(optionNameTracingEnabled, false, "enable tracing") cmd.Flags().Bool(optionNameTracingEnabled, false, "enable tracing")
cmd.Flags().String(optionNameTracingEndpoint, "127.0.0.1:6831", "endpoint to send tracing data") cmd.Flags().String(optionNameTracingEndpoint, "127.0.0.1:6831", "endpoint to send tracing data")
cmd.Flags().String(optionNameTracingHost, "", "host to send tracing data") cmd.Flags().String(optionNameTracingHost, "", "host to send tracing data")
......
...@@ -173,7 +173,6 @@ inability to use, or your interaction with other nodes or the software.`) ...@@ -173,7 +173,6 @@ inability to use, or your interaction with other nodes or the software.`)
WelcomeMessage: c.config.GetString(optionWelcomeMessage), WelcomeMessage: c.config.GetString(optionWelcomeMessage),
Bootnodes: networkConfig.bootNodes, Bootnodes: networkConfig.bootNodes,
CORSAllowedOrigins: c.config.GetStringSlice(optionCORSAllowedOrigins), CORSAllowedOrigins: c.config.GetStringSlice(optionCORSAllowedOrigins),
Standalone: c.config.GetBool(optionNameStandalone),
TracingEnabled: c.config.GetBool(optionNameTracingEnabled), TracingEnabled: c.config.GetBool(optionNameTracingEnabled),
TracingEndpoint: tracingEndpoint, TracingEndpoint: tracingEndpoint,
TracingServiceName: c.config.GetString(optionNameTracingServiceName), TracingServiceName: c.config.GetString(optionNameTracingServiceName),
......
...@@ -62,8 +62,6 @@ password-file: /var/lib/bee/password ...@@ -62,8 +62,6 @@ password-file: /var/lib/bee/password
# postage-stamp-address: "" # postage-stamp-address: ""
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url ## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# resolver-options: [] # resolver-options: []
## whether we want the node to start with no listen addresses for p2p
# standalone: false
## enable swap (default true) ## enable swap (default true)
# swap-enable: true # swap-enable: true
## swap ethereum blockchain endpoint (default "ws://localhost:8546") ## swap ethereum blockchain endpoint (default "ws://localhost:8546")
......
...@@ -45,7 +45,6 @@ services: ...@@ -45,7 +45,6 @@ services:
- BEE_PAYMENT_TOLERANCE - BEE_PAYMENT_TOLERANCE
- BEE_POSTAGE_STAMP_ADDRESS - BEE_POSTAGE_STAMP_ADDRESS
- BEE_RESOLVER_OPTIONS - BEE_RESOLVER_OPTIONS
- BEE_STANDALONE
- BEE_SWAP_ENABLE - BEE_SWAP_ENABLE
- BEE_SWAP_ENDPOINT - BEE_SWAP_ENDPOINT
- BEE_SWAP_FACTORY_ADDRESS - BEE_SWAP_FACTORY_ADDRESS
......
...@@ -69,8 +69,6 @@ BEE_CLEF_SIGNER_ENABLE=true ...@@ -69,8 +69,6 @@ BEE_CLEF_SIGNER_ENABLE=true
# BEE_POSTAGE_STAMP_ADDRESS= # BEE_POSTAGE_STAMP_ADDRESS=
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url ## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# BEE_RESOLVER_OPTIONS=[] # BEE_RESOLVER_OPTIONS=[]
## whether we want the node to start with no listen addresses for p2p
# BEE_STANDALONE=false
## enable swap (default true) ## enable swap (default true)
# BEE_SWAP_ENABLE=true # BEE_SWAP_ENABLE=true
## swap ethereum blockchain endpoint (default ws://localhost:8546) ## swap ethereum blockchain endpoint (default ws://localhost:8546)
......
...@@ -62,8 +62,6 @@ password-file: /usr/local/var/lib/swarm-bee/password ...@@ -62,8 +62,6 @@ password-file: /usr/local/var/lib/swarm-bee/password
# postage-stamp-address: "" # postage-stamp-address: ""
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url ## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# resolver-options: [] # resolver-options: []
## whether we want the node to start with no listen addresses for p2p
# standalone: false
## enable swap (default true) ## enable swap (default true)
# swap-enable: true # swap-enable: true
## swap ethereum blockchain endpoint (default "ws://localhost:8546") ## swap ethereum blockchain endpoint (default "ws://localhost:8546")
......
...@@ -52,8 +52,6 @@ password-file: ./password ...@@ -52,8 +52,6 @@ password-file: ./password
# postage-stamp-address: "" # postage-stamp-address: ""
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url ## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# resolver-options: [] # resolver-options: []
## whether we want the node to start with no listen addresses for p2p
# standalone: false
## enable swap (default true) ## enable swap (default true)
# swap-enable: true # swap-enable: true
## swap ethereum blockchain endpoint (default "ws://localhost:8546") ## swap ethereum blockchain endpoint (default "ws://localhost:8546")
......
...@@ -128,7 +128,6 @@ type Options struct { ...@@ -128,7 +128,6 @@ type Options struct {
Bootnodes []string Bootnodes []string
CORSAllowedOrigins []string CORSAllowedOrigins []string
Logger logging.Logger Logger logging.Logger
Standalone bool
TracingEnabled bool TracingEnabled bool
TracingEndpoint string TracingEndpoint string
TracingServiceName string TracingServiceName string
...@@ -212,7 +211,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -212,7 +211,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
cashoutService chequebook.CashoutService cashoutService chequebook.CashoutService
pollingInterval = time.Duration(o.BlockTime) * time.Second pollingInterval = time.Duration(o.BlockTime) * time.Second
) )
if !o.Standalone {
swapBackend, overlayEthAddress, chainID, transactionMonitor, transactionService, err = InitChain( swapBackend, overlayEthAddress, chainID, transactionMonitor, transactionService, err = InitChain(
p2pCtx, p2pCtx,
logger, logger,
...@@ -231,7 +229,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -231,7 +229,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
if o.ChainID != -1 && o.ChainID != chainID { if o.ChainID != -1 && o.ChainID != chainID {
return nil, fmt.Errorf("connected to wrong ethereum network: got chainID %d, want %d", chainID, o.ChainID) return nil, fmt.Errorf("connected to wrong ethereum network: got chainID %d, want %d", chainID, o.ChainID)
} }
}
var debugAPIService *debugapi.Service var debugAPIService *debugapi.Service
if o.DebugAPIAddr != "" { if o.DebugAPIAddr != "" {
...@@ -266,7 +263,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -266,7 +263,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
b.debugAPIServer = debugAPIServer b.debugAPIServer = debugAPIServer
} }
if !o.Standalone {
// Sync the with the given Ethereum backend: // Sync the with the given Ethereum backend:
isSynced, _, err := transaction.IsSynced(p2pCtx, swapBackend, maxDelay) isSynced, _, err := transaction.IsSynced(p2pCtx, swapBackend, maxDelay)
if err != nil { if err != nil {
...@@ -280,7 +276,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -280,7 +276,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
return nil, fmt.Errorf("waiting backend sync: %w", err) return nil, fmt.Errorf("waiting backend sync: %w", err)
} }
} }
}
if o.SwapEnable { if o.SwapEnable {
chequebookFactory, err = InitChequebookFactory( chequebookFactory, err = InitChequebookFactory(
...@@ -362,7 +357,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -362,7 +357,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
NATAddr: o.NATAddr, NATAddr: o.NATAddr,
EnableWS: o.EnableWS, EnableWS: o.EnableWS,
EnableQUIC: o.EnableQUIC, EnableQUIC: o.EnableQUIC,
Standalone: o.Standalone,
WelcomeMessage: o.WelcomeMessage, WelcomeMessage: o.WelcomeMessage,
FullNode: o.FullNodeMode, FullNode: o.FullNodeMode,
Transaction: txHash, Transaction: txHash,
...@@ -422,7 +416,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -422,7 +416,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
) )
var postageSyncStart uint64 = 0 var postageSyncStart uint64 = 0
if !o.Standalone {
chainCfg, found := config.GetChainConfig(chainID) chainCfg, found := config.GetChainConfig(chainID)
postageContractAddress, startBlock := chainCfg.PostageStamp, chainCfg.StartBlock postageContractAddress, startBlock := chainCfg.PostageStamp, chainCfg.StartBlock
if o.PostageContractAddress != "" { if o.PostageContractAddress != "" {
...@@ -457,9 +450,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -457,9 +450,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
transactionService, transactionService,
post, post,
) )
}
if !o.Standalone {
if natManager := p2ps.NATManager(); natManager != nil { if natManager := p2ps.NATManager(); natManager != nil {
// wait for nat manager to init // wait for nat manager to init
logger.Debug("initializing NAT manager") logger.Debug("initializing NAT manager")
...@@ -473,7 +464,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -473,7 +464,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
logger.Warning("NAT manager init timeout") logger.Warning("NAT manager init timeout")
} }
} }
}
// Construct protocols. // Construct protocols.
pingPong := pingpong.New(p2ps, logger, tracer) pingPong := pingpong.New(p2ps, logger, tracer)
...@@ -488,9 +478,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -488,9 +478,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
} }
var bootnodes []ma.Multiaddr var bootnodes []ma.Multiaddr
if o.Standalone {
logger.Info("Starting node in standalone mode, no p2p connections will be made or accepted")
} else {
for _, a := range o.Bootnodes { for _, a := range o.Bootnodes {
addr, err := ma.NewMultiaddr(a) addr, err := ma.NewMultiaddr(a)
if err != nil { if err != nil {
...@@ -501,7 +489,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -501,7 +489,6 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
bootnodes = append(bootnodes, addr) bootnodes = append(bootnodes, addr)
} }
}
var swapService *swap.Service var swapService *swap.Service
...@@ -510,7 +497,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -510,7 +497,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
return nil, fmt.Errorf("unable to create metrics storage for kademlia: %w", err) return nil, fmt.Errorf("unable to create metrics storage for kademlia: %w", err)
} }
kad := kademlia.New(swarmAddress, addressbook, hive, p2ps, metricsDB, logger, kademlia.Options{Bootnodes: bootnodes, StandaloneMode: o.Standalone, BootnodeMode: o.BootnodeMode}) kad := kademlia.New(swarmAddress, addressbook, hive, p2ps, metricsDB, logger, kademlia.Options{Bootnodes: bootnodes, BootnodeMode: o.BootnodeMode})
b.topologyCloser = kad b.topologyCloser = kad
b.topologyHalter = kad b.topologyHalter = kad
hive.SetAddPeersHandler(kad.AddPeers) hive.SetAddPeersHandler(kad.AddPeers)
......
...@@ -87,7 +87,6 @@ type Options struct { ...@@ -87,7 +87,6 @@ type Options struct {
NATAddr string NATAddr string
EnableWS bool EnableWS bool
EnableQUIC bool EnableQUIC bool
Standalone bool
FullNode bool FullNode bool
LightNodeLimit int LightNodeLimit int
WelcomeMessage string WelcomeMessage string
...@@ -178,10 +177,6 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay ...@@ -178,10 +177,6 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
transports = append(transports, libp2p.Transport(libp2pquic.NewTransport)) transports = append(transports, libp2p.Transport(libp2pquic.NewTransport))
} }
if o.Standalone {
opts = append(opts, libp2p.NoListenAddrs)
}
opts = append(opts, transports...) opts = append(opts, transports...)
h, err := libp2p.New(ctx, opts...) h, err := libp2p.New(ctx, opts...)
......
...@@ -66,7 +66,6 @@ var noopSanctionedPeerFn = func(_ swarm.Address) bool { return false } ...@@ -66,7 +66,6 @@ var noopSanctionedPeerFn = func(_ swarm.Address) bool { return false }
type Options struct { type Options struct {
SaturationFunc binSaturationFunc SaturationFunc binSaturationFunc
Bootnodes []ma.Multiaddr Bootnodes []ma.Multiaddr
StandaloneMode bool
BootnodeMode bool BootnodeMode bool
BitSuffixLength int BitSuffixLength int
} }
...@@ -90,7 +89,6 @@ type Kad struct { ...@@ -90,7 +89,6 @@ type Kad struct {
peerSig []chan struct{} peerSig []chan struct{}
peerSigMtx sync.Mutex peerSigMtx sync.Mutex
logger logging.Logger // logger logger logging.Logger // logger
standalone bool // indicates whether the node is working in standalone mode
bootnode bool // indicates whether the node is working in bootnode mode bootnode bool // indicates whether the node is working in bootnode mode
collector *im.Collector collector *im.Collector
quit chan struct{} // quit channel quit chan struct{} // quit channel
...@@ -136,7 +134,6 @@ func New( ...@@ -136,7 +134,6 @@ func New(
manageC: make(chan struct{}, 1), manageC: make(chan struct{}, 1),
waitNext: waitnext.New(), waitNext: waitnext.New(),
logger: logger, logger: logger,
standalone: o.StandaloneMode,
bootnode: o.BootnodeMode, bootnode: o.BootnodeMode,
collector: im.NewCollector(metricsDB), collector: im.NewCollector(metricsDB),
quit: make(chan struct{}), quit: make(chan struct{}),
...@@ -529,10 +526,6 @@ func (k *Kad) manage() { ...@@ -529,10 +526,6 @@ func (k *Kad) manage() {
default: default:
} }
if k.standalone {
continue
}
oldDepth := k.NeighborhoodDepth() oldDepth := k.NeighborhoodDepth()
k.connectNeighbours(&wg, peerConnChan, peerConnChan2) k.connectNeighbours(&wg, peerConnChan, peerConnChan2)
k.connectBalanced(&wg, peerConnChan2) k.connectBalanced(&wg, peerConnChan2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment