Skip to content

Commit 66e191a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into replace-our-max-htlcs-constant
2 parents faa6a0a + 74328bd commit 66e191a

Some content is hidden

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

47 files changed

+2376
-1086
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ jobs:
180180
cargo check --no-default-features --features=futures --release
181181
cargo doc --release
182182
RUSTDOCFLAGS="--cfg=anchors" cargo doc --release
183+
- name: Run cargo check for Taproot build.
184+
run: |
185+
cargo check --release
186+
cargo check --no-default-features --features=no-std --release
187+
cargo check --no-default-features --features=futures --release
188+
cargo doc --release
189+
env:
190+
RUSTFLAGS: '--cfg=anchors --cfg=taproot'
191+
RUSTDOCFLAGS: '--cfg=anchors --cfg=taproot'
183192

184193
fuzz:
185194
runs-on: ubuntu-latest

ci/ci-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,6 @@ fi
9494
echo -e "\n\nTest anchors builds"
9595
pushd lightning
9696
RUSTFLAGS="$RUSTFLAGS --cfg=anchors" cargo test --verbose --color always -p lightning
97+
echo -e "\n\nTest Taproot builds"
98+
RUSTFLAGS="$RUSTFLAGS --cfg=anchors --cfg=taproot" cargo test --verbose --color always -p lightning
9799
popd

fuzz/src/chanmon_consistency.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use lightning::chain::keysinterface::{KeyMaterial, InMemorySigner, Recipient, En
4141
use lightning::events;
4242
use lightning::events::MessageSendEventsProvider;
4343
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
44-
use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentSendFailure, ChannelManagerReadArgs, PaymentId};
44+
use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentSendFailure, ChannelManagerReadArgs, PaymentId, RecipientOnionFields};
4545
use lightning::ln::channel::FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
4646
use lightning::ln::msgs::{self, CommitmentUpdate, ChannelMessageHandler, DecodeError, UpdateAddHTLC, Init};
4747
use lightning::ln::script::ShutdownScript;
@@ -351,7 +351,7 @@ fn send_payment(source: &ChanMan, dest: &ChanMan, dest_chan_id: u64, amt: u64, p
351351
let mut payment_id = [0; 32];
352352
payment_id[0..8].copy_from_slice(&payment_idx.to_ne_bytes());
353353
*payment_idx += 1;
354-
if let Err(err) = source.send_payment(&Route {
354+
if let Err(err) = source.send_payment_with_route(&Route {
355355
paths: vec![vec![RouteHop {
356356
pubkey: dest.get_our_node_id(),
357357
node_features: dest.node_features(),
@@ -361,7 +361,7 @@ fn send_payment(source: &ChanMan, dest: &ChanMan, dest_chan_id: u64, amt: u64, p
361361
cltv_expiry_delta: 200,
362362
}]],
363363
payment_params: None,
364-
}, payment_hash, &Some(payment_secret), PaymentId(payment_id)) {
364+
}, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_id)) {
365365
check_payment_err(err);
366366
false
367367
} else { true }
@@ -373,7 +373,7 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
373373
let mut payment_id = [0; 32];
374374
payment_id[0..8].copy_from_slice(&payment_idx.to_ne_bytes());
375375
*payment_idx += 1;
376-
if let Err(err) = source.send_payment(&Route {
376+
if let Err(err) = source.send_payment_with_route(&Route {
377377
paths: vec![vec![RouteHop {
378378
pubkey: middle.get_our_node_id(),
379379
node_features: middle.node_features(),
@@ -390,7 +390,7 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
390390
cltv_expiry_delta: 200,
391391
}]],
392392
payment_params: None,
393-
}, payment_hash, &Some(payment_secret), PaymentId(payment_id)) {
393+
}, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_id)) {
394394
check_payment_err(err);
395395
false
396396
} else { true }
@@ -526,7 +526,18 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
526526
msg.clone()
527527
} else { panic!("Wrong event type"); }
528528
};
529+
let events = $dest.get_and_clear_pending_events();
530+
assert_eq!(events.len(), 1);
531+
if let events::Event::ChannelPending{ ref counterparty_node_id, .. } = events[0] {
532+
assert_eq!(counterparty_node_id, &$source.get_our_node_id());
533+
} else { panic!("Wrong event type"); }
534+
529535
$source.handle_funding_signed(&$dest.get_our_node_id(), &funding_signed);
536+
let events = $source.get_and_clear_pending_events();
537+
assert_eq!(events.len(), 1);
538+
if let events::Event::ChannelPending{ ref counterparty_node_id, .. } = events[0] {
539+
assert_eq!(counterparty_node_id, &$dest.get_our_node_id());
540+
} else { panic!("Wrong event type"); }
530541

531542
funding_output
532543
} }

