diff --git a/beacon_chain/rpc/rest_constants.nim b/beacon_chain/rpc/rest_constants.nim index e9186401f5..2a462b4b41 100644 --- a/beacon_chain/rpc/rest_constants.nim +++ b/beacon_chain/rpc/rest_constants.nim @@ -87,9 +87,6 @@ const "Invalid attestation data root value" UnableToGetAggregatedAttestationError* = "Unable to retrieve an aggregated attestation" - DeprecatedGetAggregatedAttestation*: string = - "Deprecated endpoint /eth/v1/validator/aggregate_attestation. Replaced with" & - "https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestationV2" MissingRandaoRevealValue* = "Missing `randao_reveal` value" InvalidRandaoRevealValue* = diff --git a/beacon_chain/rpc/rest_validator_api.nim b/beacon_chain/rpc/rest_validator_api.nim index f0d8414bd5..087db88536 100644 --- a/beacon_chain/rpc/rest_validator_api.nim +++ b/beacon_chain/rpc/rest_validator_api.nim @@ -771,46 +771,6 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) = makeAttestationData(epochRef, qhead.atSlot(qslot), qindex) RestApiResponse.jsonResponse(adata) - # https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestation - router.api2(MethodGet, "/eth/v1/validator/aggregate_attestation") do ( - attestation_data_root: Option[Eth2Digest], - slot: Option[Slot]) -> RestApiResponse: - - let attestation = - block: - let qslot = - block: - if slot.isNone(): - return RestApiResponse.jsonError(Http400, MissingSlotValueError) - let res = slot.get() - if res.isErr(): - return RestApiResponse.jsonError(Http400, InvalidSlotValueError, - $res.error()) - res.get() - let qroot = - block: - if attestation_data_root.isNone(): - return RestApiResponse.jsonError(Http400, - MissingAttestationDataRootValueError) - let res = attestation_data_root.get() - if res.isErr(): - return RestApiResponse.jsonError(Http400, - InvalidAttestationDataRootValueError, $res.error()) - res.get() - let res = - block: - let contextFork = node.dag.cfg.consensusForkAtEpoch(epoch(qslot)) - if contextFork >= ConsensusFork.Electra: - return RestApiResponse.jsonError(Http410, - DeprecatedGetAggregatedAttestation) - - node.attestationPool[].getAggregatedAttestation(qslot, qroot) - if res.isNone(): - return RestApiResponse.jsonError(Http400, - UnableToGetAggregatedAttestationError) - res.get() - RestApiResponse.jsonResponse(attestation) - # https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestationV2 router.api2(MethodGet, "/eth/v2/validator/aggregate_attestation") do ( attestation_data_root: Option[Eth2Digest], @@ -852,11 +812,10 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) = let res = block: let contextFork = node.dag.cfg.consensusForkAtEpoch(epoch(qslot)) - if contextFork < ConsensusFork.Electra: - return RestApiResponse.jsonError(Http400, - UnableToGetAggregatedAttestationError) - - node.attestationPool[].getElectraAggregatedAttestation(qslot, root, committee_index) + if contextFork >= ConsensusFork.Electra: + node.attestationPool[].getElectraAggregatedAttestation(qslot, root, committee_index) + else: + node.attestationPool[].getAggregatedAttestation(qslot, root) if res.isNone(): return RestApiResponse.jsonError(Http400, UnableToGetAggregatedAttestationError) diff --git a/beacon_chain/spec/eth2_apis/rest_validator_calls.nim b/beacon_chain/spec/eth2_apis/rest_validator_calls.nim index 0672615d21..9704f42656 100644 --- a/beacon_chain/spec/eth2_apis/rest_validator_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_validator_calls.nim @@ -63,14 +63,6 @@ proc produceAttestationDataPlain*( meth: MethodGet.} ## https://ethereum.github.io/beacon-APIs/#/Validator/produceAttestationData -proc getAggregatedAttestationPlain*( - attestation_data_root: Eth2Digest, - slot: Slot - ): RestPlainResponse {. - rest, endpoint: "/eth/v1/validator/aggregate_attestation" - meth: MethodGet.} - ## https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestation - proc getAggregatedAttestationPlainV2*( attestation_data_root: Eth2Digest, slot: Slot, @@ -78,7 +70,7 @@ proc getAggregatedAttestationPlainV2*( ): RestPlainResponse {. rest, endpoint: "/eth/v2/validator/aggregate_attestation" meth: MethodGet.} - ## https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestation + ## https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getPoolAttestationsV2 proc publishAggregateAndProofs*( body: seq[phase0.SignedAggregateAndProof] diff --git a/beacon_chain/validator_client/api.nim b/beacon_chain/validator_client/api.nim index d02254aae2..4f2c589394 100644 --- a/beacon_chain/validator_client/api.nim +++ b/beacon_chain/validator_client/api.nim @@ -1662,6 +1662,7 @@ proc submitPoolSyncCommitteeSignature*( proc getAggregatedAttestation*( vc: ValidatorClientRef, slot: Slot, + committee_index: CommitteeIndex, root: Eth2Digest, strategy: ApiStrategyKind ): Future[phase0.Attestation] {.async.} = @@ -1678,7 +1679,7 @@ proc getAggregatedAttestation*( OneThirdDuration, ViableNodeStatus, {BeaconNodeRole.AggregatedData}, - getAggregatedAttestationPlain(it, root, slot)): + getAggregatedAttestationPlainV2(it, root, slot, committee_index)): if apiResponse.isErr(): handleCommunicationError() ApiResponse[GetAggregatedAttestationResponse].err(apiResponse.error) @@ -1718,7 +1719,7 @@ proc getAggregatedAttestation*( OneThirdDuration, ViableNodeStatus, {BeaconNodeRole.AggregatedData}, - getAggregatedAttestationPlain(it, root, slot), + getAggregatedAttestationPlainV2(it, root, slot, committee_index), getAggregatedAttestationDataScore(itresponse)): if apiResponse.isErr(): handleCommunicationError() @@ -1764,7 +1765,7 @@ proc getAggregatedAttestation*( OneThirdDuration, ViableNodeStatus, {BeaconNodeRole.AggregatedData}, - getAggregatedAttestationPlain(it, root, slot)): + getAggregatedAttestationPlainV2(it, root, slot, committee_index)): if apiResponse.isErr(): handleCommunicationError() false diff --git a/beacon_chain/validator_client/attestation_service.nim b/beacon_chain/validator_client/attestation_service.nim index 33feb85dd4..fd3be30d59 100644 --- a/beacon_chain/validator_client/attestation_service.nim +++ b/beacon_chain/validator_client/attestation_service.nim @@ -281,6 +281,7 @@ proc produceAndPublishAggregates(service: AttestationServiceRef, let aggAttestation = try: await vc.getAggregatedAttestation(slot, attestationRoot, + committeeIndex, ApiStrategyKind.Best) except ValidatorApiError as exc: warn "Unable to get aggregated attestation data", slot = slot, diff --git a/ncli/resttest-rules.json b/ncli/resttest-rules.json index 071a8c38bf..a8560c342d 100644 --- a/ncli/resttest-rules.json +++ b/ncli/resttest-rules.json @@ -4477,52 +4477,6 @@ "body": [{"operator": "jstructcmpns", "value": {"code": 400, "message": ""}}] } }, - { - "topics": ["validator", "aggregate_attestation"], - "request": { - "url": "/eth/v1/validator/aggregate_attestation", - "headers": {"Accept": "application/json"} - }, - "response": { - "status": {"operator": "equals", "value": "400"}, - "headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}], - "body": [{"operator": "jstructcmpns", "value": {"code": 400, "message": ""}}] - } - }, - { - "topics": ["validator", "aggregate_attestation"], - "request": { - "url": "/eth/v1/validator/aggregate_attestation?slot=0", - "headers": {"Accept": "application/json"} - }, - "response": { - "status": {"operator": "equals", "value": "400"}, - "headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}], - "body": [{"operator": "jstructcmpns", "value": {"code": 400, "message": ""}}] - } - }, - { - "topics": ["validator", "aggregate_attestation"], - "request": { - "url": "/eth/v1/validator/aggregate_attestation?slot=&attestation_data_root=", - "headers": {"Accept": "application/json"} - }, - "response": { - "status": {"operator": "equals", "value": "400"}, - "headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}], - "body": [{"operator": "jstructcmpns", "value": {"code": 400, "message": ""}}] - } - }, - { - "topics": ["validator", "aggregate_attestation"], - "request": { - "url": "/eth/v1/validator/aggregate_attestation?slot=0&attestation_data_root=0x0000000000000000000000000000000000000000000000000000000000000000", - "headers": {"Accept": "application/json"} - }, - "response": { - "status": {"operator": "oneof", "value": ["400", "200"]} - } - }, { "topics": ["validator", "aggregate_attestation"], "request": {