Skip to content

Commit 8d51cec

Browse files
committed
cmd, les, tests: remove light client code (ethereum#28586)
* cmd, les, tests: remove light client code This commit removes the light client (LES) code. Since the merge the light client has been broken and it is hard to maintain it alongside the normal client. We decided it would be best to remove it for now and maybe rework and reintroduce it in the future. * cmd, eth: remove some more mentions of light mode * cmd: re-add flags and mark as deprecated * cmd: warn the user about deprecated flags * eth: better error message
1 parent de1a126 commit 8d51cec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+89
-20822
lines changed

cmd/geth/main.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var (
6161
utils.MinFreeDiskSpaceFlag,
6262
utils.KeyStoreDirFlag,
6363
utils.ExternalSignerFlag,
64-
utils.NoUSBFlag,
64+
utils.NoUSBFlag, // deprecated
6565
utils.DirectBroadcastFlag,
6666
utils.DisableSnapProtocolFlag,
6767
utils.EnableTrustProtocolFlag,
@@ -96,27 +96,27 @@ var (
9696
utils.ExitWhenSyncedFlag,
9797
utils.GCModeFlag,
9898
utils.SnapshotFlag,
99-
utils.TxLookupLimitFlag,
99+
utils.TxLookupLimitFlag, // deprecated
100100
utils.TransactionHistoryFlag,
101101
utils.StateSchemeFlag,
102102
utils.StateHistoryFlag,
103103
utils.PathDBSyncFlag,
104-
utils.LightServeFlag,
105-
utils.LightIngressFlag,
106-
utils.LightEgressFlag,
107-
utils.LightMaxPeersFlag,
108-
utils.LightNoPruneFlag,
109-
utils.LightKDFFlag,
110-
utils.LightNoSyncServeFlag,
104+
utils.LightServeFlag, // deprecated
105+
utils.LightIngressFlag, // deprecated
106+
utils.LightEgressFlag, // deprecated
107+
utils.LightMaxPeersFlag, // deprecated
108+
utils.LightNoPruneFlag, // deprecated
109+
utils.LightKDFFlag, // deprecated
110+
utils.LightNoSyncServeFlag, // deprecated
111111
utils.EthRequiredBlocksFlag,
112-
utils.LegacyWhitelistFlag,
112+
utils.LegacyWhitelistFlag, // deprecated
113113
utils.BloomFilterSizeFlag,
114114
utils.TriesInMemoryFlag,
115115
utils.CacheFlag,
116116
utils.CacheDatabaseFlag,
117117
utils.CacheTrieFlag,
118-
utils.CacheTrieJournalFlag,
119-
utils.CacheTrieRejournalFlag,
118+
utils.CacheTrieJournalFlag, // deprecated
119+
utils.CacheTrieRejournalFlag, // deprecated
120120
utils.CacheGCFlag,
121121
utils.CacheSnapshotFlag,
122122
// utils.CacheNoPrefetchFlag,
@@ -144,7 +144,7 @@ var (
144144
utils.NoDiscoverFlag,
145145
utils.DiscoveryV4Flag,
146146
utils.DiscoveryV5Flag,
147-
utils.LegacyDiscoveryV5Flag,
147+
utils.LegacyDiscoveryV5Flag, // deprecated
148148
utils.NetrestrictFlag,
149149
utils.NodeKeyFileFlag,
150150
utils.NodeKeyHexFlag,
@@ -321,7 +321,7 @@ func prepare(ctx *cli.Context) {
321321
log.Info("Starting Geth on BSC mainnet...")
322322
}
323323
// If we're a full node on mainnet without --cache specified, bump default cache allowance
324-
if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) && !ctx.IsSet(utils.NetworkIdFlag.Name) {
324+
if !ctx.IsSet(utils.CacheFlag.Name) && !ctx.IsSet(utils.NetworkIdFlag.Name) {
325325
// Make sure we're not on any supported preconfigured testnet either
326326
if !ctx.IsSet(utils.DeveloperFlag.Name) &&
327327
!ctx.IsSet(utils.ChapelFlag.Name) {
@@ -330,11 +330,6 @@ func prepare(ctx *cli.Context) {
330330
ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096))
331331
}
332332
}
333-
// If we're running a light client on any network, drop the cache to some meaningfully low amount
334-
if ctx.String(utils.SyncModeFlag.Name) == "light" && !ctx.IsSet(utils.CacheFlag.Name) {
335-
log.Info("Dropping default light client cache", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 128)
336-
ctx.Set(utils.CacheFlag.Name, strconv.Itoa(128))
337-
}
338333
}
339334

340335
// geth is the main entry point into the system if no special subcommand is run.

cmd/geth/run_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ func TestMain(m *testing.M) {
5555
os.Exit(m.Run())
5656
}
5757

58+
func initGeth(t *testing.T) string {
59+
args := []string{"--networkid=42", "init", "./testdata/clique.json"}
60+
t.Logf("Initializing geth: %v ", args)
61+
g := runGeth(t, args...)
62+
datadir := g.Datadir
63+
g.WaitExit()
64+
return datadir
65+
}
66+
5867
// spawns geth with the given command line args. If the args don't set --datadir, the
5968
// child g gets a temporary data directory.
6069
func runGeth(t *testing.T, args ...string) *testgeth {

cmd/utils/flags.go

Lines changed: 16 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ import (
6363
"github.com/ethereum/go-ethereum/graphql"
6464
"github.com/ethereum/go-ethereum/internal/ethapi"
6565
"github.com/ethereum/go-ethereum/internal/flags"
66-
"github.com/ethereum/go-ethereum/les"
6766
"github.com/ethereum/go-ethereum/log"
6867
"github.com/ethereum/go-ethereum/metrics"
6968
"github.com/ethereum/go-ethereum/metrics/exp"
@@ -318,7 +317,7 @@ var (
318317
}
319318
SyncModeFlag = &flags.TextMarshalerFlag{
320319
Name: "syncmode",
321-
Usage: `Blockchain sync mode ("snap", "full" or "light")`,
320+
Usage: `Blockchain sync mode ("snap" or "full")`,
322321
Value: &defaultSyncMode,
323322
Category: flags.StateCategory,
324323
}
@@ -351,41 +350,6 @@ var (
351350
Value: ethconfig.Defaults.TransactionHistory,
352351
Category: flags.StateCategory,
353352
}
354-
// Light server and client settings
355-
LightServeFlag = &cli.IntFlag{
356-
Name: "light.serve",
357-
Usage: "Maximum percentage of time allowed for serving LES requests (multi-threaded processing allows values over 100)",
358-
Value: ethconfig.Defaults.LightServ,
359-
Category: flags.LightCategory,
360-
}
361-
LightIngressFlag = &cli.IntFlag{
362-
Name: "light.ingress",
363-
Usage: "Incoming bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)",
364-
Value: ethconfig.Defaults.LightIngress,
365-
Category: flags.LightCategory,
366-
}
367-
LightEgressFlag = &cli.IntFlag{
368-
Name: "light.egress",
369-
Usage: "Outgoing bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)",
370-
Value: ethconfig.Defaults.LightEgress,
371-
Category: flags.LightCategory,
372-
}
373-
LightMaxPeersFlag = &cli.IntFlag{
374-
Name: "light.maxpeers",
375-
Usage: "Maximum number of light clients to serve, or light servers to attach to",
376-
Value: ethconfig.Defaults.LightPeers,
377-
Category: flags.LightCategory,
378-
}
379-
LightNoPruneFlag = &cli.BoolFlag{
380-
Name: "light.nopruning",
381-
Usage: "Disable ancient light chain data pruning",
382-
Category: flags.LightCategory,
383-
}
384-
LightNoSyncServeFlag = &cli.BoolFlag{
385-
Name: "light.nosyncserve",
386-
Usage: "Enables serving light clients before syncing",
387-
Category: flags.LightCategory,
388-
}
389353
// Transaction pool settings
390354
TxPoolLocalsFlag = &cli.StringFlag{
391355
Name: "txpool.locals",
@@ -1380,25 +1344,25 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
13801344
}
13811345
}
13821346

1383-
// setLes configures the les server and ultra light client settings from the command line flags.
1347+
// setLes shows the deprecation warnings for LES flags.
13841348
func setLes(ctx *cli.Context, cfg *ethconfig.Config) {
13851349
if ctx.IsSet(LightServeFlag.Name) {
1386-
cfg.LightServ = ctx.Int(LightServeFlag.Name)
1350+
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightServeFlag.Name)
13871351
}
13881352
if ctx.IsSet(LightIngressFlag.Name) {
1389-
cfg.LightIngress = ctx.Int(LightIngressFlag.Name)
1353+
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightIngressFlag.Name)
13901354
}
13911355
if ctx.IsSet(LightEgressFlag.Name) {
1392-
cfg.LightEgress = ctx.Int(LightEgressFlag.Name)
1356+
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightEgressFlag.Name)
13931357
}
13941358
if ctx.IsSet(LightMaxPeersFlag.Name) {
1395-
cfg.LightPeers = ctx.Int(LightMaxPeersFlag.Name)
1359+
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightMaxPeersFlag.Name)
13961360
}
13971361
if ctx.IsSet(LightNoPruneFlag.Name) {
1398-
cfg.LightNoPrune = ctx.Bool(LightNoPruneFlag.Name)
1362+
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightNoPruneFlag.Name)
13991363
}
14001364
if ctx.IsSet(LightNoSyncServeFlag.Name) {
1401-
cfg.LightNoSyncServe = ctx.Bool(LightNoSyncServeFlag.Name)
1365+
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightNoSyncServeFlag.Name)
14021366
}
14031367
}
14041368

