Skip to content

Commit

Permalink
Remove /eth/v1/debug/beacon/states/{state_id} (#13619)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkapka authored Feb 14, 2024
1 parent b18026f commit 1eb3731
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 49 deletions.
25 changes: 0 additions & 25 deletions beacon-chain/rpc/eth/debug/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,6 @@ import (

const errMsgStateFromConsensus = "Could not convert consensus state to response"

// GetBeaconStateSSZ returns the SSZ-serialized version of the full beacon state object for given state ID.
//
// DEPRECATED: please use GetBeaconStateV2 instead
func (s *Server) GetBeaconStateSSZ(w http.ResponseWriter, r *http.Request) {
ctx, span := trace.StartSpan(r.Context(), "debug.GetBeaconStateSSZ")
defer span.End()

stateId := mux.Vars(r)["state_id"]
if stateId == "" {
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
return
}
st, err := s.Stater.State(ctx, []byte(stateId))
if err != nil {
shared.WriteStateFetchError(w, err)
return
}
sszState, err := st.MarshalSSZ()
if err != nil {
httputil.HandleError(w, "Could not marshal state into SSZ: "+err.Error(), http.StatusInternalServerError)
return
}
httputil.WriteSsz(w, sszState, "beacon_state.ssz")
}

// GetBeaconStateV2 returns the full beacon state for a given state ID.
func (s *Server) GetBeaconStateV2(w http.ResponseWriter, r *http.Request) {
ctx, span := trace.StartSpan(r.Context(), "debug.GetBeaconStateV2")
Expand Down
22 changes: 0 additions & 22 deletions beacon-chain/rpc/eth/debug/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,6 @@ import (
"github.com/prysmaticlabs/prysm/v4/testing/util"
)

func TestGetBeaconStateSSZ(t *testing.T) {
fakeState, err := util.NewBeaconState()
require.NoError(t, err)
sszState, err := fakeState.MarshalSSZ()
require.NoError(t, err)

s := &Server{
Stater: &testutil.MockStater{
BeaconState: fakeState,
},
}

request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/debug/beacon/states/{state_id}", nil)
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
writer := httptest.NewRecorder()
writer.Body = &bytes.Buffer{}

s.GetBeaconStateSSZ(writer, request)
require.Equal(t, http.StatusOK, writer.Code)
assert.DeepEqual(t, sszState, writer.Body.Bytes())
}

func TestGetBeaconStateV2(t *testing.T) {
ctx := context.Background()
db := dbtest.SetupDB(t)
Expand Down
1 change: 0 additions & 1 deletion beacon-chain/rpc/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ func (s *Service) initializeLightClientServerRoutes(lightClientServer *lightclie
}

func (s *Service) initializeDebugServerRoutes(debugServer *debug.Server) {
s.cfg.Router.HandleFunc("/eth/v1/debug/beacon/states/{state_id}", debugServer.GetBeaconStateSSZ).Methods(http.MethodGet)
s.cfg.Router.HandleFunc("/eth/v2/debug/beacon/states/{state_id}", debugServer.GetBeaconStateV2).Methods(http.MethodGet)
s.cfg.Router.HandleFunc("/eth/v2/debug/beacon/heads", debugServer.GetForkChoiceHeadsV2).Methods(http.MethodGet)
s.cfg.Router.HandleFunc("/eth/v1/debug/fork_choice", debugServer.GetForkChoice).Methods(http.MethodGet)
Expand Down
1 change: 0 additions & 1 deletion beacon-chain/rpc/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func TestServer_InitializeRoutes(t *testing.T) {
}

debugRoutes := map[string][]string{
"/eth/v1/debug/beacon/states/{state_id}": {http.MethodGet}, //deprecated
"/eth/v2/debug/beacon/states/{state_id}": {http.MethodGet},
"/eth/v2/debug/beacon/heads": {http.MethodGet},
"/eth/v1/debug/fork_choice": {http.MethodGet},
Expand Down

0 comments on commit 1eb3731

Please sign in to comment.