From 960bf1cedb40ec496d96388478497e355867513c Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Sun, 8 Dec 2024 17:20:39 +0800 Subject: [PATCH] Let ckb-chain select rigth `Switch` for assume_valid_target array --- chain/src/verify.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/chain/src/verify.rs b/chain/src/verify.rs index dbd1839b64..56a9aeace6 100644 --- a/chain/src/verify.rs +++ b/chain/src/verify.rs @@ -199,14 +199,22 @@ impl ConsumeUnverifiedBlockProcessor { switch: Option, ) -> VerifyResult { let switch: Switch = switch.unwrap_or_else(|| { - let mut assume_valid_target = self.shared.assume_valid_target(); - match *assume_valid_target { - Some(ref target) => { - // if the target has been reached, delete it - if target - == &ckb_types::prelude::Unpack::::unpack(&BlockView::hash(block)) - { - assume_valid_target.take(); + let mut assume_valid_targets = self.shared.assume_valid_targets(); + match *assume_valid_targets { + Some(ref mut targets) => { + // + let block_hash: H256 = + ckb_types::prelude::Unpack::::unpack(&BlockView::hash(block)); + if targets.first().eq(&Some(&block_hash)) { + targets.remove(0); + info!("CKB reached one assume_valid_target: 0x{}", block_hash); + } + + if targets.is_empty() { + assume_valid_targets.take(); + info!( + "CKB reached all assume_valid_targets, will do full verification now" + ); Switch::NONE } else { Switch::DISABLE_SCRIPT