diff --git a/api/src/handlers.rs b/api/src/handlers.rs index 33fdd7d61..0d4c0653f 100644 --- a/api/src/handlers.rs +++ b/api/src/handlers.rs @@ -524,7 +524,6 @@ pub struct ChainValidationHandler { impl Handler for ChainValidationHandler { fn get(&self, _req: Request) -> ResponseFuture { - // TODO - read skip_rproofs from query params match w(&self.chain).validate(true) { Ok(_) => response(StatusCode::OK, ""), Err(e) => response( diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 829d8269c..21dcb09cd 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -462,7 +462,7 @@ impl Chain { } /// Validate the current chain state. - pub fn validate(&self, skip_rproofs: bool) -> Result<(), Error> { + pub fn validate(&self, fast_validation: bool) -> Result<(), Error> { let header = self.store.head_header()?; // Lets just treat an "empty" node that just got started up as valid. @@ -477,7 +477,7 @@ impl Chain { // ensure the view is consistent. txhashset::extending_readonly(&mut txhashset, |extension| { extension.rewind(&header)?; - extension.validate(skip_rproofs, &NoStatus)?; + extension.validate(fast_validation, &NoStatus)?; Ok(()) }) } @@ -636,6 +636,7 @@ impl Chain { extension.rewind(&header)?; // Validate the extension, generating the utxo_sum and kernel_sum. + // Full validation, including rangeproofs and kernel signature verification. let (utxo_sum, kernel_sum) = extension.validate(false, status)?; // Now that we have block_sums the total_kernel_sum on the block_header is redundant. diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index 371b35dba..a5eaa48dc 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -796,9 +796,10 @@ impl<'a> Extension<'a> { } /// Validate the txhashset state against the provided block header. + /// A "fast validation" will skip rangeproof verification and kernel signature verification. pub fn validate( &self, - skip_rproofs: bool, + fast_validation: bool, status: &TxHashsetWriteStatus, ) -> Result<((Commitment, Commitment)), Error> { self.validate_mmrs()?; @@ -814,13 +815,13 @@ impl<'a> Extension<'a> { // sum of unspent outputs minus total supply. let (output_sum, kernel_sum) = self.validate_kernel_sums()?; - // This is an expensive verification step. - self.verify_kernel_signatures(status)?; - - // Verify the rangeproof for each output in the sum above. - // This is an expensive verification step (skip for faster verification). - if !skip_rproofs { + // These are expensive verification step (skipped for "fast validation"). + if !fast_validation { + // Verify the rangeproof associated with each unspent output. self.verify_rangeproofs(status)?; + + // Verify all the kernel signatures. + self.verify_kernel_signatures(status)?; } Ok((output_sum, kernel_sum))