-
Notifications
You must be signed in to change notification settings - Fork 990
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
Conversation
8edee19
to
1e8ba0c
Compare
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. |
api_secret: Option<String>, | ||
input: &IN, | ||
read_timeout: Option<u64>, | ||
) -> Result<OUT, Error> |
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.
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?
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 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 |
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 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 ...
src/bin/cmd/client.rs
Outdated
@@ -149,6 +159,21 @@ impl HTTPNodeClient { | |||
e.reset().unwrap(); | |||
} | |||
|
|||
pub fn validate_chain(&self, fast_validation: bool) { |
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.
how come this is a new method, rather than a changed method?
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 don't really get what you mean here by a new or changed method?
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 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.
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, will call it, verify_chain
to make it clear it's a new method.
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 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.
src/bin/cmd/client.rs
Outdated
) | ||
.unwrap(); | ||
match self.send_json_request::<()>("validate_chain", ¶ms) { | ||
Ok(_) => writeln!(e, "Successfully validated chain.").unwrap(), |
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.
This output should reflect whether rangeproofs and kernels were validated.
src/bin/cmd/client.rs
Outdated
@@ -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 }; |
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.
This is simply let fast_validation = !args.is_present("fast")
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.
See in-line comments.
@@ -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> { |
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.
why not use assume_valid_rangeproofs_kernels here as well?
src/bin/cmd/client.rs
Outdated
@@ -149,6 +158,27 @@ impl HTTPNodeClient { | |||
e.reset().unwrap(); | |||
} | |||
|
|||
pub fn verify_chain(&self, fast_validation: bool) { |
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.
why not use the name assume_valid_rangeproofs_kernels here as well?
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.
Done but i let --fast
as the option for the arg verify-chain.
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 recommend more use of the name assume_valid_rangeproofs_kernels
as indicated with in-line comments.
Following this feature suggestion #3609
fast_validation
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