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

verify-chain node client arg #3678

Merged
merged 6 commits into from
Jan 7, 2022
Merged

Conversation

deevope
Copy link
Contributor

@deevope deevope commented Dec 27, 2021

Following this feature suggestion #3609

  • Add the parameter on the api fast_validation
  • Add verify-chain node client argurment

Usage:
Full chain validation
grin client verify-chain

Partial chain validation
grin client verify-chain --fast

PS: This PR need the API to gracefully shutdown, need to merge #3677

@phyro
Copy link
Member

phyro commented Dec 28, 2021

Thanks for making it a reality! Sorry for the delay. I've set up a new system at home and have hit some unexpected issues with syncing for some reason and am still figuring why. I'll try to sync on the latest master tomorrow that contains some optimizations and see if I can make it sync and then check this one. One thing we'll have to check is whether this blocks other actions (api, block processing, potential sync requests, can we get banned if we fall behind but advertise availability) due to locking or similar since I expect it to be running for some time. Maybe we don't even care for these cases, but if nothing else, to document if that's the case.

@phyro phyro requested review from phyro, yeastplume and tromp December 28, 2021 23:23
api_secret: Option<String>,
input: &IN,
read_timeout: Option<u64>,
) -> Result<OUT, Error>
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding Option parameters to multiple methods, isn't it preferable to add a new timeout member,
and a method to change it from its default value of 20secs?

Copy link
Contributor Author

@deevope deevope Dec 30, 2021

Choose a reason for hiding this comment

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

I did it a bit more cleaner but just adding a method in api/client.rs and trigger a change of timeout in function of the api method used in the request is a bit painful in the form it's built. If you have better idea, i'm open.
However these method are almost only used for cmd/client.rs

api/src/owner.rs Outdated
@@ -80,17 +80,20 @@ impl Owner {

/// Trigger a validation of the chain state.
///
/// # Arguments
/// * `fast_validation` - if false verify the rangeproof associated with each unspent output and all kernels
Copy link
Contributor

@tromp tromp Dec 29, 2021

Choose a reason for hiding this comment

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

i'd prefer this is called something like assume_valid_rangeproofs_kernels,
to reflect its importance and potential for harm.
Also, describe it's behaviour in terms of - if true ...

@@ -149,6 +159,21 @@ impl HTTPNodeClient {
e.reset().unwrap();
}

pub fn validate_chain(&self, fast_validation: bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how come this is a new method, rather than a changed method?

Copy link
Contributor Author

@deevope deevope Dec 29, 2021

Choose a reason for hiding this comment

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

I don't really get what you mean here by a new or changed method?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean that it looks like you're adding a validate_chain method to HTTPNodeClient,
whereas elsewhere in this commit, there are changes to existing validate_chain methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ok, will call it, verify_chain to make it clear it's a new method.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't object to the name. If it behaves identical to those others, then the same name is appropriate. But I just wondered, since I'm not very familiar with this code, why HTTPNodeClient didn't need such a method before and does now.

)
.unwrap();
match self.send_json_request::<()>("validate_chain", &params) {
Ok(_) => writeln!(e, "Successfully validated chain.").unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This output should reflect whether rangeproofs and kernels were validated.

@@ -191,6 +216,10 @@ pub fn client_command(client_args: &ArgMatches<'_>, global_config: GlobalConfig)
let hash = args.value_of("hash").unwrap();
node_client.invalidate_header(hash.to_string());
}
("verify-chain", Some(args)) => {
let fast_validation = if args.is_present("fast") { false } else { true };
Copy link
Contributor

Choose a reason for hiding this comment

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

This is simply let fast_validation = !args.is_present("fast")

Copy link
Contributor

@tromp tromp left a comment

Choose a reason for hiding this comment

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

See in-line comments.

@deevope deevope requested a review from tromp December 30, 2021 08:00
@@ -53,9 +53,9 @@ pub struct ChainValidationHandler {
}

impl ChainValidationHandler {
pub fn validate_chain(&self) -> Result<(), Error> {
pub fn validate_chain(&self, fast_validation: bool) -> Result<(), Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use assume_valid_rangeproofs_kernels here as well?

@@ -149,6 +158,27 @@ impl HTTPNodeClient {
e.reset().unwrap();
}

pub fn verify_chain(&self, fast_validation: bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use the name assume_valid_rangeproofs_kernels here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done but i let --fast as the option for the arg verify-chain.

Copy link
Contributor

@tromp tromp left a comment

Choose a reason for hiding this comment

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

I recommend more use of the name assume_valid_rangeproofs_kernels
as indicated with in-line comments.

@yeastplume
Copy link
Member

Reviewed requested changes, all good with me. Thanks for this PR at @deevope and for the detailed review @tromp !

@yeastplume yeastplume merged commit a3eebbc into mimblewimble:master Jan 7, 2022
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.

4 participants