Skip to content

Commit

Permalink
Merge pull request ethereum#405 from cffls/whitelist
Browse files Browse the repository at this point in the history
Rename whitelist to requiredblocks
  • Loading branch information
cffls authored May 23, 2022
2 parents 2323f2c + c02e2cb commit 63bedf3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/cli/bootnode.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

- ```save-key```: path to save the ecdsa private key

- ```dry-run```
- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode
6 changes: 3 additions & 3 deletions docs/cli/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The ```bor server``` command runs the Bor client.

- ```gcmode```: Blockchain garbage collection mode ("full", "archive")

- ```whitelist```: Comma separated block number-to-hash mappings to enforce (<number>=<hash>)
- ```requiredblocks```: Comma separated block number-to-hash mappings to enforce (<number>=<hash>)

- ```no-snapshot```: Disables the snapshot-database mode (default = false)

Expand Down Expand Up @@ -74,7 +74,7 @@ The ```bor server``` command runs the Bor client.

- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys

- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain)
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)

### JsonRPC Options

Expand Down Expand Up @@ -194,4 +194,4 @@ The ```bor server``` command runs the Bor client.

- ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts

- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued
- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued
22 changes: 11 additions & 11 deletions internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type Config struct {
// Name, or identity of the node
Name string `hcl:"name,optional"`

// Whitelist is a list of required (block number, hash) pairs to accept
Whitelist map[string]string `hcl:"whitelist,optional"`
// RequiredBlocks is a list of required (block number, hash) pairs to accept
RequiredBlocks map[string]string `hcl:"requiredblocks,optional"`

// LogLevel is the level of the logs to put out
LogLevel string `hcl:"log-level,optional"`
Expand Down Expand Up @@ -383,11 +383,11 @@ type DeveloperConfig struct {

func DefaultConfig() *Config {
return &Config{
Chain: "mainnet",
Name: Hostname(),
Whitelist: map[string]string{},
LogLevel: "INFO",
DataDir: defaultDataDir(),
Chain: "mainnet",
Name: Hostname(),
RequiredBlocks: map[string]string{},
LogLevel: "INFO",
DataDir: defaultDataDir(),
P2P: &P2PConfig{
MaxPeers: 30,
MaxPendPeers: 50,
Expand Down Expand Up @@ -745,17 +745,17 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
n.SnapDiscoveryURLs = c.P2P.Discovery.DNS
}

// whitelist
// RequiredBlocks
{
n.PeerRequiredBlocks = map[uint64]common.Hash{}
for k, v := range c.Whitelist {
for k, v := range c.RequiredBlocks {
number, err := strconv.ParseUint(k, 0, 64)
if err != nil {
return nil, fmt.Errorf("invalid whitelist block number %s: %v", k, err)
return nil, fmt.Errorf("invalid required block number %s: %v", k, err)
}
var hash common.Hash
if err = hash.UnmarshalText([]byte(v)); err != nil {
return nil, fmt.Errorf("invalid whitelist hash %s: %v", v, err)
return nil, fmt.Errorf("invalid required block hash %s: %v", v, err)
}
n.PeerRequiredBlocks[number] = hash
}
Expand Down
8 changes: 4 additions & 4 deletions internal/cli/server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestConfigMerge(t *testing.T) {
c0 := &Config{
Chain: "0",
NoSnapshot: true,
Whitelist: map[string]string{
RequiredBlocks: map[string]string{
"a": "b",
},
TxPool: &TxPoolConfig{
Expand All @@ -40,7 +40,7 @@ func TestConfigMerge(t *testing.T) {
}
c1 := &Config{
Chain: "1",
Whitelist: map[string]string{
RequiredBlocks: map[string]string{
"b": "c",
},
P2P: &P2PConfig{
Expand All @@ -55,7 +55,7 @@ func TestConfigMerge(t *testing.T) {
expected := &Config{
Chain: "1",
NoSnapshot: true,
Whitelist: map[string]string{
RequiredBlocks: map[string]string{
"a": "b",
"b": "c",
},
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestConfigLoadFile(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, config, &Config{
DataDir: "./data",
Whitelist: map[string]string{
RequiredBlocks: map[string]string{
"a": "b",
},
P2P: &P2PConfig{
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func (c *Command) Flags() *flagset.Flagset {
Value: &c.cliConfig.GcMode,
})
f.MapStringFlag(&flagset.MapStringFlag{
Name: "whitelist",
Name: "requiredblocks",
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
Value: &c.cliConfig.Whitelist,
Value: &c.cliConfig.RequiredBlocks,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "no-snapshot",
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/testdata/simple.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
data-dir = "./data"

whitelist = {
requiredblocks = {
a = "b"
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/testdata/simple.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"data-dir": "./data",
"whitelist": {
"requiredblocks": {
"a": "b"
},
"p2p": {
Expand Down

0 comments on commit 63bedf3

Please sign in to comment.