Skip to content

Commit cd8bfc0

Browse files
committed
further cleanups and clarifications to fulu builder api
1 parent 3d609f5 commit cd8bfc0

File tree

9 files changed

+55
-13
lines changed

9 files changed

+55
-13
lines changed

beacon_chain/el/engine_api_conversions.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ func asConsensusTypeFulu*(
233233
# The `mapIt` calls below are necessary only because we use different distinct
234234
# types for KZG commitments and Blobs in the `web3` and the `deneb` spec types.
235235
# Both are defined as `array[N, byte]` under the hood.
236-
blobsBundle: deneb.BlobsBundle(
236+
blobsBundle: fulu.BlobsBundleV2(
237237
commitments: KzgCommitments.init(
238238
payload.blobsBundle.commitments.mapIt(
239239
kzg_abi.KzgCommitment(bytes: it.data))),
240-
proofs: KzgProofs.init(
240+
proofs: KzgProofsV2.init(
241241
payload.blobsBundle.proofs.mapIt(
242242
kzg_abi.KzgProof(bytes: it.data))),
243243
blobs: Blobs.init(

beacon_chain/spec/datatypes/deneb.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ type
108108
excess_blob_gas*: uint64 # [New in Deneb]
109109

110110
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/deneb/validator.md#blobsbundle
111+
# https://github.com/ethereum/builder-specs/blob/ae1d97d080a12bfb7ca248b58fb1fc6b10aed02e/specs/fulu/builder.md#blobsbundle
111112
KzgProofs* = List[KzgProof, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
112113
Blobs* = List[Blob, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
113114
BlobRoots* = List[Eth2Digest, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]

beacon_chain/spec/datatypes/fulu.nim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ type
123123
column_index*: ColumnIndex
124124
row_index*: RowIndex
125125

126+
# https://github.com/ethereum/builder-specs/blob/ae1d97d080a12bfb7ca248b58fb1fc6b10aed02e/specs/fulu/builder.md#blobsbundle
127+
KzgProofsV2* = List[KzgProof, Limit FIELD_ELEMENTS_PER_EXT_BLOB * MAX_BLOB_COMMITMENTS_PER_BLOCK]
128+
129+
# https://github.com/ethereum/builder-specs/blob/ae1d97d080a12bfb7ca248b58fb1fc6b10aed02e/specs/fulu/builder.md#blobsbundle
130+
BlobsBundleV2* = object
131+
commitments*: KzgCommitments
132+
proofs*: KzgProofsV2
133+
blobs*: Blobs
134+
126135
# Not in spec, defined in order to compute custody subnets
127136
CgcBits* = BitArray[DATA_COLUMN_SIDECAR_SUBNET_COUNT]
128137

@@ -164,7 +173,7 @@ type
164173
ExecutionPayloadForSigning* = object
165174
executionPayload*: ExecutionPayload
166175
blockValue*: Wei
167-
blobsBundle*: BlobsBundle
176+
blobsBundle*: BlobsBundleV2 # [New in Fulu]
168177
executionRequests*: seq[seq[byte]]
169178

170179
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/deneb/beacon-chain.md#executionpayloadheader
@@ -606,7 +615,7 @@ type
606615

607616
BlockContents* = object
608617
`block`*: BeaconBlock
609-
kzg_proofs*: KzgProofs
618+
kzg_proofs*: KzgProofsV2
610619
blobs*: Blobs
611620

612621
func shortLog*(v: DataColumnSidecar): auto =

beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ RestJson.useDefaultSerializationFor(
270270
fulu_mev.BlindedBeaconBlock,
271271
fulu_mev.BlindedBeaconBlockBody,
272272
fulu_mev.BuilderBid,
273+
fulu_mev.ExecutionPayloadAndBlobsBundle,
273274
fulu_mev.SignedBlindedBeaconBlock,
274275
fulu_mev.SignedBuilderBid,
275276
phase0.AggregateAndProof,

beacon_chain/spec/eth2_apis/rest_types.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ type
550550
GetHeaderResponseElectra* = DataVersionEnclosedObject[electra_mev.SignedBuilderBid]
551551
GetHeaderResponseFulu* = DataVersionEnclosedObject[fulu_mev.SignedBuilderBid]
552552
SubmitBlindedBlockResponseElectra* = DataVersionEnclosedObject[electra_mev.ExecutionPayloadAndBlobsBundle]
553+
SubmitBlindedBlockResponseFulu* = DataVersionEnclosedObject[fulu_mev.ExecutionPayloadAndBlobsBundle]
553554

554555
RestNodeValidity* {.pure.} = enum
555556
valid = "VALID",

beacon_chain/spec/forks.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ template kind*(
489489
fulu.MsgTrustedSignedBeaconBlock |
490490
fulu.TrustedSignedBeaconBlock |
491491
fulu_mev.SignedBlindedBeaconBlock |
492-
fulu_mev.SignedBuilderBid]): ConsensusFork =
492+
fulu_mev.SignedBuilderBid |
493+
fulu_mev.ExecutionPayloadAndBlobsBundle]): ConsensusFork =
493494
ConsensusFork.Fulu
494495

495496
template BeaconState*(kind: static ConsensusFork): auto =

beacon_chain/spec/mev/fulu_mev.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ from stew/byteutils import to0xHex
1313
from ".."/datatypes/phase0 import AttesterSlashing
1414
from ".."/datatypes/capella import SignedBLSToExecutionChange
1515
from ".."/datatypes/deneb import BlobsBundle, KzgCommitments
16+
from ".."/datatypes/fulu import BlobsBundleV2
1617
from ".."/datatypes/electra import
1718
Attestation, AttesterSlashing, ExecutionRequests
1819
from ".."/eth2_merkleization import hash_tree_root
@@ -69,11 +70,17 @@ type
6970
message*: BlindedBeaconBlock
7071
signature*: ValidatorSig
7172

73+
# https://github.com/ethereum/builder-specs/blob/ae1d97d080a12bfb7ca248b58fb1fc6b10aed02e/specs/fulu/builder.md#executionpayloadandblobsbundle
74+
ExecutionPayloadAndBlobsBundle* = object
75+
execution_payload*: electra.ExecutionPayload
76+
blobs_bundle*: BlobsBundleV2 # [New in Fulu]
77+
7278
# Not spec, but suggested by spec
7379
BlindedExecutionPayloadAndBlobsBundle* = object
7480
execution_payload_header*: fulu.ExecutionPayloadHeader
7581
blob_kzg_commitments*: KzgCommitments # [New in Deneb]
7682

83+
7784
func shortLog*(v: BlindedBeaconBlock): auto =
7885
(
7986
slot: shortLog(v.slot),

beacon_chain/spec/state_transition.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ proc makeBeaconBlockWithRewards*(
570570
hash_tree_root(validator_changes.proposer_slashings),
571571
hash_tree_root(validator_changes.electra_attester_slashings),
572572
hash_tree_root(
573-
List[electra.Attestation, Limit MAX_ATTESTATIONS](
573+
List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA](
574574
attestations)),
575575
hash_tree_root(List[Deposit, Limit MAX_DEPOSITS](deposits)),
576576
hash_tree_root(validator_changes.voluntary_exits),

beacon_chain/validators/beacon_validators.nim

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ type
8181
executionPayloadValue*: Wei
8282
consensusBlockValue*: UInt256
8383
blobsBundle*: deneb.BlobsBundle
84+
blobsBundleV2*: fulu.BlobsBundleV2
8485

8586
BuilderBid[SBBB] = object
8687
blindedBlckPart*: SBBB
@@ -585,15 +586,24 @@ proc makeBeaconBlockForHeadAndSlot*(
585586
$error
586587

587588
if res.isOk:
589+
let val = res.get()
588590
ok(EngineBid(
589-
blck: res.get().blck,
591+
blck: val.blck,
590592
executionPayloadValue: payload.blockValue,
591-
consensusBlockValue: res.get().rewards.blockConsensusValue(),
592-
blobsBundle:
593-
when typeof(payload).kind >= ConsensusFork.Deneb:
593+
consensusBlockValue: val.rewards.blockConsensusValue(),
594+
blobsBundle: (
595+
when typeof(payload).kind >= ConsensusFork.Deneb and
596+
typeof(payload).kind < ConsensusFork.Fulu:
594597
payload.blobsBundle
595598
else:
596599
default(deneb.BlobsBundle)
600+
),
601+
blobsBundleV2: (
602+
when typeof(payload).kind >= ConsensusFork.Fulu:
603+
payload.blobsBundle
604+
else:
605+
default(fulu.BlobsBundleV2)
606+
)
597607
))
598608
else:
599609
err(res.error)
@@ -1236,7 +1246,7 @@ proc proposeBlockAux(
12361246
blobsOpt =
12371247
when consensusFork >= ConsensusFork.Deneb:
12381248
Opt.some(signedBlock.create_blob_sidecars(
1239-
engineBid.blobsBundle.proofs, engineBid.blobsBundle.blobs))
1249+
KzgProofs(engineBid.blobsBundle.proofs), engineBid.blobsBundle.blobs))
12401250
else:
12411251
Opt.none(seq[BlobSidecar])
12421252
newBlockRef = (
@@ -2043,15 +2053,27 @@ proc makeMaybeBlindedBeaconBlockForHeadAndSlotImpl[ResultType](
20432053
20442054
doAssert engineBid.blck.kind == consensusFork
20452055
template forkyBlck: untyped = engineBid.blck.forky(consensusFork)
2046-
when consensusFork >= ConsensusFork.Deneb:
2056+
when consensusFork >= ConsensusFork.Fulu:
2057+
doAssert engineBid.blobsBundleV2.commitments ==
2058+
forkyBlck.body.blob_kzg_commitments
2059+
ResultType.ok((
2060+
blck: consensusFork.MaybeBlindedBeaconBlock(
2061+
isBlinded: false,
2062+
data: consensusFork.BlockContents(
2063+
`block`: forkyBlck,
2064+
kzg_proofs: KzgProofsV2(engineBid.blobsBundleV2.proofs),
2065+
blobs: engineBid.blobsBundleV2.blobs)),
2066+
executionValue: Opt.some(engineBid.executionPayloadValue),
2067+
consensusValue: Opt.some(engineBid.consensusBlockValue)))
2068+
elif consensusFork >= ConsensusFork.Deneb:
20472069
doAssert engineBid.blobsBundle.commitments ==
20482070
forkyBlck.body.blob_kzg_commitments
20492071
ResultType.ok((
20502072
blck: consensusFork.MaybeBlindedBeaconBlock(
20512073
isBlinded: false,
20522074
data: consensusFork.BlockContents(
20532075
`block`: forkyBlck,
2054-
kzg_proofs: engineBid.blobsBundle.proofs,
2076+
kzg_proofs: KzgProofs(engineBid.blobsBundle.proofs),
20552077
blobs: engineBid.blobsBundle.blobs)),
20562078
executionValue: Opt.some(engineBid.executionPayloadValue),
20572079
consensusValue: Opt.some(engineBid.consensusBlockValue)))

0 commit comments

Comments
 (0)