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

Add validator helpers to cli #870

Merged
merged 9 commits into from
Jun 3, 2024
Merged

Conversation

JesseAbram
Copy link
Member

Closes #865

@JesseAbram JesseAbram marked this pull request as ready for review May 31, 2024 18:56
@JesseAbram JesseAbram requested review from HCastano and ameba23 May 31, 2024 18:56
Copy link
Contributor

@ameba23 ameba23 left a comment

Choose a reason for hiding this comment

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

💯 Great to have these available in the CLI. I'd be curious to try if changing an endpoint works.

As mentioned in the comments I would prefer if these were functions in entropy-client which are called here.

They should maybe also be documented in the readme.

crates/test-cli/src/lib.rs Outdated Show resolved Hide resolved
///
/// Optionally may be preceeded with "//", eg: "//Alice"
#[arg(short, long)]
//. The mnemonic to use for the call
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - also typo (doccomment needs three slashes)

crates/test-cli/src/lib.rs Outdated Show resolved Hide resolved

println!("User account: {}", user_keypair.public());

let change_endpoint_tx =
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO these should be done in a function in entropy-client ./crates/client/src/client.rs. This makes it possible to test them, and to call them from other client software.

new_endpoint: String,
// The mnemonic to use for the call, should be stash address
#[arg(short, long)]
mnemonic_option: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

As I already said with the other ones, i think --mnemonic-option is not a good name for this argument. In the context of this CLI this a mandatory argument. If they don't give it the command will not work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So we shouldn't even have this as an Option then, eh?

Copy link
Member Author

Choose a reason for hiding this comment

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

no it will work if the mnemonic is in the environment, a mnemonic is needed but it is not needed to be passed in

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok yeah you are right.

Copy link
Collaborator

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

Good call on adding these here. Main thing I'd try and address is moving some of the code to the client and potentially adding tests for them

},
/// Allows a validator to change their endloint
ChangeEndpoint {
/// New endpoint to change to
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would give an example of the expected format. Although I guess that can take all sorts of different forms, from bare IP addresses to FQDNs

crates/test-cli/src/lib.rs Outdated Show resolved Hide resolved
ChangeEndpoint {
/// New endpoint to change to
new_endpoint: String,
// The mnemonic to use for the call, should be stash address
Copy link
Collaborator

Choose a reason for hiding this comment

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

And I guess to be more specific, this is the validator stash account, correct?

crates/test-cli/src/lib.rs Outdated Show resolved Hide resolved
new_endpoint: String,
// The mnemonic to use for the call, should be stash address
#[arg(short, long)]
mnemonic_option: Option<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

So we shouldn't even have this as an Option then, eh?

let result_event = in_block
.find_first::<entropy::staking_extension::events::EndpointChanged>()?
.ok_or(anyhow!("Error with transaction"))?;
println!("Event result: {:?}", result_event);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd be a bit more specific with what we're printing here

Copy link
Member Author

Choose a reason for hiding this comment

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

well this one returns an event that is pretty descriptive and has the extra data needed


let user_keypair = <sr25519::Pair as Pair>::from_string(&mnemonic, None)?;

println!("User account: {}", user_keypair.public());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd also be more specific here (and same for the other command)

JesseAbram and others added 6 commits June 3, 2024 08:22
Co-authored-by: peg <peg@magmacollective.org>
Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
@JesseAbram JesseAbram merged commit a1ac1f3 into master Jun 3, 2024
13 checks passed
@JesseAbram JesseAbram deleted the Add-validator-helpers-to-cli branch June 3, 2024 21:35
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.

Add validator helper functions to the Cli
3 participants