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

Ignore disabled edges for routing messages #2750

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions eclair-core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ eclair {
base = 0.6 // when computing the weight for a channel, proportion that stays the same for all channels
channel-age = 0.1 // when computing the weight for a channel, consider its AGE in this proportion
channel-capacity = 0.3 // when computing the weight for a channel, consider its CAPACITY in this proportion

disabled-multiplier = 2.5 // How much we prefer relaying a message along an active channel instead of a disabled one.
}
}

Expand Down
3 changes: 1 addition & 2 deletions eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ object NodeParams extends Logging {
val ratioBase = config.getDouble("ratios.base")
val ratioAge = config.getDouble("ratios.channel-age")
val ratioCapacity = config.getDouble("ratios.channel-capacity")
val disabledMultiplier = config.getDouble("ratios.disabled-multiplier")
MessageRouteParams(maxRouteLength, Graph.MessagePath.WeightRatios(ratioBase, ratioAge, ratioCapacity, disabledMultiplier))
MessageRouteParams(maxRouteLength, Graph.MessagePath.WeightRatios(ratioBase, ratioAge, ratioCapacity))
}

val unhandledExceptionStrategy = config.getString("channel.unhandled-exception-strategy") match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ object EclairInternalsSerializer {
("maxRouteLength" | int32) ::
(("baseFactor" | double) ::
("ageFactor" | double) ::
("capacityFactor" | double) ::
("disabledMultiplier" | double)).as[Graph.MessagePath.WeightRatios]).as[MessageRouteParams]
("capacityFactor" | double)).as[Graph.MessagePath.WeightRatios]).as[MessageRouteParams]

val routerConfCodec: Codec[RouterConf] = (
("watchSpentWindow" | finiteDurationCodec) ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package fr.acinq.eclair.router

import fr.acinq.bitcoin.scalacompat.Crypto.PublicKey
import fr.acinq.bitcoin.scalacompat.{Satoshi, SatoshiLong}
import fr.acinq.eclair.router.Graph.GraphStructure.{DirectedGraph, ActiveEdge}
import fr.acinq.eclair.router.Graph.GraphStructure.{DirectedGraph, GraphEdge}
import fr.acinq.eclair.router.Router.{ChannelDesc, ChannelHop, Route}
import fr.acinq.eclair.wire.protocol.NodeAnnouncement
import fr.acinq.eclair.{MilliSatoshi, MilliSatoshiLong, ShortChannelId, TimestampSecond, TimestampSecondLong, ToMilliSatoshiConversion}
Expand Down Expand Up @@ -179,7 +179,7 @@ case class BalanceEstimate private(low: MilliSatoshi,
def didReceive(amount: MilliSatoshi, timestamp: TimestampSecond): BalanceEstimate =
otherSide.didSend(amount, timestamp).otherSide

def addEdge(edge: ActiveEdge): BalanceEstimate = copy(
def addEdge(edge: GraphEdge): BalanceEstimate = copy(
high = high.max(edge.capacity.toMilliSatoshi),
capacities = capacities.updated(edge.desc.shortChannelId, edge.capacity)
)
Expand Down Expand Up @@ -235,7 +235,7 @@ object BalanceEstimate {
case class BalancesEstimates(balances: Map[(PublicKey, PublicKey), BalanceEstimate], defaultHalfLife: FiniteDuration) {
private def get(a: PublicKey, b: PublicKey): Option[BalanceEstimate] = balances.get((a, b))

def addEdge(edge: ActiveEdge): BalancesEstimates = BalancesEstimates(
def addEdge(edge: GraphEdge): BalancesEstimates = BalancesEstimates(
balances.updatedWith((edge.desc.a, edge.desc.b))(balance =>
Some(balance.getOrElse(BalanceEstimate.empty(defaultHalfLife)).addEdge(edge))
),
Expand Down Expand Up @@ -287,7 +287,7 @@ case class BalancesEstimates(balances: Map[(PublicKey, PublicKey), BalanceEstima
case class GraphWithBalanceEstimates(graph: DirectedGraph, private val balances: BalancesEstimates) {
def addOrUpdateVertex(ann: NodeAnnouncement): GraphWithBalanceEstimates = GraphWithBalanceEstimates(graph.addOrUpdateVertex(ann), balances)

def addEdge(edge: ActiveEdge): GraphWithBalanceEstimates = GraphWithBalanceEstimates(graph.addEdge(edge), balances.addEdge(edge))
def addEdge(edge: GraphEdge): GraphWithBalanceEstimates = GraphWithBalanceEstimates(graph.addEdge(edge), balances.addEdge(edge))

def disableEdge(desc: ChannelDesc): GraphWithBalanceEstimates = GraphWithBalanceEstimates(graph.disableEdge(desc), balances.removeEdge(desc))

Expand Down Expand Up @@ -318,7 +318,7 @@ case class GraphWithBalanceEstimates(graph: DirectedGraph, private val balances:
GraphWithBalanceEstimates(graph, balances.channelCouldNotSend(hop, amount))
}

def canSend(amount: MilliSatoshi, edge: ActiveEdge): Double = {
def canSend(amount: MilliSatoshi, edge: GraphEdge): Double = {
balances.balances.get((edge.desc.a, edge.desc.b)) match {
case Some(estimate) => estimate.canSend(amount)
case None => BalanceEstimate.empty(1 hour).addEdge(edge).canSend(amount)
Expand Down