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

[Mev Boost\Builder] validator registration beacon rest api (server side) #5545

Merged
merged 13 commits into from
May 24, 2022

Conversation

tbenr
Copy link
Contributor

@tbenr tbenr commented May 20, 2022

This draft PR introduces:

  • new SszList of SignedValidatorRegistration
  • rest API serving validator registration supporting json and ssz content types
  • moved ValidatorRegistration and related Ssz schemas to tech.pegasys.teku.spec.schemas.ApiSchemas

in next PR we migrate all Ssz API objects (non-milestone specific) to this new class

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

}

@SuppressWarnings("JavaCase")
public static class SignedValidatorRegistrationOpenApiSchema {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can put this in schema with the rest of the objects if you like, most of the time the annotated objects are outside of the class...


@JsonProperty("gas_limit")
@Schema(type = "string", format = "uint64", example = EXAMPLE_UINT64)
UInt64 gas_limit;
Copy link
Contributor

@rolfyone rolfyone May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of the time schema objects have these as public final, the reason for that is then you don't also need to do the @JsonProperty annotation (or you need a getter, one of the 3 options)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I defined them public only, so I don't have to define a constructor and I don't have to use @JsonProperty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be the most compact version :)

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good generally - I just think we're starting to create schema definitions that aren't actually tied to the spec version so probably need to break the rule of putting them into SchemaDefinitions. Previously all SSZ was used with the spec and so was inherently tied to the milestone but now we're just using it to define a REST API.

Comment on lines 393 to 395
if (spec.isMilestoneSupported(SpecMilestone.BELLATRIX)) {
addMigratedEndpoint(new PostRegisterValidator(dataProvider, spec, schemaCache));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we should always add the endpoint but then just return bad request if bellatrix isn't enabled. It's weird to get a 404 based on the network config.

@@ -288,6 +290,20 @@ public ExecutionPayloadHeader deserializeJsonExecutionPayloadHeader(
.jsonDeserialize(objectMapper.createParser(jsonFile));
}

public SszList<SignedValidatorRegistration> deserializeSignedValidatorRegistrations(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other deserialise methods here are detecting based on slot automatically so I'm not sure I'd add this here since it's not actually tied to a milestone - it's more tied to the API version.

I actually wonder if this is a case where the schema shouldn't be part of SchemaDefinitions. If we put it in SchemaDefinitions we can only change the API at milestone boundaries but I'm pretty sure that's not how the API is going to evolve. And if it wasn't in SchemaDefinitions we could make this API work regardless of whether Bellatrix is enabled (though it probably wouldn't have any actual effect until Bellatrix was active).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that was my feeling. Going to move them in API itself

@tbenr tbenr force-pushed the beacon_node_register_validator branch from 7f021d6 to ab0734c Compare May 23, 2022 08:11
@tbenr tbenr marked this pull request as ready for review May 23, 2022 08:23
@tbenr tbenr force-pushed the beacon_node_register_validator branch from e37c3fd to 5735ff6 Compare May 23, 2022 12:59
Comment on lines 102 to 107
try {
request.respondAsync(
validatorDataProvider
.registerValidators(request.getRequestBody())
.thenApply(AsyncApiResponse::respondOk));
} catch (final JsonProcessingException jsonProcessingException) {
request.respondError(SC_BAD_REQUEST, jsonProcessingException.getMessage());
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rolfyone is it correct my bad request handling in case of wrong input?

@tbenr tbenr force-pushed the beacon_node_register_validator branch from d54820e to 96e56a5 Compare May 24, 2022 10:00
Copy link
Contributor

@StefanBratanov StefanBratanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tbenr tbenr merged commit e45b717 into Consensys:master May 24, 2022
@tbenr tbenr deleted the beacon_node_register_validator branch May 24, 2022 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants