@@ -188,11 +188,9 @@ proc handleDataSidecarRequest*[
188188 ](node, mediaType, block_id, indices, DataSidecarsType .maxLen.uint64 )
189189
190190proc installBeaconApiHandlers * (router: var RestRouter , node: BeaconNode ) =
191- # https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4881.md
192191 router.api2 (MethodGet , " /eth/v1/beacon/deposit_snapshot" ) do (
193192 ) -> RestApiResponse :
194- return RestApiResponse .jsonError (Http404 ,
195- NoFinalizedSnapshotAvailableError )
193+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
196194
197195 # https://ethereum.github.io/beacon-APIs/#/Beacon/getGenesis
198196 router.api2 (MethodGet , " /eth/v1/beacon/genesis" ) do () -> RestApiResponse :
@@ -1008,56 +1006,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
10081006 node.dag.isFinalized (bid)
10091007 )
10101008
1011- # https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock
10121009 router.api (MethodPost , " /eth/v1/beacon/blocks" ) do (
10131010 contentBody: Option [ContentBody ]) -> RestApiResponse :
1014- let res =
1015- block :
1016- if contentBody.isNone ():
1017- return RestApiResponse .jsonError (Http400 , EmptyRequestBodyError )
1018- let
1019- body = contentBody.get ()
1020- currentEpochFork =
1021- node.dag.cfg.consensusForkAtEpoch (node.currentSlot ().epoch ())
1022- rawVersion = request.headers.getString (" eth-consensus-version" )
1023-
1024- # The V1 endpoint doesn't require the version to be specified but the
1025- # only fork which works is the current gossip fork. Either it can use
1026- # and broadcast a block in that fork or that broadcast will not prove
1027- # useful anyway, so allow it to fail at the decoding stage.
1028- version =
1029- if rawVersion == " " :
1030- currentEpochFork.toString
1031- else :
1032- rawVersion
1033-
1034- let restBlock = decodeBody (
1035- RestPublishedSignedBlockContents , body, version).valueOr:
1036- return RestApiResponse .jsonError (error)
1037-
1038- withForkyBlck (restBlock):
1039- if restBlock.kind != node.dag.cfg.consensusForkAtEpoch (
1040- forkyBlck.message.slot.epoch):
1041- doAssert strictVerification notin node.dag.updateFlags
1042- return RestApiResponse .jsonError (Http400 , InvalidBlockObjectError )
1043-
1044- when consensusFork in [ConsensusFork .Deneb , ConsensusFork .Electra ]:
1045- await node.router.routeSignedBeaconBlock (
1046- forkyBlck, Opt .some (
1047- forkyBlck.create_blob_sidecars (kzg_proofs, blobs)),
1048- Opt .none (seq [fulu.DataColumnSidecar ]), checkValidator = true )
1049- else :
1050- await node.router.routeSignedBeaconBlock (
1051- forkyBlck, Opt .none (seq [BlobSidecar ]),
1052- Opt .none (seq [fulu.DataColumnSidecar ]), checkValidator = true )
1053-
1054- if res.isErr ():
1055- return RestApiResponse .jsonError (
1056- Http503 , BeaconNodeInSyncError , $ res.error)
1057- if res.get ().isNone ():
1058- return RestApiResponse .jsonError (Http202 , BlockValidationError )
1059-
1060- RestApiResponse .jsonMsgResponse (BlockValidationSuccess )
1011+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
10611012
10621013 # https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlockV2
10631014 router.api (MethodPost , " /eth/v2/beacon/blocks" ) do (
@@ -1169,96 +1120,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
11691120 else :
11701121 respondSszOrJson (toSignedBlindedBeaconBlock (forkyBlck), consensusFork)
11711122
1172- # https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
1173- # https://github.com/ethereum/beacon-APIs/blob/v2.4.0/apis/beacon/blocks/blinded_blocks.yaml
11741123 router.api (MethodPost , " /eth/v1/beacon/blinded_blocks" ) do (
11751124 contentBody: Option [ContentBody ]) -> RestApiResponse :
1176- # # Instructs the beacon node to use the components of the
1177- # # `SignedBlindedBeaconBlock` to construct and publish a
1178- # # `SignedBeaconBlock` by swapping out the transactions_root for the
1179- # # corresponding full list of transactions. The beacon node should
1180- # # broadcast a newly constructed `SignedBeaconBlock` to the beacon network,
1181- # # to be included in the beacon chain. The beacon node is not required to
1182- # # validate the signed `BeaconBlock`, and a successful response (20X) only
1183- # # indicates that the broadcast has been successful.
1184- if contentBody.isNone ():
1185- return RestApiResponse .jsonError (Http400 , EmptyRequestBodyError )
1186-
1187- let
1188- currentEpochFork =
1189- node.dag.cfg.consensusForkAtEpoch (node.currentSlot ().epoch ())
1190- rawVersion = request.headers.getString (" eth-consensus-version" )
1191- body = contentBody.get ()
1192-
1193- # The V1 endpoint doesn't require the version to be specified but the
1194- # only fork which works is the current gossip fork. Either it can use
1195- # and broadcast a block in that fork or that broadcast will not prove
1196- # useful anyway, so allow it to fail at the decoding stage.
1197- version =
1198- if rawVersion == " " :
1199- currentEpochFork.toString
1200- else :
1201- rawVersion
1202-
1203- if (body.contentType == OctetStreamMediaType ) and
1204- (currentEpochFork.toString != version):
1205- return RestApiResponse .jsonError (Http400 , BlockIncorrectFork )
1206-
1207- withConsensusFork (currentEpochFork):
1208- when consensusFork == ConsensusFork .Gloas :
1209- debugGloasComment " "
1210- return RestApiResponse .jsonError (
1211- Http400 , $ consensusFork & " builder API unsupported" )
1212- elif consensusFork >= ConsensusFork .Electra :
1213- let
1214- restBlock = decodeBodyJsonOrSsz (
1215- consensusFork.SignedBlindedBeaconBlock , body).valueOr:
1216- return RestApiResponse .jsonError (error)
1217- payloadBuilderClient = node.getPayloadBuilderClient (
1218- restBlock.message.proposer_index).valueOr:
1219- return RestApiResponse .jsonError (
1220- Http400 , " Unable to initialize payload builder client: " & $ error)
1221- res = await node.unblindAndRouteBlockMEV (
1222- payloadBuilderClient, restBlock)
1223-
1224- if res.isErr ():
1225- return RestApiResponse .jsonError (
1226- Http500 , InternalServerError , $ res.error)
1227- if res.get ().isNone ():
1228- return RestApiResponse .jsonError (Http202 , BlockValidationError )
1229-
1230- return RestApiResponse .jsonMsgResponse (BlockValidationSuccess )
1231- elif consensusFork >= ConsensusFork .Bellatrix :
1232- return RestApiResponse .jsonError (
1233- Http400 , $ consensusFork & " builder API unsupported" )
1234- else :
1235- # Pre-Bellatrix, this endpoint will accept a `SignedBeaconBlock`.
1236- #
1237- # This is mostly the same as /eth/v1/beacon/blocks for phase 0 and
1238- # altair.
1239- var
1240- restBlock = decodeBody (
1241- RestPublishedSignedBeaconBlock , body, version).valueOr:
1242- return RestApiResponse .jsonError (error)
1243- forked = ForkedSignedBeaconBlock (restBlock)
1244-
1245- if forked.kind != node.dag.cfg.consensusForkAtEpoch (
1246- getForkedBlockField (forked, slot).epoch):
1247- return RestApiResponse .jsonError (Http400 , InvalidBlockObjectError )
1248-
1249- let res = withBlck (forked):
1250- forkyBlck.root = hash_tree_root (forkyBlck.message)
1251- await node.router.routeSignedBeaconBlock (
1252- forkyBlck, Opt .none (seq [BlobSidecar ]),
1253- Opt .none (seq [fulu.DataColumnSidecar ]), checkValidator = true )
1254-
1255- if res.isErr ():
1256- return RestApiResponse .jsonError (
1257- Http503 , BeaconNodeInSyncError , $ res.error)
1258- elif res.get ().isNone ():
1259- return RestApiResponse .jsonError (Http202 , BlockValidationError )
1260-
1261- RestApiResponse .jsonMsgResponse (BlockValidationSuccess )
1125+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
12621126
12631127 # https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlockV2
12641128 router.api (MethodPost , " /eth/v2/beacon/blinded_blocks" ) do (
@@ -1410,24 +1274,10 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
14101274 node.dag.isFinalized (bid)
14111275 )
14121276
1413- # https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockAttestations
14141277 router.api2 (MethodGet ,
1415- " /eth/v1/beacon/blocks/{block_id}/attestations" ) do (
1278+ " /eth/v1/beacon/blocks/{block_id}/attestations" ) do (
14161279 block_id: BlockIdent ) -> RestApiResponse :
1417- let
1418- blockIdent = block_id.valueOr:
1419- return RestApiResponse .jsonError (Http400 , InvalidBlockIdValueError ,
1420- $ error)
1421- bdata = node.getForkedBlock (blockIdent).valueOr:
1422- return RestApiResponse .jsonError (Http404 , BlockNotFoundError )
1423-
1424- withBlck (bdata):
1425- let bid = BlockId (root: forkyBlck.root, slot: forkyBlck.message.slot)
1426- RestApiResponse .jsonResponseFinalized (
1427- forkyBlck.message.body.attestations.asSeq (),
1428- node.getBlockOptimistic (bdata),
1429- node.dag.isFinalized (bid)
1430- )
1280+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
14311281
14321282 # https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getBlockAttestationsV2
14331283 router.api2 (MethodGet ,
@@ -1448,33 +1298,10 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
14481298 node.dag.isFinalized (bid),
14491299 consensusFork, node.hasRestAllowedOrigin)
14501300
1451- # https://ethereum.github.io/beacon-APIs/#/Beacon/getPoolAttestations
14521301 router.api2 (MethodGet , " /eth/v1/beacon/pool/attestations" ) do (
14531302 slot: Option [Slot ],
14541303 committee_index: Option [CommitteeIndex ]) -> RestApiResponse :
1455- let vindex =
1456- if committee_index.isSome ():
1457- let rindex = committee_index.get ()
1458- if rindex.isErr ():
1459- return RestApiResponse .jsonError (Http400 ,
1460- InvalidCommitteeIndexValueError ,
1461- $ rindex.error)
1462- Opt .some (rindex.get ())
1463- else :
1464- Opt .none (CommitteeIndex )
1465- let vslot =
1466- if slot.isSome ():
1467- let rslot = slot.get ()
1468- if rslot.isErr ():
1469- return RestApiResponse .jsonError (Http400 , InvalidSlotValueError ,
1470- $ rslot.error)
1471- Opt .some (rslot.get ())
1472- else :
1473- Opt .none (Slot )
1474- var res: seq [phase0.Attestation ]
1475- for item in node.attestationPool[].attestations (vslot, vindex):
1476- res.add (item)
1477- RestApiResponse .jsonResponse (res)
1304+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
14781305
14791306 # https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getPoolAttestationsV2
14801307 router.api2 (MethodGet , " /eth/v2/beacon/pool/attestations" ) do (
@@ -1515,48 +1342,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
15151342 toSeq (node.attestationPool[].electraAttestations (vslot, vindex)),
15161343 consensusFork, node.hasRestAllowedOrigin)
15171344
1518- # https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolAttestations
15191345 router.api2 (MethodPost , " /eth/v1/beacon/pool/attestations" ) do (
15201346 contentBody: Option [ContentBody ]) -> RestApiResponse :
1521- let attestations =
1522- block :
1523- if contentBody.isNone ():
1524- return RestApiResponse .jsonError (Http400 , EmptyRequestBodyError )
1525- let dres = decodeBody (seq [phase0.Attestation ], contentBody.get ())
1526- if dres.isErr ():
1527- return RestApiResponse .jsonError (Http400 ,
1528- InvalidAttestationObjectError ,
1529- $ dres.error)
1530- dres.get ()
1531-
1532- # Since our validation logic supports batch processing, we will submit all
1533- # attestations for validation.
1534- let pending =
1535- mapIt (attestations, node.router.routeAttestation (it))
1536- let failures =
1537- block :
1538- var res: seq [RestIndexedErrorMessageItem ]
1539- await allFutures (pending)
1540- for index, future in pending:
1541- if future.completed ():
1542- let fres = future.value ()
1543- if fres.isErr ():
1544- let failure = RestIndexedErrorMessageItem (index: index,
1545- message: $ fres.error)
1546- res.add (failure)
1547- elif future.failed () or future.cancelled ():
1548- # This is unexpected failure, so we log the error message.
1549- let exc = future.error ()
1550- let failure = RestIndexedErrorMessageItem (index: index,
1551- message: $ exc.msg)
1552- res.add (failure)
1553- res
1554-
1555- if len (failures) > 0 :
1556- RestApiResponse .jsonErrorList (Http400 , AttestationValidationError ,
1557- failures)
1558- else :
1559- RestApiResponse .jsonMsgResponse (AttestationValidationSuccess )
1347+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
15601348
15611349 # https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/submitPoolAttestationsV2
15621350 router.api2 (MethodPost , " /eth/v2/beacon/pool/attestations" ) do (
@@ -1614,31 +1402,13 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
16141402 else :
16151403 RestApiResponse .jsonMsgResponse (AttestationValidationSuccess )
16161404
1617- # https://ethereum.github.io/beacon-APIs/#/Beacon/getPoolAttesterSlashings
16181405 router.api2 (MethodGet , " /eth/v1/beacon/pool/attester_slashings" ) do (
16191406 ) -> RestApiResponse :
1620- RestApiResponse .jsonResponse (
1621- toSeq (node.validatorChangePool.phase0_attester_slashings))
1407+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
16221408
1623- # https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolAttesterSlashings
16241409 router.api (MethodPost , " /eth/v1/beacon/pool/attester_slashings" ) do (
16251410 contentBody: Option [ContentBody ]) -> RestApiResponse :
1626- let slashing =
1627- block :
1628- if contentBody.isNone ():
1629- return RestApiResponse .jsonError (Http400 , EmptyRequestBodyError )
1630- let dres = decodeBody (phase0.AttesterSlashing , contentBody.get ())
1631- if dres.isErr ():
1632- return RestApiResponse .jsonError (Http400 ,
1633- InvalidAttesterSlashingObjectError ,
1634- $ dres.error)
1635- dres.get ()
1636- let res = await node.router.routeAttesterSlashing (slashing)
1637- if res.isErr ():
1638- return RestApiResponse .jsonError (Http400 ,
1639- AttesterSlashingValidationError ,
1640- $ res.error)
1641- RestApiResponse .jsonMsgResponse (AttesterSlashingValidationSuccess )
1411+ RestApiResponse .jsonError (Http410 , DeprecatedRemovalElectra )
16421412
16431413 # https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getPoolAttesterSlashingsV2
16441414 router.api2 (MethodGet , " /eth/v2/beacon/pool/attester_slashings" ) do (
0 commit comments