From dc967a3ce09f4573c1af2f8909b4619e0683b6c2 Mon Sep 17 00:00:00 2001 From: Angus Scott Date: Mon, 24 Jun 2024 10:30:36 +0100 Subject: [PATCH] Changing Caplin Finality Checkpoint API response to match spec (#10843) Changing the response for finality checkpoints to match the Ethereum specification by removing the _checkpoint postfix [https://ethereum.github.io/beacon-APIs/#/Beacon/getStateFinalityCheckpoints]( https://ethereum.github.io/beacon-APIs/#/Beacon/getStateFinalityCheckpoints) --- cl/beacon/handler/states.go | 6 +++--- cl/beacon/handler/states_test.go | 2 +- cl/beacon/handler/test_data/states_1.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cl/beacon/handler/states.go b/cl/beacon/handler/states.go index c4436429a0a..037852fd7c1 100644 --- a/cl/beacon/handler/states.go +++ b/cl/beacon/handler/states.go @@ -205,9 +205,9 @@ func (a *ApiHandler) getFullState(w http.ResponseWriter, r *http.Request) (*beac } type finalityCheckpointsResponse struct { - FinalizedCheckpoint solid.Checkpoint `json:"finalized_checkpoint"` - CurrentJustifiedCheckpoint solid.Checkpoint `json:"current_justified_checkpoint"` - PreviousJustifiedCheckpoint solid.Checkpoint `json:"previous_justified_checkpoint"` + FinalizedCheckpoint solid.Checkpoint `json:"finalized"` + CurrentJustifiedCheckpoint solid.Checkpoint `json:"current_justified"` + PreviousJustifiedCheckpoint solid.Checkpoint `json:"previous_justified"` } func (a *ApiHandler) getFinalityCheckpoints(w http.ResponseWriter, r *http.Request) (*beaconhttp.BeaconResponse, error) { diff --git a/cl/beacon/handler/states_test.go b/cl/beacon/handler/states_test.go index 73fb70380a9..58bf8657312 100644 --- a/cl/beacon/handler/states_test.go +++ b/cl/beacon/handler/states_test.go @@ -426,7 +426,7 @@ func TestGetStateFinalityCheckpoints(t *testing.T) { code: http.StatusOK, }, } - expected := `{"data":{"finalized_checkpoint":{"epoch":"1","root":"0xde46b0f2ed5e72f0cec20246403b14c963ec995d7c2825f3532b0460c09d5693"},"current_justified_checkpoint":{"epoch":"3","root":"0xa6e47f164b1a3ca30ea3b2144bd14711de442f51e5b634750a12a1734e24c987"},"previous_justified_checkpoint":{"epoch":"2","root":"0x4c3ee7969e485696669498a88c17f70e6999c40603e2f4338869004392069063"}},"execution_optimistic":false,"finalized":false,"version":"bellatrix"}` + "\n" + expected := `{"data":{"finalized":{"epoch":"1","root":"0xde46b0f2ed5e72f0cec20246403b14c963ec995d7c2825f3532b0460c09d5693"},"current_justified":{"epoch":"3","root":"0xa6e47f164b1a3ca30ea3b2144bd14711de442f51e5b634750a12a1734e24c987"},"previous_justified":{"epoch":"2","root":"0x4c3ee7969e485696669498a88c17f70e6999c40603e2f4338869004392069063"}},"execution_optimistic":false,"finalized":false,"version":"bellatrix"}` + "\n" for _, c := range cases { t.Run(c.blockID, func(t *testing.T) { server := httptest.NewServer(handler.mux) diff --git a/cl/beacon/handler/test_data/states_1.yaml b/cl/beacon/handler/test_data/states_1.yaml index f5e63003f7a..8b1e1866a8c 100644 --- a/cl/beacon/handler/test_data/states_1.yaml +++ b/cl/beacon/handler/test_data/states_1.yaml @@ -1,2 +1,2 @@ -finality_checkpoint: {"data":{"finalized_checkpoint":{"epoch":"1","root":"0xde46b0f2ed5e72f0cec20246403b14c963ec995d7c2825f3532b0460c09d5693"},"current_justified_checkpoint":{"epoch":"3","root":"0xa6e47f164b1a3ca30ea3b2144bd14711de442f51e5b634750a12a1734e24c987"},"previous_justified_checkpoint":{"epoch":"2","root":"0x4c3ee7969e485696669498a88c17f70e6999c40603e2f4338869004392069063"}},"finalized":false,"version":2,"execution_optimistic":false} +finality_checkpoint: {"data":{"finalized":{"epoch":"1","root":"0xde46b0f2ed5e72f0cec20246403b14c963ec995d7c2825f3532b0460c09d5693"},"current_justified":{"epoch":"3","root":"0xa6e47f164b1a3ca30ea3b2144bd14711de442f51e5b634750a12a1734e24c987"},"previous_justified":{"epoch":"2","root":"0x4c3ee7969e485696669498a88c17f70e6999c40603e2f4338869004392069063"}},"finalized":false,"version":2,"execution_optimistic":false} randao: {"data":{"randao":"0xdeec617717272914bfd73e02ca1da113a83cf4cf33cd4939486509e2da4ccf4e"},"finalized":false,"execution_optimistic":false}