diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/ChannelRelay.scala b/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/ChannelRelay.scala index d4223adf7e..13adf539da 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/ChannelRelay.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/ChannelRelay.scala @@ -138,7 +138,7 @@ class ChannelRelay private(nodeParams: NodeParams, Metrics.recordPaymentRelayFailed(Tags.FailureType(cmdFail), Tags.RelayType.Channel) context.log.info("rejecting htlc reason={}", cmdFail.reason) reputationRecorder ! CancelRelay(originNode, r.add.endorsement, relayId) - safeSendAndStop(r.add.channelId, cmdFail) + safeSendAndStop(r.add.channelId, cmdFail, confidence) case RelaySuccess(selectedChannelId, cmdAdd) => context.log.info("forwarding htlc #{} from channelId={} to channelId={}", r.add.id, r.add.channelId, selectedChannelId) register ! Register.Forward(forwardFailureAdapter, selectedChannelId, cmdAdd) @@ -154,19 +154,19 @@ class ChannelRelay private(nodeParams: NodeParams, val cmdFail = CMD_FAIL_HTLC(o.add.id, Right(UnknownNextPeer()), commit = true) Metrics.recordPaymentRelayFailed(Tags.FailureType(cmdFail), Tags.RelayType.Channel) reputationRecorder ! CancelRelay(originNode, r.add.endorsement, relayId) - safeSendAndStop(o.add.channelId, cmdFail) + safeSendAndStop(o.add.channelId, cmdFail, confidence, Some(channelId)) case WrappedAddResponse(addFailed@RES_ADD_FAILED(CMD_ADD_HTLC(_, _, _, _, _, _, _, _: Origin.ChannelRelayedHot, _), _, _)) => context.log.info("attempt failed with reason={}", addFailed.t.getClass.getSimpleName) context.self ! WrappedConfidence(confidence) relay(previousFailures :+ PreviouslyTried(selectedChannelId, addFailed)) - case WrappedAddResponse(_: RES_SUCCESS[_]) => + case WrappedAddResponse(r: RES_SUCCESS[_]) => context.log.debug("sent htlc to the downstream channel") - waitForAddSettled(confidence) + waitForAddSettled(confidence, r.channelId) } - def waitForAddSettled(confidence: Double): Behavior[Command] = + def waitForAddSettled(confidence: Double, channelId: ByteVector32): Behavior[Command] = Behaviors.receiveMessagePartial { case WrappedAddResponse(RES_ADD_SETTLED(o: Origin.ChannelRelayedHot, htlc, fulfill: HtlcResult.Fulfill)) => context.log.debug("relaying fulfill to upstream") @@ -174,7 +174,7 @@ class ChannelRelay private(nodeParams: NodeParams, val cmd = CMD_FULFILL_HTLC(o.originHtlcId, fulfill.paymentPreimage, commit = true) context.system.eventStream ! EventStream.Publish(ChannelPaymentRelayed(o.amountIn, o.amountOut, htlc.paymentHash, o.originChannelId, htlc.channelId, startedAt, TimestampMilli.now())) recordRelayDuration(isSuccess = true) - safeSendAndStop(o.originChannelId, cmd) + safeSendAndStop(o.originChannelId, cmd, confidence, Some(channelId)) case WrappedAddResponse(RES_ADD_SETTLED(o: Origin.ChannelRelayedHot, _, fail: HtlcResult.Fail)) => context.log.debug("relaying fail to upstream") @@ -182,10 +182,11 @@ class ChannelRelay private(nodeParams: NodeParams, Metrics.recordPaymentRelayFailed(Tags.FailureType.Remote, Tags.RelayType.Channel) val cmd = translateRelayFailure(o.originHtlcId, fail) recordRelayDuration(isSuccess = false) - safeSendAndStop(o.originChannelId, cmd) + safeSendAndStop(o.originChannelId, cmd, confidence, Some(channelId)) } - def safeSendAndStop(channelId: ByteVector32, cmd: channel.HtlcSettlementCommand): Behavior[Command] = { + def safeSendAndStop(channelId: ByteVector32, cmd: channel.HtlcSettlementCommand, confidence: Double, outgoingChannel_opt: Option[ByteVector32]): Behavior[Command] = { + context.log.info("cmd={}, startedAt={}, endedAt={}, confidence={}, originNode={}, outgoingChannel={}", cmd.getClass.getSimpleName, startedAt, TimestampMilli.now(), confidence, originNode, outgoingChannel_opt) val toSend = cmd match { case _: CMD_FULFILL_HTLC => cmd case _: CMD_FAIL_HTLC | _: CMD_FAIL_MALFORMED_HTLC => r.payload match {