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

feat: Renaming start cmd cudos related flags #382

Merged
merged 1 commit into from
Oct 2, 2024
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
40 changes: 20 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ type App struct {

invCheckPeriod uint

cudosPath string
cudosSha256 string
configPath string
configSha256 string
cudosGenesisPath string
cudosGenesisSha256 string
cudosMigrationConfigPath string
cudosMigrationConfigSha256 string

// keys to access the substores
keys map[string]*sdk.KVStoreKey
Expand Down Expand Up @@ -261,7 +261,7 @@ type App struct {
// NewSimApp returns a reference to an initialized SimApp.
func New(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
skipUpgradeHeights map[int64]bool, homePath string, invCheckPeriod uint, cudosPath string, configPath string, cudosSha256 string, configSha256 string, encodingConfig appparams.EncodingConfig, enabledProposals []wasm.ProposalType,
skipUpgradeHeights map[int64]bool, homePath string, invCheckPeriod uint, cudosGenesisPath string, cudosMigrationConfigPath string, cudosGenesisSha256 string, cudosMigrationConfigSha256 string, encodingConfig appparams.EncodingConfig, enabledProposals []wasm.ProposalType,
appOpts servertypes.AppOptions, wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp),
) *App {

Expand All @@ -285,18 +285,18 @@ func New(
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)

app := &App{
BaseApp: bApp,
legacyAmino: legacyAmino,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
invCheckPeriod: invCheckPeriod,
cudosPath: cudosPath,
configPath: configPath,
cudosSha256: cudosSha256,
configSha256: configSha256,
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
BaseApp: bApp,
legacyAmino: legacyAmino,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
invCheckPeriod: invCheckPeriod,
cudosGenesisPath: cudosGenesisPath,
cudosGenesisSha256: cudosGenesisSha256,
cudosMigrationConfigPath: cudosMigrationConfigPath,
cudosMigrationConfigSha256: cudosMigrationConfigSha256,
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
}

app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
Expand Down Expand Up @@ -731,8 +731,8 @@ func getNetworkInfo(app *App, ctx sdk.Context) (*NetworkConfig, error) {
// Load network config from file if given
var networkInfo *NetworkConfig
var err error
if app.configPath != "" {
networkInfo, err = LoadNetworkConfigFromFile(app.configPath, &app.configSha256)
if app.cudosMigrationConfigPath != "" {
networkInfo, err = LoadNetworkConfigFromFile(app.cudosMigrationConfigPath, &app.cudosMigrationConfigSha256)
if err != nil {
return nil, err
}
Expand All @@ -755,7 +755,7 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {

manifest := NewUpgradeManifest()

if app.cudosPath == "" {
if app.cudosGenesisPath == "" {
return nil, fmt.Errorf("cudos path not set")
}

Expand Down
12 changes: 6 additions & 6 deletions app/upgrade_cudos.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,19 @@ func CudosMergeUpgradeHandler(app *App, ctx sdk.Context, cudosCfg *CudosMergeCon
return fmt.Errorf("cudos CudosMergeConfig not provided (null pointer passed in)")
}

if app.cudosPath == "" {
if app.cudosGenesisPath == "" {
return fmt.Errorf("cudos path not set")
}

actualGenesisSha256Hex, err := GenerateSHA256FromFile(app.cudosPath)
actualGenesisSha256Hex, err := GenerateSHA256FromFile(app.cudosGenesisPath)
if err != nil {
return fmt.Errorf("failed to generate sha256 out of genesis file %v: %w", app.cudosPath, err)
return fmt.Errorf("failed to generate sha256 out of genesis file %v: %w", app.cudosGenesisPath, err)
}
if app.cudosSha256 != actualGenesisSha256Hex {
return fmt.Errorf("sha256 failed to verify: genesis file \"%v\" hash %v does not match expected hash %v", app.cudosPath, actualGenesisSha256Hex, app.cudosSha256)
if app.cudosGenesisSha256 != actualGenesisSha256Hex {
return fmt.Errorf("sha256 failed to verify: genesis file \"%v\" hash %v does not match expected hash %v", app.cudosGenesisPath, actualGenesisSha256Hex, app.cudosGenesisSha256)
}

_, genDoc, err := genutiltypes.GenesisStateFromGenFile(app.cudosPath)
_, genDoc, err := genutiltypes.GenesisStateFromGenFile(app.cudosGenesisPath)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/fetchd/cmd/cudos_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (

// Module init related flags
const (
FlagCudosPath = "cudos-path"
FlagConfigPath = "config-path"
FlagCudosSha256 = "cudos-sha256"
FlagConfigSha256 = "config-sha256"
FlagCudosGenesisPath = "cudos-genesis-path"
FlagCudosGenesisSha256 = "cudos-genesis-sha256"
FlagCudosMigrationConfigPath = "cudos-migration-config-path"
FlagCudosMigrationConfigSha256 = "cudos-migration-config-sha256"
)

func AddCudosFlags(startCmd *cobra.Command) {
startCmd.Flags().String(FlagCudosPath, "", "Cudos genesis file path. Required to be provided *exclusively* during cudos migration upgrade node start, *ignored* on all subsequent node starts.")
startCmd.Flags().String(FlagConfigPath, "", "Upgrade config file path. Required to be provided *exclusively* during cudos migration upgrade node start, *ignored* on all subsequent node starts.")
startCmd.Flags().String(FlagCudosSha256, "", "Sha256 of the cudos genesis file. Optional to be provided *exclusively* during cudos migration upgrade node start, *ignored* on all subsequent node starts.")
startCmd.Flags().String(FlagConfigSha256, "", fmt.Sprintf("Sha256 of the upgrade config file. Required if to be provided *exclusively* during cudos migration upgrade node start and *only IF* \"%v\" flag has been provided, *ignored* on all subsequent node starts.", FlagConfigPath))
startCmd.Flags().String(FlagCudosGenesisPath, "", "Cudos genesis file path. Required to be provided *exclusively* during cudos migration upgrade node start, *ignored* on all subsequent node starts.")
startCmd.Flags().String(FlagCudosMigrationConfigPath, "", "Upgrade config file path. Required to be provided *exclusively* during cudos migration upgrade node start, *ignored* on all subsequent node starts.")
startCmd.Flags().String(FlagCudosGenesisSha256, "", "Sha256 of the cudos genesis file. Optional to be provided *exclusively* during cudos migration upgrade node start, *ignored* on all subsequent node starts.")
startCmd.Flags().String(FlagCudosMigrationConfigSha256, "", fmt.Sprintf("Sha256 of the upgrade config file. Required if to be provided *exclusively* during cudos migration upgrade node start and *only IF* \"%v\" flag has been provided, *ignored* on all subsequent node starts.", FlagCudosMigrationConfigPath))
}
8 changes: 4 additions & 4 deletions cmd/fetchd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
cast.ToString(appOpts.Get(FlagCudosPath)),
cast.ToString(appOpts.Get(FlagConfigPath)),
cast.ToString(appOpts.Get(FlagCudosSha256)),
cast.ToString(appOpts.Get(FlagConfigSha256)),
cast.ToString(appOpts.Get(FlagCudosGenesisPath)),
cast.ToString(appOpts.Get(FlagCudosMigrationConfigPath)),
cast.ToString(appOpts.Get(FlagCudosGenesisSha256)),
cast.ToString(appOpts.Get(FlagCudosMigrationConfigSha256)),
a.encCfg,
app.GetEnabledProposals(),
appOpts,
Expand Down
Loading