Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for reading yaml/toml config in cmd/integration #7101

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/integration/commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func must(err error) {
}
}

func withConfig(cmd *cobra.Command) {
cmd.Flags().String("config", "", "yaml/toml config file location")
}

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")
Expand Down
6 changes: 4 additions & 2 deletions cmd/integration/commands/reset_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import (
"github.com/ledgerwatch/erigon-lib/kv/kvcfg"
"github.com/ledgerwatch/erigon-lib/kv/rawdbv3"
"github.com/ledgerwatch/erigon-lib/state"
"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"

"github.com/ledgerwatch/erigon/core/rawdb/rawdbhelpers"
reset2 "github.com/ledgerwatch/erigon/core/rawdb/rawdbreset"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
"github.com/ledgerwatch/erigon/ethdb/prune"
"github.com/ledgerwatch/erigon/turbo/snapshotsync"
"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"
)

var cmdResetState = &cobra.Command{
Expand Down Expand Up @@ -60,6 +61,7 @@ var cmdResetState = &cobra.Command{
}

func init() {
withConfig(cmdResetState)
withDataDir(cmdResetState)
withChain(cmdResetState)

Expand Down
31 changes: 18 additions & 13 deletions cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,41 +351,43 @@ var cmdForceSetHistoryV3 = &cobra.Command{
}

func init() {
withConfig(cmdPrintStages)
withDataDir(cmdPrintStages)
withChain(cmdPrintStages)
withHeimdall(cmdPrintStages)
rootCmd.AddCommand(cmdPrintStages)

withConfig(cmdStageSenders)
withIntegrityChecks(cmdStageSenders)
withReset(cmdStageSenders)
withBlock(cmdStageSenders)
withUnwind(cmdStageSenders)
withDataDir(cmdStageSenders)
withChain(cmdStageSenders)
withHeimdall(cmdStageSenders)

rootCmd.AddCommand(cmdStageSenders)

withConfig(cmdStageSnapshots)
withDataDir(cmdStageSnapshots)
withReset(cmdStageSnapshots)

rootCmd.AddCommand(cmdStageSnapshots)

withConfig(cmdStageHeaders)
withDataDir(cmdStageHeaders)
withUnwind(cmdStageHeaders)
withReset(cmdStageHeaders)
withChain(cmdStageHeaders)
withHeimdall(cmdStageHeaders)

rootCmd.AddCommand(cmdStageHeaders)

withConfig(cmdStageBodies)
withDataDir(cmdStageBodies)
withUnwind(cmdStageBodies)
withChain(cmdStageBodies)
withHeimdall(cmdStageBodies)

rootCmd.AddCommand(cmdStageBodies)

withConfig(cmdStageExec)
withDataDir(cmdStageExec)
withReset(cmdStageExec)
withBlock(cmdStageExec)
Expand All @@ -396,9 +398,9 @@ func init() {
withChain(cmdStageExec)
withHeimdall(cmdStageExec)
withWorkers(cmdStageExec)

rootCmd.AddCommand(cmdStageExec)

withConfig(cmdStageHashState)
withDataDir(cmdStageHashState)
withReset(cmdStageHashState)
withBlock(cmdStageHashState)
Expand All @@ -407,9 +409,9 @@ func init() {
withBatchSize(cmdStageHashState)
withChain(cmdStageHashState)
withHeimdall(cmdStageHashState)

rootCmd.AddCommand(cmdStageHashState)

withConfig(cmdStageTrie)
withDataDir(cmdStageTrie)
withReset(cmdStageTrie)
withBlock(cmdStageTrie)
Expand All @@ -418,73 +420,76 @@ func init() {
withIntegrityChecks(cmdStageTrie)
withChain(cmdStageTrie)
withHeimdall(cmdStageTrie)

rootCmd.AddCommand(cmdStageTrie)

withConfig(cmdStageHistory)
withDataDir(cmdStageHistory)
withReset(cmdStageHistory)
withBlock(cmdStageHistory)
withUnwind(cmdStageHistory)
withPruneTo(cmdStageHistory)
withChain(cmdStageHistory)
withHeimdall(cmdStageHistory)

rootCmd.AddCommand(cmdStageHistory)

withConfig(cmdLogIndex)
withDataDir(cmdLogIndex)
withReset(cmdLogIndex)
withBlock(cmdLogIndex)
withUnwind(cmdLogIndex)
withPruneTo(cmdLogIndex)
withChain(cmdLogIndex)
withHeimdall(cmdLogIndex)

rootCmd.AddCommand(cmdLogIndex)

withConfig(cmdCallTraces)
withDataDir(cmdCallTraces)
withReset(cmdCallTraces)
withBlock(cmdCallTraces)
withUnwind(cmdCallTraces)
withPruneTo(cmdCallTraces)
withChain(cmdCallTraces)
withHeimdall(cmdCallTraces)

rootCmd.AddCommand(cmdCallTraces)

withConfig(cmdStageTxLookup)
withReset(cmdStageTxLookup)
withBlock(cmdStageTxLookup)
withUnwind(cmdStageTxLookup)
withDataDir(cmdStageTxLookup)
withPruneTo(cmdStageTxLookup)
withChain(cmdStageTxLookup)
withHeimdall(cmdStageTxLookup)

rootCmd.AddCommand(cmdStageTxLookup)

withConfig(cmdPrintMigrations)
withDataDir(cmdPrintMigrations)
rootCmd.AddCommand(cmdPrintMigrations)

withConfig(cmdRemoveMigration)
withDataDir(cmdRemoveMigration)
withMigration(cmdRemoveMigration)
withChain(cmdRemoveMigration)
withHeimdall(cmdRemoveMigration)
rootCmd.AddCommand(cmdRemoveMigration)

withConfig(cmdRunMigrations)
withDataDir(cmdRunMigrations)
withChain(cmdRunMigrations)
withHeimdall(cmdRunMigrations)
rootCmd.AddCommand(cmdRunMigrations)

withConfig(cmdSetSnap)
withDataDir2(cmdSetSnap)
withChain(cmdSetSnap)
rootCmd.AddCommand(cmdSetSnap)

withConfig(cmdForceSetHistoryV3)
withDataDir2(cmdForceSetHistoryV3)
cmdForceSetHistoryV3.Flags().BoolVar(&_forceSetHistoryV3, "history.v3", false, "")
rootCmd.AddCommand(cmdForceSetHistoryV3)

rootCmd.AddCommand(cmdForceSetHistoryV3)

withConfig(cmdSetPrune)
withDataDir(cmdSetPrune)
withChain(cmdSetPrune)
cmdSetPrune.Flags().StringVar(&pruneFlag, "prune", "hrtc", "")
Expand Down
2 changes: 1 addition & 1 deletion cmd/integration/commands/state_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
)

func init() {
withConfig(stateDomains)
withDataDir(stateDomains)
withUnwind(stateDomains)
withUnwindEvery(stateDomains)
Expand All @@ -52,7 +53,6 @@ func init() {
withStartTx(stateDomains)
withCommitment(stateDomains)
withTraceFromTx(stateDomains)

rootCmd.AddCommand(stateDomains)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/integration/commands/state_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ var loopExecCmd = &cobra.Command{
}

func init() {
withConfig(stateStages)
withDataDir2(stateStages)
withReferenceChaindata(stateStages)
withUnwind(stateStages)
Expand All @@ -131,24 +132,23 @@ func init() {
withChain(stateStages)
withHeimdall(stateStages)
withWorkers(stateStages)

rootCmd.AddCommand(stateStages)

withConfig(loopIhCmd)
withDataDir(loopIhCmd)
withBatchSize(loopIhCmd)
withUnwind(loopIhCmd)
withChain(loopIhCmd)
withHeimdall(loopIhCmd)

rootCmd.AddCommand(loopIhCmd)

withConfig(loopExecCmd)
withDataDir(loopExecCmd)
withBatchSize(loopExecCmd)
withUnwind(loopExecCmd)
withChain(loopExecCmd)
withHeimdall(loopExecCmd)
withWorkers(loopExecCmd)

rootCmd.AddCommand(loopExecCmd)
}

Expand Down
7 changes: 7 additions & 0 deletions turbo/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ func SetFlagsFromConfigFile(ctx *cli.Context) error {

func SetCobraFlagsFromConfigFile(cmd *cobra.Command) error {
flags := cmd.Flags()

// flag might not be set for any reason so just exit if we're not aware of it
exists := flags.Lookup(configFlag.Name)
if exists == nil {
return nil
}

filePath, err := flags.GetString(configFlag.Name)
if err != nil {
return err
Expand Down