From acb4c539f7753efab69f430b84b6261e740d5d43 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 17 Feb 2022 19:29:59 +0000 Subject: [PATCH] Drop `fuzztarget` feature entirely Some time ago we started transitioning to `cfg(fuzzing)` instead of exposing a full feature. Here we complete the transition. --- fuzz/Cargo.toml | 4 +- lightning-invoice/fuzz/Cargo.toml | 3 +- lightning/Cargo.toml | 1 - lightning/src/chain/chainmonitor.rs | 8 +-- lightning/src/chain/channelmonitor.rs | 16 +++--- lightning/src/lib.rs | 6 +- lightning/src/ln/chan_utils.rs | 2 +- lightning/src/ln/channel.rs | 68 +++++++++++------------ lightning/src/ln/channelmanager.rs | 6 +- lightning/src/ln/mod.rs | 8 +-- lightning/src/ln/msgs.rs | 4 +- lightning/src/routing/router.rs | 10 ++-- lightning/src/util/chacha20.rs | 8 +-- lightning/src/util/chacha20poly1305rfc.rs | 8 +-- lightning/src/util/fuzz_wrappers.rs | 4 +- lightning/src/util/mod.rs | 10 ++-- 16 files changed, 83 insertions(+), 83 deletions(-) diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 3b6d027d..bc1f0a47 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Automatically generated"] publish = false # Because the function is unused it gets dropped before we link lightning, so # we have to duplicate build.rs here. Note that this is only required for -# fuzztarget mode. +# fuzzing mode. [package.metadata] cargo-fuzz = true @@ -18,7 +18,7 @@ stdin_fuzz = [] [dependencies] afl = { version = "0.4", optional = true } -lightning = { path = "../lightning", features = ["fuzztarget"] } +lightning = { path = "../lightning", features = ["regex"] } bitcoin = { version = "0.27", features = ["fuzztarget", "secp-lowmemory"] } hex = "0.3" honggfuzz = { version = "0.5", optional = true } diff --git a/lightning-invoice/fuzz/Cargo.toml b/lightning-invoice/fuzz/Cargo.toml index eb583a41..d741864a 100644 --- a/lightning-invoice/fuzz/Cargo.toml +++ b/lightning-invoice/fuzz/Cargo.toml @@ -14,7 +14,8 @@ honggfuzz_fuzz = ["honggfuzz"] [dependencies] honggfuzz = { version = "0.5", optional = true } afl = { version = "0.4", optional = true } -lightning-invoice = { path = ".."} +lightning-invoice = { path = ".." } +lightning = { path = "../../lightning", features = ["regex"] } bech32 = "0.8" # Prevent this from interfering with workspaces diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml index c5d0c556..5f6f2ef6 100644 --- a/lightning/Cargo.toml +++ b/lightning/Cargo.toml @@ -11,7 +11,6 @@ Still missing tons of error-handling. See GitHub issues for suggested projects i """ [features] -fuzztarget = ["bitcoin/fuzztarget", "regex"] # Internal test utilities exposed to other repo crates _test_utils = ["hex", "regex", "bitcoin/bitcoinconsensus"] # Unlog messages superior at targeted level. diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index 05f88329..19095fa2 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -474,7 +474,7 @@ where C::Target: chain::Filter, /// This wrapper avoids having to update some of our tests for now as they assume the direct /// chain::Watch API wherein we mark a monitor fully-updated by just calling /// channel_monitor_updated once with the highest ID. - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] pub fn force_channel_monitor_updated(&self, funding_txo: OutPoint, monitor_update_id: u64) { self.pending_monitor_events.lock().unwrap().push(MonitorEvent::UpdateCompleted { funding_txo, @@ -482,7 +482,7 @@ where C::Target: chain::Filter, }); } - #[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] + #[cfg(any(test, fuzzing, feature = "_test_utils"))] pub fn get_and_clear_pending_events(&self) -> Vec { use util::events::EventsProvider; let events = core::cell::RefCell::new(Vec::new()); @@ -630,9 +630,9 @@ where C::Target: chain::Filter, // We should never ever trigger this from within ChannelManager. Technically a // user could use this object with some proxying in between which makes this // possible, but in tests and fuzzing, this should be a panic. - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] panic!("ChannelManager generated a channel update for a channel that was not yet registered!"); - #[cfg(not(any(test, feature = "fuzztarget")))] + #[cfg(not(any(test, fuzzing)))] Err(ChannelMonitorUpdateErr::PermanentFailure) }, Some(monitor_state) => { diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index e6f6ceda..96caaad2 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -59,7 +59,7 @@ use sync::Mutex; /// An update generated by the underlying Channel itself which contains some new information the /// ChannelMonitor should be made aware of. -#[cfg_attr(any(test, feature = "fuzztarget", feature = "_test_utils"), derive(PartialEq))] +#[cfg_attr(any(test, fuzzing, feature = "_test_utils"), derive(PartialEq))] #[derive(Clone)] #[must_use] pub struct ChannelMonitorUpdate { @@ -441,7 +441,7 @@ impl_writeable_tlv_based_enum_upgradable!(OnchainEvent, ); -#[cfg_attr(any(test, feature = "fuzztarget", feature = "_test_utils"), derive(PartialEq))] +#[cfg_attr(any(test, fuzzing, feature = "_test_utils"), derive(PartialEq))] #[derive(Clone)] pub(crate) enum ChannelMonitorUpdateStep { LatestHolderCommitmentTXInfo { @@ -711,9 +711,9 @@ pub(crate) struct ChannelMonitorImpl { /// Transaction outputs to watch for on-chain spends. pub type TransactionOutputs = (Txid, Vec<(u32, TxOut)>); -#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] -/// Used only in testing and fuzztarget to check serialization roundtrips don't change the -/// underlying object +#[cfg(any(test, fuzzing, feature = "_test_utils"))] +/// Used only in testing and fuzzing to check serialization roundtrips don't change the underlying +/// object impl PartialEq for ChannelMonitor { fn eq(&self, other: &Self) -> bool { let inner = self.inner.lock().unwrap(); @@ -722,9 +722,9 @@ impl PartialEq for ChannelMonitor { } } -#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] -/// Used only in testing and fuzztarget to check serialization roundtrips don't change the -/// underlying object +#[cfg(any(test, fuzzing, feature = "_test_utils"))] +/// Used only in testing and fuzzing to check serialization roundtrips don't change the underlying +/// object impl PartialEq for ChannelMonitorImpl { fn eq(&self, other: &Self) -> bool { if self.latest_update_id != other.latest_update_id || diff --git a/lightning/src/lib.rs b/lightning/src/lib.rs index 8fdf63ff..13218985 100644 --- a/lightning/src/lib.rs +++ b/lightning/src/lib.rs @@ -18,8 +18,8 @@ //! generated/etc. This makes it a good candidate for tight integration into an existing wallet //! instead of having a rather-separate lightning appendage to a wallet. -#![cfg_attr(not(any(test, feature = "fuzztarget", feature = "_test_utils")), deny(missing_docs))] -#![cfg_attr(not(any(test, feature = "fuzztarget", feature = "_test_utils")), forbid(unsafe_code))] +#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), deny(missing_docs))] +#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), forbid(unsafe_code))] #![deny(broken_intra_doc_links)] // In general, rust is absolutely horrid at supporting users doing things like, @@ -43,7 +43,7 @@ extern crate bitcoin; extern crate core; #[cfg(any(test, feature = "_test_utils"))] extern crate hex; -#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] extern crate regex; +#[cfg(any(test, fuzzing, feature = "_test_utils"))] extern crate regex; #[cfg(not(feature = "std"))] extern crate core2; diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index e1661763..6dc05c2e 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -1251,7 +1251,7 @@ impl CommitmentTransaction { if let &Some(ref b_htlcout) = b { a_htlcout.cltv_expiry.cmp(&b_htlcout.cltv_expiry) // Note that due to hash collisions, we have to have a fallback comparison - // here for fuzztarget mode (otherwise at least chanmon_fail_consistency + // here for fuzzing mode (otherwise at least chanmon_fail_consistency // may fail)! .then(a_htlcout.payment_hash.0.cmp(&b_htlcout.payment_hash.0)) // For non-HTLC outputs, if they're copying our SPK we don't really care if we diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index fb921314..d3a9df14 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -46,7 +46,7 @@ use io; use prelude::*; use core::{cmp,mem,fmt}; use core::ops::Deref; -#[cfg(any(test, feature = "fuzztarget", debug_assertions))] +#[cfg(any(test, fuzzing, debug_assertions))] use sync::Mutex; use bitcoin::hashes::hex::ToHex; @@ -670,9 +670,9 @@ pub(super) struct Channel { // `next_remote_commit_tx_fee_msat` properly predict what the next commitment transaction fee will // be, by comparing the cached values to the fee of the tranaction generated by // `build_commitment_transaction`. - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_local_commitment_tx_fee_info_cached: Mutex>, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_remote_commitment_tx_fee_info_cached: Mutex>, /// lnd has a long-standing bug where, upon reconnection, if the channel is not yet confirmed @@ -684,7 +684,7 @@ pub(super) struct Channel { /// See-also pub workaround_lnd_bug_4006: Option, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] // When we receive an HTLC fulfill on an outbound path, we may immediately fulfill the // corresponding HTLC on the inbound path. If, then, the outbound path channel is // disconnected and reconnected (before we've exchange commitment_signed and revoke_and_ack @@ -697,7 +697,7 @@ pub(super) struct Channel { channel_type: ChannelTypeFeatures, } -#[cfg(any(test, feature = "fuzztarget"))] +#[cfg(any(test, fuzzing))] struct CommitmentTxInfoCached { fee: u64, total_pending_htlcs: usize, @@ -940,14 +940,14 @@ impl Channel { announcement_sigs: None, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_local_commitment_tx_fee_info_cached: Mutex::new(None), - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_remote_commitment_tx_fee_info_cached: Mutex::new(None), workaround_lnd_bug_4006: None, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] historical_inbound_htlc_fulfills: HashSet::new(), // We currently only actually support one channel type, so don't retry with new types @@ -1245,14 +1245,14 @@ impl Channel { announcement_sigs: None, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_local_commitment_tx_fee_info_cached: Mutex::new(None), - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_remote_commitment_tx_fee_info_cached: Mutex::new(None), workaround_lnd_bug_4006: None, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] historical_inbound_htlc_fulfills: HashSet::new(), channel_type, @@ -1650,7 +1650,7 @@ impl Channel { } } if pending_idx == core::usize::MAX { - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] // If we failed to find an HTLC to fulfill, make sure it was previously fulfilled and // this is simply a duplicate claim, not previously failed and we lost funds. debug_assert!(self.historical_inbound_htlc_fulfills.contains(&htlc_id_arg)); @@ -1676,7 +1676,7 @@ impl Channel { if htlc_id_arg == htlc_id { // Make sure we don't leave latest_monitor_update_id incremented here: self.latest_monitor_update_id -= 1; - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] debug_assert!(self.historical_inbound_htlc_fulfills.contains(&htlc_id_arg)); return UpdateFulfillFetch::DuplicateClaim {}; } @@ -1697,11 +1697,11 @@ impl Channel { self.holding_cell_htlc_updates.push(HTLCUpdateAwaitingACK::ClaimHTLC { payment_preimage: payment_preimage_arg, htlc_id: htlc_id_arg, }); - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] self.historical_inbound_htlc_fulfills.insert(htlc_id_arg); return UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, msg: None }; } - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] self.historical_inbound_htlc_fulfills.insert(htlc_id_arg); { @@ -1782,7 +1782,7 @@ impl Channel { } } if pending_idx == core::usize::MAX { - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] // If we failed to find an HTLC to fail, make sure it was previously fulfilled and this // is simply a duplicate fail, not previously failed and we failed-back too early. debug_assert!(self.historical_inbound_htlc_fulfills.contains(&htlc_id_arg)); @@ -1795,7 +1795,7 @@ impl Channel { match pending_update { &HTLCUpdateAwaitingACK::ClaimHTLC { htlc_id, .. } => { if htlc_id_arg == htlc_id { - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] debug_assert!(self.historical_inbound_htlc_fulfills.contains(&htlc_id_arg)); return Ok(None); } @@ -2367,7 +2367,7 @@ impl Channel { let num_htlcs = included_htlcs + addl_htlcs; let res = Self::commit_tx_fee_msat(self.feerate_per_kw, num_htlcs, self.opt_anchors()); - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] { let mut fee = res; if fee_spike_buffer_htlc.is_some() { @@ -2445,7 +2445,7 @@ impl Channel { let num_htlcs = included_htlcs + addl_htlcs; let res = Self::commit_tx_fee_msat(self.feerate_per_kw, num_htlcs, self.opt_anchors()); - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] { let mut fee = res; if fee_spike_buffer_htlc.is_some() { @@ -2728,7 +2728,7 @@ impl Channel { return Err((None, ChannelError::Close("Funding remote cannot afford proposed new fee".to_owned()))); } } - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] { if self.is_outbound() { let projected_commit_tx_info = self.next_local_commitment_tx_fee_info_cached.lock().unwrap().take(); @@ -3035,7 +3035,7 @@ impl Channel { return Err(ChannelError::Close("Received an unexpected revoke_and_ack".to_owned())); } - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] { *self.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None; *self.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None; @@ -4466,9 +4466,9 @@ impl Channel { // If we generated the funding transaction and it doesn't match what it // should, the client is really broken and we should just panic and // tell them off. That said, because hash collisions happen with high - // probability in fuzztarget mode, if we're fuzzing we just close the + // probability in fuzzing mode, if we're fuzzing we just close the // channel and move on. - #[cfg(not(feature = "fuzztarget"))] + #[cfg(not(fuzzing))] panic!("Client called ChannelManager::funding_transaction_generated with bogus transaction!"); } self.update_time_counter += 1; @@ -4480,7 +4480,7 @@ impl Channel { if input.witness.is_empty() { // We generated a malleable funding transaction, implying we've // just exposed ourselves to funds loss to our counterparty. - #[cfg(not(feature = "fuzztarget"))] + #[cfg(not(fuzzing))] panic!("Client called ChannelManager::funding_transaction_generated with bogus transaction!"); } } @@ -4937,9 +4937,9 @@ impl Channel { // Prior to static_remotekey, my_current_per_commitment_point was critical to claiming // current to_remote balances. However, it no longer has any use, and thus is now simply // set to a dummy (but valid, as required by the spec) public key. - // fuzztarget mode marks a subset of pubkeys as invalid so that we can hit "invalid pubkey" + // fuzzing mode marks a subset of pubkeys as invalid so that we can hit "invalid pubkey" // branches, but we unwrap it below, so we arbitrarily select a dummy pubkey which is both - // valid, and valid in fuzztarget mode's arbitrary validity criteria: + // valid, and valid in fuzzing mode's arbitrary validity criteria: let mut pk = [2; 33]; pk[1] = 0xff; let dummy_pubkey = PublicKey::from_slice(&pk).unwrap(); let data_loss_protect = if self.cur_counterparty_commitment_transaction_number + 1 < INITIAL_COMMITMENT_NUMBER { @@ -5225,7 +5225,7 @@ impl Channel { let counterparty_commitment_txid = commitment_stats.tx.trust().txid(); let (signature, htlc_signatures); - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] { if !self.is_outbound() { let projected_commit_tx_info = self.next_remote_commitment_tx_fee_info_cached.lock().unwrap().take(); @@ -5711,9 +5711,9 @@ impl Writeable for Channel { self.channel_update_status.write(writer)?; - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] (self.historical_inbound_htlc_fulfills.len() as u64).write(writer)?; - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] for htlc in self.historical_inbound_htlc_fulfills.iter() { htlc.write(writer)?; } @@ -5975,9 +5975,9 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel let channel_update_status = Readable::read(reader)?; - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] let mut historical_inbound_htlc_fulfills = HashSet::new(); - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] { let htlc_fulfills_len: u64 = Readable::read(reader)?; for _ in 0..htlc_fulfills_len { @@ -6151,14 +6151,14 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel announcement_sigs, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_local_commitment_tx_fee_info_cached: Mutex::new(None), - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] next_remote_commitment_tx_fee_info_cached: Mutex::new(None), workaround_lnd_bug_4006: None, - #[cfg(any(test, feature = "fuzztarget"))] + #[cfg(any(test, fuzzing))] historical_inbound_htlc_fulfills, channel_type: channel_type.unwrap(), diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 0a0407ea..6d8f5de2 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -1788,7 +1788,7 @@ impl ChannelMana let mut channel_state = self.channel_state.lock().unwrap(); match channel_state.by_id.entry(temporary_channel_id) { hash_map::Entry::Occupied(_) => { - if cfg!(feature = "fuzztarget") { + if cfg!(fuzzing) { return Err(APIError::APIMisuseError { err: "Fuzzy bad RNG".to_owned() }); } else { panic!("RNG is bad???"); @@ -4914,7 +4914,7 @@ impl ChannelMana /// In chanmon_consistency_target, we'd like to be able to restore monitor updating without /// handling all pending events (i.e. not PendingHTLCsForwardable). Thus, we expose monitor /// update events as a separate process method here. - #[cfg(feature = "fuzztarget")] + #[cfg(fuzzing)] pub fn process_monitor_events(&self) { self.process_pending_monitor_events(); } @@ -5236,7 +5236,7 @@ impl ChannelMana } } - #[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] + #[cfg(any(test, fuzzing, feature = "_test_utils"))] pub fn get_and_clear_pending_events(&self) -> Vec { let events = core::cell::RefCell::new(Vec::new()); let event_handler = |event: &events::Event| events.borrow_mut().push(event.clone()); diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs index 41d978e8..44704ae5 100644 --- a/lightning/src/ln/mod.rs +++ b/lightning/src/ln/mod.rs @@ -29,14 +29,14 @@ pub mod chan_utils; pub mod features; pub mod script; -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] pub mod peer_channel_encryptor; -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] pub(crate) mod peer_channel_encryptor; -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] pub mod channel; -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] pub(crate) mod channel; mod onion_utils; diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 203e2426..b078b6f3 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -937,9 +937,9 @@ mod fuzzy_internal_msgs { pub(crate) pad: Vec, } } -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] pub use self::fuzzy_internal_msgs::*; -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] pub(crate) use self::fuzzy_internal_msgs::*; #[derive(Clone)] diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index dc2f8fd1..65119f0f 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -455,7 +455,7 @@ struct PathBuildingHop<'a> { /// decrease as well. Thus, we have to explicitly track which nodes have been processed and /// avoid processing them again. was_processed: bool, - #[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))] + #[cfg(all(not(feature = "_bench_unstable"), any(test, fuzzing)))] // In tests, we apply further sanity checks on cases where we skip nodes we already processed // to ensure it is specifically in cases where the fee has gone down because of a decrease in // value_contribution_msat, which requires tracking it here. See comments below where it is @@ -896,14 +896,14 @@ where L::Target: Logger { path_htlc_minimum_msat, path_penalty_msat: u64::max_value(), was_processed: false, - #[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))] + #[cfg(all(not(feature = "_bench_unstable"), any(test, fuzzing)))] value_contribution_msat, } }); #[allow(unused_mut)] // We only use the mut in cfg(test) let mut should_process = !old_entry.was_processed; - #[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))] + #[cfg(all(not(feature = "_bench_unstable"), any(test, fuzzing)))] { // In test/fuzzing builds, we do extra checks to make sure the skipping // of already-seen nodes only happens in cases we expect (see below). @@ -992,13 +992,13 @@ where L::Target: Logger { old_entry.fee_msat = 0; // This value will be later filled with hop_use_fee_msat of the following channel old_entry.path_htlc_minimum_msat = path_htlc_minimum_msat; old_entry.path_penalty_msat = path_penalty_msat; - #[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))] + #[cfg(all(not(feature = "_bench_unstable"), any(test, fuzzing)))] { old_entry.value_contribution_msat = value_contribution_msat; } did_add_update_path_to_src_node = true; } else if old_entry.was_processed && new_cost < old_cost { - #[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))] + #[cfg(all(not(feature = "_bench_unstable"), any(test, fuzzing)))] { // If we're skipping processing a node which was previously // processed even though we found another path to it with a diff --git a/lightning/src/util/chacha20.rs b/lightning/src/util/chacha20.rs index 85c0a47d..3578fb36 100644 --- a/lightning/src/util/chacha20.rs +++ b/lightning/src/util/chacha20.rs @@ -11,7 +11,7 @@ use io; -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] mod real_chacha { use core::cmp; use core::convert::TryInto; @@ -272,10 +272,10 @@ mod real_chacha { } } } -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] pub use self::real_chacha::ChaCha20; -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] mod fuzzy_chacha { pub struct ChaCha20 {} @@ -297,7 +297,7 @@ mod fuzzy_chacha { pub fn process_in_place(&mut self, _input_output: &mut [u8]) {} } } -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] pub use self::fuzzy_chacha::ChaCha20; pub(crate) struct ChaChaReader<'a, R: io::Read> { diff --git a/lightning/src/util/chacha20poly1305rfc.rs b/lightning/src/util/chacha20poly1305rfc.rs index fdd51e75..e0e155ce 100644 --- a/lightning/src/util/chacha20poly1305rfc.rs +++ b/lightning/src/util/chacha20poly1305rfc.rs @@ -10,7 +10,7 @@ // This is a port of Andrew Moons poly1305-donna // https://github.com/floodyberry/poly1305-donna -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] mod real_chachapoly { use util::chacha20::ChaCha20; use util::poly1305::Poly1305; @@ -94,10 +94,10 @@ mod real_chachapoly { } } } -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] pub use self::real_chachapoly::ChaCha20Poly1305RFC; -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] mod fuzzy_chachapoly { #[derive(Clone, Copy)] pub struct ChaCha20Poly1305RFC { @@ -141,5 +141,5 @@ mod fuzzy_chachapoly { } } } -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] pub use self::fuzzy_chachapoly::ChaCha20Poly1305RFC; diff --git a/lightning/src/util/fuzz_wrappers.rs b/lightning/src/util/fuzz_wrappers.rs index 8f15844e..afe9c402 100644 --- a/lightning/src/util/fuzz_wrappers.rs +++ b/lightning/src/util/fuzz_wrappers.rs @@ -10,11 +10,11 @@ macro_rules! hash_to_message { ($slice: expr) => { { - #[cfg(not(feature = "fuzztarget"))] + #[cfg(not(fuzzing))] { ::bitcoin::secp256k1::Message::from_slice($slice).unwrap() } - #[cfg(feature = "fuzztarget")] + #[cfg(fuzzing)] { match ::bitcoin::secp256k1::Message::from_slice($slice) { Ok(msg) => msg, diff --git a/lightning/src/util/mod.rs b/lightning/src/util/mod.rs index 6e04f856..a1e92a0f 100644 --- a/lightning/src/util/mod.rs +++ b/lightning/src/util/mod.rs @@ -24,11 +24,11 @@ pub mod invoice; pub(crate) mod atomic_counter; pub(crate) mod byte_utils; pub(crate) mod chacha20; -#[cfg(feature = "fuzztarget")] +#[cfg(fuzzing)] pub mod zbase32; -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] pub(crate) mod zbase32; -#[cfg(not(feature = "fuzztarget"))] +#[cfg(not(fuzzing))] pub(crate) mod poly1305; pub(crate) mod chacha20poly1305rfc; pub(crate) mod transaction_utils; @@ -45,11 +45,11 @@ pub(crate) mod crypto; pub mod logger; pub mod config; -#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] +#[cfg(any(test, fuzzing, feature = "_test_utils"))] pub mod test_utils; /// impls of traits that add exra enforcement on the way they're called. Useful for detecting state /// machine errors and used in fuzz targets and tests. -#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] +#[cfg(any(test, fuzzing, feature = "_test_utils"))] pub mod enforcing_trait_impls; -- 2.30.2