diff --git a/cmd/geth/main.go b/cmd/geth/main.go index cfc1a62b6d76..77291702cd8c 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -101,7 +101,7 @@ var ( utils.UltraLightFractionFlag, utils.UltraLightOnlyAnnounceFlag, utils.LightNoSyncServeFlag, - utils.WhitelistFlag, + utils.AuthorizationListFlag, utils.BloomFilterSizeFlag, utils.CacheFlag, utils.CacheDatabaseFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index f39e4f402fca..da62a598a91d 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -52,7 +52,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ utils.EthStatsURLFlag, utils.IdentityFlag, utils.LightKDFFlag, - utils.WhitelistFlag, + utils.AuthorizationListFlag, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2953a00329dc..e0283932cb6a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -226,9 +226,13 @@ var ( Name: "lightkdf", Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength", } - WhitelistFlag = cli.StringFlag{ + DeprecatedAuthorizationListFlag = cli.StringFlag{ Name: "whitelist", - Usage: "Comma separated block number-to-hash mappings to enforce (=)", + Usage: "[DEPRECATED: will be replaced by 'authorizationlist'] Comma separated block number-to-hash mappings to authorize (=)", + } + AuthorizationListFlag = cli.StringFlag{ + Name: "authorizationlist", + Usage: "Comma separated block number-to-hash mappings to authorize (=)", } BloomFilterSizeFlag = cli.Uint64Flag{ Name: "bloomfilter.size", @@ -1406,26 +1410,29 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { } } -func setWhitelist(ctx *cli.Context, cfg *ethconfig.Config) { - whitelist := ctx.GlobalString(WhitelistFlag.Name) - if whitelist == "" { +func setAuthorizationList(ctx *cli.Context, cfg *ethconfig.Config) { + authorizationList := ctx.GlobalString(AuthorizationListFlag.Name) + if authorizationList == "" { + authorizationList = ctx.GlobalString(DeprecatedAuthorizationListFlag.Name) + } + if authorizationList == "" { return } - cfg.Whitelist = make(map[uint64]common.Hash) - for _, entry := range strings.Split(whitelist, ",") { + cfg.AuthorizationList = make(map[uint64]common.Hash) + for _, entry := range strings.Split(authorizationList, ",") { parts := strings.Split(entry, "=") if len(parts) != 2 { - Fatalf("Invalid whitelist entry: %s", entry) + Fatalf("Invalid authorized entry: %s", entry) } number, err := strconv.ParseUint(parts[0], 0, 64) if err != nil { - Fatalf("Invalid whitelist block number %s: %v", parts[0], err) + Fatalf("Invalid authorized block number %s: %v", parts[0], err) } var hash common.Hash if err = hash.UnmarshalText([]byte(parts[1])); err != nil { - Fatalf("Invalid whitelist hash %s: %v", parts[1], err) + Fatalf("Invalid authorized hash %s: %v", parts[1], err) } - cfg.Whitelist[number] = hash + cfg.AuthorizationList[number] = hash } } @@ -1492,7 +1499,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { setTxPool(ctx, &cfg.TxPool) setEthash(ctx, cfg) setMiner(ctx, &cfg.Miner) - setWhitelist(ctx, cfg) + setAuthorizationList(ctx, cfg) setLes(ctx, cfg) // Cap the cache allowance and tune the garbage collector diff --git a/eth/backend.go b/eth/backend.go index 793d3b81f1b1..c8b92705f6c2 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -212,15 +212,15 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { checkpoint = params.TrustedCheckpoints[genesisHash] } if eth.handler, err = newHandler(&handlerConfig{ - Database: chainDb, - Chain: eth.blockchain, - TxPool: eth.txPool, - Network: config.NetworkId, - Sync: config.SyncMode, - BloomCache: uint64(cacheLimit), - EventMux: eth.eventMux, - Checkpoint: checkpoint, - Whitelist: config.Whitelist, + Database: chainDb, + Chain: eth.blockchain, + TxPool: eth.txPool, + Network: config.NetworkId, + Sync: config.SyncMode, + BloomCache: uint64(cacheLimit), + EventMux: eth.eventMux, + Checkpoint: checkpoint, + AuthorizationList: config.AuthorizationList, }); err != nil { return nil, err } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 89cdb75597e0..06f700651694 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -136,8 +136,8 @@ type Config struct { TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved. - // Whitelist of required block number -> hash values to accept - Whitelist map[uint64]common.Hash `toml:"-"` + // AuthorizationList of required block number -> hash values to accept + AuthorizationList map[uint64]common.Hash `toml:"-"` // not in the TOML configuration // Light client options LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 2310dd44997b..e00644e87d2c 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -26,7 +26,7 @@ func (c Config) MarshalTOML() (interface{}, error) { NoPruning bool NoPrefetch bool TxLookupLimit uint64 `toml:",omitempty"` - Whitelist map[uint64]common.Hash `toml:"-"` + AuthorizationList map[uint64]common.Hash `toml:"-"` LightServ int `toml:",omitempty"` LightIngress int `toml:",omitempty"` LightEgress int `toml:",omitempty"` @@ -69,7 +69,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.NoPruning = c.NoPruning enc.NoPrefetch = c.NoPrefetch enc.TxLookupLimit = c.TxLookupLimit - enc.Whitelist = c.Whitelist + enc.AuthorizationList = c.AuthorizationList enc.LightServ = c.LightServ enc.LightIngress = c.LightIngress enc.LightEgress = c.LightEgress @@ -116,7 +116,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { NoPruning *bool NoPrefetch *bool TxLookupLimit *uint64 `toml:",omitempty"` - Whitelist map[uint64]common.Hash `toml:"-"` + AuthorizationList map[uint64]common.Hash `toml:"-"` LightServ *int `toml:",omitempty"` LightIngress *int `toml:",omitempty"` LightEgress *int `toml:",omitempty"` @@ -178,8 +178,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.TxLookupLimit != nil { c.TxLookupLimit = *dec.TxLookupLimit } - if dec.Whitelist != nil { - c.Whitelist = dec.Whitelist + if dec.AuthorizationList != nil { + c.AuthorizationList = dec.AuthorizationList } if dec.LightServ != nil { c.LightServ = *dec.LightServ diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index 3ba7753916c3..c7842d8973e0 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -748,9 +748,9 @@ func (f *TxFetcher) rescheduleTimeout(timer *mclock.Timer, trigger chan struct{} } // scheduleFetches starts a batch of retrievals for all available idle peers. -func (f *TxFetcher) scheduleFetches(timer *mclock.Timer, timeout chan struct{}, whitelist map[string]struct{}) { +func (f *TxFetcher) scheduleFetches(timer *mclock.Timer, timeout chan struct{}, authorizationList map[string]struct{}) { // Gather the set of peers we want to retrieve from (default to all) - actives := whitelist + actives := authorizationList if actives == nil { actives = make(map[string]struct{}) for peer := range f.announces { diff --git a/eth/handler.go b/eth/handler.go index 06a8088bf07c..8ef012c37294 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -76,15 +76,15 @@ type txPool interface { // handlerConfig is the collection of initialization parameters to create a full // node network handler. type handlerConfig struct { - Database ethdb.Database // Database for direct sync insertions - Chain *core.BlockChain // Blockchain to serve data from - TxPool txPool // Transaction pool to propagate from - Network uint64 // Network identifier to adfvertise - Sync downloader.SyncMode // Whether to fast or full sync - BloomCache uint64 // Megabytes to alloc for fast sync bloom - EventMux *event.TypeMux // Legacy event mux, deprecate for `feed` - Checkpoint *params.TrustedCheckpoint // Hard coded checkpoint for sync challenges - Whitelist map[uint64]common.Hash // Hard coded whitelist for sync challenged + Database ethdb.Database // Database for direct sync insertions + Chain *core.BlockChain // Blockchain to serve data from + TxPool txPool // Transaction pool to propagate from + Network uint64 // Network identifier to adfvertise + Sync downloader.SyncMode // Whether to fast or full sync + BloomCache uint64 // Megabytes to alloc for fast sync bloom + EventMux *event.TypeMux // Legacy event mux, deprecate for `feed` + Checkpoint *params.TrustedCheckpoint // Hard coded checkpoint for sync challenges + AuthorizationList map[uint64]common.Hash // Hard coded authorization list for sync challenged } type handler struct { @@ -114,7 +114,7 @@ type handler struct { txsSub event.Subscription minedBlockSub *event.TypeMuxSubscription - whitelist map[uint64]common.Hash + authorizationList map[uint64]common.Hash // channels for fetcher, syncer, txsyncLoop quitSync chan struct{} @@ -131,15 +131,15 @@ func newHandler(config *handlerConfig) (*handler, error) { config.EventMux = new(event.TypeMux) // Nicety initialization for tests } h := &handler{ - networkID: config.Network, - forkFilter: forkid.NewFilter(config.Chain), - eventMux: config.EventMux, - database: config.Database, - txpool: config.TxPool, - chain: config.Chain, - peers: newPeerSet(), - whitelist: config.Whitelist, - quitSync: make(chan struct{}), + networkID: config.Network, + forkFilter: forkid.NewFilter(config.Chain), + eventMux: config.EventMux, + database: config.Database, + txpool: config.TxPool, + chain: config.Chain, + peers: newPeerSet(), + authorizationList: config.AuthorizationList, + quitSync: make(chan struct{}), } if config.Sync == downloader.FullSync { // The database seems empty as the current block is the genesis. Yet the fast @@ -327,8 +327,8 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error { } }() } - // If we have any explicit whitelist block hashes, request them - for number := range h.whitelist { + // If we have any explicit authorized block hashes, request them + for number := range h.authorizationList { if err := peer.RequestHeadersByNumber(number, 1, 0, false); err != nil { return err } diff --git a/eth/handler_eth.go b/eth/handler_eth.go index 3ff9f2245be7..4ee404e886ad 100644 --- a/eth/handler_eth.go +++ b/eth/handler_eth.go @@ -140,13 +140,13 @@ func (h *ethHandler) handleHeaders(peer *eth.Peer, headers []*types.Header) erro } return nil } - // Otherwise if it's a whitelisted block, validate against the set - if want, ok := h.whitelist[headers[0].Number.Uint64()]; ok { + // Otherwise if it's a authorized block, validate against the set + if want, ok := h.authorizationList[headers[0].Number.Uint64()]; ok { if hash := headers[0].Hash(); want != hash { - peer.Log().Info("Whitelist mismatch, dropping peer", "number", headers[0].Number.Uint64(), "hash", hash, "want", want) - return errors.New("whitelist block mismatch") + peer.Log().Info("Authorized block mismatch, dropping peer", "number", headers[0].Number.Uint64(), "hash", hash, "want", want) + return errors.New("Authorized block mismatch") } - peer.Log().Debug("Whitelist block verified", "number", headers[0].Number.Uint64(), "hash", want) + peer.Log().Debug("Authorized block verified", "number", headers[0].Number.Uint64(), "hash", want) } // Irrelevant of the fork checks, send the header to the fetcher just in case headers = h.blockFetcher.FilterHeaders(peer.ID(), headers, time.Now())