2020-10-27 15:53:49 +00:00
package cli
import (
"fmt"
2022-02-16 17:38:54 +00:00
"path/filepath"
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
"strings"
2021-07-10 02:19:44 +00:00
"time"
2020-10-27 15:53:49 +00:00
"github.com/c2h5oh/datasize"
2021-09-12 07:50:17 +00:00
"github.com/ledgerwatch/erigon-lib/etl"
2021-07-29 11:53:13 +00:00
"github.com/ledgerwatch/erigon-lib/kv"
2022-02-16 17:38:54 +00:00
"github.com/ledgerwatch/erigon-lib/kv/kvcache"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli/httpcfg"
2021-05-20 18:25:53 +00:00
"github.com/ledgerwatch/erigon/cmd/utils"
2021-09-01 21:16:25 +00:00
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/hexutil"
2021-05-20 18:25:53 +00:00
"github.com/ledgerwatch/erigon/eth/ethconfig"
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
"github.com/ledgerwatch/erigon/ethdb/prune"
2021-05-20 18:25:53 +00:00
"github.com/ledgerwatch/erigon/node"
2021-07-29 10:23:23 +00:00
"github.com/ledgerwatch/log/v3"
2021-03-23 09:00:07 +00:00
"github.com/spf13/pflag"
2020-10-27 15:53:49 +00:00
"github.com/urfave/cli"
)
var (
2021-04-27 12:31:00 +00:00
DatabaseVerbosityFlag = cli . IntFlag {
Name : "database.verbosity" ,
2021-05-11 08:22:34 +00:00
Usage : "Enabling internal db logs. Very high verbosity levels may require recompile db. Default: 2, means warning." ,
Value : 2 ,
2021-04-27 12:31:00 +00:00
}
2020-10-27 15:53:49 +00:00
BatchSizeFlag = cli . StringFlag {
Name : "batchSize" ,
Usage : "Batch size for the execution stage" ,
Value : "512M" ,
}
EtlBufferSizeFlag = cli . StringFlag {
Name : "etl.bufferSize" ,
Usage : "Buffer size for ETL operations." ,
Value : etl . BufferOptimalSize . String ( ) ,
}
2021-07-01 03:14:10 +00:00
BlockDownloaderWindowFlag = cli . IntFlag {
Name : "blockDownloaderWindow" ,
Usage : "Outstanding limit of block bodies being downloaded" ,
2021-08-03 03:19:18 +00:00
Value : 32768 ,
2021-07-01 03:14:10 +00:00
}
2020-10-27 15:53:49 +00:00
PrivateApiAddr = cli . StringFlag {
Name : "private.api.addr" ,
Usage : "private api network address, for example: 127.0.0.1:9090, empty string means not to start the listener. do not expose to public network. serves remote database interface" ,
2021-07-01 21:30:55 +00:00
Value : "127.0.0.1:9090" ,
2020-10-27 15:53:49 +00:00
}
2021-03-23 07:28:04 +00:00
PrivateApiRateLimit = cli . IntFlag {
Name : "private.api.ratelimit" ,
Usage : "Amount of requests server handle simultaneously - requests over this limit will wait. Increase it - if clients see 'request timeout' while server load is low - it means your 'hot data' is small or have much RAM. " ,
2021-08-13 15:51:59 +00:00
Value : kv . ReadersLimit - 128 ,
2021-03-23 07:28:04 +00:00
}
2021-06-13 20:14:52 +00:00
MaxPeersFlag = cli . IntFlag {
Name : "maxpeers" ,
Usage : "Maximum number of network peers (network disabled if set to 0)" ,
Value : node . DefaultConfig . P2P . MaxPeers ,
}
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
PruneFlag = cli . StringFlag {
Name : "prune" ,
2022-02-16 17:38:54 +00:00
Usage : ` Choose which ancient data delete from DB :
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
h - prune history ( ChangeSets , HistoryIndices - used by historical state access )
r - prune receipts ( Receipts , Logs , LogTopicIndex , LogAddressIndex - used by eth_getLogs and similar RPC methods )
t - prune transaction by it ' s hash index
c - prune call traces ( used by trace_ * methods )
Does delete data older than 90 K block ( can set another value by ' -- prune . * . older ' flags ) .
If item is NOT in the list - means NO pruning for this data . s
Example : -- prune = hrtc ` ,
Value : "disabled" ,
}
PruneHistoryFlag = cli . Uint64Flag {
2021-07-22 11:55:56 +00:00
Name : "prune.h.older" ,
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
Usage : ` Prune data after this amount of blocks (if --prune flag has 'h', then default is 90K) ` ,
}
PruneReceiptFlag = cli . Uint64Flag {
2021-07-22 11:55:56 +00:00
Name : "prune.r.older" ,
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
Usage : ` Prune data after this amount of blocks (if --prune flag has 'r', then default is 90K) ` ,
}
PruneTxIndexFlag = cli . Uint64Flag {
2021-07-22 11:55:56 +00:00
Name : "prune.t.older" ,
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
Usage : ` Prune data after this amount of blocks (if --prune flag has 't', then default is 90K) ` ,
}
PruneCallTracesFlag = cli . Uint64Flag {
2021-07-22 11:55:56 +00:00
Name : "prune.c.older" ,
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
Usage : ` Prune data after this amount of blocks (if --prune flag has 'c', then default is 90K) ` ,
}
2021-09-23 02:13:19 +00:00
PruneHistoryBeforeFlag = cli . Uint64Flag {
Name : "prune.h.before" ,
Usage : ` Prune data before this block ` ,
}
PruneReceiptBeforeFlag = cli . Uint64Flag {
Name : "prune.r.before" ,
Usage : ` Prune data before this block ` ,
}
PruneTxIndexBeforeFlag = cli . Uint64Flag {
Name : "prune.t.before" ,
Usage : ` Prune data before this block ` ,
}
PruneCallTracesBeforeFlag = cli . Uint64Flag {
Name : "prune.c.before" ,
Usage : ` Prune data before this block ` ,
}
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
ExperimentsFlag = cli . StringFlag {
Name : "experiments" ,
Usage : ` Enable some experimental stages :
* tevm - write TEVM translated code to the DB ` ,
2021-05-08 22:07:16 +00:00
Value : "default" ,
2020-10-27 15:53:49 +00:00
}
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
2020-10-27 15:53:49 +00:00
// mTLS flags
TLSFlag = cli . BoolFlag {
Name : "tls" ,
Usage : "Enable TLS handshake" ,
}
TLSCertFlag = cli . StringFlag {
Name : "tls.cert" ,
Usage : "Specify certificate" ,
Value : "" ,
}
TLSKeyFlag = cli . StringFlag {
Name : "tls.key" ,
Usage : "Specify key file" ,
Value : "" ,
}
TLSCACertFlag = cli . StringFlag {
Name : "tls.cacert" ,
Usage : "Specify certificate authority" ,
Value : "" ,
}
2021-10-05 09:06:45 +00:00
StateStreamDisableFlag = cli . BoolFlag {
Name : "state.stream.disable" ,
Usage : "Disable streaming of state changes from core to RPC daemon" ,
2021-05-23 14:53:18 +00:00
}
2021-07-10 02:19:44 +00:00
// Throttling Flags
SyncLoopThrottleFlag = cli . StringFlag {
Name : "sync.loop.throttle" ,
Usage : "Sets the minimum time between sync loop starts (e.g. 1h30m, default is none)" ,
Value : "" ,
}
2021-07-22 15:49:36 +00:00
2021-09-01 21:16:25 +00:00
BadBlockFlag = cli . StringFlag {
2021-07-22 15:49:36 +00:00
Name : "bad.block" ,
2021-09-01 21:16:25 +00:00
Usage : "Marks block with given hex string as bad and forces initial reorg before normal staged sync" ,
Value : "" ,
2021-07-22 15:49:36 +00:00
}
2021-12-06 12:03:46 +00:00
HealthCheckFlag = cli . BoolFlag {
Name : "healthcheck" ,
Usage : "Enable grpc health check" ,
}
2020-10-27 15:53:49 +00:00
)
2021-03-23 09:00:07 +00:00
func ApplyFlagsForEthConfig ( ctx * cli . Context , cfg * ethconfig . Config ) {
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
mode , err := prune . FromCli (
ctx . GlobalString ( PruneFlag . Name ) ,
ctx . GlobalUint64 ( PruneHistoryFlag . Name ) ,
ctx . GlobalUint64 ( PruneReceiptFlag . Name ) ,
ctx . GlobalUint64 ( PruneTxIndexFlag . Name ) ,
ctx . GlobalUint64 ( PruneCallTracesFlag . Name ) ,
2021-09-23 02:13:19 +00:00
ctx . GlobalUint64 ( PruneHistoryBeforeFlag . Name ) ,
ctx . GlobalUint64 ( PruneReceiptBeforeFlag . Name ) ,
ctx . GlobalUint64 ( PruneTxIndexBeforeFlag . Name ) ,
ctx . GlobalUint64 ( PruneCallTracesBeforeFlag . Name ) ,
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
strings . Split ( ctx . GlobalString ( ExperimentsFlag . Name ) , "," ) ,
)
2020-10-27 15:53:49 +00:00
if err != nil {
utils . Fatalf ( fmt . Sprintf ( "error while parsing mode: %v" , err ) )
}
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
cfg . Prune = mode
2020-10-27 15:53:49 +00:00
if ctx . GlobalString ( BatchSizeFlag . Name ) != "" {
err := cfg . BatchSize . UnmarshalText ( [ ] byte ( ctx . GlobalString ( BatchSizeFlag . Name ) ) )
if err != nil {
utils . Fatalf ( "Invalid batchSize provided: %v" , err )
}
}
if ctx . GlobalString ( EtlBufferSizeFlag . Name ) != "" {
sizeVal := datasize . ByteSize ( 0 )
size := & sizeVal
err := size . UnmarshalText ( [ ] byte ( ctx . GlobalString ( EtlBufferSizeFlag . Name ) ) )
if err != nil {
utils . Fatalf ( "Invalid batchSize provided: %v" , err )
}
etl . BufferOptimalSize = * size
}
2020-11-13 16:16:47 +00:00
2021-10-05 09:06:45 +00:00
cfg . StateStream = ! ctx . GlobalBool ( StateStreamDisableFlag . Name )
2021-07-01 03:14:10 +00:00
cfg . BlockDownloaderWindow = ctx . GlobalInt ( BlockDownloaderWindowFlag . Name )
2021-07-10 02:19:44 +00:00
if ctx . GlobalString ( SyncLoopThrottleFlag . Name ) != "" {
syncLoopThrottle , err := time . ParseDuration ( ctx . GlobalString ( SyncLoopThrottleFlag . Name ) )
if err != nil {
utils . Fatalf ( "Invalid time duration provided in %s: %v" , SyncLoopThrottleFlag . Name , err )
}
cfg . SyncLoopThrottle = syncLoopThrottle
}
2021-09-01 21:16:25 +00:00
2021-09-02 08:49:49 +00:00
if ctx . GlobalString ( BadBlockFlag . Name ) != "" {
bytes , err := hexutil . Decode ( ctx . GlobalString ( BadBlockFlag . Name ) )
if err != nil {
2022-03-01 15:40:51 +00:00
log . Warn ( "Error decoding block hash" , "hash" , ctx . GlobalString ( BadBlockFlag . Name ) , "err" , err )
2021-09-02 08:49:49 +00:00
} else {
cfg . BadBlockHash = common . BytesToHash ( bytes )
}
2021-09-01 21:16:25 +00:00
}
2021-11-21 03:32:14 +00:00
2020-10-27 15:53:49 +00:00
}
2021-07-10 02:19:44 +00:00
2021-03-23 09:00:07 +00:00
func ApplyFlagsForEthConfigCobra ( f * pflag . FlagSet , cfg * ethconfig . Config ) {
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
if v := f . String ( PruneFlag . Name , PruneFlag . Value , PruneFlag . Usage ) ; v != nil {
var experiments [ ] string
if exp := f . StringSlice ( ExperimentsFlag . Name , nil , ExperimentsFlag . Usage ) ; exp != nil {
experiments = * exp
}
var exactH , exactR , exactT , exactC uint64
if v := f . Uint64 ( PruneHistoryFlag . Name , PruneHistoryFlag . Value , PruneHistoryFlag . Usage ) ; v != nil {
exactH = * v
}
if v := f . Uint64 ( PruneReceiptFlag . Name , PruneReceiptFlag . Value , PruneReceiptFlag . Usage ) ; v != nil {
exactR = * v
}
if v := f . Uint64 ( PruneTxIndexFlag . Name , PruneTxIndexFlag . Value , PruneTxIndexFlag . Usage ) ; v != nil {
exactT = * v
}
if v := f . Uint64 ( PruneCallTracesFlag . Name , PruneCallTracesFlag . Value , PruneCallTracesFlag . Usage ) ; v != nil {
exactC = * v
}
2021-09-23 02:13:19 +00:00
var beforeH , beforeR , beforeT , beforeC uint64
if v := f . Uint64 ( PruneHistoryBeforeFlag . Name , PruneHistoryBeforeFlag . Value , PruneHistoryBeforeFlag . Usage ) ; v != nil {
beforeH = * v
}
if v := f . Uint64 ( PruneReceiptBeforeFlag . Name , PruneReceiptBeforeFlag . Value , PruneReceiptBeforeFlag . Usage ) ; v != nil {
beforeR = * v
}
if v := f . Uint64 ( PruneTxIndexBeforeFlag . Name , PruneTxIndexBeforeFlag . Value , PruneTxIndexBeforeFlag . Usage ) ; v != nil {
beforeT = * v
}
if v := f . Uint64 ( PruneCallTracesBeforeFlag . Name , PruneCallTracesBeforeFlag . Value , PruneCallTracesBeforeFlag . Usage ) ; v != nil {
beforeC = * v
}
mode , err := prune . FromCli ( * v , exactH , exactR , exactT , exactC , beforeH , beforeR , beforeT , beforeC , experiments )
2021-03-23 09:00:07 +00:00
if err != nil {
utils . Fatalf ( fmt . Sprintf ( "error while parsing mode: %v" , err ) )
}
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
cfg . Prune = mode
2021-03-23 09:00:07 +00:00
}
if v := f . String ( BatchSizeFlag . Name , BatchSizeFlag . Value , BatchSizeFlag . Usage ) ; v != nil {
err := cfg . BatchSize . UnmarshalText ( [ ] byte ( * v ) )
if err != nil {
utils . Fatalf ( "Invalid batchSize provided: %v" , err )
}
}
if v := f . String ( EtlBufferSizeFlag . Name , EtlBufferSizeFlag . Value , EtlBufferSizeFlag . Usage ) ; v != nil {
sizeVal := datasize . ByteSize ( 0 )
size := & sizeVal
err := size . UnmarshalText ( [ ] byte ( * v ) )
if err != nil {
utils . Fatalf ( "Invalid batchSize provided: %v" , err )
}
etl . BufferOptimalSize = * size
}
2021-10-05 09:06:45 +00:00
cfg . StateStream = true
if v := f . Bool ( StateStreamDisableFlag . Name , false , StateStreamDisableFlag . Usage ) ; v != nil {
cfg . StateStream = false
2021-05-23 14:53:18 +00:00
}
2021-03-23 09:00:07 +00:00
}
2020-10-27 15:53:49 +00:00
func ApplyFlagsForNodeConfig ( ctx * cli . Context , cfg * node . Config ) {
setPrivateApi ( ctx , cfg )
2022-02-16 17:38:54 +00:00
setEmbeddedRpcDaemon ( ctx , cfg )
2021-07-28 02:47:38 +00:00
cfg . DatabaseVerbosity = kv . DBVerbosityLvl ( ctx . GlobalInt ( DatabaseVerbosityFlag . Name ) )
2020-10-27 15:53:49 +00:00
}
2022-02-16 17:38:54 +00:00
func setEmbeddedRpcDaemon ( ctx * cli . Context , cfg * node . Config ) {
c := & httpcfg . HttpCfg {
2022-02-22 09:23:54 +00:00
Enabled : ctx . GlobalBool ( utils . HTTPEnabledFlag . Name ) ,
2022-02-22 17:39:48 +00:00
DataDir : cfg . DataDir ,
2022-02-16 17:38:54 +00:00
Chaindata : filepath . Join ( cfg . DataDir , "chaindata" ) ,
TLSKeyFile : cfg . TLSKeyFile ,
TLSCACert : cfg . TLSCACert ,
TLSCertfile : cfg . TLSCertFile ,
HttpListenAddress : ctx . GlobalString ( utils . HTTPListenAddrFlag . Name ) ,
HttpPort : ctx . GlobalInt ( utils . HTTPPortFlag . Name ) ,
EngineHTTPListenAddress : ctx . GlobalString ( utils . EngineAddr . Name ) ,
EnginePort : ctx . GlobalInt ( utils . EnginePort . Name ) ,
HttpCORSDomain : strings . Split ( ctx . GlobalString ( utils . HTTPCORSDomainFlag . Name ) , "," ) ,
HttpVirtualHost : strings . Split ( ctx . GlobalString ( utils . HTTPVirtualHostsFlag . Name ) , "," ) ,
API : strings . Split ( ctx . GlobalString ( utils . HTTPApiFlag . Name ) , "," ) ,
2022-02-21 02:32:42 +00:00
WebsocketEnabled : ctx . GlobalIsSet ( utils . WSEnabledFlag . Name ) ,
RpcBatchConcurrency : ctx . GlobalUint ( utils . RpcBatchConcurrencyFlag . Name ) ,
2022-03-08 03:43:14 +00:00
DBReadConcurrency : ctx . GlobalInt ( utils . DBReadConcurrencyFlag . Name ) ,
2022-02-21 02:32:42 +00:00
RpcAllowListFilePath : ctx . GlobalString ( utils . RpcAccessListFlag . Name ) ,
Gascap : ctx . GlobalUint64 ( utils . RpcGasCapFlag . Name ) ,
MaxTraces : ctx . GlobalUint64 ( utils . TraceMaxtracesFlag . Name ) ,
TraceCompatibility : ctx . GlobalBool ( utils . RpcTraceCompatFlag . Name ) ,
StarknetGRPCAddress : ctx . GlobalString ( utils . StarknetGrpcAddressFlag . Name ) ,
TevmEnabled : ctx . GlobalBool ( utils . TevmFlag . Name ) ,
TxPoolApiAddr : ctx . GlobalString ( utils . TxpoolApiAddrFlag . Name ) ,
2022-02-16 17:38:54 +00:00
StateCache : kvcache . DefaultCoherentConfig ,
}
if ctx . GlobalIsSet ( utils . HttpCompressionFlag . Name ) {
c . HttpCompression = ctx . GlobalBool ( utils . HttpCompressionFlag . Name )
} else {
c . HttpCompression = true
}
if ctx . GlobalIsSet ( utils . WsCompressionFlag . Name ) {
c . WebsocketCompression = ctx . GlobalBool ( utils . WsCompressionFlag . Name )
} else {
c . WebsocketCompression = true
}
c . StateCache . CodeKeysLimit = ctx . GlobalInt ( utils . StateCacheFlag . Name )
/ *
rootCmd . PersistentFlags ( ) . BoolVar ( & cfg . GRPCServerEnabled , "grpc" , false , "Enable GRPC server" )
rootCmd . PersistentFlags ( ) . StringVar ( & cfg . GRPCListenAddress , "grpc.addr" , node . DefaultGRPCHost , "GRPC server listening interface" )
rootCmd . PersistentFlags ( ) . IntVar ( & cfg . GRPCPort , "grpc.port" , node . DefaultGRPCPort , "GRPC server listening port" )
rootCmd . PersistentFlags ( ) . BoolVar ( & cfg . GRPCHealthCheckEnabled , "grpc.healthcheck" , false , "Enable GRPC health check" )
* /
cfg . Http = * c
}
2020-10-27 15:53:49 +00:00
// setPrivateApi populates configuration fields related to the remote
2021-11-21 03:32:14 +00:00
// read-only interface to the database
2020-10-27 15:53:49 +00:00
func setPrivateApi ( ctx * cli . Context , cfg * node . Config ) {
cfg . PrivateApiAddr = ctx . GlobalString ( PrivateApiAddr . Name )
2021-03-23 07:28:04 +00:00
cfg . PrivateApiRateLimit = uint32 ( ctx . GlobalUint64 ( PrivateApiRateLimit . Name ) )
2021-07-28 02:47:38 +00:00
maxRateLimit := uint32 ( kv . ReadersLimit - 128 ) // leave some readers for P2P
2021-03-23 07:28:04 +00:00
if cfg . PrivateApiRateLimit > maxRateLimit {
log . Warn ( "private.api.ratelimit is too big" , "force" , maxRateLimit )
cfg . PrivateApiRateLimit = maxRateLimit
}
2020-10-27 15:53:49 +00:00
if ctx . GlobalBool ( TLSFlag . Name ) {
certFile := ctx . GlobalString ( TLSCertFlag . Name )
keyFile := ctx . GlobalString ( TLSKeyFlag . Name )
if certFile == "" {
log . Warn ( "Could not establish TLS grpc: missing certificate" )
return
} else if keyFile == "" {
log . Warn ( "Could not establish TLS grpc: missing key file" )
return
}
cfg . TLSConnection = true
cfg . TLSCertFile = certFile
cfg . TLSKeyFile = keyFile
cfg . TLSCACert = ctx . GlobalString ( TLSCACertFlag . Name )
}
2021-12-06 12:03:46 +00:00
cfg . HealthCheck = ctx . GlobalBool ( HealthCheckFlag . Name )
2020-10-27 15:53:49 +00:00
}