Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inclusive terms: change whitelist terms #23290

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func maybeSkipArchive(env build.Environment) {
os.Exit(0)
}
if env.Branch != "master" && !strings.HasPrefix(env.Tag, "v1.") {
log.Printf("skipping archive creation because branch %q, tag %q is not on the whitelist", env.Branch, env.Tag)
log.Printf("skipping archive creation because branch %q, tag %q is not on the inclusion list", env.Branch, env.Tag)
os.Exit(0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ func signer(c *cli.Context) error {
cors := utils.SplitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))

srv := rpc.NewServer()
err := node.RegisterApisFromWhitelist(rpcAPI, []string{"account"}, srv, false)
err := node.RegisterApisFromAllowList(rpcAPI, []string{"account"}, srv, false)
if err != nil {
utils.Fatalf("Could not register API: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var (
utils.UltraLightFractionFlag,
utils.UltraLightOnlyAnnounceFlag,
utils.LightNoSyncServeFlag,
utils.WhitelistFlag,
utils.AllowListFlag,
Copy link
Member

Choose a reason for hiding this comment

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

You disabled the whitelist flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
utils.AllowListFlag,
utils.WhitelistFlag,
utils.AllowListFlag,

should it work or should we use only Whitelist flag?

utils.BloomFilterSizeFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.EthStatsURLFlag,
utils.IdentityFlag,
utils.LightKDFFlag,
utils.WhitelistFlag,
utils.AllowListFlag,
},
},
{
Expand Down
27 changes: 15 additions & 12 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ var (
Name: "lightkdf",
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
}
WhitelistFlag = cli.StringFlag{
Name: "whitelist",
AllowListFlag = cli.StringFlag{
Name: "allowlist",
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
}
BloomFilterSizeFlag = cli.Uint64Flag{
Expand Down Expand Up @@ -1403,26 +1403,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 setAllowList(ctx *cli.Context, cfg *ethconfig.Config) {
allowList := ctx.GlobalString(AllowListFlag.Name)
if allowList == "" {
allowList = ctx.GlobalString(WhitelistFlag.Name)
}
if allowList == "" {
return
}
cfg.Whitelist = make(map[uint64]common.Hash)
for _, entry := range strings.Split(whitelist, ",") {
cfg.AllowList = make(map[uint64]common.Hash)
for _, entry := range strings.Split(allowList, ",") {
parts := strings.Split(entry, "=")
if len(parts) != 2 {
Fatalf("Invalid whitelist entry: %s", entry)
Fatalf("Invalid allowlist 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 allowlist 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 allowlist hash %s: %v", parts[1], err)
}
cfg.Whitelist[number] = hash
cfg.AllowList[number] = hash
}
}

Expand Down Expand Up @@ -1489,7 +1492,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)
setAllowList(ctx, cfg)
setLes(ctx, cfg)

// Cap the cache allowance and tune the garbage collector
Expand Down
5 changes: 5 additions & 0 deletions cmd/utils/flags_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ var (
Usage: "API's offered over the HTTP-RPC interface (deprecated and will be removed June 2021, use --http.api)",
Value: "",
}
// (Deprecated 2021, term)
WhitelistFlag = cli.StringFlag{
Name: "whitelist", // replaced by allowlist
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
}
)

// showDeprecated displays deprecated flags that will be soon removed from the codebase.
Expand Down
4 changes: 2 additions & 2 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// pending or queued one, it overwrites the previous transaction if its price is higher.
//
// If a newly added transaction is marked as local, its sending account will be
// whitelisted, preventing any associated transaction from being dropped out of the pool
// due to pricing constraints.
// be added to the allowlist, preventing any associated transaction from being dropped
// out of the pool due to pricing constraints.
func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err error) {
// If the transaction is already known, discard it
hash := tx.Hash()
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
BloomCache: uint64(cacheLimit),
EventMux: eth.eventMux,
Checkpoint: checkpoint,
Whitelist: config.Whitelist,
AllowList: config.AllowList,
}); err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,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:"-"`
// AllowList of required block number -> hash values to accept
AllowList map[uint64]common.Hash `toml:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This change breaks compatibility with config files, so we cannot apply it without providing some kind of translator / deprecation mechanism.

You can check how to do this in https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/config.go#L238

Copy link
Contributor Author

@baptiste-b-pegasys baptiste-b-pegasys Jul 29, 2021

Choose a reason for hiding this comment

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

When I've done it, seeing the tag "-" I thought it was omitted, just here for reference not in the config file.
A team member gave me this reference https://github.com/BurntSushi/toml/blob/ebe1404fc680a89e43605f720106b16be2ba141c/encode.go#L561-L563

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I didn't notice that! That's OK then.


// Light client options
LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
Expand Down
10 changes: 5 additions & 5 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions eth/fetcher/tx_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}, allowList map[string]struct{}) {
// Gather the set of peers we want to retrieve from (default to all)
actives := whitelist
actives := allowList
if actives == nil {
actives = make(map[string]struct{})
for peer := range f.announces {
Expand Down
10 changes: 5 additions & 5 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type handlerConfig struct {
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
AllowList map[uint64]common.Hash // Hard coded allow list for sync challenged
}

type handler struct {
Expand Down Expand Up @@ -114,7 +114,7 @@ type handler struct {
txsSub event.Subscription
minedBlockSub *event.TypeMuxSubscription

whitelist map[uint64]common.Hash
allowList map[uint64]common.Hash

// channels for fetcher, syncer, txsyncLoop
txsyncCh chan *txsync
Expand All @@ -139,7 +139,7 @@ func newHandler(config *handlerConfig) (*handler, error) {
txpool: config.TxPool,
chain: config.Chain,
peers: newPeerSet(),
whitelist: config.Whitelist,
allowList: config.AllowList,
txsyncCh: make(chan *txsync),
quitSync: make(chan struct{}),
}
Expand Down Expand Up @@ -329,8 +329,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 allow list block hashes, request them
for number := range h.allowList {
if err := peer.RequestHeadersByNumber(number, 1, 0, false); err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions eth/handler_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 block in the allowlist, validate against the set
if want, ok := h.allowList[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("allowed mismatch, dropping peer", "number", headers[0].Number.Uint64(), "hash", hash, "want", want)
return errors.New("allowed block mismatch")
}
peer.Log().Debug("Whitelist block verified", "number", headers[0].Number.Uint64(), "hash", want)
peer.Log().Debug("Allowed 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())
Expand Down
16 changes: 8 additions & 8 deletions node/rpcstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (h *httpServer) enableRPC(apis []rpc.API, config httpConfig) error {

// Create RPC server and handler.
srv := rpc.NewServer()
if err := RegisterApisFromWhitelist(apis, config.Modules, srv, false); err != nil {
if err := RegisterApisFromAllowList(apis, config.Modules, srv, false); err != nil {
return err
}
h.httpConfig = config
Expand Down Expand Up @@ -312,7 +312,7 @@ func (h *httpServer) enableWS(apis []rpc.API, config wsConfig) error {

// Create RPC server and handler.
srv := rpc.NewServer()
if err := RegisterApisFromWhitelist(apis, config.Modules, srv, false); err != nil {
if err := RegisterApisFromAllowList(apis, config.Modules, srv, false); err != nil {
return err
}
h.wsConfig = config
Expand Down Expand Up @@ -515,20 +515,20 @@ func (is *ipcServer) stop() error {
return err
}

// RegisterApisFromWhitelist checks the given modules' availability, generates a whitelist based on the allowed modules,
// RegisterApisFromAllowList checks the given modules' availability, generates an allowlist based on the allowed modules,
// and then registers all of the APIs exposed by the services.
func RegisterApisFromWhitelist(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll bool) error {
func RegisterApisFromAllowList(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

For this function, both terms are not appropriate. The 'list' here really just a list of API names that should be registered, so we could simply call it RegisterAPIs.

if bad, available := checkModuleAvailability(modules, apis); len(bad) > 0 {
log.Error("Unavailable modules in HTTP API list", "unavailable", bad, "available", available)
}
// Generate the whitelist based on the allowed modules
whitelist := make(map[string]bool)
// Generate the allow list based on the allowed modules
allowList := make(map[string]bool)
for _, module := range modules {
whitelist[module] = true
allowList[module] = true
}
// Register all the APIs exposed by the services
for _, api := range apis {
if exposeAll || whitelist[api.Namespace] || (len(whitelist) == 0 && api.Public) {
if exposeAll || allowList[api.Namespace] || (len(allowList) == 0 && api.Public) {
if err := srv.RegisterName(api.Namespace, api.Service); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions p2p/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var (
errAlreadyDialing = errors.New("already dialing")
errAlreadyConnected = errors.New("already connected")
errRecentlyDialed = errors.New("recently dialed")
errNotWhitelisted = errors.New("not contained in netrestrict whitelist")
errNotAllowListed = errors.New("not contained in netrestrict allowList")
Copy link
Member

Choose a reason for hiding this comment

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

This sounds like a mouthfull.

Copy link
Contributor

Choose a reason for hiding this comment

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

The error name could be errNetRestrict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
errNotAllowListed = errors.New("not contained in netrestrict allowList")
errNotAllowListed = errors.New("not contained in the netrestrict allowed list")

Copy link
Contributor

Choose a reason for hiding this comment

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

"not contained in netrestrict list"

errNoPort = errors.New("node does not provide TCP port")
)

Expand Down Expand Up @@ -133,7 +133,7 @@ type dialConfig struct {
self enode.ID // our own ID
maxDialPeers int // maximum number of dialed peers
maxActiveDials int // maximum number of active dials
netRestrict *netutil.Netlist // IP whitelist, disabled if nil
netRestrict *netutil.Netlist // IP allowlist, disabled if nil
resolver nodeResolver
dialer NodeDialer
log log.Logger
Expand Down Expand Up @@ -402,7 +402,7 @@ func (d *dialScheduler) checkDial(n *enode.Node) error {
return errAlreadyConnected
}
if d.netRestrict != nil && !d.netRestrict.Contains(n.IP()) {
return errNotWhitelisted
return errNotAllowListed
}
if d.history.contains(string(n.ID().Bytes())) {
return errRecentlyDialed
Expand Down
2 changes: 1 addition & 1 deletion p2p/discover/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Config struct {
PrivateKey *ecdsa.PrivateKey

// These settings are optional:
NetRestrict *netutil.Netlist // network whitelist
NetRestrict *netutil.Netlist // network allow list
Bootnodes []*enode.Node // list of bootstrap nodes
Unhandled chan<- ReadPacket // unhandled packets are sent on this channel
Log log.Logger // if set, log messages go here
Expand Down
2 changes: 1 addition & 1 deletion p2p/discover/v4_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func (t *UDPv4) nodeFromRPC(sender *net.UDPAddr, rn v4wire.Node) (*node, error)
return nil, err
}
if t.netrestrict != nil && !t.netrestrict.Contains(rn.IP) {
return nil, errors.New("not contained in netrestrict whitelist")
return nil, errors.New("not contained in netrestrict allow list")
}
key, err := v4wire.DecodePubkey(crypto.S256(), rn.ID)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (srv *Server) RemovePeer(node *enode.Node) {
}
}

// AddTrustedPeer adds the given node to a reserved whitelist which allows the
// AddTrustedPeer adds the given node to a reserved allow list which allows the
// node to always connect, even if the slot are full.
func (srv *Server) AddTrustedPeer(node *enode.Node) {
select {
Expand Down Expand Up @@ -903,7 +903,7 @@ func (srv *Server) checkInboundConn(remoteIP net.IP) error {
}
// Reject connections that do not match NetRestrict.
if srv.NetRestrict != nil && !srv.NetRestrict.Contains(remoteIP) {
return fmt.Errorf("not whitelisted in NetRestrict")
return fmt.Errorf("not in the NetRestrict allow list")
}
// Reject Internet peers that try too often.
now := srv.clock.Now()
Expand Down
2 changes: 1 addition & 1 deletion rpc/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func wsHandshakeValidator(allowedOrigins []string) func(*http.Request) bool {
if _, ok := req.Header["Origin"]; !ok {
return true
}
// Verify origin against whitelist.
// Verify origin against allow list.
origin := strings.ToLower(req.Header.Get("Origin"))
if allowAllOrigins || originIsAllowed(origins, origin) {
return true
Expand Down
Loading