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

improve several kwild cmd issues with config parsing and error handling #1284

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

jchappelow
Copy link
Member

@jchappelow jchappelow commented Jan 23, 2025

Going through several small things that @KwilLuke mentioned yesterday

  • some commands try to read ~/.kwild/config.toml unnecessarily, leading to confusing errors if the file is invalid since it's really irrelevant to the command
  • fix misuses of display.PrintErr and document proper use
  • use the conf.ActiveConfig, which is the merged configuration in several commands instead of manually loading the toml file
  • revise the start command's docs to reflect that it is no longer the default command
  • setup init will error if the destination directory already exists. Previous it ran with unpredictable results.

@jchappelow jchappelow changed the title WIP improve several kwild cmd aspects improve several kwild cmd issues with config parsing and error handling Jan 24, 2025
@jchappelow jchappelow marked this pull request as ready for review January 24, 2025 00:30

// clean up any previous temp admin snapshots
err = cleanupTmpKwilAdminDir(dir)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charithabandi AFAICT, this was deleting the directory that was just created above, and the PGDump function was recreating it internally. Please double check this for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, its temporary dir for storing snapshots till we get the genesis hash, we don't actually need it after.

Copy link
Member Author

@jchappelow jchappelow Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that's why we defer the cleanup, but I'm saying the original order in this function made no sense. It created it and immediately removed it, then created it again (this last one inside snapshot.PGDump).

},
}

cmd.Flags().StringVarP(&genesisFile, "genesis", "g", "", "optional path to the genesis file to patch with the computed app hash")
cmd.Flags().StringVarP(&rootDir, "root-dir", "r", "", "optional path to the root directory of the kwild node from which the genesis hash will be computed")
Copy link
Member Author

@jchappelow jchappelow Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Root is bound globally. A handful of commands hide the flag, but the root command binds it for all subcommands.

Copy link
Collaborator

@brennanjl brennanjl Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have root dir bound globally?

Entire subcommand (e.g. validators) have no use for it.

Copy link
Member Author

@jchappelow jchappelow Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost all commands actually do. In the case of all the commands that use admin RPC, like validators, the on-disk config is used as a default when --rpcserver is not set on the CLI (if the config file doesn't exist, the hard-coded default are used, of course). This means root directory can affect it.
We have the ability to hide it for other commands as needed though. For example key gen had it's own output flag, and the root flag their was confusing, so I hid it.

use node config file in snapshot and reset commands

fix more misuse of display.PrintErr
@brennanjl brennanjl merged commit f3f382d into kwilteam:main Jan 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants