Skip to content

Commit 57d1c0a

Browse files
authored
Merge branch 'lightningdevkit:main' into lightningdevkit#2364
2 parents 10ea10e + a37a16a commit 57d1c0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4649
-2559
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
include:
2323
- toolchain: stable
2424
platform: ubuntu-latest
25-
coverage: true
2625
# 1.48.0 is the MSRV for all crates except lightning-transaction-sync and Win/Mac
2726
- toolchain: 1.48.0
2827
platform: ubuntu-latest
@@ -50,46 +49,31 @@ jobs:
5049
run: |
5150
sudo apt-get -y install shellcheck
5251
shellcheck ci/ci-tests.sh
53-
- name: Run CI script with coverage generation
54-
if: matrix.coverage
55-
shell: bash # Default on Winblows is powershell
56-
run: LDK_COVERAGE_BUILD=true ./ci/ci-tests.sh
5752
- name: Run CI script
58-
if: "!matrix.coverage"
5953
shell: bash # Default on Winblows is powershell
6054
run: ./ci/ci-tests.sh
61-
- name: Install deps for kcov
62-
if: matrix.coverage
63-
run: |
64-
sudo apt-get update
65-
sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
66-
- name: Install kcov
67-
if: matrix.coverage
68-
run: |
69-
wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
70-
tar xzf master.tar.gz
71-
cd kcov-master && mkdir build && cd build
72-
cmake ..
73-
make
74-
make install DESTDIR=../../kcov-build
75-
cd ../.. && rm -rf kcov-master master.tar.gz
76-
- name: Generate coverage report
77-
if: matrix.coverage
78-
run: |
79-
for file in target/debug/deps/lightning*; do
80-
[ -x "${file}" ] || continue;
81-
mkdir -p "target/cov/$(basename $file)";
82-
./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file";
83-
done
84-
- name: Upload coverage
85-
if: matrix.coverage
86-
uses: codecov/codecov-action@v3
55+
56+
coverage:
57+
strategy:
58+
fail-fast: false
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout source code
62+
uses: actions/checkout@v3
8763
with:
64+
fetch-depth: 0
65+
- name: Install Rust stable toolchain
66+
run: |
67+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
68+
- name: Run tests with coverage generation
69+
run: |
70+
cargo install cargo-llvm-cov
71+
export RUSTFLAGS="-Clink-dead-code -Coverflow-checks=off"
72+
cargo llvm-cov --features rest-client,rpc-client,tokio,futures,serde --codecov --hide-instantiations --output-path=target/codecov.json
8873
# Could you use this to fake the coverage report for your PR? Sure.
8974
# Will anyone be impressed by your amazing coverage? No
9075
# Maybe if codecov wasn't broken we wouldn't need to do this...
91-
token: f421b687-4dc2-4387-ac3d-dc3b2528af57
92-
fail_ci_if_error: true
76+
bash <(curl -s https://codecov.io/bash) -f target/codecov.json -t "f421b687-4dc2-4387-ac3d-dc3b2528af57"
9377
9478
benchmark:
9579
runs-on: ubuntu-latest

bench/benches/bench.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ criterion_group!(benches,
1313
lightning::routing::router::benches::generate_routes_with_probabilistic_scorer,
1414
lightning::routing::router::benches::generate_mpp_routes_with_probabilistic_scorer,
1515
lightning::routing::router::benches::generate_large_mpp_routes_with_probabilistic_scorer,
16+
lightning::routing::router::benches::generate_routes_with_nonlinear_probabilistic_scorer,
17+
lightning::routing::router::benches::generate_mpp_routes_with_nonlinear_probabilistic_scorer,
18+
lightning::routing::router::benches::generate_large_mpp_routes_with_nonlinear_probabilistic_scorer,
1619
lightning::sign::benches::bench_get_secure_random_bytes,
1720
lightning::ln::channelmanager::bench::bench_sends,
1821
lightning_persister::fs_store::bench::bench_sends,

ci/ci-tests.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,45 @@ PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
2929
# The quote crate switched to Rust edition 2021 starting with v1.0.31, i.e., has MSRV of 1.56
3030
[ "$RUSTC_MINOR_VERSION" -lt 56 ] && cargo update -p quote --precise "1.0.30" --verbose
3131

32+
# The syn crate depends on too-new proc-macro2 starting with v2.0.33, i.e., has MSRV of 1.56
33+
if [ "$RUSTC_MINOR_VERSION" -lt 56 ]; then
34+
SYN_2_DEP=$(grep -o '"syn 2.*' Cargo.lock | tr -d '",' | tr ' ' ':')
35+
cargo update -p "$SYN_2_DEP" --precise "2.0.32" --verbose
36+
fi
37+
3238
# The proc-macro2 crate switched to Rust edition 2021 starting with v1.0.66, i.e., has MSRV of 1.56
3339
[ "$RUSTC_MINOR_VERSION" -lt 56 ] && cargo update -p proc-macro2 --precise "1.0.65" --verbose
3440

3541
# The memchr crate switched to an MSRV of 1.60 starting with v2.6.0
3642
[ "$RUSTC_MINOR_VERSION" -lt 60 ] && cargo update -p memchr --precise "2.5.0" --verbose
3743

38-
[ "$LDK_COVERAGE_BUILD" != "" ] && export RUSTFLAGS="-C link-dead-code"
39-
4044
export RUST_BACKTRACE=1
4145

4246
echo -e "\n\nBuilding and testing all workspace crates..."
4347
cargo test --verbose --color always
44-
cargo build --verbose --color always
48+
cargo check --verbose --color always
4549

4650
echo -e "\n\nBuilding and testing Block Sync Clients with features"
4751
pushd lightning-block-sync
4852
cargo test --verbose --color always --features rest-client
49-
cargo build --verbose --color always --features rest-client
53+
cargo check --verbose --color always --features rest-client
5054
cargo test --verbose --color always --features rpc-client
51-
cargo build --verbose --color always --features rpc-client
55+
cargo check --verbose --color always --features rpc-client
5256
cargo test --verbose --color always --features rpc-client,rest-client
53-
cargo build --verbose --color always --features rpc-client,rest-client
57+
cargo check --verbose --color always --features rpc-client,rest-client
5458
cargo test --verbose --color always --features rpc-client,rest-client,tokio
55-
cargo build --verbose --color always --features rpc-client,rest-client,tokio
59+
cargo check --verbose --color always --features rpc-client,rest-client,tokio
5660
popd
5761

5862
if [[ $RUSTC_MINOR_VERSION -gt 67 && "$HOST_PLATFORM" != *windows* ]]; then
5963
echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
6064
pushd lightning-transaction-sync
6165
cargo test --verbose --color always --features esplora-blocking
62-
cargo build --verbose --color always --features esplora-blocking
66+
cargo check --verbose --color always --features esplora-blocking
6367
cargo test --verbose --color always --features esplora-async
64-
cargo build --verbose --color always --features esplora-async
68+
cargo check --verbose --color always --features esplora-async
6569
cargo test --verbose --color always --features esplora-async-https
66-
cargo build --verbose --color always --features esplora-async-https
70+
cargo check --verbose --color always --features esplora-async-https
6771
popd
6872
fi
6973

@@ -89,7 +93,7 @@ fi
8993
echo -e "\n\nBuilding with all Log-Limiting features"
9094
pushd lightning
9195
grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
92-
cargo build --verbose --color always --features "$FEATURE"
96+
cargo check --verbose --color always --features "$FEATURE"
9397
done
9498
popd
9599

@@ -120,6 +124,10 @@ if [[ $RUSTC_MINOR_VERSION -gt 67 ]]; then
120124
# lightning-transaction-sync's MSRV is 1.67
121125
cargo check --verbose --color always --features lightning-transaction-sync
122126
else
127+
# The memchr crate switched to an MSRV of 1.60 starting with v2.6.0
128+
# This is currently only a release dependency via core2, which we intend to work with
129+
# rust-bitcoin to remove soon.
130+
[ "$RUSTC_MINOR_VERSION" -lt 60 ] && cargo update -p memchr --precise "2.5.0" --verbose
123131
cargo check --verbose --color always
124132
fi
125133
popd

fuzz/src/chanmon_consistency.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ struct TestChainMonitor {
125125
// "fails" if we ever force-close a channel, we avoid doing so, always saving the latest
126126
// fully-serialized monitor state here, as well as the corresponding update_id.
127127
pub latest_monitors: Mutex<HashMap<OutPoint, (u64, Vec<u8>)>>,
128-
pub should_update_manager: atomic::AtomicBool,
129128
}
130129
impl TestChainMonitor {
131130
pub fn new(broadcaster: Arc<TestBroadcaster>, logger: Arc<dyn Logger>, feeest: Arc<FuzzEstimator>, persister: Arc<TestPersister>, keys: Arc<KeyProvider>) -> Self {
@@ -135,18 +134,16 @@ impl TestChainMonitor {
135134
keys,
136135
persister,
137136
latest_monitors: Mutex::new(HashMap::new()),
138-
should_update_manager: atomic::AtomicBool::new(false),
139137
}
140138
}
141139
}
142140
impl chain::Watch<TestChannelSigner> for TestChainMonitor {
143-
fn watch_channel(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor<TestChannelSigner>) -> chain::ChannelMonitorUpdateStatus {
141+
fn watch_channel(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor<TestChannelSigner>) -> Result<chain::ChannelMonitorUpdateStatus, ()> {
144142
let mut ser = VecWriter(Vec::new());
145143
monitor.write(&mut ser).unwrap();
146144
if let Some(_) = self.latest_monitors.lock().unwrap().insert(funding_txo, (monitor.get_latest_update_id(), ser.0)) {
147145
panic!("Already had monitor pre-watch_channel");
148146
}
149-
self.should_update_manager.store(true, atomic::Ordering::Relaxed);
150147
self.chain_monitor.watch_channel(funding_txo, monitor)
151148
}
152149

@@ -162,7 +159,6 @@ impl chain::Watch<TestChannelSigner> for TestChainMonitor {
162159
let mut ser = VecWriter(Vec::new());
163160
deserialized_monitor.write(&mut ser).unwrap();
164161
map_entry.insert((update.update_id, ser.0));
165-
self.should_update_manager.store(true, atomic::Ordering::Relaxed);
166162
self.chain_monitor.update_channel(funding_txo, update)
167163
}
168164

@@ -375,6 +371,7 @@ fn send_payment(source: &ChanMan, dest: &ChanMan, dest_chan_id: u64, amt: u64, p
375371
channel_features: dest.channel_features(),
376372
fee_msat: amt,
377373
cltv_expiry_delta: 200,
374+
maybe_announced_channel: true,
378375
}], blinded_tail: None }],
379376
route_params: None,
380377
}, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_id)) {
@@ -409,13 +406,15 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
409406
channel_features: middle.channel_features(),
410407
fee_msat: first_hop_fee,
411408
cltv_expiry_delta: 100,
409+
maybe_announced_channel: true,
412410
}, RouteHop {
413411
pubkey: dest.get_our_node_id(),
414412
node_features: dest.node_features(),
415413
short_channel_id: dest_chan_id,
416414
channel_features: dest.channel_features(),
417415
fee_msat: amt,
418416
cltv_expiry_delta: 200,
417+
maybe_announced_channel: true,
419418
}], blinded_tail: None }],
420419
route_params: None,
421420
}, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_id)) {
@@ -501,7 +500,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
501500
let res = (<(BlockHash, ChanMan)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, chain_monitor.clone());
502501
for (funding_txo, mon) in monitors.drain() {
503502
assert_eq!(chain_monitor.chain_monitor.watch_channel(funding_txo, mon),
504-
ChannelMonitorUpdateStatus::Completed);
503+
Ok(ChannelMonitorUpdateStatus::Completed));
505504
}
506505
res
507506
} }
@@ -1101,11 +1100,9 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
11011100
if !chan_a_disconnected {
11021101
nodes[1].peer_disconnected(&nodes[0].get_our_node_id());
11031102
chan_a_disconnected = true;
1104-
drain_msg_events_on_disconnect!(0);
1105-
}
1106-
if monitor_a.should_update_manager.load(atomic::Ordering::Relaxed) {
1107-
node_a_ser.0.clear();
1108-
nodes[0].write(&mut node_a_ser).unwrap();
1103+
push_excess_b_events!(nodes[1].get_and_clear_pending_msg_events().drain(..), Some(0));
1104+
ab_events.clear();
1105+
ba_events.clear();
11091106
}
11101107
let (new_node_a, new_monitor_a) = reload_node!(node_a_ser, 0, monitor_a, keys_manager_a, fee_est_a);
11111108
nodes[0] = new_node_a;
@@ -1134,11 +1131,9 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
11341131
if !chan_b_disconnected {
11351132
nodes[1].peer_disconnected(&nodes[2].get_our_node_id());
11361133
chan_b_disconnected = true;
1137-
drain_msg_events_on_disconnect!(2);
1138-
}
1139-
if monitor_c.should_update_manager.load(atomic::Ordering::Relaxed) {
1140-
node_c_ser.0.clear();
1141-
nodes[2].write(&mut node_c_ser).unwrap();
1134+
push_excess_b_events!(nodes[1].get_and_clear_pending_msg_events().drain(..), Some(2));
1135+
bc_events.clear();
1136+
cb_events.clear();
11421137
}
11431138
let (new_node_c, new_monitor_c) = reload_node!(node_c_ser, 2, monitor_c, keys_manager_c, fee_est_c);
11441139
nodes[2] = new_node_c;
@@ -1304,15 +1299,18 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
13041299
_ => test_return!(),
13051300
}
13061301

1307-
node_a_ser.0.clear();
1308-
nodes[0].write(&mut node_a_ser).unwrap();
1309-
monitor_a.should_update_manager.store(false, atomic::Ordering::Relaxed);
1310-
node_b_ser.0.clear();
1311-
nodes[1].write(&mut node_b_ser).unwrap();
1312-
monitor_b.should_update_manager.store(false, atomic::Ordering::Relaxed);
1313-
node_c_ser.0.clear();
1314-
nodes[2].write(&mut node_c_ser).unwrap();
1315-
monitor_c.should_update_manager.store(false, atomic::Ordering::Relaxed);
1302+
if nodes[0].get_and_clear_needs_persistence() == true {
1303+
node_a_ser.0.clear();
1304+
nodes[0].write(&mut node_a_ser).unwrap();
1305+
}
1306+
if nodes[1].get_and_clear_needs_persistence() == true {
1307+
node_b_ser.0.clear();
1308+
nodes[1].write(&mut node_b_ser).unwrap();
1309+
}
1310+
if nodes[2].get_and_clear_needs_persistence() == true {
1311+
node_c_ser.0.clear();
1312+
nodes[2].write(&mut node_c_ser).unwrap();
1313+
}
13161314
}
13171315
}
13181316

fuzz/src/onion_hop_data.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@
1111
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
1212

