From: Matt Corallo Date: Thu, 9 Feb 2023 19:20:22 +0000 (+0000) Subject: Remove genesis block hash from public API X-Git-Tag: v0.0.114-beta~5^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=2c3e12e30925b007b7eec235b29236171ad2ed0e;p=rust-lightning Remove genesis block hash from public API Forcing users to pass a genesis block hash has ended up being error-prone largely due to byte-swapping questions for bindings users. Further, our API is currently inconsistent - in `ChannelManager` we take a `Bitcoin::Network` but in `NetworkGraph` we take the genesis block hash. Luckily `NetworkGraph` is the only remaining place where we require users pass the genesis block hash, so swapping it for a `Network` is a simple change. --- diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index ca4246688..71fb26b6a 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -450,7 +450,7 @@ pub fn do_test(data: &[u8], logger: &Arc) { // it's easier to just increment the counter here so the keys don't change. keys_manager.counter.fetch_sub(3, Ordering::AcqRel); let our_id = &keys_manager.get_node_id(Recipient::Node).unwrap(); - let network_graph = Arc::new(NetworkGraph::new(genesis_block(network).block_hash(), Arc::clone(&logger))); + let network_graph = Arc::new(NetworkGraph::new(network, Arc::clone(&logger))); let gossip_sync = Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger))); let scorer = FixedPenaltyScorer::with_penalty(0); diff --git a/fuzz/src/process_network_graph.rs b/fuzz/src/process_network_graph.rs index 661581151..c900a7d38 100644 --- a/fuzz/src/process_network_graph.rs +++ b/fuzz/src/process_network_graph.rs @@ -1,14 +1,12 @@ // Imports that need to be added manually use lightning_rapid_gossip_sync::RapidGossipSync; -use bitcoin::hashes::Hash as TraitImport; use crate::utils::test_logger; /// Actual fuzz test, method signature and name are fixed fn do_test(data: &[u8], out: Out) { - let block_hash = bitcoin::BlockHash::all_zeros(); let logger = test_logger::TestLogger::new("".to_owned(), out); - let network_graph = lightning::routing::gossip::NetworkGraph::new(block_hash, &logger); + let network_graph = lightning::routing::gossip::NetworkGraph::new(bitcoin::Network::Bitcoin, &logger); let rapid_sync = RapidGossipSync::new(&network_graph); let _ = rapid_sync.update_network_graph(data); } diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs index a7c50de4a..93de35c5d 100644 --- a/fuzz/src/router.rs +++ b/fuzz/src/router.rs @@ -24,7 +24,6 @@ use lightning::util::ser::Readable; use bitcoin::hashes::Hash; use bitcoin::secp256k1::PublicKey; use bitcoin::network::constants::Network; -use bitcoin::blockdata::constants::genesis_block; use crate::utils::test_logger; @@ -189,7 +188,7 @@ pub fn do_test(data: &[u8], out: Out) { let logger = test_logger::TestLogger::new("".to_owned(), out); let our_pubkey = get_pubkey!(); - let net_graph = NetworkGraph::new(genesis_block(Network::Bitcoin).header.block_hash(), &logger); + let net_graph = NetworkGraph::new(Network::Bitcoin, &logger); let chain_source = FuzzChainSource { input: Arc::clone(&input), net_graph: &net_graph, diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 97d0462eb..ce94f0107 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -941,7 +941,7 @@ mod tests { let logger = Arc::new(test_utils::TestLogger::with_id(format!("node {}", i))); let network = Network::Testnet; let genesis_block = genesis_block(network); - let network_graph = Arc::new(NetworkGraph::new(genesis_block.header.block_hash(), logger.clone())); + let network_graph = Arc::new(NetworkGraph::new(network, logger.clone())); let scorer = Arc::new(Mutex::new(TestScorer::new())); let seed = [i as u8; 32]; let router = Arc::new(DefaultRouter::new(network_graph.clone(), logger.clone(), seed, scorer.clone())); diff --git a/lightning-rapid-gossip-sync/src/lib.rs b/lightning-rapid-gossip-sync/src/lib.rs index ff0e481b3..3bceb2e28 100644 --- a/lightning-rapid-gossip-sync/src/lib.rs +++ b/lightning-rapid-gossip-sync/src/lib.rs @@ -53,8 +53,7 @@ //! # } //! # let logger = FakeLogger {}; //! -//! let block_hash = genesis_block(Network::Bitcoin).header.block_hash(); -//! let network_graph = NetworkGraph::new(block_hash, &logger); +//! let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); //! let rapid_sync = RapidGossipSync::new(&network_graph); //! let snapshot_contents: &[u8] = &[0; 0]; //! let new_last_sync_timestamp_result = rapid_sync.update_network_graph(snapshot_contents); @@ -161,7 +160,6 @@ impl>, L: Deref> RapidGossipSync where L mod tests { use std::fs; - use bitcoin::blockdata::constants::genesis_block; use bitcoin::Network; use lightning::ln::msgs::DecodeError; @@ -225,9 +223,8 @@ mod tests { let sync_test = FileSyncTest::new(tmp_directory, &valid_response); let graph_sync_test_file = sync_test.get_test_file_path(); - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -258,9 +255,8 @@ mod tests { #[test] fn measure_native_read_from_file() { - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -290,7 +286,6 @@ mod tests { pub mod bench { use test::Bencher; - use bitcoin::blockdata::constants::genesis_block; use bitcoin::Network; use lightning::ln::msgs::DecodeError; @@ -301,10 +296,9 @@ pub mod bench { #[bench] fn bench_reading_full_graph_from_file(b: &mut Bencher) { - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); b.iter(|| { - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); let rapid_sync = RapidGossipSync::new(&network_graph); let sync_result = rapid_sync.sync_network_graph_with_file_path("./res/full_graph.lngossip"); if let Err(crate::error::GraphSyncError::DecodeError(DecodeError::Io(io_error))) = &sync_result { diff --git a/lightning-rapid-gossip-sync/src/processing.rs b/lightning-rapid-gossip-sync/src/processing.rs index f84f205c9..4b6de04c6 100644 --- a/lightning-rapid-gossip-sync/src/processing.rs +++ b/lightning-rapid-gossip-sync/src/processing.rs @@ -237,7 +237,6 @@ impl>, L: Deref> RapidGossipSync where L #[cfg(test)] mod tests { - use bitcoin::blockdata::constants::genesis_block; use bitcoin::Network; use lightning::ln::msgs::DecodeError; @@ -269,9 +268,8 @@ mod tests { #[test] fn network_graph_fails_to_update_from_clipped_input() { - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); let example_input = vec![ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, @@ -309,9 +307,8 @@ mod tests { 68, 226, 0, 6, 11, 0, 1, 128, ]; - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -338,9 +335,8 @@ mod tests { 2, 68, 226, 0, 6, 11, 0, 1, 128, ]; - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -375,9 +371,8 @@ mod tests { 0, 1, 0, 0, 0, 125, 255, 2, 68, 226, 0, 6, 11, 0, 1, 5, 0, 0, 0, 0, 29, 129, 25, 192, ]; - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -442,9 +437,8 @@ mod tests { 25, 192, ]; - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -502,9 +496,8 @@ mod tests { 25, 192, ]; - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -528,9 +521,8 @@ mod tests { #[test] fn full_update_succeeds() { - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -560,9 +552,8 @@ mod tests { #[test] fn full_update_succeeds_at_the_beginning_of_the_unix_era() { - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); @@ -576,14 +567,13 @@ mod tests { #[test] fn timestamp_edge_cases_are_handled_correctly() { // this is the timestamp encoded in the binary data of valid_input below - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); let latest_succeeding_time = VALID_BINARY_TIMESTAMP + STALE_RGS_UPDATE_AGE_LIMIT_SECS; let earliest_failing_time = latest_succeeding_time + 1; { - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); let rapid_sync = RapidGossipSync::new(&network_graph); @@ -593,7 +583,7 @@ mod tests { } { - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); assert_eq!(network_graph.read_only().channels().len(), 0); let rapid_sync = RapidGossipSync::new(&network_graph); @@ -630,9 +620,8 @@ mod tests { 0, 0, 1, ]; - let block_hash = genesis_block(Network::Bitcoin).block_hash(); let logger = TestLogger::new(); - let network_graph = NetworkGraph::new(block_hash, &logger); + let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); let rapid_sync = RapidGossipSync::new(&network_graph); let update_result = rapid_sync.update_network_graph(&unknown_version_input[..]); diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 61de296c1..3ee4dc2fe 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -8672,13 +8672,12 @@ pub mod bench { // Note that this is unrealistic as each payment send will require at least two fsync // calls per node. let network = bitcoin::Network::Testnet; - let genesis_hash = bitcoin::blockdata::constants::genesis_block(network).header.block_hash(); let tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new()), blocks: Arc::new(Mutex::new(Vec::new()))}; let fee_estimator = test_utils::TestFeeEstimator { sat_per_kw: Mutex::new(253) }; let logger_a = test_utils::TestLogger::with_id("node a".to_owned()); let scorer = Mutex::new(test_utils::TestScorer::new()); - let router = test_utils::TestRouter::new(Arc::new(NetworkGraph::new(genesis_hash, &logger_a)), &scorer); + let router = test_utils::TestRouter::new(Arc::new(NetworkGraph::new(network, &logger_a)), &scorer); let mut config: UserConfig = Default::default(); config.channel_handshake_config.minimum_depth = 1; @@ -8722,7 +8721,7 @@ pub mod bench { assert_eq!(&tx_broadcaster.txn_broadcasted.lock().unwrap()[..], &[tx.clone()]); let block = Block { - header: BlockHeader { version: 0x20000000, prev_blockhash: genesis_hash, merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 }, + header: BlockHeader { version: 0x20000000, prev_blockhash: BestBlock::from_genesis(network), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 }, txdata: vec![tx], }; Listen::block_connected(&node_a, &block, 1); @@ -8761,7 +8760,7 @@ pub mod bench { _ => panic!("Unexpected event"), } - let dummy_graph = NetworkGraph::new(genesis_hash, &logger_a); + let dummy_graph = NetworkGraph::new(network, &logger_a); let mut payment_count: u64 = 0; macro_rules! send_payment { diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index fd867bc6a..6274c8bf6 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -2300,7 +2300,7 @@ pub fn create_node_cfgs<'a>(node_count: usize, chanmon_cfgs: &'a Vec PartialEq for NetworkGraph where L::Target: Logger { impl NetworkGraph where L::Target: Logger { /// Creates a new, empty, network graph. - pub fn new(genesis_hash: BlockHash, logger: L) -> NetworkGraph { + pub fn new(network: Network, logger: L) -> NetworkGraph { Self { secp_ctx: Secp256k1::verification_only(), - genesis_hash, + genesis_hash: genesis_block(network).header.block_hash(), logger, channels: RwLock::new(IndexedMap::new()), nodes: RwLock::new(IndexedMap::new()), @@ -1960,9 +1963,8 @@ pub(crate) mod tests { use crate::sync::Arc; fn create_network_graph() -> NetworkGraph> { - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); let logger = Arc::new(test_utils::TestLogger::new()); - NetworkGraph::new(genesis_hash, logger) + NetworkGraph::new(Network::Testnet, logger) } fn create_gossip_sync(network_graph: &NetworkGraph>) -> ( @@ -2137,8 +2139,7 @@ pub(crate) mod tests { let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx); // Test if the UTXO lookups were not supported - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let network_graph = NetworkGraph::new(genesis_hash, &logger); + let network_graph = NetworkGraph::new(Network::Testnet, &logger); let mut gossip_sync = P2PGossipSync::new(&network_graph, None, &logger); match gossip_sync.handle_channel_announcement(&valid_announcement) { Ok(res) => assert!(res), @@ -2162,7 +2163,7 @@ pub(crate) mod tests { // Test if an associated transaction were not on-chain (or not confirmed). let chain_source = test_utils::TestChainSource::new(Network::Testnet); *chain_source.utxo_ret.lock().unwrap() = UtxoResult::Sync(Err(UtxoLookupError::UnknownTx)); - let network_graph = NetworkGraph::new(genesis_hash, &logger); + let network_graph = NetworkGraph::new(Network::Testnet, &logger); gossip_sync = P2PGossipSync::new(&network_graph, Some(&chain_source), &logger); let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| { @@ -2255,8 +2256,7 @@ pub(crate) mod tests { let secp_ctx = Secp256k1::new(); let logger = test_utils::TestLogger::new(); let chain_source = test_utils::TestChainSource::new(Network::Testnet); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let network_graph = NetworkGraph::new(genesis_hash, &logger); + let network_graph = NetworkGraph::new(Network::Testnet, &logger); let gossip_sync = P2PGossipSync::new(&network_graph, Some(&chain_source), &logger); let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap(); @@ -2358,8 +2358,7 @@ pub(crate) mod tests { #[test] fn handling_network_update() { let logger = test_utils::TestLogger::new(); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let network_graph = NetworkGraph::new(genesis_hash, &logger); + let network_graph = NetworkGraph::new(Network::Testnet, &logger); let secp_ctx = Secp256k1::new(); let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap(); @@ -2424,7 +2423,7 @@ pub(crate) mod tests { { // Get a new network graph since we don't want to track removed nodes in this test with "std" - let network_graph = NetworkGraph::new(genesis_hash, &logger); + let network_graph = NetworkGraph::new(Network::Testnet, &logger); // Announce a channel to test permanent node failure let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx); @@ -2459,8 +2458,7 @@ pub(crate) mod tests { // Test the removal of channels with `remove_stale_channels_and_tracking`. let logger = test_utils::TestLogger::new(); let chain_source = test_utils::TestChainSource::new(Network::Testnet); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let network_graph = NetworkGraph::new(genesis_hash, &logger); + let network_graph = NetworkGraph::new(Network::Testnet, &logger); let gossip_sync = P2PGossipSync::new(&network_graph, Some(&chain_source), &logger); let secp_ctx = Secp256k1::new(); diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index b4e2b1384..b456e15a2 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -3256,9 +3256,8 @@ mod tests { let scorer = ln_test_utils::TestScorer::new(); let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet); let random_seed_bytes = keys_manager.get_secure_random_bytes(); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); let logger = ln_test_utils::TestLogger::new(); - let network_graph = NetworkGraph::new(genesis_hash, &logger); + let network_graph = NetworkGraph::new(Network::Testnet, &logger); let route = get_route(&source_node_id, &payment_params, &network_graph.read_only(), Some(&our_chans.iter().collect::>()), route_val, 42, &logger, &scorer, &random_seed_bytes); route @@ -4690,9 +4689,8 @@ mod tests { // payment) htlc_minimum_msat. In the original algorithm, this resulted in node4's // "previous hop" being set to node 3, creating a loop in the path. let secp_ctx = Secp256k1::new(); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); let logger = Arc::new(ln_test_utils::TestLogger::new()); - let network = Arc::new(NetworkGraph::new(genesis_hash, Arc::clone(&logger))); + let network = Arc::new(NetworkGraph::new(Network::Testnet, Arc::clone(&logger))); let gossip_sync = P2PGossipSync::new(Arc::clone(&network), None, Arc::clone(&logger)); let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx); let scorer = ln_test_utils::TestScorer::new(); @@ -4958,9 +4956,8 @@ mod tests { // route over multiple channels with the same first hop. let secp_ctx = Secp256k1::new(); let (_, our_id, _, nodes) = get_nodes(&secp_ctx); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); let logger = Arc::new(ln_test_utils::TestLogger::new()); - let network_graph = NetworkGraph::new(genesis_hash, Arc::clone(&logger)); + let network_graph = NetworkGraph::new(Network::Testnet, Arc::clone(&logger)); let scorer = ln_test_utils::TestScorer::new(); let config = UserConfig::default(); let payment_params = PaymentParameters::from_node_id(nodes[0], 42).with_features(channelmanager::provided_invoice_features(&config)); diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 7504e0840..31158d41b 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -1759,8 +1759,7 @@ mod tests { } fn network_graph(logger: &TestLogger) -> NetworkGraph<&TestLogger> { - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let mut network_graph = NetworkGraph::new(genesis_hash, logger); + let mut network_graph = NetworkGraph::new(Network::Testnet, logger); add_channel(&mut network_graph, 42, source_privkey(), target_privkey()); add_channel(&mut network_graph, 43, target_privkey(), recipient_privkey()); @@ -2226,8 +2225,7 @@ mod tests { // we do not score such channels. let secp_ctx = Secp256k1::new(); let logger = TestLogger::new(); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let mut network_graph = NetworkGraph::new(genesis_hash, &logger); + let mut network_graph = NetworkGraph::new(Network::Testnet, &logger); let secret_a = SecretKey::from_slice(&[42; 32]).unwrap(); let secret_b = SecretKey::from_slice(&[43; 32]).unwrap(); let secret_c = SecretKey::from_slice(&[44; 32]).unwrap(); diff --git a/lightning/src/routing/test_utils.rs b/lightning/src/routing/test_utils.rs index b737bab35..68264207f 100644 --- a/lightning/src/routing/test_utils.rs +++ b/lightning/src/routing/test_utils.rs @@ -141,8 +141,7 @@ pub(super) fn build_line_graph() -> ( let secp_ctx = Secp256k1::new(); let logger = Arc::new(test_utils::TestLogger::new()); let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet)); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let network_graph = Arc::new(NetworkGraph::new(genesis_hash, Arc::clone(&logger))); + let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, Arc::clone(&logger))); let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)); // Build network from our_id to node 19: @@ -195,8 +194,7 @@ pub(super) fn build_graph() -> ( let secp_ctx = Secp256k1::new(); let logger = Arc::new(test_utils::TestLogger::new()); let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet)); - let genesis_hash = genesis_block(Network::Testnet).header.block_hash(); - let network_graph = Arc::new(NetworkGraph::new(genesis_hash, Arc::clone(&logger))); + let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, Arc::clone(&logger))); let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)); // Build network from our_id to node6: // diff --git a/lightning/src/routing/utxo.rs b/lightning/src/routing/utxo.rs index 020993f23..0e5bd8d64 100644 --- a/lightning/src/routing/utxo.rs +++ b/lightning/src/routing/utxo.rs @@ -561,16 +561,14 @@ mod tests { use crate::util::test_utils::{TestChainSource, TestLogger}; use crate::ln::msgs; - use bitcoin::blockdata::constants::genesis_block; use bitcoin::secp256k1::{Secp256k1, SecretKey}; use core::sync::atomic::Ordering; fn get_network() -> (TestChainSource, NetworkGraph>) { let logger = Box::new(TestLogger::new()); - let genesis_hash = genesis_block(bitcoin::Network::Testnet).header.block_hash(); let chain_source = TestChainSource::new(bitcoin::Network::Testnet); - let network_graph = NetworkGraph::new(genesis_hash, logger); + let network_graph = NetworkGraph::new(bitcoin::Network::Testnet, logger); (chain_source, network_graph) }