Skip to content

Commit

Permalink
VC: Deprecate fallback path to produceBlockV2, use produceBlockV3 alw…
Browse files Browse the repository at this point in the history
…ays. (#6300)

* Remove fallback path to publishBlockV2(), use publishBlockV3().

* Update AllTests.md.
  • Loading branch information
cheatfate authored May 21, 2024
1 parent d7c5bc0 commit 34853ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 486 deletions.
2 changes: 1 addition & 1 deletion AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -1030,4 +1030,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9

---TOTAL---
OK: 686/691 Fail: 0/691 Skip: 5/691
OK: 687/692 Fail: 0/692 Skip: 5/692
109 changes: 0 additions & 109 deletions beacon_chain/validator_client/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2022,97 +2022,6 @@ proc publishContributionAndProofs*(
raise (ref ValidatorApiError)(
msg: "Failed to publish sync committee contribution", data: failures)

proc produceBlockV2*(
vc: ValidatorClientRef,
slot: Slot,
randao_reveal: ValidatorSig,
graffiti: GraffitiBytes,
strategy: ApiStrategyKind
): Future[ProduceBlockResponseV2] {.async.} =
const
RequestName = "produceBlockV2"

var failures: seq[ApiNodeFailure]

case strategy
of ApiStrategyKind.First, ApiStrategyKind.Best:
let res = vc.firstSuccessParallel(
RestPlainResponse,
ProduceBlockResponseV2,
SlotDuration,
ViableNodeStatus,
{BeaconNodeRole.BlockProposalData},
produceBlockV2Plain(it, slot, randao_reveal, graffiti)):
if apiResponse.isErr():
handleCommunicationError()
ApiResponse[ProduceBlockResponseV2].err(apiResponse.error)
else:
let response = apiResponse.get()
case response.status:
of 200:
let
version = response.headers.getString("eth-consensus-version")
res = decodeBytes(ProduceBlockResponseV2, response.data,
response.contentType, version)
if res.isErr():
handleUnexpectedData()
ApiResponse[ProduceBlockResponseV2].err($res.error)
else:
ApiResponse[ProduceBlockResponseV2].ok(res.get())
of 400:
handle400()
ApiResponse[ProduceBlockResponseV2].err(ResponseInvalidError)
of 500:
handle500()
ApiResponse[ProduceBlockResponseV2].err(ResponseInternalError)
of 503:
handle503()
ApiResponse[ProduceBlockResponseV2].err(ResponseNoSyncError)
else:
handleUnexpectedCode()
ApiResponse[ProduceBlockResponseV2].err(ResponseUnexpectedError)

if res.isErr():
raise (ref ValidatorApiError)(msg: res.error, data: failures)
return res.get()

of ApiStrategyKind.Priority:
vc.firstSuccessSequential(
RestPlainResponse,
SlotDuration,
ViableNodeStatus,
{BeaconNodeRole.BlockProposalData},
produceBlockV2Plain(it, slot, randao_reveal, graffiti)):
if apiResponse.isErr():
handleCommunicationError()
false
else:
let response = apiResponse.get()
case response.status:
of 200:
let
version = response.headers.getString("eth-consensus-version")
res = decodeBytes(ProduceBlockResponseV2, response.data,
response.contentType, version)
if res.isOk(): return res.get()
handleUnexpectedData()
false
of 400:
handle400()
false
of 500:
handle500()
false
of 503:
handle503()
false
else:
handleUnexpectedCode()
false

raise (ref ValidatorApiError)(
msg: "Failed to produce block", data: failures)

proc produceBlockV3*(
vc: ValidatorClientRef,
slot: Slot,
Expand Down Expand Up @@ -2161,24 +2070,15 @@ proc produceBlockV3*(
ApiResponse[ProduceBlockResponseV3].ok(res.get())
of 400:
handle400()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
ApiResponse[ProduceBlockResponseV3].err(ResponseInvalidError)
of 404:
# TODO (cheatfate): Remove this handler when produceBlockV2 support
# will be dropped.
handle400()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
ApiResponse[ProduceBlockResponseV3].err(ResponseInvalidError)
of 500:
handle500()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
ApiResponse[ProduceBlockResponseV3].err(ResponseInternalError)
of 503:
handle503()
ApiResponse[ProduceBlockResponseV3].err(ResponseNoSyncError)
else:
handleUnexpectedCode()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
ApiResponse[ProduceBlockResponseV3].err(ResponseUnexpectedError)

if res.isErr():
Expand Down Expand Up @@ -2216,24 +2116,15 @@ proc produceBlockV3*(
false
of 400:
handle400()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
false
of 404:
# TODO (cheatfate): Remove this handler when produceBlockV2 support
# will be dropped.
handle400()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
false
of 500:
handle500()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
false
of 503:
handle503()
false
else:
handleUnexpectedCode()
node.features.incl(RestBeaconNodeFeature.NoProduceBlockV3)
false

raise (ref ValidatorApiError)(
Expand Down
Loading

0 comments on commit 34853ca

Please sign in to comment.