Skip to content

Commit

Permalink
Fix error logs formatting in TxPublisher (#2136)
Browse files Browse the repository at this point in the history
I always forget that `log.error` doesn't use the same formatting as
other log.* methods (it optimizes for showing a Throwable).
  • Loading branch information
t-bast committed Jan 24, 2022
1 parent 0a37213 commit 85f9455
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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 =>
Expand All @@ -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))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 =>
Expand All @@ -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
}
}
Expand All @@ -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)
Expand All @@ -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 =>
Expand All @@ -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))
Expand Down

0 comments on commit 85f9455

Please sign in to comment.