2020-07-14 01:56:29 +00:00
package commands
2020-07-05 06:18:21 +00:00
2020-08-22 10:12:33 +00:00
import (
2022-10-05 10:54:54 +00:00
"github.com/ledgerwatch/erigon/turbo/cli"
2021-04-19 21:58:05 +00:00
"github.com/spf13/cobra"
2021-05-20 18:25:53 +00:00
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/eth/ethconfig"
2020-08-22 10:12:33 +00:00
)
2020-07-05 06:18:21 +00:00
var (
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
chaindata string
databaseVerbosity int
referenceChaindata string
block , pruneTo , unwind uint64
unwindEvery uint64
batchSizeStr string
reset bool
bucket string
2022-06-07 04:00:37 +00:00
datadirCli , toChaindata string
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
migration string
integrityFast , integritySlow bool
file string
2022-02-07 21:30:46 +00:00
HeimdallURL string
2022-12-10 22:55:31 +00:00
txtrace bool // Whether to trace the execution (should only be used together with `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
pruneFlag string
pruneH , pruneR , pruneT , pruneC uint64
2021-09-23 02:13:19 +00:00
pruneHBefore , pruneRBefore uint64
pruneTBefore , pruneCBefore uint64
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
experiments [ ] string
2022-12-10 22:55:31 +00:00
chain string // Which chain to use (mainnet, rinkeby, goerli, etc.)
2022-08-12 14:45:09 +00:00
2022-11-07 04:42:44 +00:00
_forceSetHistoryV3 bool
workers , reconWorkers uint64
2020-07-05 06:18:21 +00:00
)
func must ( err error ) {
if err != nil {
panic ( err )
}
}
2021-03-23 09:00:07 +00:00
func withMining ( cmd * cobra . Command ) {
cmd . Flags ( ) . Bool ( "mine" , false , "Enable mining" )
cmd . Flags ( ) . StringArray ( "miner.notify" , nil , "Comma separated HTTP URL list to notify of new work packages" )
2022-01-05 09:36:24 +00:00
cmd . Flags ( ) . Uint64 ( "miner.gaslimit" , ethconfig . Defaults . Miner . GasLimit , "Target gas limit for mined blocks" )
2021-03-23 09:00:07 +00:00
cmd . Flags ( ) . Int64 ( "miner.gasprice" , ethconfig . Defaults . Miner . GasPrice . Int64 ( ) , "Target gas price for mined blocks" )
cmd . Flags ( ) . String ( "miner.etherbase" , "0" , "Public address for block mining rewards (default = first account" )
cmd . Flags ( ) . String ( "miner.extradata" , "" , "Block extra data set by the miner (default = client version)" )
cmd . Flags ( ) . Duration ( "miner.recommit" , ethconfig . Defaults . Miner . Recommit , "Time interval to recreate the block being mined" )
cmd . Flags ( ) . Bool ( "miner.noverify" , false , "Disable remote sealing verification" )
}
2020-12-16 14:35:14 +00:00
func withFile ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & file , "file" , "" , "path to file" )
must ( cmd . MarkFlagFilename ( "file" ) )
must ( cmd . MarkFlagRequired ( "file" ) )
}
2020-07-07 07:11:10 +00:00
func withReferenceChaindata ( cmd * cobra . Command ) {
2021-02-21 18:41:59 +00:00
cmd . Flags ( ) . StringVar ( & referenceChaindata , "chaindata.reference" , "" , "path to the 2nd (reference/etalon) db" )
must ( cmd . MarkFlagDirname ( "chaindata.reference" ) )
2020-07-07 07:11:10 +00:00
}
2020-10-28 03:18:10 +00:00
func withToChaindata ( cmd * cobra . Command ) {
2021-02-21 18:41:59 +00:00
cmd . Flags ( ) . StringVar ( & toChaindata , "chaindata.to" , "" , "target chaindata" )
must ( cmd . MarkFlagDirname ( "chaindata.to" ) )
2020-10-28 03:18:10 +00:00
}
2020-07-07 04:00:25 +00:00
func withBlock ( cmd * cobra . Command ) {
cmd . Flags ( ) . Uint64Var ( & block , "block" , 0 , "block test at this block" )
}
func withUnwind ( cmd * cobra . Command ) {
cmd . Flags ( ) . Uint64Var ( & unwind , "unwind" , 0 , "how much blocks unwind on each iteration" )
}
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
func withPruneTo ( cmd * cobra . Command ) {
cmd . Flags ( ) . Uint64Var ( & pruneTo , "prune.to" , 0 , "how much blocks unwind on each iteration" )
}
2020-07-07 04:00:25 +00:00
func withUnwindEvery ( cmd * cobra . Command ) {
2021-02-21 18:41:59 +00:00
cmd . Flags ( ) . Uint64Var ( & unwindEvery , "unwind.every" , 0 , "each iteration test will move forward `--unwind.every` blocks, then unwind `--unwind` blocks" )
2020-07-07 04:00:25 +00:00
}
2020-07-07 07:11:10 +00:00
func withReset ( cmd * cobra . Command ) {
2020-07-07 04:00:25 +00:00
cmd . Flags ( ) . BoolVar ( & reset , "reset" , false , "reset given stage" )
2020-07-05 06:18:21 +00:00
}
2020-07-07 07:11:10 +00:00
func withBucket ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & bucket , "bucket" , "" , "reset given stage" )
}
2020-07-28 13:07:36 +00:00
2022-02-22 17:39:48 +00:00
func withDataDir2 ( cmd * cobra . Command ) {
2022-09-29 05:14:51 +00:00
// --datadir is required, but no --chain flag: read chainConfig from db instead
cmd . Flags ( ) . StringVar ( & datadirCli , utils . DataDirFlag . Name , "" , utils . DataDirFlag . Usage )
2021-03-23 09:00:07 +00:00
must ( cmd . MarkFlagDirname ( utils . DataDirFlag . Name ) )
must ( cmd . MarkFlagRequired ( utils . DataDirFlag . Name ) )
2021-05-11 08:22:34 +00:00
cmd . Flags ( ) . IntVar ( & databaseVerbosity , "database.verbosity" , 2 , "Enabling internal db logs. Very high verbosity levels may require recompile db. Default: 2, means warning." )
2021-03-23 09:00:07 +00:00
}
2022-02-22 17:39:48 +00:00
func withDataDir ( cmd * cobra . Command ) {
2022-09-29 05:14:51 +00:00
cmd . Flags ( ) . StringVar ( & datadirCli , "datadir" , "" , "data directory for temporary ELT files" )
2022-08-13 14:46:25 +00:00
must ( cmd . MarkFlagRequired ( "datadir" ) )
2021-04-19 07:25:26 +00:00
must ( cmd . MarkFlagDirname ( "datadir" ) )
cmd . Flags ( ) . StringVar ( & chaindata , "chaindata" , "" , "path to the db" )
must ( cmd . MarkFlagDirname ( "chaindata" ) )
2021-05-11 08:22:34 +00:00
cmd . Flags ( ) . IntVar ( & databaseVerbosity , "database.verbosity" , 2 , "Enabling internal db logs. Very high verbosity levels may require recompile db. Default: 2, means warning" )
2020-07-28 13:07:36 +00:00
}
2020-09-05 06:27:47 +00:00
2020-10-21 17:01:40 +00:00
func withBatchSize ( cmd * cobra . Command ) {
2022-10-05 10:54:54 +00:00
cmd . Flags ( ) . StringVar ( & batchSizeStr , "batchSize" , cli . BatchSizeFlag . Value , cli . BatchSizeFlag . Usage )
2020-09-05 06:27:47 +00:00
}
2020-10-17 13:00:12 +00:00
2021-02-21 18:41:59 +00:00
func withIntegrityChecks ( cmd * cobra . Command ) {
2021-08-15 12:45:38 +00:00
cmd . Flags ( ) . BoolVar ( & integritySlow , "integrity.slow" , false , "enable slow data-integrity checks" )
2021-02-21 18:41:59 +00:00
cmd . Flags ( ) . BoolVar ( & integrityFast , "integrity.fast" , true , "enable fast data-integrity checks" )
}
2020-10-17 13:00:12 +00:00
func withMigration ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & migration , "migration" , "" , "action to apply to given migration" )
}
2020-10-31 11:51:56 +00:00
2021-03-27 21:43:38 +00:00
func withTxTrace ( cmd * cobra . Command ) {
cmd . Flags ( ) . BoolVar ( & txtrace , "txtrace" , false , "enable tracing of transactions" )
}
2021-05-25 22:26:25 +00:00
func withChain ( cmd * cobra . Command ) {
2022-12-10 22:55:31 +00:00
cmd . Flags ( ) . StringVar ( & chain , "chain" , "mainnet" , "pick a chain to assume (mainnet, sepolia, etc.)" )
2022-08-13 14:46:25 +00:00
must ( cmd . MarkFlagRequired ( "chain" ) )
2021-05-25 22:26:25 +00:00
}
2022-02-07 21:30:46 +00:00
func withHeimdall ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & HeimdallURL , "bor.heimdall" , "http://localhost:1317" , "URL of Heimdall service" )
}
2022-09-10 03:37:56 +00:00
func withWorkers ( cmd * cobra . Command ) {
2022-11-07 04:42:44 +00:00
cmd . Flags ( ) . Uint64Var ( & workers , "exec.workers" , uint64 ( ethconfig . Defaults . Sync . ExecWorkerCount ) , "" )
cmd . Flags ( ) . Uint64Var ( & reconWorkers , "recon.workers" , uint64 ( ethconfig . Defaults . Sync . ReconWorkerCount ) , "" )
2022-09-10 03:37:56 +00:00
}