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

8424 attestations handler #8456

Merged
merged 36 commits into from
Aug 27, 2024

Conversation

mehdi-aouadi
Copy link
Contributor

@mehdi-aouadi mehdi-aouadi commented Jul 19, 2024

PR Description

Add PostAttestationsRequest for the new post attestations V2 API (remote validator api handler).
The new sendSignedAttesationsV2 isn't used in production code yet. A hidden option will be added in a separate PR in order to activate it progressively (same way for block v3).
The sendSignedAttestations is deprecated and should be progressively replaced by the new sendSignedAttestationsV2.

Fixed Issue(s)

#8424

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.

@mehdi-aouadi mehdi-aouadi self-assigned this Jul 19, 2024
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

  • Added sendSignedAttestationsV2 method in beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java
  • Introduced new tests for sendSignedAttestationsV2 in beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java
  • Added JSON schema for /eth/v2/beacon/pool/attestations in data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/paths/_eth_v2_beacon_pool_attestations.json
  • Introduced PostAttestationV2 endpoint in data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/PostAttestationV2.java
  • Added unit tests for PostAttestationV2 in data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/PostAttestationV2Test.java

26 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Added sendSignedAttestationsV2 method with SpecMilestone parameter in validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java
  • Removed unnecessary imports and redundant method in validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/PostAttestationsRequestTest.java
  • Introduced sendSignedAttestationsV2 method with SpecMilestone parameter in validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Added sendSignedAttestationsV2 method with SpecMilestone parameter in beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java
  • Added new test cases for sendSignedAttestationsV2 in beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java
  • Introduced PostAttestationsV2IntegrationTest for new API endpoint in data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/beacon/PostAttestationsV2IntegrationTest.java
  • Updated JsonTypeDefinitionBeaconRestApi.java to use PostAttestationsV2
  • Renamed and updated PostAttestationsV2.java and PostAttestationsV2Test.java to reflect new API endpoint

17 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings

this.spec = spec;
}

public Optional<PostDataFailureResponse> postAttestations(
Copy link

Choose a reason for hiding this comment

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

Logic: Ensure that the attestations list is not empty before proceeding with the request.

Map.of(HEADER_CONSENSUS_VERSION, specMilestone.name().toLowerCase(Locale.ROOT)),
attestations,
attestationsListTypeDefinition,
new ResponseHandler<>());
Copy link

Choose a reason for hiding this comment

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

Logic: Handle potential exceptions from the postJson method to avoid unhandled runtime errors.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Introduced sendSignedAttestationsV2 method in beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java
  • Deprecated sendSignedAttestations method in beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java
  • sendSignedAttestationsV2 processes attestations individually and converts results into a list of errors
  • New method not yet used in production; activation via hidden option in a future PR

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Added new REST API endpoint /eth/v2/beacon/pool/attestations in data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/PostAttestationsV2.java
  • Updated tests for new API in data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/PostAttestationsV2Test.java
  • Introduced submitAttestationsV2 method in data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java
  • Ensure SpecMilestone header is correctly provided and handled
  • Thorough testing recommended for new API and method

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Updated data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/beacon/PostAttestationsV2IntegrationTest.java to use sendSignedAttestationsV2
  • Tests now cover successful posts, partial failures, and missing/incorrect consensus headers

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@mehdi-aouadi mehdi-aouadi force-pushed the 8424-attestations-handler branch 2 times, most recently from 74dde7e to 1eab44e Compare August 1, 2024 10:14
@mehdi-aouadi mehdi-aouadi marked this pull request as draft August 1, 2024 19:52
@mehdi-aouadi mehdi-aouadi marked this pull request as ready for review August 2, 2024 14:58
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces the new PostAttestation V2 API to handle Electra attestations, along with several updates and refactors across the codebase to support this new functionality.

  • Added data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/PostAttestationsV2.java to handle POST requests for submitting attestation objects.
  • Updated data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java to include a new method createAggregateAndMetaData for the new API.
  • Introduced data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v2/beacon/PostAttestationsV2Test.java to cover various scenarios for the new handler.
  • Modified validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/PostAttestationsRequest.java to support the new API endpoint.
  • Updated data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v2/beacon/PostAttestationsV2IntegrationTest.java to use sendSignedAttestationsV2 and cover successful posts, partial failures, and missing/incorrect consensus headers.

207 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings

@mehdi-aouadi mehdi-aouadi force-pushed the 8424-attestations-handler branch 2 times, most recently from 9a5aa5d to b0ae3eb Compare August 14, 2024 13:15
public SendSignedAttestationsRequest(
final HttpUrl baseEndpoint, final OkHttpClient okHttpClient) {
super(baseEndpoint, okHttpClient);
}

public List<SubmitDataError> submit(final List<Attestation> attestations) {
public List<SubmitDataError> submit(final List<Attestation> attestations, final Spec spec) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm lost on prs they all look so similar, but in teh same way i think maybe spec in the constructor is probably better....

Copy link
Contributor Author

@mehdi-aouadi mehdi-aouadi Aug 22, 2024

Choose a reason for hiding this comment

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

It's the same pattern but different APIs that's why they look the same :)
Anyway I refactored the request to pass the spec in the constructor. Left the attestations to the submit method though because we have to check if the list is empty and get the first element to get the slot and the milestone otherwise...

Copy link
Contributor

@tbenr tbenr left a comment

Choose a reason for hiding this comment

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

generally ok, need to clarify one thing

Copy link
Contributor

@tbenr tbenr left a comment

Choose a reason for hiding this comment

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

LGTM

@mehdi-aouadi mehdi-aouadi merged commit e4c973f into Consensys:master Aug 27, 2024
17 checks passed
@mehdi-aouadi mehdi-aouadi deleted the 8424-attestations-handler branch August 27, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants