Skip to content

Commit

Permalink
fix: dag crawling invalid source check
Browse files Browse the repository at this point in the history
  • Loading branch information
grumbach committed Jul 23, 2024
1 parent a121e83 commit 7fc6a99
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions sn_client/src/audit/dag_crawling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl Client {
// use iteration instead of recursion to avoid stack overflow
let mut ancestors_to_verify = new_spend.spend.ancestors.clone();
let mut depth = 0;
let mut known_ancestors = BTreeSet::new();
let mut known_ancestors = BTreeSet::from_iter([dag.source()]);
let start = std::time::Instant::now();

while !ancestors_to_verify.is_empty() {
Expand Down Expand Up @@ -404,20 +404,8 @@ impl Client {
debug!("Depth {depth} - Got {spends_len} spends for parent: {addrs_to_verify:?}");
trace!("Spends for {addrs_to_verify:?} - {spends:?}");

// check if we reached the genesis spend
known_ancestors.extend(addrs_to_verify.clone());
if spends
.iter()
.all(|s| s.spend.unique_pubkey == *sn_transfers::GENESIS_SPEND_UNIQUE_KEY)
&& spends.len() == 1
{
debug!(
"Depth {depth} - reached genesis spend on one branch: {addrs_to_verify:?}"
);
continue;
}

// add spends to the dag
known_ancestors.extend(addrs_to_verify.clone());
for (spend, addr) in spends.clone().into_iter().zip(addrs_to_verify) {
let is_new_spend = dag.insert(addr, spend.clone());

Expand Down

0 comments on commit 7fc6a99

Please sign in to comment.