Skip to content

Commit 1a73449

Browse files
authored
Merge pull request #1347 from jkczyz/2022-03-log-approximation
Use log approximation in ProbabilisticScorer
2 parents 0e0aabe + f041a64 commit 1a73449

File tree

9 files changed

+199
-52
lines changed

9 files changed

+199
-52
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ jobs:
122122
cargo test --verbose --color always --no-default-features --features no-std
123123
# check if there is a conflict between no-std and the default std feature
124124
cargo test --verbose --color always --features no-std
125+
# check no-std compatibility across dependencies
126+
cd ..
127+
cd no-std-check
128+
cargo check --verbose --color always
125129
cd ..
126130
- name: Test on no-std builds Rust ${{ matrix.toolchain }} and full code-linking for coverage generation
127131
if: "matrix.build-no-std && matrix.coverage"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ lightning-c-bindings/a.out
88
Cargo.lock
99
.idea
1010
lightning/target
11+
no-std-check/target

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ members = [
99
"lightning-background-processor",
1010
]
1111

12+
exclude = [
13+
"no-std-check",
14+
]
15+
1216
# Our tests do actual crypo and lots of work, the tradeoff for -O1 is well worth it.
1317
# Ideally we would only do this in profile.test, but profile.test only applies to
1418
# the test binary, not dependencies, which means most of the critical code still

lightning-invoice/src/utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use lightning::chain;
1010
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
1111
use lightning::chain::keysinterface::{Recipient, KeysInterface, Sign};
1212
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
13-
use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, PhantomRouteHints, MIN_FINAL_CLTV_EXPIRY, MIN_CLTV_EXPIRY_DELTA};
13+
use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, MIN_FINAL_CLTV_EXPIRY};
14+
#[cfg(feature = "std")]
15+
use lightning::ln::channelmanager::{PhantomRouteHints, MIN_CLTV_EXPIRY_DELTA};
1416
use lightning::ln::msgs::LightningError;
1517
use lightning::routing::scoring::Score;
1618
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};

lightning/src/routing/router.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,9 +1537,9 @@ where L::Target: Logger {
15371537

15381538
#[cfg(test)]
15391539
mod tests {
1540-
use routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters, Score};
15411540
use routing::network_graph::{NetworkGraph, NetGraphMsgHandler, NodeId};
15421541
use routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop, RouteHop, RoutingFees};
1542+
use routing::scoring::Score;
15431543
use chain::transaction::OutPoint;
15441544
use ln::features::{ChannelFeatures, InitFeatures, InvoiceFeatures, NodeFeatures};
15451545
use ln::msgs::{ErrorAction, LightningError, OptionalField, UnsignedChannelAnnouncement, ChannelAnnouncement, RoutingMessageHandler,
@@ -4970,6 +4970,8 @@ mod tests {
49704970
#[test]
49714971
#[cfg(not(feature = "no-std"))]
49724972
fn generate_routes() {
4973+
use routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters};
4974+
49734975
let mut d = match super::test_utils::get_route_file() {
49744976
Ok(f) => f,
49754977
Err(e) => {
@@ -5002,6 +5004,8 @@ mod tests {
50025004
#[test]
50035005
#[cfg(not(feature = "no-std"))]
50045006
fn generate_routes_mpp() {
5007+
use routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters};
5008+
50055009
let mut d = match super::test_utils::get_route_file() {
50065010
Ok(f) => f,
50075011
Err(e) => {

lightning/src/routing/scoring.rs

Lines changed: 165 additions & 50 deletions
Large diffs are not rendered by default.

lightning/src/util/test_utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,10 @@ impl events::MessageSendEventsProvider for TestRoutingMessageHandler {
411411

412412
pub struct TestLogger {
413413
level: Level,
414+
#[cfg(feature = "std")]
414415
id: String,
416+
#[cfg(not(feature = "std"))]
417+
_id: String,
415418
pub lines: Mutex<HashMap<(String, String), usize>>,
416419
}
417420

@@ -422,7 +425,10 @@ impl TestLogger {
422425
pub fn with_id(id: String) -> TestLogger {
423426
TestLogger {
424427
level: Level::Trace,
428+
#[cfg(feature = "std")]
425429
id,
430+
#[cfg(not(feature = "std"))]
431+
_id: id,
426432
lines: Mutex::new(HashMap::new())
427433
}
428434
}

no-std-check/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "no-std-check"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[features]
7+
default = ["lightning/no-std", "lightning-invoice/no-std"]
8+
9+
[dependencies]
10+
lightning = { path = "../lightning", default-features = false }
11+
lightning-invoice = { path = "../lightning-invoice", default-features = false }

no-std-check/src/lib.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)