Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/Fibonacci747_perf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- avoid string copy when importing slashing protection JSON [#16081](https://github.com/OffchainLabs/prysm/pull/16081)
7 changes: 3 additions & 4 deletions validator/rpc/handlers_slashing.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package rpc

import (
"bytes"
"encoding/json"
"io"
"net/http"
"strings"

"github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace"
"github.com/OffchainLabs/prysm/v7/network/httputil"
Expand Down Expand Up @@ -74,9 +74,8 @@ func (s *Server) ImportSlashingProtection(w http.ResponseWriter, r *http.Request
httputil.HandleError(w, "empty slashing_protection_json specified", http.StatusBadRequest)
return
}
enc := []byte(req.SlashingProtectionJson)
buf := bytes.NewBuffer(enc)
if err := s.db.ImportStandardProtectionJSON(ctx, buf); err != nil {
rdr := strings.NewReader(req.SlashingProtectionJson)
if err := s.db.ImportStandardProtectionJSON(ctx, rdr); err != nil {
httputil.HandleError(w, errors.Wrap(err, "could not import slashing protection history").Error(), http.StatusInternalServerError)
return
}
Expand Down