1313
use crate::utils::test_logger;
14+
use lightning::util::test_utils;
1415

1516
#[inline]
1617
pub fn onion_hop_data_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
17-
use lightning::util::ser::Readable;
18+
use lightning::util::ser::ReadableArgs;
1819
let mut r = ::std::io::Cursor::new(data);
19-
let _ = <lightning::ln::msgs::InboundOnionPayload as Readable>::read(&mut r);
20+
let node_signer = test_utils::TestNodeSigner::new(test_utils::privkey(42));
21+
let _ = <lightning::ln::msgs::InboundOnionPayload as ReadableArgs<&&test_utils::TestNodeSigner>>::read(&mut r, &&node_signer);
2022
}
2123

2224
#[no_mangle]
2325
pub extern "C" fn onion_hop_data_run(data: *const u8, datalen: usize) {
24-
use lightning::util::ser::Readable;
26+
use lightning::util::ser::ReadableArgs;
2527
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
2628
let mut r = ::std::io::Cursor::new(data);
27-
let _ = <lightning::ln::msgs::InboundOnionPayload as Readable>::read(&mut r);
29+
let node_signer = test_utils::TestNodeSigner::new(test_utils::privkey(42));
30+
let _ = <lightning::ln::msgs::InboundOnionPayload as ReadableArgs<&&test_utils::TestNodeSigner>>::read(&mut r, &&node_signer);
2831
}

