From be592e02feaeab0f26d7674a1d87cad20fe8d30b Mon Sep 17 00:00:00 2001 From: Agnish Ghosh Date: Thu, 31 Oct 2024 11:53:29 +0530 Subject: [PATCH] fix vc api --- .../spec/eth2_apis/rest_beacon_calls.nim | 33 ++++++++++++++++++- beacon_chain/validator_client/api.nim | 18 ++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim b/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim index 20122f63a..2d4865d32 100644 --- a/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_beacon_calls.nim @@ -26,7 +26,8 @@ type bellatrix.SignedBeaconBlock | capella.SignedBeaconBlock | DenebSignedBlockContents | - ElectraSignedBlockContents + ElectraSignedBlockContents | + FuluSignedBlockContents proc getGenesis*(): RestResponse[GetGenesisResponse] {. rest, endpoint: "/eth/v1/beacon/genesis", @@ -163,6 +164,11 @@ proc publishBlock*(body: ElectraSignedBlockContents): RestPlainResponse {. meth: MethodPost.} ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock +proc publishBlock*(body: FuluSignedBlockContents): RestPlainResponse {. + rest, endpoint: "/eth/v1/beacon/blocks", + meth: MethodPost.} + ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock + proc publishSszBlock*( client: RestClientRef, blck: ForkySignedBeaconBlock @@ -217,6 +223,14 @@ proc publishBlockV2( meth: MethodPost.} ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlockV2 +proc publishBlockV2( + broadcast_validation: Option[BroadcastValidationType], + body: FuluSignedBlockContents +): RestPlainResponse {.rest, endpoint: "/eth/v2/beacon/blocks", + meth: MethodPost.} + ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlockV2 + + proc publishBlockV2*( client: RestClientRef, broadcast_validation: Option[BroadcastValidationType], @@ -229,6 +243,8 @@ proc publishBlockV2*( ConsensusFork.Deneb.toString() elif blck is ElectraSignedBlockContents: ConsensusFork.Electra.toString() + elif blck is FuluSignedBlockContents: + ConsensusFork.Fulu.toString() else: typeof(blck).kind.toString() client.publishBlockV2( @@ -248,6 +264,8 @@ proc publishSszBlockV2*( ConsensusFork.Deneb.toString() elif blck is ElectraSignedBlockContents: ConsensusFork.Electra.toString() + elif blck is FuluSignedBlockContents: + ConsensusFork.Fulu.toString() else: typeof(blck).kind.toString() client.publishBlockV2( @@ -290,6 +308,12 @@ proc publishBlindedBlock*(body: electra_mev.SignedBlindedBeaconBlock): meth: MethodPost.} ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock +proc publishBlindedBlock*(body: fulu_mev.SignedBlindedBeaconBlock): + RestPlainResponse {. + rest, endpoint: "/eth/v1/beacon/blinded_blocks", + meth: MethodPost.} + ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock + proc publishSszBlindedBlock*( client: RestClientRef, blck: ForkySignedBeaconBlock @@ -344,6 +368,13 @@ proc publishBlindedBlockV2*( meth: MethodPost.} ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock +proc publishBlindedBlockV2*( + broadcast_validation: Option[BroadcastValidationType], + body: fulu_mev.SignedBlindedBeaconBlock +): RestPlainResponse {.rest, endpoint: "/eth/v2/beacon/blinded_blocks", + meth: MethodPost.} + ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock + proc publishBlindedBlockV2*( client: RestClientRef, broadcast_validation: Option[BroadcastValidationType], diff --git a/beacon_chain/validator_client/api.nim b/beacon_chain/validator_client/api.nim index 05fe14e55..a2ab31e0b 100644 --- a/beacon_chain/validator_client/api.nim +++ b/beacon_chain/validator_client/api.nim @@ -2511,6 +2511,8 @@ proc publishBlockV2*( publishBlockV2(it, some(broadcast_validation), data.denebData) of ConsensusFork.Electra: publishBlockV2(it, some(broadcast_validation), data.electraData) + of ConsensusFork.Fulu: + publishBlockV2(it, some(broadcast_validation), data.fuluData) do: if apiResponse.isErr(): handleCommunicationError() @@ -2562,6 +2564,8 @@ proc publishBlockV2*( publishBlockV2(it, some(broadcast_validation), data.denebData) of ConsensusFork.Electra: publishBlockV2(it, some(broadcast_validation), data.electraData) + of ConsensusFork.Fulu: + publishBlockV2(it, some(broadcast_validation), data.fuluData) do: if apiResponse.isErr(): @@ -2627,6 +2631,8 @@ proc publishBlock*( publishBlock(it, data.denebData) of ConsensusFork.Electra: publishBlock(it, data.electraData) + of ConsensusFork.Fulu: + publishBlock(it, data.fuluData) do: if apiResponse.isErr(): handleCommunicationError() @@ -2675,6 +2681,8 @@ proc publishBlock*( publishBlock(it, data.denebData) of ConsensusFork.Electra: publishBlock(it, data.electraData) + of ConsensusFork.Fulu: + publishBlock(it, data.fuluData) do: if apiResponse.isErr(): @@ -2841,6 +2849,9 @@ proc publishBlindedBlockV2*( of ConsensusFork.Electra: publishBlindedBlockV2(it, some(broadcast_validation), data.electraData) + of ConsensusFork.Fulu: + publishBlindedBlockV2(it, some(broadcast_validation), + data.fuluData) do: if apiResponse.isErr(): handleCommunicationError() @@ -2897,6 +2908,9 @@ proc publishBlindedBlockV2*( of ConsensusFork.Electra: publishBlindedBlockV2(it, some(broadcast_validation), data.electraData) + of ConsensusFork.Fulu: + publishBlindedBlockV2(it, some(broadcast_validation), + data.fuluData) do: if apiResponse.isErr(): handleCommunicationError() @@ -2960,6 +2974,8 @@ proc publishBlindedBlock*( publishBlindedBlock(it, data.denebData) of ConsensusFork.Electra: publishBlindedBlock(it, data.electraData) + of ConsensusFork.Fulu: + publishBlindedBlock(it, data.fuluData) do: if apiResponse.isErr(): handleCommunicationError() @@ -3007,6 +3023,8 @@ proc publishBlindedBlock*( publishBlindedBlock(it, data.denebData) of ConsensusFork.Electra: publishBlindedBlock(it, data.electraData) + of ConsensusFork.Fulu: + publishBlindedBlock(it, data.fuluData) do: if apiResponse.isErr(): handleCommunicationError()