Skip to content

Commit

Permalink
remove V1 endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Miranda committed Sep 2, 2024
1 parent e104f34 commit 364b3bc
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 106 deletions.
3 changes: 0 additions & 3 deletions beacon_chain/rpc/rest_constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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* =
Expand Down
49 changes: 4 additions & 45 deletions beacon_chain/rpc/rest_validator_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 1 addition & 9 deletions beacon_chain/spec/eth2_apis/rest_validator_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,14 @@ 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,
committee_index: CommitteeIndex
): 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]
Expand Down
7 changes: 4 additions & 3 deletions beacon_chain/validator_client/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,7 @@ proc submitPoolSyncCommitteeSignature*(
proc getAggregatedAttestation*(
vc: ValidatorClientRef,
slot: Slot,
committee_index: CommitteeIndex,
root: Eth2Digest,
strategy: ApiStrategyKind
): Future[phase0.Attestation] {.async.} =
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions beacon_chain/validator_client/attestation_service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
46 changes: 0 additions & 46 deletions ncli/resttest-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 364b3bc

Please sign in to comment.