From b0f5be9759af3306b0b182e313f52c77c9348d1e Mon Sep 17 00:00:00 2001 From: Martin Hutchinson Date: Wed, 17 Jun 2026 14:16:22 +0000 Subject: [PATCH 1/2] Handle pushback without logging This avoids spammers spamming the logs --- witness/http.go | 5 ++--- witness/http_test.go | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/witness/http.go b/witness/http.go index 70d2f422..2b8fd356 100644 --- a/witness/http.go +++ b/witness/http.go @@ -54,9 +54,6 @@ func (a *HTTPHandler) AddCheckpoint(w http.ResponseWriter, r *http.Request) { sc, body, contentType, err := a.handleUpdate(r.Context(), oldSize, cp, proof) if err != nil { status := http.StatusInternalServerError - if errors.Is(err, ErrPushback) { - status = http.StatusTooManyRequests - } w.WriteHeader(status) return } @@ -90,6 +87,8 @@ func (a *HTTPHandler) handleUpdate(ctx context.Context, oldSize uint64, newCP [] return http.StatusUnprocessableEntity, nil, "", nil case errors.Is(updateErr, ErrRootMismatch): return http.StatusConflict, nil, "", nil + case errors.Is(updateErr, ErrPushback): + return http.StatusTooManyRequests, nil, "", nil default: slog.ErrorContext(ctx, "Unknown error", slog.Any("error", updateErr)) return http.StatusInternalServerError, nil, "", updateErr diff --git a/witness/http_test.go b/witness/http_test.go index 551f3876..8d65864f 100644 --- a/witness/http_test.go +++ b/witness/http_test.go @@ -124,7 +124,12 @@ func TestHandler(t *testing.T) { name: "ErrRootMismatch", witness: &testWitness{updateErr: ErrRootMismatch}, wantStatus: http.StatusConflict, + }, { + name: "ErrPushback", + witness: &testWitness{updateErr: ErrPushback}, + wantStatus: http.StatusTooManyRequests, }, + } { t.Run(test.name, func(t *testing.T) { a := HTTPHandler{ From 5a1cde199bda6d1736c7b3c447b13b299fc91b32 Mon Sep 17 00:00:00 2001 From: Martin Hutchinson Date: Wed, 17 Jun 2026 14:40:21 +0000 Subject: [PATCH 2/2] Restore formatting --- witness/http_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/witness/http_test.go b/witness/http_test.go index 8d65864f..f9186f38 100644 --- a/witness/http_test.go +++ b/witness/http_test.go @@ -129,7 +129,6 @@ func TestHandler(t *testing.T) { witness: &testWitness{updateErr: ErrPushback}, wantStatus: http.StatusTooManyRequests, }, - } { t.Run(test.name, func(t *testing.T) { a := HTTPHandler{