Skip to content

Commit 709725d

Browse files
committed
fix fulu builder api changes
1 parent 74289bf commit 709725d

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

beacon_chain/validators/beacon_validators.nim

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -920,14 +920,45 @@ proc getBuilderBid[
920920
proc proposeBlockMEV(
921921
node: BeaconNode, payloadBuilderClient: RestClientRef,
922922
blindedBlock:
923-
electra_mev.SignedBlindedBeaconBlock |
923+
electra_mev.SignedBlindedBeaconBlock):
924+
Future[Result[Opt[BlockRef], string]] {.async: (raises: [CancelledError]).} =
925+
let unblindedBlockRef = await node.unblindAndRouteBlockMEV(
926+
payloadBuilderClient, blindedBlock)
927+
if unblindedBlockRef.isOk and unblindedBlockRef.get.isSome:
928+
beacon_blocks_proposed.inc()
929+
return ok(unblindedBlockRef.get)
930+
else:
931+
# unblindedBlockRef.isOk and unblindedBlockRef.get.isNone indicates that
932+
# the block failed to validate and integrate into the DAG, which for the
933+
# purpose of this return value, is equivalent. It's used to drive Beacon
934+
# REST API output.
935+
#
936+
# https://collective.flashbots.net/t/post-mortem-april-3rd-2023-mev-boost-relay-incident-and-related-timing-issue/1540
937+
# has caused false positives, because
938+
# "A potential mitigation to this attack is to introduce a cutoff timing
939+
# into the proposer's slot whereafter this time (e.g. 3 seconds) the relay
940+
# will no longer return a block to the proposer. Relays began to roll out
941+
# this mitigation in the evening of April 3rd UTC time with a 2 second
942+
# cutoff, and notified other relays to do the same. After receiving
943+
# credible reports of honest validators missing their slots the suggested
944+
# timing cutoff was increased to 3 seconds."
945+
let errMsg =
946+
if unblindedBlockRef.isErr:
947+
unblindedBlockRef.error
948+
else:
949+
"Unblinded block not returned to proposer"
950+
err errMsg
951+
952+
proc proposeBlockMEV(
953+
node: BeaconNode, payloadBuilderClient: RestClientRef,
954+
blindedBlock:
924955
fulu_mev.SignedBlindedBeaconBlock):
925-
Future[Result[BlockRef, string]] {.async: (raises: [CancelledError]).} =
956+
Future[Result[Opt[BlockRef], string]] {.async: (raises: [CancelledError]).} =
926957
let unblindedBlockRef = await node.unblindAndRouteBlockMEV(
927958
payloadBuilderClient, blindedBlock)
928-
return if unblindedBlockRef.isOk and unblindedBlockRef.get.isSome:
959+
if unblindedBlockRef.isOk:
929960
beacon_blocks_proposed.inc()
930-
ok(unblindedBlockRef.get.get)
961+
return ok(Opt.none(BlockRef))
931962
else:
932963
# unblindedBlockRef.isOk and unblindedBlockRef.get.isNone indicates that
933964
# the block failed to validate and integrate into the DAG, which for the
@@ -1156,7 +1187,12 @@ proc proposeBlockAux(
11561187
maybeUnblindedBlock = await proposeBlockMEV(
11571188
node, payloadBuilderClient, blindedBlock)
11581189
1159-
return maybeUnblindedBlock.valueOr:
1190+
if maybeUnblindedBlock.isOk():
1191+
if maybeUnblindedBlock.get.isSome():
1192+
return maybeUnblindedBlock.get.get
1193+
else:
1194+
return head
1195+
else:
11601196
warn "Blinded block proposal incomplete",
11611197
head = shortLog(head), slot, validator_index,
11621198
validator = shortLog(validator),

0 commit comments

Comments
 (0)