lightning-background-processor/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lightning-background-processor"
3-
version = "0.0.116"
3+
version = "0.0.117-alpha1"
44
authors = ["Valentine Wallace <[email protected]>"]
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/lightningdevkit/rust-lightning"
@@ -22,11 +22,11 @@ default = ["std"]
2222

2323
[dependencies]
2424
bitcoin = { version = "0.29.0", default-features = false }
25-
lightning = { version = "0.0.116", path = "../lightning", default-features = false }
26-
lightning-rapid-gossip-sync = { version = "0.0.116", path = "../lightning-rapid-gossip-sync", default-features = false }
25+
lightning = { version = "0.0.117-alpha1", path = "../lightning", default-features = false }
26+
lightning-rapid-gossip-sync = { version = "0.0.117-alpha1", path = "../lightning-rapid-gossip-sync", default-features = false }
2727

2828
[dev-dependencies]
2929
tokio = { version = "1.14", features = [ "macros", "rt", "rt-multi-thread", "sync", "time" ] }
30-
lightning = { version = "0.0.116", path = "../lightning", features = ["_test_utils"] }
31-
lightning-invoice = { version = "0.24.0", path = "../lightning-invoice" }
32-
lightning-persister = { version = "0.0.116", path = "../lightning-persister" }
30+
lightning = { version = "0.0.117-alpha1", path = "../lightning", features = ["_test_utils"] }
31+
lightning-invoice = { version = "0.25.0-alpha1", path = "../lightning-invoice" }
32+
lightning-persister = { version = "0.0.117-alpha1", path = "../lightning-persister" }

0 commit comments

Comments
 (0)