diff --git a/zebra-consensus/src/block.rs b/zebra-consensus/src/block.rs index b044f4f93..7b782259b 100644 --- a/zebra-consensus/src/block.rs +++ b/zebra-consensus/src/block.rs @@ -151,15 +151,8 @@ where check::difficulty_is_valid(&block.header, network, &height, &hash)?; check::equihash_solution_is_valid(&block.header)?; - // Since errors cause an early exit, try to do the - // quick checks first. - - // Field validity and structure checks - let now = Utc::now(); - check::time_is_valid_at(&block.header, now, &height, &hash) - .map_err(VerifyBlockError::Time)?; - check::coinbase_is_first(&block)?; - check::subsidy_is_valid(&block, network)?; + // Next, check the Merkle root validity, to ensure that + // the header binds to the transactions in the blocks. // Precomputing this avoids duplicating transaction hash computations. let transaction_hashes = block @@ -170,6 +163,16 @@ where check::merkle_root_validity(&block, &transaction_hashes)?; + // Since errors cause an early exit, try to do the + // quick checks first. + + // Field validity and structure checks + let now = Utc::now(); + check::time_is_valid_at(&block.header, now, &height, &hash) + .map_err(VerifyBlockError::Time)?; + check::coinbase_is_first(&block)?; + check::subsidy_is_valid(&block, network)?; + let mut async_checks = FuturesUnordered::new(); let known_utxos = new_outputs(&block, &transaction_hashes);