Merge pull request #630 from maticnetwork/arpit/master-to-qa

RPC fix for coinbase address
This commit is contained in:
Arpit Temani 2022-12-15 14:40:33 +05:30 committed by GitHub
commit 7217f79767
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 479 additions and 213 deletions

View file

@ -1,7 +1,7 @@
# Documentation # Documentation
- [The new command line interface](./cli) [The new command line interface (CLI)](./cli) in this version of Bor aims to give users more control over the codebase when interacting with and starting a node. We have made every effort to keep most of the flags similar to the old CLI, except for a few notable changes. One major change is the use of the --config flag, which previously represented fields without available flags. It now represents all flags available to the user, and will overwrite any other flags if provided. As a node operator, you still have the flexibility to modify flags as needed. Please note that this change does not affect the internal functionality of the node, and it remains compatible with Geth and the Ethereum Virtual Machine (EVM).
## Additional notes ## Additional notes
@ -11,6 +11,8 @@
$ bor server <flags> $ bor server <flags>
``` ```
See [here](./cli/server.md) for more flag details.
- The `bor dumpconfig` sub-command prints the default configurations, in the TOML format, on the terminal. One can `pipe (>)` this to a file (say `config.toml`) and use it to start bor. - The `bor dumpconfig` sub-command prints the default configurations, in the TOML format, on the terminal. One can `pipe (>)` this to a file (say `config.toml`) and use it to start bor.
- A toml file now can be used instead of flags and can contain all configuration for the node to run. To simply run bor with a configuration file, the following command can be used. - A toml file now can be used instead of flags and can contain all configuration for the node to run. To simply run bor with a configuration file, the following command can be used.

View file

@ -44,6 +44,10 @@
- [```server```](./server.md) - [```server```](./server.md)
- [```snapshot```](./snapshot.md)
- [```snapshot prune-state```](./snapshot_prune-state.md)
- [```status```](./status.md) - [```status```](./status.md)
- [```version```](./version.md) - [```version```](./version.md)

View file

@ -6,4 +6,4 @@ The ```account import``` command imports an account in Json format to the Bor da
- ```datadir```: Path of the data directory to store information - ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information - ```keystore```: Path of the data directory to store keys

View file

@ -6,4 +6,4 @@ The `account list` command lists all the accounts in the Bor data directory.
- ```datadir```: Path of the data directory to store information - ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information - ```keystore```: Path of the data directory to store keys

View file

@ -6,4 +6,4 @@ The `account new` command creates a new local account file on the Bor data direc
- ```datadir```: Path of the data directory to store information - ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information - ```keystore```: Path of the data directory to store keys

View file

@ -2,16 +2,16 @@
## Options ## Options
- ```listen-addr```: listening address of bootnode (<ip>:<port>) - ```listen-addr```: listening address of bootnode (<ip>:<port>) (default: 0.0.0.0:30303)
- ```v5```: Enable UDP v5 - ```v5```: Enable UDP v5 (default: false)
- ```log-level```: Log level (trace|debug|info|warn|error|crit) - ```log-level```: Log level (trace|debug|info|warn|error|crit) (default: info)
- ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>) - ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: none)
- ```node-key```: file or hex node key - ```node-key```: file or hex node key
- ```save-key```: path to save the ecdsa private key - ```save-key```: path to save the ecdsa private key
- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode - ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode (default: false)

View file

@ -8,6 +8,6 @@ The ```chain sethead <number>``` command sets the current chain to a certain blo
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```yes```: Force set head - ```yes```: Force set head (default: false)

View file

@ -4,6 +4,6 @@ The ```bor debug block <number>``` command will create an archive containing tra
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```output```: Output directory - ```output```: Output directory

View file

@ -4,8 +4,8 @@ The ```debug pprof <enode>``` command will create an archive containing bor ppro
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```seconds```: seconds to trace - ```seconds```: seconds to trace (default: 2)
- ```output```: Output directory - ```output```: Output directory

View file

@ -4,6 +4,6 @@ The ```peers add <enode>``` command joins the local client to another remote pee
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```trusted```: Add the peer as a trusted - ```trusted```: Add the peer as a trusted (default: false)

View file

@ -4,4 +4,4 @@ The ```peers list``` command lists the connected peers.
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

View file

@ -4,6 +4,6 @@ The ```peers remove <enode>``` command disconnects the local client from a conne
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```trusted```: Add the peer as a trusted - ```trusted```: Add the peer as a trusted (default: false)

View file

@ -4,4 +4,4 @@ The ```peers status <peer id>``` command displays the status of a peer by its id
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

View file

@ -4,6 +4,6 @@ The ```bor removedb``` command will remove the blockchain and state databases at
## Options ## Options
- ```address```: Address of the grpc endpoint - ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```datadir```: Path of the data directory to store information - ```datadir```: Path of the data directory to store information

View file

@ -4,49 +4,53 @@ The ```bor server``` command runs the Bor client.
## Options ## Options
- ```chain```: Name of the chain to sync ('mumbai', 'mainnet') or path to a genesis file - ```chain```: Name of the chain to sync ('mumbai', 'mainnet') or path to a genesis file (default: mainnet)
- ```identity```: Name/Identity of the node - ```identity```: Name/Identity of the node
- ```log-level```: Set log level for the server - ```log-level```: Set log level for the server (default: INFO)
- ```datadir```: Path of the data directory to store information - ```datadir```: Path of the data directory to store information
- ```datadir.ancient```: Data directory for ancient chain segments (default = inside chaindata)
- ```keystore```: Path of the directory where keystores are located - ```keystore```: Path of the directory where keystores are located
- ```config```: File for the config file - ```config```: File for the config file
- ```syncmode```: Blockchain sync mode (only "full" sync supported) - ```syncmode```: Blockchain sync mode (only "full" sync supported) (default: full)
- ```gcmode```: Blockchain garbage collection mode ("full", "archive") - ```gcmode```: Blockchain garbage collection mode ("full", "archive") (default: full)
- ```eth.requiredblocks```: Comma separated block number-to-hash mappings to require for peering (<number>=<hash>) - ```eth.requiredblocks```: Comma separated block number-to-hash mappings to require for peering (<number>=<hash>)
- ```snapshot```: Enables the snapshot-database mode (default = true) - ```snapshot```: Enables the snapshot-database mode (default: true)
- ```bor.logs```: Enables bor log retrieval (default = false) - ```bor.logs```: Enables bor log retrieval (default: false)
- ```bor.heimdall```: URL of Heimdall service - ```bor.heimdall```: URL of Heimdall service (default: http://localhost:1317)
- ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose) - ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose) (default: false)
- ```bor.heimdallgRPC```: Address of Heimdall gRPC service
- ```ethstats```: Reporting URL of a ethstats service (nodename:secret@host:port) - ```ethstats```: Reporting URL of a ethstats service (nodename:secret@host:port)
- ```gpo.blocks```: Number of recent blocks to check for gas prices - ```gpo.blocks```: Number of recent blocks to check for gas prices (default: 20)
- ```gpo.percentile```: Suggested gas price is the given percentile of a set of recent transaction gas prices - ```gpo.percentile```: Suggested gas price is the given percentile of a set of recent transaction gas prices (default: 60)
- ```gpo.maxprice```: Maximum gas price will be recommended by gpo - ```gpo.maxprice```: Maximum gas price will be recommended by gpo (default: 5000000000000)
- ```gpo.ignoreprice```: Gas price below which gpo will ignore transactions - ```gpo.ignoreprice```: Gas price below which gpo will ignore transactions (default: 2)
- ```disable-bor-wallet```: Disable the personal wallet endpoints - ```disable-bor-wallet```: Disable the personal wallet endpoints (default: true)
- ```grpc.addr```: Address and port to bind the GRPC server - ```grpc.addr```: Address and port to bind the GRPC server (default: :3131)
- ```dev```: Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled - ```dev```: Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled (default: false)
- ```dev.period```: Block period to use in developer mode (0 = mine only if transaction pending) - ```dev.period```: Block period to use in developer mode (0 = mine only if transaction pending) (default: 0)
### Account Management Options ### Account Management Options
@ -54,111 +58,113 @@ The ```bor server``` command runs the Bor client.
- ```password```: Password file to use for non-interactive password input - ```password```: Password file to use for non-interactive password input
- ```allow-insecure-unlock```: Allow insecure account unlocking when account-related RPCs are exposed by http - ```allow-insecure-unlock```: Allow insecure account unlocking when account-related RPCs are exposed by http (default: false)
- ```lightkdf```: Reduce key-derivation RAM & CPU usage at some expense of KDF strength - ```lightkdf```: Reduce key-derivation RAM & CPU usage at some expense of KDF strength (default: false)
### Cache Options ### Cache Options
- ```cache```: Megabytes of memory allocated to internal caching (default = 4096 mainnet full node) - ```cache```: Megabytes of memory allocated to internal caching (default: 1024)
- ```cache.database```: Percentage of cache memory allowance to use for database io - ```cache.database```: Percentage of cache memory allowance to use for database io (default: 50)
- ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode) - ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default: 15)
- ```cache.trie.journal```: Disk journal directory for trie cache to survive node restarts - ```cache.trie.journal```: Disk journal directory for trie cache to survive node restarts (default: triecache)
- ```cache.trie.rejournal```: Time interval to regenerate the trie cache journal - ```cache.trie.rejournal```: Time interval to regenerate the trie cache journal (default: 1h0m0s)
- ```cache.gc```: Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode) - ```cache.gc```: Percentage of cache memory allowance to use for trie pruning (default: 25)
- ```cache.snapshot```: Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode) - ```cache.snapshot```: Percentage of cache memory allowance to use for snapshot caching (default: 10)
- ```cache.noprefetch```: Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data) - ```cache.noprefetch```: Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data) (default: false)
- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys - ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys (default: false)
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain) - ```cache.triesinmemory```: Number of block states (tries) to keep in memory (default = 128) (default: 128)
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default: 2350000)
### JsonRPC Options ### JsonRPC Options
- ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite) - ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite) (default: 50000000)
- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap) - ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap) (default: 5)
- ```ipcdisable```: Disable the IPC-RPC server - ```ipcdisable```: Disable the IPC-RPC server (default: false)
- ```ipcpath```: Filename for IPC socket/pipe within the datadir (explicit paths escape it) - ```ipcpath```: Filename for IPC socket/pipe within the datadir (explicit paths escape it)
- ```http.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) - ```http.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) (default: localhost)
- ```http.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. - ```http.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: localhost)
- ```ws.origins```: Origins from which to accept websockets requests - ```ws.origins```: Origins from which to accept websockets requests (default: localhost)
- ```graphql.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) - ```graphql.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) (default: localhost)
- ```graphql.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. - ```graphql.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: localhost)
- ```http```: Enable the HTTP-RPC server - ```http```: Enable the HTTP-RPC server (default: false)
- ```http.addr```: HTTP-RPC server listening interface - ```http.addr```: HTTP-RPC server listening interface (default: localhost)
- ```http.port```: HTTP-RPC server listening port - ```http.port```: HTTP-RPC server listening port (default: 8545)
- ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths. - ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```http.api```: API's offered over the HTTP-RPC interface - ```http.api```: API's offered over the HTTP-RPC interface (default: eth,net,web3,txpool,bor)
- ```ws```: Enable the WS-RPC server - ```ws```: Enable the WS-RPC server (default: false)
- ```ws.addr```: WS-RPC server listening interface - ```ws.addr```: WS-RPC server listening interface (default: localhost)
- ```ws.port```: WS-RPC server listening port - ```ws.port```: WS-RPC server listening port (default: 8546)
- ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths. - ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```ws.api```: API's offered over the WS-RPC interface - ```ws.api```: API's offered over the WS-RPC interface (default: net,web3)
- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well. - ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well. (default: false)
### P2P Options ### P2P Options
- ```bind```: Network binding address - ```bind```: Network binding address (default: 0.0.0.0)
- ```port```: Network listening port - ```port```: Network listening port (default: 30303)
- ```bootnodes```: Comma separated enode URLs for P2P discovery bootstrap - ```bootnodes```: Comma separated enode URLs for P2P discovery bootstrap
- ```maxpeers```: Maximum number of network peers (network disabled if set to 0) - ```maxpeers```: Maximum number of network peers (network disabled if set to 0) (default: 50)
- ```maxpendpeers```: Maximum number of pending connection attempts - ```maxpendpeers```: Maximum number of pending connection attempts (default: 50)
- ```nat```: NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) - ```nat```: NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: any)
- ```nodiscover```: Disables the peer discovery mechanism (manual peer addition) - ```nodiscover```: Disables the peer discovery mechanism (manual peer addition) (default: false)
- ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism - ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false)
### Sealer Options ### Sealer Options
- ```mine```: Enable mining - ```mine```: Enable mining (default: false)
- ```miner.etherbase```: Public address for block mining rewards - ```miner.etherbase```: Public address for block mining rewards
- ```miner.extradata```: Block extra data set by the miner (default = client version) - ```miner.extradata```: Block extra data set by the miner (default = client version)
- ```miner.gaslimit```: Target gas ceiling (gas limit) for mined blocks - ```miner.gaslimit```: Target gas ceiling (gas limit) for mined blocks (default: 30000000)
- ```miner.gasprice```: Minimum gas price for mining a transaction - ```miner.gasprice```: Minimum gas price for mining a transaction (default: 1000000000)
### Telemetry Options ### Telemetry Options
- ```metrics```: Enable metrics collection and reporting - ```metrics```: Enable metrics collection and reporting (default: false)
- ```metrics.expensive```: Enable expensive metrics collection and reporting - ```metrics.expensive```: Enable expensive metrics collection and reporting (default: false)
- ```metrics.influxdb```: Enable metrics export/push to an external InfluxDB database (v1) - ```metrics.influxdb```: Enable metrics export/push to an external InfluxDB database (v1) (default: false)
- ```metrics.influxdb.endpoint```: InfluxDB API endpoint to report metrics to - ```metrics.influxdb.endpoint```: InfluxDB API endpoint to report metrics to
@ -170,11 +176,11 @@ The ```bor server``` command runs the Bor client.
- ```metrics.influxdb.tags```: Comma-separated InfluxDB tags (key/values) attached to all measurements - ```metrics.influxdb.tags```: Comma-separated InfluxDB tags (key/values) attached to all measurements
- ```metrics.prometheus-addr```: Address for Prometheus Server - ```metrics.prometheus-addr```: Address for Prometheus Server (default: 127.0.0.1:7071)
- ```metrics.opencollector-endpoint```: OpenCollector Endpoint (host:port) - ```metrics.opencollector-endpoint```: OpenCollector Endpoint (host:port) (default: 127.0.0.1:4317)
- ```metrics.influxdbv2```: Enable metrics export/push to an external InfluxDB v2 database - ```metrics.influxdbv2```: Enable metrics export/push to an external InfluxDB v2 database (default: false)
- ```metrics.influxdb.token```: Token to authorize access to the database (v2 only) - ```metrics.influxdb.token```: Token to authorize access to the database (v2 only)
@ -186,22 +192,22 @@ The ```bor server``` command runs the Bor client.
- ```txpool.locals```: Comma separated accounts to treat as locals (no flush, priority inclusion) - ```txpool.locals```: Comma separated accounts to treat as locals (no flush, priority inclusion)
- ```txpool.nolocals```: Disables price exemptions for locally submitted transactions - ```txpool.nolocals```: Disables price exemptions for locally submitted transactions (default: false)
- ```txpool.journal```: Disk journal for local transaction to survive node restarts - ```txpool.journal```: Disk journal for local transaction to survive node restarts (default: transactions.rlp)
- ```txpool.rejournal```: Time interval to regenerate the local transaction journal - ```txpool.rejournal```: Time interval to regenerate the local transaction journal (default: 1h0m0s)
- ```txpool.pricelimit```: Minimum gas price limit to enforce for acceptance into the pool - ```txpool.pricelimit```: Minimum gas price limit to enforce for acceptance into the pool (default: 1)
- ```txpool.pricebump```: Price bump percentage to replace an already existing transaction - ```txpool.pricebump```: Price bump percentage to replace an already existing transaction (default: 10)
- ```txpool.accountslots```: Minimum number of executable transaction slots guaranteed per account - ```txpool.accountslots```: Minimum number of executable transaction slots guaranteed per account (default: 16)
- ```txpool.globalslots```: Maximum number of executable transaction slots for all accounts - ```txpool.globalslots```: Maximum number of executable transaction slots for all accounts (default: 32768)
- ```txpool.accountqueue```: Maximum number of non-executable transaction slots permitted per account - ```txpool.accountqueue```: Maximum number of non-executable transaction slots permitted per account (default: 16)
- ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts - ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts (default: 32768)
- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued - ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued (default: 3h0m0s)

