mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-01 10:41:34 +02:00
routing: forget info for contradictions
If we encounter invalid mission control data, we fall back to no knowledge about the node pair.
This commit is contained in:
parent
5ba9619d22
commit
5afb0de8a8
@ -488,6 +488,18 @@ func (p *BimodalEstimator) probabilityFormula(capacityMsat, successAmountMsat,
|
|||||||
return 0.0, nil
|
return 0.0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The next statement is a safety check against an illogical condition.
|
||||||
|
// We discard the knowledge for the channel in that case since we have
|
||||||
|
// inconsistent data.
|
||||||
|
if failAmount <= successAmount {
|
||||||
|
log.Warnf("Fail amount (%s) is smaller than or equal to the "+
|
||||||
|
"success amount (%s) for capacity (%s)",
|
||||||
|
failAmountMsat, successAmountMsat, capacityMsat)
|
||||||
|
|
||||||
|
successAmount = 0
|
||||||
|
failAmount = capacity
|
||||||
|
}
|
||||||
|
|
||||||
// Mission control may have some outdated values, we correct them here.
|
// Mission control may have some outdated values, we correct them here.
|
||||||
// TODO(bitromortac): there may be better decisions to make in these
|
// TODO(bitromortac): there may be better decisions to make in these
|
||||||
// cases, e.g., resetting failAmount=cap and successAmount=0.
|
// cases, e.g., resetting failAmount=cap and successAmount=0.
|
||||||
@ -508,18 +520,6 @@ func (p *BimodalEstimator) probabilityFormula(capacityMsat, successAmountMsat,
|
|||||||
successAmount = capacity
|
successAmount = capacity
|
||||||
}
|
}
|
||||||
|
|
||||||
// The next statement is a safety check against an illogical condition,
|
|
||||||
// otherwise the renormalization integral would become zero. This may
|
|
||||||
// happen if a large channel gets closed and smaller ones remain, but
|
|
||||||
// it should recover with the time decay.
|
|
||||||
if failAmount <= successAmount {
|
|
||||||
log.Tracef("fail amount (%v) is smaller than or equal the "+
|
|
||||||
"success amount (%v) for capacity (%v)",
|
|
||||||
failAmountMsat, successAmountMsat, capacityMsat)
|
|
||||||
|
|
||||||
return 0.0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot send more than the fail amount.
|
// We cannot send more than the fail amount.
|
||||||
if amount >= failAmount {
|
if amount >= failAmount {
|
||||||
return 0.0, nil
|
return 0.0, nil
|
||||||
|
@ -192,22 +192,25 @@ func TestSuccessProbability(t *testing.T) {
|
|||||||
amount: largeAmount,
|
amount: largeAmount,
|
||||||
expectedProbability: 0.0,
|
expectedProbability: 0.0,
|
||||||
},
|
},
|
||||||
// Same success and failure amounts (illogical).
|
// Same success and failure amounts (illogical), which gets
|
||||||
|
// reset to no knowledge.
|
||||||
{
|
{
|
||||||
name: "previous f/s, same",
|
name: "previous f/s, same",
|
||||||
capacity: capacity,
|
capacity: capacity,
|
||||||
failAmount: largeAmount,
|
failAmount: largeAmount,
|
||||||
successAmount: largeAmount,
|
successAmount: largeAmount,
|
||||||
amount: largeAmount,
|
amount: largeAmount,
|
||||||
expectedProbability: 0.0,
|
expectedProbability: 0.5,
|
||||||
},
|
},
|
||||||
// Higher success than failure amount (illogical).
|
// Higher success than failure amount (illogical), which gets
|
||||||
|
// reset to no knowledge.
|
||||||
{
|
{
|
||||||
name: "previous f/s, higher success",
|
name: "previous f/s, illogical",
|
||||||
capacity: capacity,
|
capacity: capacity,
|
||||||
failAmount: smallAmount,
|
failAmount: smallAmount,
|
||||||
successAmount: largeAmount,
|
successAmount: largeAmount,
|
||||||
expectedProbability: 0.0,
|
amount: largeAmount,
|
||||||
|
expectedProbability: 0.5,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user