Add /eth/v2/validator/aggregate_attestation (#14481)

* add endpoint

* changelog

* fix tests

* fix endpoint

* remove useless broken code

* review + fix endpoint

* gaz

* fix aggregate selection proof test

* fixes

* new way of aggregating

* nit

* fix part of the tests

* fix tests

* cleanup

* fix AggSelectionProof test

* tests

* v1 tests

* v2 tests

* commiittee bits

---------

Co-authored-by: rkapka <radoslaw.kapka@gmail.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
Sammy Rosso
2024-11-07 14:34:18 +01:00
committed by GitHub
parent 847498c648
commit ff8240a04f
9 changed files with 484 additions and 321 deletions

View File

@@ -2,6 +2,7 @@ package beacon_api
import (
"context"
"encoding/json"
"net/url"
"strconv"
@@ -52,7 +53,12 @@ func (c *beaconApiValidatorClient) submitAggregateSelectionProof(
return nil, err
}
aggregatedAttestation, err := convertAttestationToProto(aggregateAttestationResponse.Data)
var attData *structs.Attestation
if err := json.Unmarshal(aggregateAttestationResponse.Data, &attData); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal aggregate attestation data")
}
aggregatedAttestation, err := convertAttestationToProto(attData)
if err != nil {
return nil, errors.Wrap(err, "failed to convert aggregate attestation json to proto")
}

View File

@@ -2,6 +2,7 @@ package beacon_api
import (
"context"
"encoding/json"
"errors"
"fmt"
"testing"
@@ -124,6 +125,9 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
test.attestationDataErr,
).Times(test.attestationDataCalled)
attestationJSON, err := json.Marshal(jsonifyAttestation(aggregateAttestation))
require.NoError(t, err)
// Call attestation data to get attestation data root to query aggregate attestation.
jsonRestHandler.EXPECT().Get(
gomock.Any(),
@@ -132,7 +136,7 @@ func TestSubmitAggregateSelectionProof(t *testing.T) {
).SetArg(
2,
structs.AggregateAttestationResponse{
Data: jsonifyAttestation(aggregateAttestation),
Data: attestationJSON,
},
).Return(
test.aggregateAttestationErr,