@@ -1509,27 +1473,8 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
15091473
setBootstrapNodes(ctx, cfg)
15101474
setBootstrapNodesV5(ctx, cfg)
15111475

1512-
lightClient := ctx.String(SyncModeFlag.Name) == "light"
1513-
lightServer := (ctx.Int(LightServeFlag.Name) != 0)
1514-
1515-
lightPeers := ctx.Int(LightMaxPeersFlag.Name)
1516-
if lightClient && !ctx.IsSet(LightMaxPeersFlag.Name) {
1517-
// dynamic default - for clients we use 1/10th of the default for servers
1518-
lightPeers /= 10
1519-
}
1520-
15211476
if ctx.IsSet(MaxPeersFlag.Name) {
15221477
cfg.MaxPeers = ctx.Int(MaxPeersFlag.Name)
1523-
if lightServer && !ctx.IsSet(LightMaxPeersFlag.Name) {
1524-
cfg.MaxPeers += lightPeers
1525-
}
1526-
} else {
1527-
if lightServer {
1528-
cfg.MaxPeers += lightPeers
1529-
}
1530-
if lightClient && ctx.IsSet(LightMaxPeersFlag.Name) && cfg.MaxPeers < lightPeers {
1531-
cfg.MaxPeers = lightPeers
1532-
}
15331478
}
15341479
// if max peers per ip is not set, use max peers
15351480
if cfg.MaxPeersPerIP <= 0 {
@@ -1540,36 +1485,21 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
15401485
cfg.MaxPeersPerIP = ctx.Int(MaxPeersPerIPFlag.Name)
15411486
}
15421487

