mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
skip rangeproof and kernel signature verification unless we are doing a "full" chain validation (#1678)
This commit is contained in:
parent
463567b19e
commit
acf61db463
3 changed files with 11 additions and 10 deletions
|
@ -524,7 +524,6 @@ pub struct ChainValidationHandler {
|
|||
|
||||
impl Handler for ChainValidationHandler {
|
||||
fn get(&self, _req: Request<Body>) -> ResponseFuture {
|
||||
// TODO - read skip_rproofs from query params
|
||||
match w(&self.chain).validate(true) {
|
||||
Ok(_) => response(StatusCode::OK, ""),
|
||||
Err(e) => response(
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue