From 965d180ec49501240863736bca012badf02b0cd7 Mon Sep 17 00:00:00 2001 From: qima Date: Sat, 8 Jun 2024 05:16:52 +0800 Subject: [PATCH] feat(auditor): skip royalty track using default key --- sn_client/src/audit/dag_crawling.rs | 13 +++++++++++-- sn_transfers/src/lib.rs | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sn_client/src/audit/dag_crawling.rs b/sn_client/src/audit/dag_crawling.rs index ce9609380a..080614b4bb 100644 --- a/sn_client/src/audit/dag_crawling.rs +++ b/sn_client/src/audit/dag_crawling.rs @@ -11,8 +11,8 @@ use crate::{Client, Error, SpendDag}; use futures::{future::join_all, StreamExt}; use sn_networking::{GetRecordError, NetworkError}; use sn_transfers::{ - SignedSpend, SpendAddress, SpendReason, WalletError, WalletResult, GENESIS_SPEND_UNIQUE_KEY, - NETWORK_ROYALTIES_PK, + SignedSpend, SpendAddress, SpendReason, WalletError, WalletResult, + DEFAULT_NETWORK_ROYALTIES_PK, GENESIS_SPEND_UNIQUE_KEY, NETWORK_ROYALTIES_PK, }; use std::{ collections::{BTreeMap, BTreeSet}, @@ -520,6 +520,12 @@ fn beta_track_analyze_spend(spend: &SignedSpend) -> BTreeSet { .iter() .map(|derivation_idx| NETWORK_ROYALTIES_PK.new_unique_pubkey(derivation_idx)) .collect(); + let default_royalty_pubkeys: BTreeSet<_> = spend + .spend + .network_royalties + .iter() + .map(|derivation_idx| DEFAULT_NETWORK_ROYALTIES_PK.new_unique_pubkey(derivation_idx)) + .collect(); let new_utxos: BTreeSet<_> = spend .spend @@ -527,6 +533,9 @@ fn beta_track_analyze_spend(spend: &SignedSpend) -> BTreeSet { .outputs .iter() .filter_map(|output| { + if default_royalty_pubkeys.contains(&output.unique_pubkey) { + return None; + } if !royalty_pubkeys.contains(&output.unique_pubkey) { Some(SpendAddress::from_unique_pubkey(&output.unique_pubkey)) } else { diff --git a/sn_transfers/src/lib.rs b/sn_transfers/src/lib.rs index 0130776689..ab96cc12dd 100644 --- a/sn_transfers/src/lib.rs +++ b/sn_transfers/src/lib.rs @@ -102,6 +102,12 @@ lazy_static! { Err(err) => panic!("Failed to parse network royalties PK: {err:?}"), } }; + pub static ref DEFAULT_NETWORK_ROYALTIES_PK: MainPubkey = { + match MainPubkey::from_hex(DEFAULT_NETWORK_ROYALTIES_STR) { + Ok(pk) => pk, + Err(err) => panic!("Failed to parse default network royalties PK: {err:?}"), + } + }; } lazy_static! {