1543-
if !(lightClient || lightServer) {
1544-
lightPeers = 0
1545-
}
1546-
ethPeers := cfg.MaxPeers - lightPeers
1547-
if lightClient {
1548-
ethPeers = 0
1549-
}
1550-
log.Info("Maximum peer count", "ETH", ethPeers, "LES", lightPeers, "total", cfg.MaxPeers)
1488+
ethPeers := cfg.MaxPeers
1489+
log.Info("Maximum peer count", "ETH", ethPeers, "total", cfg.MaxPeers)
15511490

15521491
if ctx.IsSet(MaxPendingPeersFlag.Name) {
15531492
cfg.MaxPendingPeers = ctx.Int(MaxPendingPeersFlag.Name)
15541493
}
1555-
if ctx.IsSet(NoDiscoverFlag.Name) || lightClient {
1494+
if ctx.IsSet(NoDiscoverFlag.Name) {
15561495
cfg.NoDiscovery = true
15571496
}
15581497

1559-
// Disallow --nodiscover when used in conjunction with light mode.
1560-
if (lightClient || lightServer) && ctx.Bool(NoDiscoverFlag.Name) {
1561-
Fatalf("Cannot use --" + NoDiscoverFlag.Name + " in light client or light server mode")
1562-
}
15631498
CheckExclusive(ctx, DiscoveryV4Flag, NoDiscoverFlag)
15641499
CheckExclusive(ctx, DiscoveryV5Flag, NoDiscoverFlag)
15651500
cfg.DiscoveryV4 = ctx.Bool(DiscoveryV4Flag.Name)
15661501
cfg.DiscoveryV5 = ctx.Bool(DiscoveryV5Flag.Name)
15671502

1568-
// If we're running a light client or server, force enable the v5 peer discovery.
1569-
if lightClient || lightServer {
1570-
cfg.DiscoveryV5 = true
1571-
}
1572-
15731503
if netrestrict := ctx.String(NetrestrictFlag.Name); netrestrict != "" {
15741504
list, err := netutil.ParseNetlist(netrestrict)
15751505
if err != nil {
@@ -1701,12 +1631,7 @@ func setBLSWalletDir(ctx *cli.Context, cfg *node.Config) {
17011631
}
17021632
}
17031633

1704-
func setGPO(ctx *cli.Context, cfg *gasprice.Config, light bool) {
1705-
// If we are running the light client, apply another group
1706-
// settings for gas oracle.
1707-
if light {
1708-
*cfg = ethconfig.LightClientGPO
1709-
}
1634+
func setGPO(ctx *cli.Context, cfg *gasprice.Config) {
17101635
if ctx.IsSet(GpoBlocksFlag.Name) {
17111636
cfg.Blocks = ctx.Int(GpoBlocksFlag.Name)
17121637
}
@@ -1866,13 +1791,12 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
18661791
// SetEthConfig applies eth-related command line flags to the config.
18671792
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18681793
// Avoid conflicting network flags
1869-
CheckExclusive(ctx, BSCMainnetFlag, DeveloperFlag, ChapelFlag)
1870-
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
1794+
CheckExclusive(ctx, BSCMainnetFlag, DeveloperFlag)
18711795
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
18721796

18731797
// Set configurations from CLI flags
18741798
setEtherbase(ctx, cfg)
1875-
setGPO(ctx, &cfg.GPO, ctx.String(SyncModeFlag.Name) == "light")
1799+
setGPO(ctx, &cfg.GPO)
18761800
setTxPool(ctx, &cfg.TxPool)
18771801
setMiner(ctx, &cfg.Miner)
18781802
setRequiredBlocks(ctx, cfg)
@@ -1986,9 +1910,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
19861910
cfg.TransactionHistory = 0
19871911
log.Warn("Disabled transaction unindexing for archive node")
19881912
}
1989-
if ctx.IsSet(LightServeFlag.Name) && cfg.TransactionHistory != 0 {
1990-
log.Warn("LES server cannot serve old transaction status and cannot connect below les/4 protocol version if transaction lookup index is limited")
1991-
}
19921913
if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheTrieFlag.Name) {
19931914
cfg.TrieCleanCache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheTrieFlag.Name) / 100
19941915
}
@@ -2157,9 +2078,6 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) {
21572078
return // already set through flags/config
21582079
}
21592080
protocol := "all"
2160-
if cfg.SyncMode == downloader.LightSync {
2161-
protocol = "les"
2162-
}
21632081
if url := params.KnownDNSNetwork(genesis, protocol); url != "" {
21642082
cfg.EthDiscoveryURLs = []string{url}
21652083
cfg.SnapDiscoveryURLs = cfg.EthDiscoveryURLs
@@ -2169,27 +2087,12 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) {
21692087
}
21702088