5
docs/cli/snapshot.md Normal file
View file

@ -0,0 +1,5 @@
# snapshot
The ```snapshot``` command groups snapshot related actions:
- [```snapshot prune-state```](./snapshot_prune-state.md): Prune state databases at the given datadir location.

View file

@ -0,0 +1,21 @@
# Prune state
The ```bor snapshot prune-state``` command will prune historical state data with the help of the state snapshot. All trie nodes and contract codes that do not belong to the specified version state will be deleted from the database. After pruning, only two version states are available: genesis and the specific one.
## Options
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys
- ```datadir.ancient```: Path of the ancient data directory to store information
- ```bloomfilter.size```: Size of the bloom filter (default: 2048)
### Cache Options
- ```cache```: Megabytes of memory allocated to internal caching (default: 1024)
- ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default: 25)
- ```cache.trie.journal```: Path of the trie journal directory to store information (default: triecache)

View file

@ -189,6 +189,16 @@ func Commands() map[string]MarkDownCommandFactory {
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"snapshot": func() (MarkDownCommand, error) {
return &SnapshotCommand{
UI: ui,
}, nil
},
"snapshot prune-state": func() (MarkDownCommand, error) {
return &PruneStateCommand{
Meta: meta,
}, nil
},
} }
} }
@ -248,7 +258,7 @@ func (m *Meta) NewFlagSet(n string) *flagset.Flagset {
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "keystore", Name: "keystore",
Value: &m.keyStoreDir, Value: &m.keyStoreDir,
Usage: "Path of the data directory to store information", Usage: "Path of the data directory to store keys",
}) })
return f return f