fuzz/src/full_stack.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ use lightning::chain::transaction::OutPoint;
3737
use lightning::chain::keysinterface::{InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider};
3838
use lightning::events::Event;
3939
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
40-
use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentId};
40+
use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentId, RecipientOnionFields, Retry};
4141
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
4242
use lightning::ln::msgs::{self, DecodeError};
4343
use lightning::ln::script::ShutdownScript;
4444
use lightning::routing::gossip::{P2PGossipSync, NetworkGraph};
4545
use lightning::routing::utxo::UtxoLookup;
46-
use lightning::routing::router::{find_route, InFlightHtlcs, PaymentParameters, Route, RouteParameters, Router};
47-
use lightning::routing::scoring::FixedPenaltyScorer;
46+
use lightning::routing::router::{InFlightHtlcs, PaymentParameters, Route, RouteParameters, Router};
4847
use lightning::util::config::UserConfig;
4948
use lightning::util::errors::APIError;
5049
use lightning::util::enforcing_trait_impls::{EnforcingSigner, EnforcementState};
@@ -449,10 +448,8 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
449448
// keys subsequently generated in this test. Rather than regenerating all the messages manually,
450449
// it's easier to just increment the counter here so the keys don't change.
451450
keys_manager.counter.fetch_sub(3, Ordering::AcqRel);
452-
let our_id = &keys_manager.get_node_id(Recipient::Node).unwrap();
453451
let network_graph = Arc::new(NetworkGraph::new(network, Arc::clone(&logger)));
454452
let gossip_sync = Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
455-
let scorer = FixedPenaltyScorer::with_penalty(0);
456453

457454
let peers = RefCell::new([false; 256]);
458455
let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {
@@ -514,18 +511,16 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
514511
payment_params,
515512
final_value_msat,
516513
};
517-
let random_seed_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();
518-
let route = match find_route(&our_id, &params, &network_graph, None, Arc::clone(&logger), &scorer, &random_seed_bytes) {
519-
Ok(route) => route,
520-
Err(_) => return,
521-
};
522514
let mut payment_hash = PaymentHash([0; 32]);
523515
payment_hash.0[0..8].copy_from_slice(&be64_to_array(payments_sent));
524516
let mut sha = Sha256::engine();
525517
sha.input(&payment_hash.0[..]);
526518
payment_hash.0 = Sha256::from_engine(sha).into_inner();
527519
payments_sent += 1;
528-
match channelmanager.send_payment(&route, payment_hash, &None, PaymentId(payment_hash.0)) {
520+
match channelmanager.send_payment(payment_hash,
521+
RecipientOnionFields::spontaneous_empty(), PaymentId(payment_hash.0), params,
522+
Retry::Attempts(0))
523+
{
529524
Ok(_) => {},
530525
Err(_) => return,
531526
}
@@ -537,12 +532,6 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
537532
payment_params,
538533
final_value_msat,
539534
};
540-
let random_seed_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();
541-
let mut route = match find_route(&our_id, &params, &network_graph, None, Arc::clone(&logger), &scorer, &random_seed_bytes) {
542-
Ok(route) => route,
543-
Err(_) => return,
544-
};
545-
route.paths.push(route.paths[0].clone());
546535
let mut payment_hash = PaymentHash([0; 32]);
547536
payment_hash.0[0..8].copy_from_slice(&be64_to_array(payments_sent));
548537
let mut sha = Sha256::engine();
@@ -552,7 +541,10 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
552541
let mut payment_secret = PaymentSecret([0; 32]);
553542
payment_secret.0[0..8].copy_from_slice(&be64_to_array(payments_sent));
554543
payments_sent += 1;
555-
match channelmanager.send_payment(&route, payment_hash, &Some(payment_secret), PaymentId(payment_hash.0)) {
544+
match channelmanager.send_payment(payment_hash,
545+
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0),
546+
params, Retry::Attempts(0))
547+
{
556548
Ok(_) => {},
557549
Err(_) => return,
558550
}

lightning-background-processor/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ all-features = true
1414
rustdoc-args = ["--cfg", "docsrs"]
1515

1616
[features]
17-
futures = [ "futures-util" ]
17+
futures = [ ]
1818
std = ["lightning/std", "lightning-rapid-gossip-sync/std"]
1919

2020
default = ["std"]
@@ -23,9 +23,9 @@ default = ["std"]
2323
bitcoin = { version = "0.29.0", default-features = false }
2424
lightning = { version = "0.0.114", path = "../lightning", default-features = false }
2525
lightning-rapid-gossip-sync = { version = "0.0.114", path = "../lightning-rapid-gossip-sync", default-features = false }
26-
futures-util = { version = "0.3", default-features = false, features = ["async-await-macro"], optional = true }
2726

2827
[dev-dependencies]
28+
tokio = { version = "1.14", features = [ "macros", "rt", "rt-multi-thread", "sync", "time" ] }
2929
lightning = { version = "0.0.114", path = "../lightning", features = ["_test_utils"] }
3030
lightning-invoice = { version = "0.22.0", path = "../lightning-invoice" }
3131
lightning-persister = { version = "0.0.114", path = "../lightning-persister" }

0 commit comments

Comments
 (0)