21712089
// RegisterEthService adds an Ethereum client to the stack.
2172-
// The second return value is the full node instance, which may be nil if the
2173-
// node is running as a light client.
2090+
// The second return value is the full node instance.
21742091
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend, *eth.Ethereum) {
2175-
if cfg.SyncMode == downloader.LightSync {
2176-
backend, err := les.New(stack, cfg)
2177-
if err != nil {
2178-
Fatalf("Failed to register the Ethereum service: %v", err)
2179-
}
2180-
stack.RegisterAPIs(tracers.APIs(backend.ApiBackend))
2181-
return backend.ApiBackend, nil
2182-
}
21832092
backend, err := eth.New(stack, cfg)
21842093
if err != nil {
21852094
Fatalf("Failed to register the Ethereum service: %v", err)
21862095
}
2187-
if cfg.LightServ > 0 {
2188-
_, err := les.NewLesServer(stack, backend, cfg)
2189-
if err != nil {
2190-
Fatalf("Failed to create the LES server: %v", err)
2191-
}
2192-
}
21932096
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
21942097
return backend.APIBackend, backend
21952098
}
@@ -2238,13 +2141,12 @@ func EnableMinerInfo(ctx *cli.Context, minerConfig miner.Config) SetupMetricsOpt
22382141

22392142
// RegisterFilterAPI adds the eth log filtering RPC API to the node.
22402143
func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconfig.Config) *filters.FilterSystem {
2241-
isLightClient := ethcfg.SyncMode == downloader.LightSync
22422144
filterSystem := filters.NewFilterSystem(backend, filters.Config{
22432145
LogCacheSize: ethcfg.FilterLogCacheSize,
22442146
})
22452147
stack.RegisterAPIs([]rpc.API{{
22462148
Namespace: "eth",
2247-
Service: filters.NewFilterAPI(filterSystem, isLightClient, ethcfg.RangeLimit),
2149+
Service: filters.NewFilterAPI(filterSystem, ethcfg.RangeLimit),
22482150
}})
22492151
return filterSystem
22502152
}

0 commit comments

Comments
 (0)