Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/validatorapi: propose v1 and v2 returns 404 #3167

Merged
merged 1 commit into from
Jul 9, 2024
Merged
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
22 changes: 22 additions & 0 deletions core/validatorapi/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ func NewRouter(ctx context.Context, h Handler, eth2Cl eth2wrap.Client, isBuilder
Handler: getValidator(h),
Methods: []string{http.MethodGet},
},
{
Name: "propose_block",
Path: "/eth/v2/validator/blocks/{slot}",
Handler: respond404(),
Methods: []string{http.MethodGet},
},
{
Name: "propose_blinded_block",
Path: "/eth/v1/validator/blinded_blocks/{slot}",
Handler: respond404(),
Methods: []string{http.MethodGet},
},
{
Name: "propose_block_v3",
Path: "/eth/v3/validator/blocks/{slot}",
Expand Down Expand Up @@ -616,6 +628,16 @@ func submitContributionAndProofs(s eth2client.SyncCommitteeContributionsSubmitte
}
}

// respond404 returns a handler function always returning http.StatusNotFound
func respond404() handlerFunc {
return func(_ context.Context, _ map[string]string, _ url.Values, _ contentType, _ []byte) (any, http.Header, error) {
return nil, nil, apiError{
StatusCode: http.StatusNotFound,
Message: "NotFound",
}
}
}

// proposeBlockV3 returns a handler function returning an unsigned BeaconBlock or BlindedBeaconBlock.
func proposeBlockV3(p eth2client.ProposalProvider, builderEnabled core.BuilderEnabled) handlerFunc {
return func(ctx context.Context, params map[string]string, query url.Values, _ contentType, _ []byte) (any, http.Header, error) {
Expand Down
24 changes: 24 additions & 0 deletions core/validatorapi/router_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,30 @@ func TestRawRouter(t *testing.T) {

testRawRouter(t, handler, callback)
})

t.Run("propose_block returns 404", func(t *testing.T) {
handler := testHandler{}

callback := func(ctx context.Context, baseURL string) {
res, err := http.Post(baseURL+"/eth/v2/validator/blocks/123", "application/json", bytes.NewReader([]byte{}))
require.NoError(t, err)
require.Equal(t, http.StatusNotFound, res.StatusCode)
}

testRawRouter(t, handler, callback)
})

t.Run("propose_blinded_block returns 404", func(t *testing.T) {
handler := testHandler{}

callback := func(ctx context.Context, baseURL string) {
res, err := http.Post(baseURL+"/eth/v1/validator/blinded_blocks/123", "application/json", bytes.NewReader([]byte{}))
require.NoError(t, err)
require.Equal(t, http.StatusNotFound, res.StatusCode)
}

testRawRouter(t, handler, callback)
})
})

t.Run("submit bellatrix ssz proposal", func(t *testing.T) {
Expand Down
Loading