Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase scoring params #3483

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ where L::Target: Logger {
pub struct ProbabilisticScoringFeeParameters {
/// A fixed penalty in msats to apply to each channel.
///
/// Default value: 500 msat
/// Default value: 1000 msat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheBlueMatt

Should we use this opportunity to define constants for each parameter?
This could simplify documentation maintenance and allow us to define constants cleanly using multiplier syntax.

Something like:

const BASE_PENALTY_MSAT: u64 = 100 * 1000;
const BASE_PENALTY_AMOUNT_MULTIPLIER_MSAT: u64 = 8192 * 100;
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ben showed the operands to show how much mutiny deviated from the defaults - I think we should set a single number for the default settings.

pub base_penalty_msat: u64,

/// A multiplier used with the payment amount to calculate a fixed penalty applied to each
Expand All @@ -500,7 +500,7 @@ pub struct ProbabilisticScoringFeeParameters {
///
/// ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30`
///
/// Default value: 8,192 msat
/// Default value: 1,000,000 msat
///
/// [`base_penalty_msat`]: Self::base_penalty_msat
pub base_penalty_amount_multiplier_msat: u64,
Expand All @@ -518,7 +518,7 @@ pub struct ProbabilisticScoringFeeParameters {
///
/// `-log10(success_probability) * liquidity_penalty_multiplier_msat`
///
/// Default value: 30,000 msat
/// Default value: 450,000 msat
///
/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life
pub liquidity_penalty_multiplier_msat: u64,
Expand All @@ -540,7 +540,7 @@ pub struct ProbabilisticScoringFeeParameters {
/// probabilities, the multiplier will have a decreasing effect as the negative `log10` will
/// fall below `1`.
///
/// Default value: 192 msat
/// Default value: 2880 msat
pub liquidity_penalty_amount_multiplier_msat: u64,

/// A multiplier used in conjunction with the negative `log10` of the channel's success
Expand All @@ -554,7 +554,7 @@ pub struct ProbabilisticScoringFeeParameters {
/// track which of several buckets those bounds fall into, exponentially decaying the
/// probability of each bucket as new samples are added.
///
/// Default value: 10,000 msat
/// Default value: 150,000 msat
///
/// [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat
pub historical_liquidity_penalty_multiplier_msat: u64,
Expand All @@ -575,7 +575,7 @@ pub struct ProbabilisticScoringFeeParameters {
/// channel, we track which of several buckets those bounds fall into, exponentially decaying
/// the probability of each bucket as new samples are added.
///
/// Default value: 64 msat
/// Default value: 960 msat
///
/// [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat
pub historical_liquidity_penalty_amount_multiplier_msat: u64,
Expand Down Expand Up @@ -642,15 +642,15 @@ pub struct ProbabilisticScoringFeeParameters {
impl Default for ProbabilisticScoringFeeParameters {
fn default() -> Self {
Self {
base_penalty_msat: 500,
base_penalty_amount_multiplier_msat: 8192,
liquidity_penalty_multiplier_msat: 30_000,
liquidity_penalty_amount_multiplier_msat: 192,
base_penalty_msat: 1000,
base_penalty_amount_multiplier_msat: 1_000_000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit hefty base_penalty_amount_multiplier_msat, isn't it? :)
https://github.com/MutinyWallet/mutiny-node/blob/68d545d1f82ba0d0e64980d056dc16ee7f00d457/mutiny-core/src/node.rs#L1944

Suggested change
base_penalty_amount_multiplier_msat: 1_000_000,
base_penalty_amount_multiplier_msat: 8192 * 100,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8192 * 100 ~= 1_000_000 if you squint hard enough :)

See the commit message for the reasoning - would I pay an extra 0.1% of current total flow over a channel for better routing ? yes.

liquidity_penalty_multiplier_msat: 450_000,
liquidity_penalty_amount_multiplier_msat: 2880,
manual_node_penalties: new_hash_map(),
anti_probing_penalty_msat: 250,
considered_impossible_penalty_msat: 1_0000_0000_000,
historical_liquidity_penalty_multiplier_msat: 10_000,
historical_liquidity_penalty_amount_multiplier_msat: 64,
historical_liquidity_penalty_multiplier_msat: 150_000,
historical_liquidity_penalty_amount_multiplier_msat: 960,
linear_success_probability: false,
}
}
Expand Down Expand Up @@ -3012,47 +3012,47 @@ mod tests {
info,
short_channel_id: 42,
});
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 11497);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 247695);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 1_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 7408);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 186364);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 2_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 6151);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 167493);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 3_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 5427);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 156641);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 4_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4955);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 149565);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 5_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4736);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 146262);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 6_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4484);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 142487);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 7_450_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4484);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 142487);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 7_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4263);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 139185);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 8_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4263);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 139185);
let usage = ChannelUsage {
effective_capacity: EffectiveCapacity::Total { capacity_msat: 9_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4044);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 135883);
}

#[test]
Expand Down
Loading