From 85f94554c0c513011cabd0149d581f3d7505686f Mon Sep 17 00:00:00 2001 From: Bastien Teinturier <31281497+t-bast@users.noreply.github.com> Date: Mon, 24 Jan 2022 11:01:46 +0100 Subject: [PATCH] Fix error logs formatting in TxPublisher (#2136) I always forget that `log.error` doesn't use the same formatting as other log.* methods (it optimizes for showing a Throwable). --- .../channel/publish/FinalTxPublisher.scala | 2 +- .../channel/publish/MempoolTxMonitor.scala | 8 ++++---- .../channel/publish/ReplaceableTxFunder.scala | 4 ++-- .../publish/ReplaceableTxPrePublisher.scala | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/FinalTxPublisher.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/FinalTxPublisher.scala index f019b994c1..bc09975151 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/FinalTxPublisher.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/FinalTxPublisher.scala @@ -105,7 +105,7 @@ private class FinalTxPublisher(nodeParams: NodeParams, timers.startSingleTimer(CheckParentTx, (1 + Random.nextLong(nodeParams.maxTxPublishRetryDelay.toMillis)).millis) Behaviors.same case UnknownFailure(reason) => - log.error("could not check parent tx", reason) + log.error("could not check parent tx: ", reason) sendResult(TxPublisher.TxRejected(txPublishContext.id, cmd, TxPublisher.TxRejectedReason.UnknownTxFailure)) case Stop => Behaviors.stopped } diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitor.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitor.scala index 5c672ce288..afbe247f86 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitor.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitor.scala @@ -112,7 +112,7 @@ private class MempoolTxMonitor(nodeParams: NodeParams, checkInputStatus(cmd.input) Behaviors.same case PublishFailed(reason) => - log.error("could not publish transaction", reason) + log.error("could not publish transaction: ", reason) sendFinalResult(TxRejected(cmd.tx.txid, TxRejectedReason.UnknownTxFailure)) case status: InputStatus => if (status.spentConfirmed) { @@ -126,7 +126,7 @@ private class MempoolTxMonitor(nodeParams: NodeParams, sendFinalResult(TxRejected(cmd.tx.txid, TxRejectedReason.WalletInputGone)) } case CheckInputFailed(reason) => - log.error("could not check input status", reason) + log.error("could not check input status: ", reason) sendFinalResult(TxRejected(cmd.tx.txid, TxRejectedReason.TxSkipped(retryNextBlock = true))) // we act as if the input is potentially still spendable } } @@ -163,7 +163,7 @@ private class MempoolTxMonitor(nodeParams: NodeParams, checkInputStatus(cmd.input) Behaviors.same case GetTxConfirmationsFailed(reason) => - log.error("could not get tx confirmations", reason) + log.error("could not get tx confirmations: ", reason) // We will retry when the next block is found. Behaviors.same case status: InputStatus => @@ -178,7 +178,7 @@ private class MempoolTxMonitor(nodeParams: NodeParams, sendFinalResult(TxRejected(cmd.tx.txid, TxRejectedReason.WalletInputGone)) } case CheckInputFailed(reason) => - log.error("could not check input status", reason) + log.error("could not check input status: ", reason) sendFinalResult(TxRejected(cmd.tx.txid, TxRejectedReason.TxSkipped(retryNextBlock = true)), Some(messageAdapter)) } } diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunder.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunder.scala index 9ed945bd56..8a75ef4972 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunder.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunder.scala @@ -311,7 +311,7 @@ private class ReplaceableTxFunder(nodeParams: NodeParams, context.system.eventStream ! EventStream.Publish(NotifyNodeOperator(NotificationsLogger.Warning, nodeOperatorMessage)) log.warn("cannot add inputs to {}: {}", cmd.desc, reason.getMessage) } else { - log.error("cannot add inputs to {}: {}", cmd.desc, reason) + log.error(s"cannot add inputs to ${cmd.desc}: ", reason) } replyTo ! FundingFailed(TxPublisher.TxRejectedReason.CouldNotFund) Behaviors.stopped @@ -377,7 +377,7 @@ private class ReplaceableTxFunder(nodeParams: NodeParams, replyTo ! TransactionReady(FundedTx(fullySignedTx, amountIn, txFeerate)) Behaviors.stopped case SignWalletInputsFailed(reason) => - log.error("cannot sign {}: {}", cmd.desc, reason) + log.error(s"cannot sign ${cmd.desc}: ", reason) // We reply with the failure only once the utxos are unlocked, otherwise there is a risk that our parent stops // itself, which will automatically stop us before we had a chance to unlock them. unlockAndStop(locallySignedTx.txInfo.input.outPoint, locallySignedTx.txInfo.tx, TxPublisher.TxRejectedReason.UnknownTxFailure) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPrePublisher.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPrePublisher.scala index 8b2b213162..beed33a4a9 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPrePublisher.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPrePublisher.scala @@ -169,7 +169,7 @@ private class ReplaceableTxPrePublisher(nodeParams: NodeParams, replyTo ! PreconditionsFailed(TxPublisher.TxRejectedReason.TxSkipped(retryNextBlock = true)) Behaviors.stopped case UnknownFailure(reason) => - log.error(s"could not check ${cmd.desc} preconditions, proceeding anyway", reason) + log.error(s"could not check ${cmd.desc} preconditions, proceeding anyway: ", reason) // If our checks fail, we don't want it to prevent us from trying to publish our commit tx. replyTo ! PreconditionsOk(ClaimLocalAnchorWithWitnessData(localAnchorTx)) Behaviors.stopped @@ -197,7 +197,7 @@ private class ReplaceableTxPrePublisher(nodeParams: NodeParams, replyTo ! PreconditionsFailed(TxPublisher.TxRejectedReason.ConflictingTxConfirmed) Behaviors.stopped case UnknownFailure(reason) => - log.error(s"could not check ${cmd.desc} preconditions, proceeding anyway", reason) + log.error(s"could not check ${cmd.desc} preconditions, proceeding anyway: ", reason) // If our checks fail, we don't want it to prevent us from trying to publish our htlc transactions. extractHtlcWitnessData(htlcTx, cmd.commitments) match { case Some(txWithWitnessData) => replyTo ! PreconditionsOk(txWithWitnessData) @@ -219,11 +219,11 @@ private class ReplaceableTxPrePublisher(nodeParams: NodeParams, } match { case Some(preimage) => Some(HtlcSuccessWithWitnessData(tx, remoteSig, preimage)) case None => - log.error("preimage not found for htlcId={}, skipping...", tx.htlcId) + log.error(s"preimage not found for htlcId=${tx.htlcId}, skipping...") None } case None => - log.error("remote signature not found for htlcId={}, skipping...", tx.htlcId) + log.error(s"remote signature not found for htlcId=${tx.htlcId}, skipping...") None } case tx: HtlcTimeoutTx => @@ -232,7 +232,7 @@ private class ReplaceableTxPrePublisher(nodeParams: NodeParams, } match { case Some(remoteSig) => Some(HtlcTimeoutWithWitnessData(tx, remoteSig)) case None => - log.error("remote signature not found for htlcId={}, skipping...", tx.htlcId) + log.error(s"remote signature not found for htlcId=${tx.htlcId}, skipping...") None } } @@ -259,7 +259,7 @@ private class ReplaceableTxPrePublisher(nodeParams: NodeParams, replyTo ! PreconditionsFailed(TxPublisher.TxRejectedReason.ConflictingTxConfirmed) Behaviors.stopped case UnknownFailure(reason) => - log.error(s"could not check ${cmd.desc} preconditions, proceeding anyway", reason) + log.error(s"could not check ${cmd.desc} preconditions, proceeding anyway: ", reason) // If our checks fail, we don't want it to prevent us from trying to publish our htlc transactions. extractClaimHtlcWitnessData(claimHtlcTx, cmd.commitments) match { case Some(txWithWitnessData) => replyTo ! PreconditionsOk(txWithWitnessData) @@ -277,7 +277,7 @@ private class ReplaceableTxPrePublisher(nodeParams: NodeParams, } match { case Some(preimage) => Some(LegacyClaimHtlcSuccessWithWitnessData(tx, preimage)) case None => - log.error("preimage not found for legacy htlcId={}, skipping...", tx.htlcId) + log.error(s"preimage not found for legacy htlcId=${tx.htlcId}, skipping...") None } case tx: ClaimHtlcSuccessTx => @@ -286,7 +286,7 @@ private class ReplaceableTxPrePublisher(nodeParams: NodeParams, } match { case Some(preimage) => Some(ClaimHtlcSuccessWithWitnessData(tx, preimage)) case None => - log.error("preimage not found for htlcId={}, skipping...", tx.htlcId) + log.error(s"preimage not found for htlcId=${tx.htlcId}, skipping...") None } case tx: ClaimHtlcTimeoutTx => Some(ClaimHtlcTimeoutWithWitnessData(tx))