-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
There was a problem hiding this 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
/// | ||
/// Optionally may be preceeded with "//", eg: "//Alice" | ||
#[arg(short, long)] | ||
//. The mnemonic to use for the call |
There was a problem hiding this comment.
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
|
||
println!("User account: {}", user_keypair.public()); | ||
|
||
let change_endpoint_tx = |
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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
crates/test-cli/src/lib.rs
Outdated
}, | ||
/// Allows a validator to change their endloint | ||
ChangeEndpoint { | ||
/// New endpoint to change to |
There was a problem hiding this comment.
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
ChangeEndpoint { | ||
/// New endpoint to change to | ||
new_endpoint: String, | ||
// The mnemonic to use for the call, should be stash address |
There was a problem hiding this comment.
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?
new_endpoint: String, | ||
// The mnemonic to use for the call, should be stash address | ||
#[arg(short, long)] | ||
mnemonic_option: Option<String>, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
crates/test-cli/src/lib.rs
Outdated
|
||
let user_keypair = <sr25519::Pair as Pair>::from_string(&mnemonic, None)?; | ||
|
||
println!("User account: {}", user_keypair.public()); |
There was a problem hiding this comment.
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)
Closes #865