View file

@ -27,6 +27,7 @@ type FlagVar struct {
Name string Name string
Usage string Usage string
Group string Group string
Default any
} }
func (f *Flagset) addFlag(fl *FlagVar) { func (f *Flagset) addFlag(fl *FlagVar) {
@ -38,8 +39,12 @@ func (f *Flagset) Help() string {
items := []string{} items := []string{}
for _, item := range f.flags { for _, item := range f.flags {
if item.Default != nil {
items = append(items, fmt.Sprintf(" -%s\n %s (default: %v)", item.Name, item.Usage, item.Default))
} else {
items = append(items, fmt.Sprintf(" -%s\n %s", item.Name, item.Usage)) items = append(items, fmt.Sprintf(" -%s\n %s", item.Name, item.Usage))
} }
}
return str + strings.Join(items, "\n\n") return str + strings.Join(items, "\n\n")
} }
@ -85,9 +90,13 @@ func (f *Flagset) MarkDown() string {
} }
for _, item := range groups[k] { for _, item := range groups[k] {
if item.Default != nil {
items = append(items, fmt.Sprintf("- ```%s```: %s (default: %v)", item.Name, item.Usage, item.Default))
} else {
items = append(items, fmt.Sprintf("- ```%s```: %s", item.Name, item.Usage)) items = append(items, fmt.Sprintf("- ```%s```: %s", item.Name, item.Usage))
} }
} }
}
return strings.Join(items, "\n\n") return strings.Join(items, "\n\n")
} }
@ -113,6 +122,7 @@ func (f *Flagset) BoolFlag(b *BoolFlag) {
Name: b.Name, Name: b.Name,
Usage: b.Usage, Usage: b.Usage,
Group: b.Group, Group: b.Group,
Default: b.Default,
}) })
f.set.BoolVar(b.Value, b.Name, b.Default, b.Usage) f.set.BoolVar(b.Value, b.Name, b.Default, b.Usage)
} }
@ -123,14 +133,25 @@ type StringFlag struct {
Default string Default string
Value *string Value *string
Group string Group string
HideDefaultFromDoc bool
} }
func (f *Flagset) StringFlag(b *StringFlag) { func (f *Flagset) StringFlag(b *StringFlag) {
if b.Default == "" || b.HideDefaultFromDoc {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: b.Name, Name: b.Name,
Usage: b.Usage, Usage: b.Usage,
Group: b.Group, Group: b.Group,
Default: nil,
}) })
} else {
f.addFlag(&FlagVar{
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
Default: b.Default,
})
}
f.set.StringVar(b.Value, b.Name, b.Default, b.Usage) f.set.StringVar(b.Value, b.Name, b.Default, b.Usage)
} }
@ -147,6 +168,7 @@ func (f *Flagset) IntFlag(i *IntFlag) {
Name: i.Name, Name: i.Name,
Usage: i.Usage, Usage: i.Usage,
Group: i.Group, Group: i.Group,
Default: i.Default,
}) })
f.set.IntVar(i.Value, i.Name, i.Default, i.Usage) f.set.IntVar(i.Value, i.Name, i.Default, i.Usage)
} }
@ -164,6 +186,7 @@ func (f *Flagset) Uint64Flag(i *Uint64Flag) {
Name: i.Name, Name: i.Name,
Usage: i.Usage, Usage: i.Usage,
Group: i.Group, Group: i.Group,
Default: fmt.Sprintf("%d", i.Default),
}) })
f.set.Uint64Var(i.Value, i.Name, i.Default, i.Usage) f.set.Uint64Var(i.Value, i.Name, i.Default, i.Usage)
} }
@ -173,6 +196,7 @@ type BigIntFlag struct {
Usage string Usage string
Value *big.Int Value *big.Int
Group string Group string
Default *big.Int
} }
func (b *BigIntFlag) String() string { func (b *BigIntFlag) String() string {
@ -207,6 +231,7 @@ func (f *Flagset) BigIntFlag(b *BigIntFlag) {
Name: b.Name, Name: b.Name,
Usage: b.Usage, Usage: b.Usage,
Group: b.Group, Group: b.Group,
Default: b.Default,
}) })
f.set.Var(b, b.Name, b.Usage) f.set.Var(b, b.Name, b.Usage)
} }
@ -247,11 +272,21 @@ func (i *SliceStringFlag) Set(value string) error {
} }
func (f *Flagset) SliceStringFlag(s *SliceStringFlag) { func (f *Flagset) SliceStringFlag(s *SliceStringFlag) {
if s.Default == nil || len(s.Default) == 0 {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: s.Name, Name: s.Name,
Usage: s.Usage, Usage: s.Usage,
Group: s.Group, Group: s.Group,
Default: nil,
}) })
} else {
f.addFlag(&FlagVar{
Name: s.Name,
Usage: s.Usage,
Group: s.Group,
Default: strings.Join(s.Default, ","),
})
}
f.set.Var(s, s.Name, s.Usage) f.set.Var(s, s.Name, s.Usage)
} }
@ -268,6 +303,7 @@ func (f *Flagset) DurationFlag(d *DurationFlag) {
Name: d.Name, Name: d.Name,
Usage: d.Usage, Usage: d.Usage,
Group: d.Group, Group: d.Group,
Default: d.Default,
}) })
f.set.DurationVar(d.Value, d.Name, d.Default, "") f.set.DurationVar(d.Value, d.Name, d.Default, "")
} }
@ -277,21 +313,26 @@ type MapStringFlag struct {
Usage string Usage string
Value *map[string]string Value *map[string]string
Group string Group string
Default map[string]string
} }
func (m *MapStringFlag) String() string { func formatMapString(m map[string]string) string {
if m.Value == nil { if len(m) == 0 {
return "" return ""
} }
ls := []string{} ls := []string{}
for k, v := range *m.Value { for k, v := range m {
ls = append(ls, k+"="+v) ls = append(ls, k+"="+v)
} }
return strings.Join(ls, ",") return strings.Join(ls, ",")
} }
func (m *MapStringFlag) String() string {
return formatMapString(*m.Value)
}
func (m *MapStringFlag) Set(value string) error { func (m *MapStringFlag) Set(value string) error {
if m.Value == nil { if m.Value == nil {
m.Value = &map[string]string{} m.Value = &map[string]string{}
@ -311,11 +352,21 @@ func (m *MapStringFlag) Set(value string) error {
} }
func (f *Flagset) MapStringFlag(m *MapStringFlag) { func (f *Flagset) MapStringFlag(m *MapStringFlag) {
if m.Default == nil || len(m.Default) == 0 {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: m.Name, Name: m.Name,
Usage: m.Usage, Usage: m.Usage,
Group: m.Group, Group: m.Group,
Default: nil,
}) })
} else {
f.addFlag(&FlagVar{
Name: m.Name,
Usage: m.Usage,
Group: m.Group,
Default: formatMapString(m.Default),
})
}
f.set.Var(m, m.Name, m.Usage) f.set.Var(m, m.Name, m.Usage)
} }
@ -332,6 +383,7 @@ func (f *Flagset) Float64Flag(i *Float64Flag) {
Name: i.Name, Name: i.Name,
Usage: i.Usage, Usage: i.Usage,
Group: i.Group, Group: i.Group,
Default: i.Default,
}) })
f.set.Float64Var(i.Value, i.Name, i.Default, "") f.set.Float64Var(i.Value, i.Name, i.Default, "")
} }

View file

@ -26,6 +26,7 @@ type RemoveDBCommand struct {
const ( const (
chaindataPath string = "chaindata" chaindataPath string = "chaindata"
ancientPath string = "ancient" ancientPath string = "ancient"
trieCacheJournalPath string = "triecache"
lightchaindataPath string = "lightchaindata" lightchaindataPath string = "lightchaindata"
) )

View file

@ -686,7 +686,7 @@ func (c *Config) loadChain() error {
//nolint:gocognit //nolint:gocognit
func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*ethconfig.Config, error) { func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*ethconfig.Config, error) {
dbHandles, err := makeDatabaseHandles() dbHandles, err := MakeDatabaseHandles()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1075,7 +1075,7 @@ func (c *Config) Merge(cc ...*Config) error {
return nil return nil
} }
func makeDatabaseHandles() (int, error) { func MakeDatabaseHandles() (int, error) {
limit, err := fdlimit.Maximum() limit, err := fdlimit.Maximum()
if err != nil { if err != nil {
return -1, err return -1, err

View file

@ -20,6 +20,7 @@ func (c *Command) Flags() *flagset.Flagset {
Usage: "Name/Identity of the node", Usage: "Name/Identity of the node",
Value: &c.cliConfig.Identity, Value: &c.cliConfig.Identity,
Default: c.cliConfig.Identity, Default: c.cliConfig.Identity,
HideDefaultFromDoc: true,
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "log-level", Name: "log-level",
@ -32,6 +33,7 @@ func (c *Command) Flags() *flagset.Flagset {
Usage: "Path of the data directory to store information", Usage: "Path of the data directory to store information",
Value: &c.cliConfig.DataDir, Value: &c.cliConfig.DataDir,
Default: c.cliConfig.DataDir, Default: c.cliConfig.DataDir,
HideDefaultFromDoc: true,
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "datadir.ancient", Name: "datadir.ancient",
@ -65,16 +67,17 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "eth.requiredblocks", Name: "eth.requiredblocks",
Usage: "Comma separated block number-to-hash mappings to require for peering (<number>=<hash>)", Usage: "Comma separated block number-to-hash mappings to require for peering (<number>=<hash>)",
Value: &c.cliConfig.RequiredBlocks, Value: &c.cliConfig.RequiredBlocks,
Default: c.cliConfig.RequiredBlocks,
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "snapshot", Name: "snapshot",
Usage: `Enables the snapshot-database mode (default = true)`, Usage: `Enables the snapshot-database mode`,
Value: &c.cliConfig.Snapshot, Value: &c.cliConfig.Snapshot,
Default: c.cliConfig.Snapshot, Default: c.cliConfig.Snapshot,
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "bor.logs", Name: "bor.logs",
Usage: `Enables bor log retrieval (default = false)`, Usage: `Enables bor log retrieval`,
Value: &c.cliConfig.BorLogs, Value: &c.cliConfig.BorLogs,
Default: c.cliConfig.BorLogs, Default: c.cliConfig.BorLogs,
}) })
@ -212,6 +215,7 @@ func (c *Command) Flags() *flagset.Flagset {
Usage: "Minimum gas price for mining a transaction", Usage: "Minimum gas price for mining a transaction",
Value: c.cliConfig.Sealer.GasPrice, Value: c.cliConfig.Sealer.GasPrice,
Group: "Sealer", Group: "Sealer",
Default: c.cliConfig.Sealer.GasPrice,
}) })
// ethstats // ethstats
@ -239,17 +243,19 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "gpo.maxprice", Name: "gpo.maxprice",
Usage: "Maximum gas price will be recommended by gpo", Usage: "Maximum gas price will be recommended by gpo",
Value: c.cliConfig.Gpo.MaxPrice, Value: c.cliConfig.Gpo.MaxPrice,
Default: c.cliConfig.Gpo.MaxPrice,
}) })
f.BigIntFlag(&flagset.BigIntFlag{ f.BigIntFlag(&flagset.BigIntFlag{
Name: "gpo.ignoreprice", Name: "gpo.ignoreprice",
Usage: "Gas price below which gpo will ignore transactions", Usage: "Gas price below which gpo will ignore transactions",
Value: c.cliConfig.Gpo.IgnorePrice, Value: c.cliConfig.Gpo.IgnorePrice,
Default: c.cliConfig.Gpo.IgnorePrice,
}) })
// cache options // cache options
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache", Name: "cache",
Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)", Usage: "Megabytes of memory allocated to internal caching",
Value: &c.cliConfig.Cache.Cache, Value: &c.cliConfig.Cache.Cache,
Default: c.cliConfig.Cache.Cache, Default: c.cliConfig.Cache.Cache,
Group: "Cache", Group: "Cache",
@ -263,7 +269,7 @@ func (c *Command) Flags() *flagset.Flagset {
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.trie", Name: "cache.trie",
Usage: "Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)", Usage: "Percentage of cache memory allowance to use for trie caching",
Value: &c.cliConfig.Cache.PercTrie, Value: &c.cliConfig.Cache.PercTrie,
Default: c.cliConfig.Cache.PercTrie, Default: c.cliConfig.Cache.PercTrie,
Group: "Cache", Group: "Cache",
@ -284,14 +290,14 @@ func (c *Command) Flags() *flagset.Flagset {
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.gc", Name: "cache.gc",
Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)", Usage: "Percentage of cache memory allowance to use for trie pruning",
Value: &c.cliConfig.Cache.PercGc, Value: &c.cliConfig.Cache.PercGc,
Default: c.cliConfig.Cache.PercGc, Default: c.cliConfig.Cache.PercGc,
Group: "Cache", Group: "Cache",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.snapshot", Name: "cache.snapshot",
Usage: "Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)", Usage: "Percentage of cache memory allowance to use for snapshot caching",
Value: &c.cliConfig.Cache.PercSnapshot, Value: &c.cliConfig.Cache.PercSnapshot,
Default: c.cliConfig.Cache.PercSnapshot, Default: c.cliConfig.Cache.PercSnapshot,
Group: "Cache", Group: "Cache",
@ -319,7 +325,7 @@ func (c *Command) Flags() *flagset.Flagset {
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txlookuplimit", Name: "txlookuplimit",
Usage: "Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)", Usage: "Number of recent blocks to maintain transactions index for",
Value: &c.cliConfig.Cache.TxLookupLimit, Value: &c.cliConfig.Cache.TxLookupLimit,
Default: c.cliConfig.Cache.TxLookupLimit, Default: c.cliConfig.Cache.TxLookupLimit,
Group: "Cache", Group: "Cache",
@ -586,6 +592,7 @@ func (c *Command) Flags() *flagset.Flagset {
Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements", Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
Value: &c.cliConfig.Telemetry.InfluxDB.Tags, Value: &c.cliConfig.Telemetry.InfluxDB.Tags,
Group: "Telemetry", Group: "Telemetry",
Default: c.cliConfig.Telemetry.InfluxDB.Tags,
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.prometheus-addr", Name: "metrics.prometheus-addr",

183
internal/cli/snapshot.go Normal file
View file

@ -0,0 +1,183 @@
// Snapshot related commands
package cli
import (
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state/pruner"
"github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/mitchellh/cli"
)
// SnapshotCommand is the command to group the snapshot commands
type SnapshotCommand struct {
UI cli.Ui
}
// MarkDown implements cli.MarkDown interface
func (a *SnapshotCommand) MarkDown() string {
items := []string{
"# snapshot",
"The ```snapshot``` command groups snapshot related actions:",
"- [```snapshot prune-state```](./snapshot_prune-state.md): Prune state databases at the given datadir location.",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface
func (c *SnapshotCommand) Help() string {
return `Usage: bor snapshot <subcommand>
This command groups snapshot related actions.
Prune the state trie:
$ bor snapshot prune-state`
}
// Synopsis implements the cli.Command interface
func (c *SnapshotCommand) Synopsis() string {
return "Snapshot related commands"
}
// Run implements the cli.Command interface
func (c *SnapshotCommand) Run(args []string) int {
return cli.RunResultHelp
}
type PruneStateCommand struct {
*Meta
datadirAncient string
cache uint64
cacheTrie uint64
cacheTrieJournal string
bloomfilterSize uint64
}
// MarkDown implements cli.MarkDown interface
func (c *PruneStateCommand) MarkDown() string {
items := []string{
"# Prune state",
"The ```bor snapshot prune-state``` command will prune historical state data with the help of the state snapshot. All trie nodes and contract codes that do not belong to the specified version state will be deleted from the database. After pruning, only two version states are available: genesis and the specific one.",
c.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface
func (c *PruneStateCommand) Help() string {
return `Usage: bor snapshot prune-state <datadir>
This command will prune state databases at the given datadir location` + c.Flags().Help()
}
// Synopsis implements the cli.Command interface
func (c *PruneStateCommand) Synopsis() string {
return "Prune state databases"
}
// Flags: datadir, datadir.ancient, cache.trie.journal, bloomfilter.size
func (c *PruneStateCommand) Flags() *flagset.Flagset {
flags := c.NewFlagSet("prune-state")
flags.StringFlag(&flagset.StringFlag{
Name: "datadir.ancient",
Value: &c.datadirAncient,
Usage: "Path of the ancient data directory to store information",
Default: "",
})
flags.Uint64Flag(&flagset.Uint64Flag{
Name: "cache",
Usage: "Megabytes of memory allocated to internal caching",
Value: &c.cache,
Default: 1024.0,
Group: "Cache",
})
flags.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.trie",
Usage: "Percentage of cache memory allowance to use for trie caching",
Value: &c.cacheTrie,
Default: 25,
Group: "Cache",
})
flags.StringFlag(&flagset.StringFlag{
Name: "cache.trie.journal",
Value: &c.cacheTrieJournal,
Usage: "Path of the trie journal directory to store information",
Default: trieCacheJournalPath,
Group: "Cache",
})
flags.Uint64Flag(&flagset.Uint64Flag{
Name: "bloomfilter.size",
Value: &c.bloomfilterSize,
Usage: "Size of the bloom filter",
Default: 2048,
})
return flags
}
// Run implements the cli.Command interface
func (c *PruneStateCommand) Run(args []string) int {
flags := c.Flags()
if err := flags.Parse(args); err != nil {
c.UI.Error(err.Error())
return 1
}
datadir := c.dataDir
if datadir == "" {
c.UI.Error("datadir is required")
return 1
}
// Create the node
node, err := node.New(&node.Config{
DataDir: datadir,
})
if err != nil {
c.UI.Error(err.Error())
return 1
}
dbHandles, err := server.MakeDatabaseHandles()
if err != nil {
c.UI.Error(err.Error())
return 1
}
chaindb, err := node.OpenDatabaseWithFreezer(chaindataPath, int(c.cache), dbHandles, c.datadirAncient, "", false)
if err != nil {
c.UI.Error(err.Error())
return 1
}
pruner, err := pruner.NewPruner(chaindb, node.ResolvePath(""), node.ResolvePath(c.cacheTrieJournal), c.bloomfilterSize)
if err != nil {
log.Error("Failed to open snapshot tree", "err", err)
return 1
}
if err = pruner.Prune(common.Hash{}); err != nil {
log.Error("Failed to prune state", "err", err)
return 1
}
return 0
}

View file

@ -819,20 +819,6 @@ func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.H
return nil return nil
} }
// getAuthor: returns the author of the Block
func (s *PublicBlockChainAPI) getAuthor(head *types.Header) *common.Address {
// get author using Author() function from: /consensus/clique/clique.go
// In Production: get author using Author() function from: /consensus/bor/bor.go
author, err := s.b.Engine().Author(head)
// make sure we don't send error to the user, return 0x0 instead
if err != nil {
add := common.HexToAddress("0x0000000000000000000000000000000000000000")
return &add
}
// change the coinbase (0x0) with the miner address
return &author
}
// GetBlockByNumber returns the requested canonical block. // GetBlockByNumber returns the requested canonical block.
// - When blockNr is -1 the chain head is returned. // - When blockNr is -1 the chain head is returned.
// - When blockNr is -2 the pending chain head is returned. // - When blockNr is -2 the pending chain head is returned.
@ -841,7 +827,6 @@ func (s *PublicBlockChainAPI) getAuthor(head *types.Header) *common.Address {
func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
block, err := s.b.BlockByNumber(ctx, number) block, err := s.b.BlockByNumber(ctx, number)
if block != nil && err == nil { if block != nil && err == nil {
response, err := s.rpcMarshalBlock(ctx, block, true, fullTx) response, err := s.rpcMarshalBlock(ctx, block, true, fullTx)
if err == nil && number == rpc.PendingBlockNumber { if err == nil && number == rpc.PendingBlockNumber {
// Pending blocks need to nil out a few fields // Pending blocks need to nil out a few fields
@ -850,12 +835,6 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B
} }
} }
if err == nil && number != rpc.PendingBlockNumber {
author := s.getAuthor(block.Header())
response["miner"] = author
}
// append marshalled bor transaction // append marshalled bor transaction
if err == nil && response != nil { if err == nil && response != nil {
response = s.appendRPCMarshalBorTransaction(ctx, block, response, fullTx) response = s.appendRPCMarshalBorTransaction(ctx, block, response, fullTx)
@ -874,10 +853,6 @@ func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Ha
response, err := s.rpcMarshalBlock(ctx, block, true, fullTx) response, err := s.rpcMarshalBlock(ctx, block, true, fullTx)
// append marshalled bor transaction // append marshalled bor transaction
if err == nil && response != nil { if err == nil && response != nil {
author := s.getAuthor(block.Header())
response["miner"] = author
return s.appendRPCMarshalBorTransaction(ctx, block, response, fullTx), err return s.appendRPCMarshalBorTransaction(ctx, block, response, fullTx), err
} }
return response, err return response, err

View file

@ -23,8 +23,8 @@ import (
const ( const (
VersionMajor = 0 // Major version component of the current release VersionMajor = 0 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release VersionMinor = 3 // Minor version component of the current release
VersionPatch = 1 // Patch version component of the current release VersionPatch = 2 // Patch version component of the current release
VersionMeta = "mumbai" // Version metadata to append to the version string VersionMeta = "beta" // Version metadata to append to the version string
) )
// Version holds the textual version string. // Version holds the textual version string.