Skip to content

Commit ca8555a

Browse files
committed
rm Electra builder API support
1 parent b887a1a commit ca8555a

15 files changed

+91
-402
lines changed

AllTests-mainnet.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,15 +831,15 @@ AllTests-mainnet
831831
```
832832
## MEV calls serialization/deserialization and behavior test suite
833833
```diff
834-
+ /eth/v1/builder/blinded_blocks [json/json] test OK
835-
+ /eth/v1/builder/blinded_blocks [json/ssz] test OK
836-
+ /eth/v1/builder/blinded_blocks [ssz/json] test OK
837-
+ /eth/v1/builder/blinded_blocks [ssz/ssz] test OK
838834
+ /eth/v1/builder/header [json] test OK
839835
+ /eth/v1/builder/header [ssz] test OK
840836
+ /eth/v1/builder/status test OK
841837
+ /eth/v1/builder/validators [json] test OK
842838
+ /eth/v1/builder/validators [ssz] test OK
839+
+ /eth/v2/builder/blinded_blocks [json/json] test OK
840+
+ /eth/v2/builder/blinded_blocks [json/ssz] test OK
841+
+ /eth/v2/builder/blinded_blocks [ssz/json] test OK
842+
+ /eth/v2/builder/blinded_blocks [ssz/ssz] test OK
843843
```
844844
## Message signatures
845845
```diff

beacon_chain/rpc/rest_beacon_api.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
11621162
debugGloasComment ""
11631163
return RestApiResponse.jsonError(
11641164
Http400, $consensusFork & " builder API unsupported")
1165-
elif consensusFork >= ConsensusFork.Electra:
1165+
elif consensusFork >= ConsensusFork.Fulu:
11661166
let
11671167
restBlock = decodeBodyJsonOrSsz(
11681168
consensusFork.SignedBlindedBeaconBlock, body).valueOr:

beacon_chain/rpc/rest_validator_api.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
416416
# produceBlockV3 won't work past Fulu.
417417
return RestApiResponse.jsonError(
418418
Http500, "Unsupported fork for block production: " & $consensusFork)
419-
elif consensusFork >= ConsensusFork.Electra:
419+
elif consensusFork >= ConsensusFork.Fulu:
420420
let
421421
message = (await node.makeMaybeBlindedBeaconBlockForHeadAndSlot(
422422
consensusFork, proposer, qrandao, qgraffiti, qhead, qslot,

beacon_chain/spec/eth2_apis/eth2_rest_json_serialization.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,7 @@ RestJson.useDefaultSerializationFor(
281281
electra.TrustedAttestation,
282282
electra_mev.BlindedBeaconBlock,
283283
electra_mev.BlindedBeaconBlockBody,
284-
electra_mev.BuilderBid,
285-
electra_mev.ExecutionPayloadAndBlobsBundle,
286284
electra_mev.SignedBlindedBeaconBlock,
287-
electra_mev.SignedBuilderBid,
288285
fulu.BeaconBlock,
289286
fulu.BeaconBlockBody,
290287
fulu.BeaconState,
@@ -1261,7 +1258,7 @@ proc readValue*(
12611258
ForkedMaybeBlindedBeaconBlock.init(
12621259
RestJson.decode(string(v.data), consensusFork.BlockContents)
12631260
)
1264-
elif consensusFork >= ConsensusFork.Electra:
1261+
elif consensusFork >= ConsensusFork.Fulu:
12651262
if v.execution_payload_blinded:
12661263
ForkedMaybeBlindedBeaconBlock.init(
12671264
RestJson.decode(string(v.data), consensusFork.BlindedBlockContents),

beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ type
7070
capella.SignedBeaconBlock |
7171
phase0.SignedBeaconBlock |
7272
DenebSignedBlockContents |
73+
deneb_mev.SignedBlindedBeaconBlock |
7374
ElectraSignedBlockContents |
7475
FuluSignedBlockContents |
7576
GloasSignedBlockContents |
7677
ForkedMaybeBlindedBeaconBlock |
77-
deneb_mev.SignedBlindedBeaconBlock |
7878
electra_mev.SignedBlindedBeaconBlock |
7979
fulu_mev.SignedBlindedBeaconBlock
8080

@@ -95,9 +95,7 @@ type
9595
seq[RestSyncCommitteeSelection]
9696

9797
MevDecodeTypes* =
98-
GetHeaderResponseElectra |
99-
GetHeaderResponseFulu |
100-
SubmitBlindedBlockResponseElectra
98+
GetHeaderResponseFulu
10199

102100
DecodeTypes* =
103101
DataEnclosedObject |
@@ -904,7 +902,7 @@ proc decodeBytes*[T: ProduceBlockResponseV3](
904902
debugGloasComment ""
905903
when consensusFork == ConsensusFork.Gloas:
906904
return err("gloas produceblockv3 not available yet")
907-
elif consensusFork >= ConsensusFork.Electra:
905+
elif consensusFork >= ConsensusFork.Fulu:
908906
if blinded:
909907
let contents =
910908
? readSszResBytes(consensusFork.BlindedBlockContents, value)

beacon_chain/spec/eth2_apis/rest_types.nim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,7 @@ type
560560
GetValidatorsLivenessResponse* = DataEnclosedObject[seq[RestLivenessItem]]
561561
SubmitBeaconCommitteeSelectionsResponse* = DataEnclosedObject[seq[RestBeaconCommitteeSelection]]
562562
SubmitSyncCommitteeSelectionsResponse* = DataEnclosedObject[seq[RestSyncCommitteeSelection]]
563-
564-
GetHeaderResponseElectra* = DataVersionEnclosedObject[electra_mev.SignedBuilderBid]
565563
GetHeaderResponseFulu* = DataVersionEnclosedObject[fulu_mev.SignedBuilderBid]
566-
SubmitBlindedBlockResponseElectra* = DataVersionEnclosedObject[electra_mev.ExecutionPayloadAndBlobsBundle]
567564

568565
RestNodeValidity* {.pure.} = enum
569566
valid = "VALID",

beacon_chain/spec/forks.nim

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -179,30 +179,24 @@ type
179179
gloas.ExecutionPayloadForSigning
180180

181181
ForkyBlindedBeaconBlock* =
182-
electra_mev.BlindedBeaconBlock |
183182
fulu_mev.BlindedBeaconBlock
184183

185184
SomeForkyBlindedBeaconBlock* =
186185
ForkyBlindedBeaconBlock |
187-
electra_mev.SigVerifiedBlindedBeaconBlock |
188186
fulu_mev.SigVerifiedBlindedBeaconBlock
189187

190188
SomeForkyBlindedBeaconBlockBody* =
191-
electra_mev.BlindedBeaconBlockBody |
192189
fulu_mev.BlindedBeaconBlockBody |
193-
electra_mev.SigVerifiedBlindedBeaconBlockBody |
194190
fulu_mev.SigVerifiedBlindedBeaconBlockBody
195191

196192
ForkyBuilderBid* =
197-
electra_mev.BuilderBid |
198193
fulu_mev.BuilderBid
199194

200195
ForkyBlobsBundle* =
201196
deneb.BlobsBundle |
202197
fulu.BlobsBundle
203198

204199
ForkySignedBuilderBid* =
205-
electra_mev.SignedBuilderBid |
206200
fulu_mev.SignedBuilderBid
207201

208202
ForkyBlockContents* =
@@ -269,7 +263,7 @@ type
269263
of ConsensusFork.Deneb:
270264
denebData*: deneb.BlockContents
271265
of ConsensusFork.Electra:
272-
electraData*: electra_mev.MaybeBlindedBeaconBlock
266+
electraData*: electra.BlockContents
273267
of ConsensusFork.Fulu:
274268
fuluData*: fulu_mev.MaybeBlindedBeaconBlock
275269
of ConsensusFork.Gloas:
@@ -478,10 +472,7 @@ template kind*(
478472
electra.TrustedSignedBeaconBlock |
479473
electra.AggregateAndProof |
480474
electra.SignedAggregateAndProof |
481-
electra_mev.BlindedBeaconBlock |
482-
electra_mev.SignedBlindedBeaconBlock |
483-
electra_mev.SignedBuilderBid |
484-
electra_mev.ExecutionPayloadAndBlobsBundle]): ConsensusFork =
475+
electra_mev.SignedBlindedBeaconBlock]): ConsensusFork =
485476
ConsensusFork.Electra
486477

487478
template kind*(
@@ -648,40 +639,30 @@ template ExecutionPayloadForSigning*(kind: static ConsensusFork): typedesc =
648639
template BlindedBeaconBlock*(kind: static ConsensusFork): auto =
649640
when kind == ConsensusFork.Fulu:
650641
fulu_mev.BlindedBeaconBlock
651-
elif kind == ConsensusFork.Electra:
652-
electra_mev.BlindedBeaconBlock
653642
else:
654643
{.error: "BlindedBeaconBlock unsupported in " & $kind.}
655644

656645
template MaybeBlindedBeaconBlock*(kind: static ConsensusFork): auto =
657646
when kind == ConsensusFork.Fulu:
658647
fulu_mev.MaybeBlindedBeaconBlock
659-
elif kind == ConsensusFork.Electra:
660-
electra_mev.MaybeBlindedBeaconBlock
661648
else:
662649
{.error: "MaybeBlindedBeaconBlock unsupported in " & $kind.}
663650

664651
template SignedBlindedBeaconBlock*(kind: static ConsensusFork): typedesc =
665652
when kind == ConsensusFork.Fulu:
666653
fulu_mev.SignedBlindedBeaconBlock
667-
elif kind == ConsensusFork.Electra:
668-
electra_mev.SignedBlindedBeaconBlock
669654
else:
670655
{.error: "SignedBlindedBeaconBlock unsupported in " & $kind.}
671656

672657
template BuilderBid*(kind: static ConsensusFork): typedesc =
673658
when kind == ConsensusFork.Fulu:
674659
fulu_mev.BuilderBid
675-
elif kind == ConsensusFork.Electra:
676-
electra_mev.BuilderBid
677660
else:
678661
{.error: "BuilderBid unsupported in " & $kind.}
679662

680663
template SignedBuilderBid*(kind: static ConsensusFork): typedesc =
681664
when kind == ConsensusFork.Fulu:
682665
fulu_mev.SignedBuilderBid
683-
elif kind == ConsensusFork.Electra:
684-
electra_mev.SignedBuilderBid
685666
else:
686667
{.error: "SignedBuilderBid unsupported in " & $kind.}
687668

@@ -1392,17 +1373,11 @@ template withForkyMaybeBlindedBlck*(
13921373
template forkyMaybeBlindedBlck: untyped {.inject, used.} = d.data
13931374
body
13941375
of ConsensusFork.Electra:
1395-
const consensusFork {.inject, used.} = ConsensusFork.Electra
1396-
template d: untyped = b.electraData
1397-
case d.isBlinded:
1398-
of true:
1399-
const isBlinded {.inject, used.} = true
1400-
template forkyMaybeBlindedBlck: untyped {.inject, used.} = d.blindedData
1401-
body
1402-
of false:
1403-
const isBlinded {.inject, used.} = false
1404-
template forkyMaybeBlindedBlck: untyped {.inject, used.} = d.data
1405-
body
1376+
const
1377+
consensusFork {.inject, used.} = ConsensusFork.Electra
1378+
isBlinded {.inject, used.} = false
1379+
template forkyMaybeBlindedBlck: untyped {.inject, used.} = b.electraData
1380+
body
14061381
of ConsensusFork.Deneb:
14071382
const
14081383
consensusFork {.inject, used.} = ConsensusFork.Deneb
@@ -1920,9 +1895,7 @@ template init*(T: type ForkedMaybeBlindedBeaconBlock,
19201895
evalue: Opt[UInt256], cvalue: Opt[UInt256]): T =
19211896
ForkedMaybeBlindedBeaconBlock(
19221897
kind: ConsensusFork.Electra,
1923-
electraData: electra_mev.MaybeBlindedBeaconBlock(
1924-
isBlinded: false,
1925-
data: blck),
1898+
electraData: blck,
19261899
consensusValue: cvalue,
19271900
executionValue: evalue)
19281901

beacon_chain/spec/mev/electra_mev.nim

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,6 @@ from ".."/datatypes/deneb import BlobsBundle, ExecutionPayloadHeader, KzgCommitm
1616
from ".."/eth2_merkleization import hash_tree_root
1717

1818
type
19-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#validatorregistrationv1
20-
ValidatorRegistrationV1* = object
21-
fee_recipient*: ExecutionAddress
22-
gas_limit*: uint64
23-
timestamp*: uint64
24-
pubkey*: ValidatorPubKey
25-
26-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#signedvalidatorregistrationv1
27-
SignedValidatorRegistrationV1* = object
28-
message*: ValidatorRegistrationV1
29-
signature*: ValidatorSig
30-
31-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/electra/builder.md#builderbid
32-
BuilderBid* = object
33-
header*: deneb.ExecutionPayloadHeader
34-
blob_kzg_commitments*: KzgCommitments
35-
execution_requests*: ExecutionRequests # [New in Electra]
36-
value*: UInt256
37-
pubkey*: ValidatorPubKey
38-
39-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#signedbuilderbid
40-
SignedBuilderBid* = object
41-
message*: BuilderBid
42-
signature*: ValidatorSig
43-
4419
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/electra/builder.md#blindedbeaconblockbody
4520
BlindedBeaconBlockBody* = object
4621
randao_reveal*: ValidatorSig
@@ -86,42 +61,11 @@ type
8661
state_root*: Eth2Digest
8762
body*: BlindedBeaconBlockBody # [Modified in Deneb]
8863

89-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#blindedbeaconblock
90-
SigVerifiedBlindedBeaconBlock* = object
91-
slot*: Slot
92-
proposer_index*: uint64
93-
parent_root*: Eth2Digest
94-
state_root*: Eth2Digest
95-
body*: SigVerifiedBlindedBeaconBlockBody # [Modified in Deneb]
96-
97-
MaybeBlindedBeaconBlock* = object
98-
case isBlinded*: bool
99-
of false:
100-
data*: electra.BlockContents
101-
of true:
102-
blindedData*: BlindedBeaconBlock
103-
10464
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#signedblindedbeaconblock
10565
SignedBlindedBeaconBlock* = object
10666
message*: BlindedBeaconBlock
10767
signature*: ValidatorSig
10868

109-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/deneb/builder.md#executionpayloadandblobsbundle
110-
ExecutionPayloadAndBlobsBundle* = object
111-
execution_payload*: deneb.ExecutionPayload
112-
blobs_bundle*: BlobsBundle
113-
114-
const
115-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#domain-types
116-
DOMAIN_APPLICATION_BUILDER* = DomainType([byte 0x00, 0x00, 0x00, 0x01])
117-
118-
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/validator.md#constants
119-
EPOCHS_PER_VALIDATOR_REGISTRATION_SUBMISSION* = 1
120-
121-
# Spec is 1 second, but mev-boost indirection can induce delay when the relay
122-
# itself has already consumed the entire second.
123-
BUILDER_PROPOSAL_DELAY_TOLERANCE* = 1500.milliseconds
124-
12569
func shortLog*(v: BlindedBeaconBlock): auto =
12670
(
12771
slot: shortLog(v.slot),
@@ -150,7 +94,3 @@ func shortLog*(v: SignedBlindedBeaconBlock): auto =
15094
blck: shortLog(v.message),
15195
signature: shortLog(v.signature)
15296
)
153-
154-
template asSigVerified*(
155-
x: BlindedBeaconBlock): SigVerifiedBlindedBeaconBlock =
156-
isomorphicCast[SigVerifiedBlindedBeaconBlock](x)

beacon_chain/spec/mev/fulu_mev.nim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ from ".."/datatypes/electra import
1818
from ".."/eth2_merkleization import hash_tree_root
1919

2020
type
21+
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#validatorregistrationv1
22+
ValidatorRegistrationV1* = object
23+
fee_recipient*: ExecutionAddress
24+
gas_limit*: uint64
25+
timestamp*: uint64
26+
pubkey*: ValidatorPubKey
27+
28+
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#signedvalidatorregistrationv1
29+
SignedValidatorRegistrationV1* = object
30+
message*: ValidatorRegistrationV1
31+
signature*: ValidatorSig
32+
2133
BuilderBid* = object
2234
header*: deneb.ExecutionPayloadHeader
2335
blob_kzg_commitments*: KzgCommitments
@@ -94,6 +106,17 @@ type
94106
message*: BlindedBeaconBlock
95107
signature*: ValidatorSig
96108

109+
const
110+
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/builder.md#domain-types
111+
DOMAIN_APPLICATION_BUILDER* = DomainType([byte 0x00, 0x00, 0x00, 0x01])
112+
113+
# https://github.com/ethereum/builder-specs/blob/v0.5.0/specs/bellatrix/validator.md#constants
114+
EPOCHS_PER_VALIDATOR_REGISTRATION_SUBMISSION* = 1
115+
116+
# Spec is 1 second, but mev-boost indirection can induce delay when the relay
117+
# itself has already consumed the entire second.
118+
BUILDER_PROPOSAL_DELAY_TOLERANCE* = 1500.milliseconds
119+
97120
func shortLog*(v: BlindedBeaconBlock): auto =
98121
(
99122
slot: shortLog(v.slot),

beacon_chain/spec/mev/rest_mev_calls.nim

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
66
# at your option. This file may not be copied, modified, or distributed except according to those terms.
77

8-
{.push raises: [].}
8+
{.push raises: [], gcsafe.}
99

1010
import
1111
chronos, presto/client,
@@ -47,32 +47,13 @@ proc getHeader*(
4747
restAcceptType = "application/octet-stream,application/json;q=0.5",
4848
)
4949

50-
proc submitBlindedBlockPlain*(
51-
body: electra_mev.SignedBlindedBeaconBlock
52-
): RestPlainResponse {.
53-
rest, endpoint: "/eth/v1/builder/blinded_blocks",
54-
meth: MethodPost, connection: {Dedicated, Close}.}
55-
## https://github.com/ethereum/builder-specs/blob/v0.5.0/apis/builder/blinded_blocks.yaml
56-
5750
proc submitBlindedBlockV2Plain*(
5851
body: fulu_mev.SignedBlindedBeaconBlock
5952
): RestPlainResponse {.
6053
rest, endpoint: "/eth/v2/builder/blinded_blocks",
6154
meth: MethodPost, connection: {Dedicated, Close}.}
6255
## https://github.com/ethereum/builder-specs/blob/ae1d97d080a12bfb7ca248b58fb1fc6b10aed02e/apis/builder/blinded_blocks_v2.yaml
6356

64-
proc submitBlindedBlock*(
65-
client: RestClientRef,
66-
body: electra_mev.SignedBlindedBeaconBlock
67-
): Future[RestPlainResponse] {.
68-
async: (raises: [CancelledError, RestEncodingError, RestDnsResolveError,
69-
RestCommunicationError], raw: true).} =
70-
client.submitBlindedBlockPlain(
71-
body,
72-
restAcceptType = "application/octet-stream,application/json;q=0.5",
73-
extraHeaders = @[("eth-consensus-version", toString(typeof(body).kind))]
74-
)
75-
7657
proc submitBlindedBlock*(
7758
client: RestClientRef,
7859
body: fulu_mev.SignedBlindedBeaconBlock

0 commit comments

Comments
 (0)