Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
var announcementSigsSent = Set.empty[RealShortChannelId]
// we keep track of the splice_locked we sent after channel_reestablish and it's funding tx index to avoid sending it again
private var spliceLockedSent = Map.empty[TxId, Long]
// after restart we need to read the relay fees from db (but only once)
var needToLoadRelayFeesFromDb = false

private def trimAnnouncementSigsStashIfNeeded(): Unit = {
if (announcementSigsStash.size >= 10) {
Expand Down Expand Up @@ -452,14 +454,8 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
goto(CLOSING) using closing
case normal: DATA_NORMAL =>
context.system.eventStream.publish(ShortChannelIdAssigned(self, normal.channelId, normal.lastAnnouncement_opt, normal.aliases, remoteNodeId))
// we check the configuration because the values for channel_update may have changed while eclair was down
val fees = getRelayFees(nodeParams, remoteNodeId, normal.commitments.announceChannel)
if (fees.feeBase != normal.channelUpdate.feeBaseMsat ||
fees.feeProportionalMillionths != normal.channelUpdate.feeProportionalMillionths ||
nodeParams.channelConf.expiryDelta != normal.channelUpdate.cltvExpiryDelta) {
log.debug("refreshing channel_update due to configuration changes")
self ! CMD_UPDATE_RELAY_FEE(ActorRef.noSender, fees.feeBase, fees.feeProportionalMillionths)
}
// at the next reconnection we will make sure the relay fees are in sync with the conf and the db, but only need this once
needToLoadRelayFeesFromDb = true
// we need to periodically re-send channel updates, otherwise channel will be considered stale and get pruned by network
// we take into account the date of the last update so that we don't send superfluous updates when we restart the app
val periodicRefreshInitialDelay = Helpers.nextChannelUpdateRefresh(normal.channelUpdate.timestamp)
Expand Down Expand Up @@ -2722,6 +2718,18 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
Some(shutdown1)
}

// we check the configuration because the values for channel_update may have changed while eclair was down
if (needToLoadRelayFeesFromDb) {
val relayFees = getRelayFees(nodeParams, remoteNodeId, d.commitments.announceChannel)
if (relayFees.feeBase != d.channelUpdate.feeBaseMsat ||
relayFees.feeProportionalMillionths != d.channelUpdate.feeProportionalMillionths ||
nodeParams.channelConf.expiryDelta != d.channelUpdate.cltvExpiryDelta) {
log.debug("refreshing channel_update due to configuration changes")
self ! CMD_UPDATE_RELAY_FEE(ActorRef.noSender, relayFees.feeBase, relayFees.feeProportionalMillionths)
}
needToLoadRelayFeesFromDb = false
}

if (d.commitments.announceChannel) {
// we will re-enable the channel after some delay to prevent flappy updates in case the connection is unstable
startSingleTimer(Reconnected.toString, BroadcastChannelUpdate(Reconnected), 10 seconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ class RestoreSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Chan
val newAlice: TestFSMRef[ChannelState, ChannelData, Channel] = TestFSMRef(new Channel(newConfig, Alice.channelKeys(), aliceWallet, Bob.nodeParams.nodeId, alice2blockchain.ref, alice2relayer.ref, FakeTxPublisherFactory(alice2blockchain)), alicePeer.ref)
newAlice ! INPUT_RESTORED(oldStateData)

val u1 = channelUpdateListener.expectMsgType[ChannelUpdateParametersChanged]
assert(!Announcements.areSameRelayParams(u1.channelUpdate, oldStateData.channelUpdate))
assert(u1.channelUpdate.feeBaseMsat == newConfig.relayParams.privateChannelFees.feeBase)
assert(u1.channelUpdate.feeProportionalMillionths == newConfig.relayParams.privateChannelFees.feeProportionalMillionths)
assert(u1.channelUpdate.cltvExpiryDelta == newConfig.channelConf.expiryDelta)

newAlice ! INPUT_RECONNECTED(alice2bob.ref, aliceInit, bobInit)
bob ! INPUT_RECONNECTED(bob2alice.ref, bobInit, aliceInit)
Expand All @@ -144,6 +139,11 @@ class RestoreSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Chan
awaitCond(newAlice.stateName == NORMAL)
awaitCond(bob.stateName == NORMAL)

val u1 = channelUpdateListener.expectMsgType[ChannelUpdateParametersChanged]
assert(!Announcements.areSameRelayParams(u1.channelUpdate, oldStateData.channelUpdate))
assert(u1.channelUpdate.feeBaseMsat == newConfig.relayParams.privateChannelFees.feeBase)
assert(u1.channelUpdate.feeProportionalMillionths == newConfig.relayParams.privateChannelFees.feeProportionalMillionths)
assert(u1.channelUpdate.cltvExpiryDelta == newConfig.channelConf.expiryDelta)
channelUpdateListener.expectNoMessage()

// we simulate a disconnection
Expand Down
Loading