From 63246659f21c284bd6977ac0bd2c990b23e1d5dd Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 6 Sep 2024 13:17:01 +0200 Subject: [PATCH 1/9] integ: improve liquidity policy logs --- .../kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt index c620176e5..2192d96e1 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt @@ -30,7 +30,7 @@ sealed class LiquidityPolicy { is Auto -> { val maxAbsoluteFee = if (skipAbsoluteFeeCheck && source == LiquidityEvents.Source.OffChainPayment) Long.MAX_VALUE.msat else this.maxAbsoluteFee.toMilliSatoshi() val maxRelativeFee = amount * maxRelativeFeeBasisPoints / 10_000 - logger.info { "liquidity policy check: fee=$fee maxAbsoluteFee=$maxAbsoluteFee maxRelativeFee=$maxRelativeFee policy=$this" } + logger.info { "liquidity policy check: amount=$amount fee=$fee maxAbsoluteFee=$maxAbsoluteFee maxRelativeFee=$maxRelativeFee policy=$this" } when { fee > maxRelativeFee -> LiquidityEvents.Rejected.Reason.TooExpensive.OverRelativeFee(maxRelativeFeeBasisPoints) fee > maxAbsoluteFee -> LiquidityEvents.Rejected.Reason.TooExpensive.OverAbsoluteFee(this.maxAbsoluteFee) From 473de4376791737eaf0ce79c31d3f6f652719c80 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 6 Sep 2024 13:50:16 +0200 Subject: [PATCH 2/9] integ: more details in channel mdc --- .../kotlin/fr/acinq/lightning/logging/MDCLogger.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt b/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt index bfd07b795..4358f0a57 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt @@ -92,7 +92,10 @@ fun ChannelState.mdc(): Map { else -> {} } when(state) { - is ChannelStateWithCommitments -> put("commitments", "active=${state.commitments.active.map { it.fundingTxIndex }} inactive=${state.commitments.inactive.map { it.fundingTxIndex }}") + is ChannelStateWithCommitments -> { + put("commitments", "active=${state.commitments.active.map { it.fundingTxIndex }} inactive=${state.commitments.inactive.map { it.fundingTxIndex }}") + put("balances", "toLocal=${state.commitments.latest.localCommit.spec.toLocal} toRemote=${state.commitments.latest.localCommit.spec.toRemote} capacity=${state.commitments.latest.fundingAmount}") + } else -> {} } } From c13ffbe02a21dd84ced406ce4609cd1be312bef0 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 6 Sep 2024 15:10:42 +0200 Subject: [PATCH 3/9] integ: improve splice ack logs --- .../kotlin/fr/acinq/lightning/channel/ChannelCommand.kt | 1 + .../kotlin/fr/acinq/lightning/channel/states/Normal.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt index a4086d9b4..2642b46d4 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt @@ -98,6 +98,7 @@ sealed class ChannelCommand { ) : Splice() { val pushAmount: MilliSatoshi = spliceIn?.pushAmount ?: 0.msat val spliceOutputs: List = spliceOut?.let { listOf(TxOut(it.amount, it.scriptPubKey)) } ?: emptyList() + val liquidityFees: LiquidityAds.Fees? = requestRemoteFunding?.fees(feerate, isChannelCreation = false) data class SpliceIn(val walletInputs: List, val pushAmount: MilliSatoshi = 0.msat) data class SpliceOut(val amount: Satoshi, val scriptPubKey: ByteVector) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt index 99f010425..941c6d9d1 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt @@ -511,7 +511,7 @@ data class Normal( } is SpliceAck -> when (spliceStatus) { is SpliceStatus.Requested -> { - logger.info { "our peer accepted our splice request and will contribute ${cmd.message.fundingContribution} to the funding transaction" } + logger.info { "our peer accepted our splice request with remote.amount=${cmd.message.fundingContribution} remote.push=${cmd.message.pushAmount} liquidityFees=${spliceStatus.command.liquidityFees}" } when (val liquidityPurchase = LiquidityAds.validateRemoteFunding( spliceStatus.command.requestRemoteFunding, remoteNodeId, From 9e4a984242ec563ece7c8d1cedb5b94e1a27fa23 Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 9 Sep 2024 15:22:32 +0200 Subject: [PATCH 4/9] integ: improve request on-the-fly logs --- src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt index 0144026ca..c4aa97cac 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt @@ -1423,7 +1423,7 @@ class Peer( else -> { val leaseFees = cmd.fees(targetFeerate, isChannelCreation = false) val totalFees = ChannelManagementFees(miningFee = localMiningFee.min(localBalance.truncateToSatoshi()) + leaseFees.miningFee, serviceFee = leaseFees.serviceFee) - logger.info { "requesting on-the-fly splice for paymentHash=${cmd.paymentHash} feerate=$targetFeerate fee=${totalFees.total} paymentType=${paymentDetails.paymentType}" } + logger.info { "requesting on-the-fly splice for paymentHash=${cmd.paymentHash} requestedAmount=${cmd.requestedAmount} feerate=$targetFeerate fee=${totalFees.total} paymentType=${paymentDetails.paymentType}" } val spliceCommand = ChannelCommand.Commitment.Splice.Request( replyTo = CompletableDeferred(), spliceIn = null, From 18d8b014110651405f97855ce1a3aa025330f234 Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 9 Sep 2024 15:37:52 +0200 Subject: [PATCH 5/9] integ: move 'no changes to sign' log to info --- .../kotlin/fr/acinq/lightning/channel/states/Normal.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt index 941c6d9d1..9aeac75be 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt @@ -58,7 +58,7 @@ data class Normal( is ChannelCommand.Commitment.UpdateFee -> handleCommandResult(cmd, commitments.sendFee(cmd), cmd.commit) is ChannelCommand.Commitment.Sign -> when { !commitments.changes.localHasChanges() -> { - logger.warning { "no changes to sign" } + logger.info { "no changes to sign" } Pair(this@Normal, listOf()) } commitments.remoteNextCommitInfo is Either.Left -> { From 66f83f94a586564a7e7f514205e89f03ae135161 Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 9 Sep 2024 18:23:19 +0200 Subject: [PATCH 6/9] integ: add feeCredit to payment handler mdc --- .../kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt index 1ad78651c..b9bca7c30 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt @@ -170,7 +170,7 @@ class IncomingPaymentHandler(val nodeParams: NodeParams, val db: PaymentsDb) { /** Main payment processing, that handles payment parts. */ private suspend fun processPaymentPart(paymentPart: PaymentPart, remoteFeatures: Features, currentBlockHeight: Int, currentFeerate: FeeratePerKw, remoteFundingRates: LiquidityAds.WillFundRates?, currentFeeCredit: MilliSatoshi): ProcessAddResult { - val logger = MDCLogger(logger.logger, staticMdc = paymentPart.mdc()) + val logger = MDCLogger(logger.logger, staticMdc = paymentPart.mdc() + ("feeCredit" to currentFeeCredit)) when (paymentPart) { is HtlcPart -> logger.info { "processing htlc part expiry=${paymentPart.htlc.cltvExpiry}" } is WillAddHtlcPart -> logger.info { "processing on-the-fly funding part amount=${paymentPart.amount} expiry=${paymentPart.htlc.expiry}" } From 8e30a8df0449f5b40cf17378a564c91d646fcc59 Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 9 Sep 2024 18:30:52 +0200 Subject: [PATCH 7/9] integ: more fee credit logs --- .../kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt index b9bca7c30..955a6934e 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt @@ -370,6 +370,7 @@ class IncomingPaymentHandler(val nodeParams: NodeParams, val db: PaymentsDb) { // We must use the worst case fees that applies to channel creation. val fees = fundingRate.fees(currentFeerate, requestedAmount, requestedAmount, isChannelCreation = true).total val canAddToFeeCredit = Features.canUseFeature(nodeParams.features, remoteFeatures, Feature.FundingFeeCredit) && (willAddHtlcAmount + currentFeeCredit) <= liquidityPolicy.maxAllowedFeeCredit + logger.info { "on-the-fly assessment: amount=$requestedAmount feerate=$currentFeerate fees=$fees" } val rejected = when { // We never reject if we can add payments to our fee credit until making an on-chain operation becomes acceptable. canAddToFeeCredit -> null From 60c79a40733a6ac229893729a0cdb4774b606895 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 20 Sep 2024 15:38:12 +0200 Subject: [PATCH 8/9] remove docker-related println --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index e1285491e..80f49ee05 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -290,7 +290,6 @@ val dockerTestEnv by tasks.creating(Exec::class) { } val dockerCleanup by tasks.creating(Exec::class) { - println("Cleaning up dockers...") workingDir = projectDir.resolve("docker-local-test") commandLine("bash", "env.sh", "elx-stop", "btc-stop", "remove") } From 4e2e8ec74e48dd6c477308b3cab6265534761bdb Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 2 Sep 2024 15:53:06 +0200 Subject: [PATCH 9/9] include liquidity target in liquidity policy logs --- .../kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt index 2192d96e1..359c72b2e 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt @@ -30,7 +30,7 @@ sealed class LiquidityPolicy { is Auto -> { val maxAbsoluteFee = if (skipAbsoluteFeeCheck && source == LiquidityEvents.Source.OffChainPayment) Long.MAX_VALUE.msat else this.maxAbsoluteFee.toMilliSatoshi() val maxRelativeFee = amount * maxRelativeFeeBasisPoints / 10_000 - logger.info { "liquidity policy check: amount=$amount fee=$fee maxAbsoluteFee=$maxAbsoluteFee maxRelativeFee=$maxRelativeFee policy=$this" } + logger.info { "liquidity policy check: amount=$amount liquidityTarget=${inboundLiquidityTarget ?: 0.sat} fee=$fee maxAbsoluteFee=$maxAbsoluteFee maxRelativeFee=$maxRelativeFee policy=$this" } when { fee > maxRelativeFee -> LiquidityEvents.Rejected.Reason.TooExpensive.OverRelativeFee(maxRelativeFeeBasisPoints) fee > maxAbsoluteFee -> LiquidityEvents.Rejected.Reason.TooExpensive.OverAbsoluteFee(this.maxAbsoluteFee)