From 945f31dfc700be8a48b8995df7b7993909e51e11 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 24 Aug 2024 17:30:02 -0400 Subject: [PATCH] Have the scan flag blocks with change/branch/forwarded as notable --- processor/scanner/src/db.rs | 5 +++++ processor/scanner/src/report.rs | 1 + processor/scanner/src/scan.rs | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/processor/scanner/src/db.rs b/processor/scanner/src/db.rs index cccbe5f6..0710ae30 100644 --- a/processor/scanner/src/db.rs +++ b/processor/scanner/src/db.rs @@ -120,6 +120,7 @@ impl ScannerDb { } // TODO: This will be called from the Eventuality task yet this field is read by the scan task // We need to write the argument for its safety + // TODO: retire_key needs to set the notable block pub(crate) fn retire_key(txn: &mut impl DbTxn, key: KeyFor) { let mut keys: Vec>>> = ActiveKeys::get(txn).expect("retiring key yet no active keys"); @@ -276,6 +277,10 @@ impl ScannerDb { SerializedForwardedOutput::set(txn, id.as_ref(), &buf); } + pub(crate) fn flag_notable(txn: &mut impl DbTxn, block_number: u64) { + NotableBlock::set(txn, block_number, &()); + } + // TODO: Use a DbChannel here, and send the instructions to the report task and the outputs to // the eventuality task? That way this cleans up after itself pub(crate) fn set_in_instructions( diff --git a/processor/scanner/src/report.rs b/processor/scanner/src/report.rs index 17cdca35..37ef8874 100644 --- a/processor/scanner/src/report.rs +++ b/processor/scanner/src/report.rs @@ -46,6 +46,7 @@ impl ContinuallyRan for ReportTask { for b in next_to_potentially_report ..= highest_reportable { let mut txn = self.db.txn(); + // If this block is notable, create the Batch(s) for it if ScannerDb::::is_block_notable(&txn, b) { let in_instructions = ScannerDb::::in_instructions(&txn, b) .expect("reporting block which didn't set its InInstructions"); diff --git a/processor/scanner/src/scan.rs b/processor/scanner/src/scan.rs index 365f0f14..8c8e07b3 100644 --- a/processor/scanner/src/scan.rs +++ b/processor/scanner/src/scan.rs @@ -152,6 +152,14 @@ impl ContinuallyRan for ScanForOutputsTask { to do so at a higher level. */ if output.kind() != OutputType::External { + // While we don't report these outputs, we still need consensus on this block and + // accordingly still need to set it as notable + let balance = outputs.balance(); + // We ensure it's over the dust limit to prevent people sending 1 satoshi from causing + // an invocation of a consensus/signing protocol + if balance.amount.0 >= self.feed.dust(balance.coin).0 { + ScannerDb::::flag_notable(&mut txn, b); + } continue; }