Skip to content

Commit 044f3fa

Browse files
authored
Merge pull request #4266 from TheBlueMatt/2025-10-reorg-blocksource-swap
Use `BestBlock` for chain state serialization (and somewhat parallelize init)
2 parents 47122e8 + 74e1da3 commit 044f3fa

28 files changed

+588
-366
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use bitcoin::transaction::{Transaction, TxOut};
2929
use bitcoin::FeeRate;
3030

3131
use bitcoin::block::Header;
32-
use bitcoin::hash_types::{BlockHash, Txid};
32+
use bitcoin::hash_types::Txid;
3333
use bitcoin::hashes::sha256::Hash as Sha256;
3434
use bitcoin::hashes::sha256d::Hash as Sha256dHash;
3535
use bitcoin::hashes::Hash as TraitImport;
@@ -75,11 +75,11 @@ use lightning::sign::{
7575
SignerProvider,
7676
};
7777
use lightning::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
78-
use lightning::util::async_poll::{MaybeSend, MaybeSync};
7978
use lightning::util::config::UserConfig;
8079
use lightning::util::errors::APIError;
8180
use lightning::util::hash_tables::*;
8281
use lightning::util::logger::Logger;
82+
use lightning::util::native_async::{MaybeSend, MaybeSync};
8383
use lightning::util::ser::{LengthReadable, ReadableArgs, Writeable, Writer};
8484
use lightning::util::test_channel_signer::{EnforcementState, SignerOp, TestChannelSigner};
8585
use lightning::util::test_utils::TestWalletSource;
@@ -332,7 +332,7 @@ impl chain::Watch<TestChannelSigner> for TestChainMonitor {
332332
.map(|(_, data)| data)
333333
.unwrap_or(&map_entry.persisted_monitor);
334334
let deserialized_monitor =
335-
<(BlockHash, channelmonitor::ChannelMonitor<TestChannelSigner>)>::read(
335+
<(BestBlock, channelmonitor::ChannelMonitor<TestChannelSigner>)>::read(
336336
&mut &latest_monitor_data[..],
337337
(&*self.keys, &*self.keys),
338338
)
@@ -1034,7 +1034,7 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(data: &[u8], underlying_out:
10341034
// Use a different value of `use_old_mons` if we have another monitor (only for node B)
10351035
// by shifting `use_old_mons` one in base-3.
10361036
use_old_mons /= 3;
1037-
let mon = <(BlockHash, ChannelMonitor<TestChannelSigner>)>::read(
1037+
let mon = <(BestBlock, ChannelMonitor<TestChannelSigner>)>::read(
10381038
&mut &serialized_mon[..],
10391039
(&**keys, &**keys),
10401040
)
@@ -1069,7 +1069,7 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(data: &[u8], underlying_out:
10691069
};
10701070

10711071
let manager =
1072-
<(BlockHash, ChanMan)>::read(&mut &ser[..], read_args).expect("Failed to read manager");
1072+
<(BestBlock, ChanMan)>::read(&mut &ser[..], read_args).expect("Failed to read manager");
10731073
let res = (manager.1, chain_monitor.clone());
10741074
for (channel_id, mon) in monitors.drain() {
10751075
assert_eq!(

fuzz/src/chanmon_deser.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
22
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
33

4-
use bitcoin::hash_types::BlockHash;
5-
6-
use lightning::chain::channelmonitor;
4+
use lightning::chain::{channelmonitor, BestBlock};
75
use lightning::util::ser::{ReadableArgs, Writeable, Writer};
86
use lightning::util::test_channel_signer::TestChannelSigner;
97
use lightning::util::test_utils::OnlyReadsKeysInterface;
@@ -23,14 +21,14 @@ impl Writer for VecWriter {
2321
#[inline]
2422
pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
2523
if let Ok((latest_block_hash, monitor)) =
26-
<(BlockHash, channelmonitor::ChannelMonitor<TestChannelSigner>)>::read(
24+
<(BestBlock, channelmonitor::ChannelMonitor<TestChannelSigner>)>::read(
2725
&mut Cursor::new(data),
2826
(&OnlyReadsKeysInterface {}, &OnlyReadsKeysInterface {}),
2927
) {
3028
let mut w = VecWriter(Vec::new());
3129
monitor.write(&mut w).unwrap();
3230
let deserialized_copy =
33-
<(BlockHash, channelmonitor::ChannelMonitor<TestChannelSigner>)>::read(
31+
<(BestBlock, channelmonitor::ChannelMonitor<TestChannelSigner>)>::read(
3432
&mut Cursor::new(&w.0),
3533
(&OnlyReadsKeysInterface {}, &OnlyReadsKeysInterface {}),
3634
)

fuzz/src/full_stack.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ use lightning::sign::{
6363
SignerProvider,
6464
};
6565
use lightning::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
66-
use lightning::util::async_poll::{MaybeSend, MaybeSync};
6766
use lightning::util::config::{ChannelConfig, UserConfig};
6867
use lightning::util::hash_tables::*;
6968
use lightning::util::logger::Logger;
69+
use lightning::util::native_async::{MaybeSend, MaybeSync};
7070
use lightning::util::ser::{Readable, Writeable};
7171
use lightning::util::test_channel_signer::{EnforcementState, TestChannelSigner};
7272
use lightning::util::test_utils::TestWalletSource;
@@ -1958,8 +1958,8 @@ pub fn write_fst_seeds(path: &str) {
19581958

19591959
#[cfg(test)]
19601960
mod tests {
1961-
use lightning::util::async_poll::{MaybeSend, MaybeSync};
19621961
use lightning::util::logger::{Logger, Record};
1962+
use lightning::util::native_async::{MaybeSend, MaybeSync};
19631963
use std::collections::HashMap;
19641964
use std::sync::{Arc, Mutex};
19651965

lightning-background-processor/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ use lightning::routing::utxo::UtxoLookup;
5555
#[cfg(not(c_bindings))]
5656
use lightning::sign::EntropySource;
5757
use lightning::sign::{ChangeDestinationSource, ChangeDestinationSourceSync, OutputSpender};
58-
#[cfg(not(c_bindings))]
59-
use lightning::util::async_poll::MaybeSend;
6058
use lightning::util::logger::Logger;
59+
#[cfg(not(c_bindings))]
60+
use lightning::util::native_async::MaybeSend;
6161
use lightning::util::persist::{
6262
KVStore, KVStoreSync, KVStoreSyncWrapper, CHANNEL_MANAGER_PERSISTENCE_KEY,
6363
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE, CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../lightning/src/util/async_poll.rs

0 commit comments

Comments
 (0)