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 (
|
2021-04-19 21:58:05 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2021-03-23 09:00:07 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/utils"
|
2021-04-19 21:58:05 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/common/paths"
|
2021-03-23 09:00:07 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/eth/ethconfig"
|
2020-08-22 10:12:33 +00:00
|
|
|
)
|
2020-07-05 06:18:21 +00:00
|
|
|
|
|
|
|
var (
|
2020-07-07 07:11:10 +00:00
|
|
|
chaindata string
|
2020-10-28 03:18:10 +00:00
|
|
|
database string
|
2021-05-10 15:07:22 +00:00
|
|
|
databaseVerbosity int
|
2020-10-13 12:56:16 +00:00
|
|
|
snapshotMode string
|
|
|
|
snapshotDir string
|
2020-10-28 03:18:10 +00:00
|
|
|
toChaindata string
|
2020-07-07 07:11:10 +00:00
|
|
|
referenceChaindata string
|
|
|
|
block uint64
|
|
|
|
unwind uint64
|
|
|
|
unwindEvery uint64
|
2020-10-21 17:01:40 +00:00
|
|
|
batchSizeStr string
|
2020-07-07 07:11:10 +00:00
|
|
|
reset bool
|
|
|
|
bucket string
|
2020-07-28 13:07:36 +00:00
|
|
|
datadir string
|
2020-10-13 22:42:04 +00:00
|
|
|
mapSizeStr string
|
2020-10-17 13:00:12 +00:00
|
|
|
migration string
|
2021-02-21 18:41:59 +00:00
|
|
|
integritySlow bool
|
|
|
|
integrityFast bool
|
2020-11-28 15:08:02 +00:00
|
|
|
silkwormPath string
|
2020-12-16 14:35:14 +00:00
|
|
|
file string
|
2021-03-27 21:43:38 +00:00
|
|
|
txtrace bool // Whether to trace the execution (should only be used together eith `block`)
|
2021-05-06 17:37:38 +00:00
|
|
|
storageMode string
|
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")
|
|
|
|
cmd.Flags().Uint64("miner.gastarget", ethconfig.Defaults.Miner.GasFloor, "Target gas floor for mined blocks")
|
|
|
|
cmd.Flags().Uint64("miner.gaslimit", ethconfig.Defaults.Miner.GasCeil, "Target gas ceiling for mined blocks")
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2021-03-23 09:00:07 +00:00
|
|
|
func withDatadir2(cmd *cobra.Command) {
|
2021-04-19 21:58:05 +00:00
|
|
|
cmd.Flags().String(utils.DataDirFlag.Name, paths.DefaultDataDir(), utils.DataDirFlag.Usage)
|
2021-03-23 09:00:07 +00:00
|
|
|
must(cmd.MarkFlagDirname(utils.DataDirFlag.Name))
|
|
|
|
must(cmd.MarkFlagRequired(utils.DataDirFlag.Name))
|
|
|
|
cmd.Flags().StringVar(&database, "database", "", "lmdb|mdbx")
|
2021-05-10 15:07:22 +00:00
|
|
|
cmd.Flags().IntVar(&databaseVerbosity, "database.verbosity", -1, "Enabling internal db logs. Very high verbosity levels may require recompile db.")
|
2021-03-23 09:00:07 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 13:07:36 +00:00
|
|
|
func withDatadir(cmd *cobra.Command) {
|
2021-04-19 21:58:05 +00:00
|
|
|
cmd.Flags().StringVar(&datadir, "datadir", paths.DefaultDataDir(), "data directory for temporary ELT files")
|
2021-04-19 07:25:26 +00:00
|
|
|
must(cmd.MarkFlagDirname("datadir"))
|
|
|
|
cmd.Flags().StringVar(&mapSizeStr, "lmdb.mapSize", "", "map size for LMDB")
|
|
|
|
|
|
|
|
cmd.Flags().StringVar(&chaindata, "chaindata", "", "path to the db")
|
|
|
|
must(cmd.MarkFlagDirname("chaindata"))
|
|
|
|
|
|
|
|
cmd.Flags().StringVar(&snapshotMode, "snapshot.mode", "", "set of snapshots to use")
|
|
|
|
cmd.Flags().StringVar(&snapshotDir, "snapshot.dir", "", "snapshot dir")
|
|
|
|
must(cmd.MarkFlagDirname("snapshot.dir"))
|
|
|
|
|
|
|
|
cmd.Flags().StringVar(&database, "database", "", "lmdb|mdbx")
|
2021-05-10 15:07:22 +00:00
|
|
|
cmd.Flags().IntVar(&databaseVerbosity, "database.verbosity", -1, "Enabling internal db logs. Very high verbosity levels may require recompile db.")
|
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) {
|
|
|
|
cmd.Flags().StringVar(&batchSizeStr, "batchSize", "512M", "batch size for execution stage")
|
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) {
|
|
|
|
cmd.Flags().BoolVar(&integritySlow, "integrity.slow", true, "enable slow data-integrity checks")
|
|
|
|
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
|
|
|
|
2020-11-28 15:08:02 +00:00
|
|
|
func withSilkworm(cmd *cobra.Command) {
|
|
|
|
cmd.Flags().StringVar(&silkwormPath, "silkworm", "", "file path of libsilkworm_tg_api.so")
|
|
|
|
must(cmd.MarkFlagFilename("silkworm"))
|
|
|
|
}
|
2021-03-27 21:43:38 +00:00
|
|
|
|
|
|
|
func withTxTrace(cmd *cobra.Command) {
|
|
|
|
cmd.Flags().BoolVar(&txtrace, "txtrace", false, "enable tracing of transactions")
|
|
|
|
}
|