Small encoding fixes on logs and http error code change (#13345)

* fixing some bad encodings

* changing http error to align with other clients

* fixing unit test
This commit is contained in:
james-prysm 2023-12-20 12:18:55 -06:00 committed by GitHub
parent c6801df05a
commit 856907d760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -340,7 +340,7 @@ func decodeIds(w http.ResponseWriter, st state.BeaconState, rawIds []string, ign
if ignoreUnknown {
continue
}
httputil.HandleError(w, fmt.Sprintf("Unknown pubkey %s", pubkey), http.StatusBadRequest)
httputil.HandleError(w, fmt.Sprintf("Unknown validator: %s", hexutil.Encode(pubkey)), http.StatusNotFound)
return nil, false
}
ids = append(ids, valIndex)

View File

@ -772,11 +772,11 @@ func TestGetValidator(t *testing.T) {
writer.Body = &bytes.Buffer{}
s.GetValidator(writer, request)
assert.Equal(t, http.StatusBadRequest, writer.Code)
assert.Equal(t, http.StatusNotFound, writer.Code)
e := &httputil.DefaultJsonError{}
require.NoError(t, json.Unmarshal(writer.Body.Bytes(), e))
assert.Equal(t, http.StatusBadRequest, e.Code)
assert.StringContains(t, "Unknown pubkey", e.Message)
assert.Equal(t, http.StatusNotFound, e.Code)
assert.StringContains(t, "Unknown validator", e.Message)
})
t.Run("execution optimistic", func(t *testing.T) {
chainService := &chainMock.ChainService{Optimistic: true}

View File

@ -6,6 +6,7 @@ import (
"sync/atomic"
"time"
"github.com/ethereum/go-ethereum/common/hexutil"
emptypb "github.com/golang/protobuf/ptypes/empty"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/signing"
@ -147,7 +148,7 @@ func (v *validator) SubmitSignedContributionAndProof(ctx context.Context, slot p
if contribution.AggregationBits.Count() == 0 {
log.WithFields(logrus.Fields{
"slot": slot,
"pubkey": pubKey,
"pubkey": hexutil.Encode(pubKey[:]),
"subnet": subnet,
}).Warn("Sync contribution for validator has no bits set.")
continue