Add LateResponseLoggerFilter
MODIFY
WalletWasabi.Backend/Controllers/WabiSabiController.cs
WalletWasabi.Backend/Controllers/WabiSabiController.cs
@@ -12,6 +12,7 @@ namespace WalletWasabi.Backend.Controllers;
[ApiController]
[ExceptionTranslate]
+[LateResponseLoggerFilter]
[Route("[controller]")]
[Produces("application/json")]
public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler

ADD
WalletWasabi.Backend/Filters/LateResponseLoggerFilter.cs
+using Microsoft.AspNetCore.Mvc.Filters;
+using WalletWasabi.Logging;
+using WalletWasabi.WabiSabi.Backend.Models;
+
+namespace WalletWasabi.Backend.Filters;
+
+public class LateResponseLoggerFilter : ExceptionFilterAttribute
+{
+ public override void OnException(ExceptionContext context)
+ {
+ if (context.Exception is not WrongPhaseException ex)
+ {
+ return;
+ }
+
+ var actionName = ((Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor)context.ActionDescriptor).ActionName;
+
+ Logger.LogInfo($"Request '{actionName}' missing the phase '{string.Join(",", ex.ExpectedPhases)}' by '{ex.Late}'. Round id '{ex.RoundId}' is in phase '{ex.CurrentPhase}'.");
+ }
+}

MODIFY
WalletWasabi/WabiSabi/Backend/Models/WrongPhaseException.cs
WalletWasabi/WabiSabi/Backend/Models/WrongPhaseException.cs
@@ -15,7 +15,7 @@ public class WrongPhaseException : WabiSabiProtocolException
public Phase[] ExpectedPhases { get; }
public uint256 RoundId { get; }
- public WrongPhaseException(Round round, Phase[] expectedPhases) : base(WabiSabiProtocolErrorCode.WrongPhase, $"Round ({round.Id}): Wrong phase ({round.Phase}).")
+ public WrongPhaseException(Round round, params Phase[] expectedPhases) : base(WabiSabiProtocolErrorCode.WrongPhase, $"Round ({round.Id}): Wrong phase ({round.Phase}).")
{
var latestExpectedPhase = expectedPhases.OrderBy(p => (int)p).Last();
var now = DateTimeOffset.UtcNow;

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
@@ -48,7 +48,7 @@ public partial class Arena : IWabiSabiApiRequestHandler
if (round.IsInputRegistrationEnded(Config.MaxInputCountByRound))
{
- throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.WrongPhase);
+ throw new WrongPhaseException(round, Phase.InputRegistration);
}
if (round is BlameRound blameRound && !blameRound.BlameWhitelist.Contains(coin.Outpoint))

Add LateResponseLoggerFilter