@@ -33,8 +33,22 @@ import (
33
33
type PayloadVersion byte
34
34
35
35
var (
36
+ // PayloadV1 is the identifier of ExecutionPayloadV1 introduced in paris fork.
37
+ // https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#executionpayloadv1
36
38
PayloadV1 PayloadVersion = 0x1
39
+
40
+ // PayloadV2 is the identifier of ExecutionPayloadV2 introduced in shanghai fork.
41
+ //
42
+ // https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#executionpayloadv2
43
+ // ExecutionPayloadV2 has the syntax of ExecutionPayloadV1 and appends a
44
+ // single field: withdrawals.
37
45
PayloadV2 PayloadVersion = 0x2
46
+
47
+ // PayloadV3 is the identifier of ExecutionPayloadV3 introduced in cancun fork.
48
+ //
49
+ // https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md#executionpayloadv3
50
+ // ExecutionPayloadV3 has the syntax of ExecutionPayloadV2 and appends the new
51
+ // fields: blobGasUsed and excessBlobGas.
38
52
PayloadV3 PayloadVersion = 0x3
39
53
)
40
54
@@ -106,13 +120,18 @@ type StatelessPayloadStatusV1 struct {
106
120
type ExecutionPayloadEnvelope struct {
107
121
ExecutionPayload * ExecutableData `json:"executionPayload" gencodec:"required"`
108
122
BlockValue * big.Int `json:"blockValue" gencodec:"required"`
109
- BlobsBundle * BlobsBundleV1 `json:"blobsBundle"`
123
+ BlobsBundle * BlobsBundle `json:"blobsBundle"`
110
124
Requests [][]byte `json:"executionRequests"`
111
125
Override bool `json:"shouldOverrideBuilder"`
112
126
Witness * hexutil.Bytes `json:"witness,omitempty"`
113
127
}
114
128
115
- type BlobsBundleV1 struct {
129
+ // BlobsBundle includes the marshalled sidecar data. Note this structure is
130
+ // shared by BlobsBundleV1 and BlobsBundleV2 for the sake of simplicity.
131
+ //
132
+ // - BlobsBundleV1: proofs contain exactly len(blobs) kzg proofs.
133
+ // - BlobsBundleV2: proofs contain exactly CELLS_PER_EXT_BLOB * len(blobs) cell proofs.
134
+ type BlobsBundle struct {
116
135
Commitments []hexutil.Bytes `json:"commitments"`
117
136
Proofs []hexutil.Bytes `json:"proofs"`
118
137
Blobs []hexutil.Bytes `json:"blobs"`
@@ -125,7 +144,7 @@ type BlobAndProofV1 struct {
125
144
126
145
type BlobAndProofV2 struct {
127
146
Blob hexutil.Bytes `json:"blob"`
128
- CellProofs []hexutil.Bytes `json:"proofs"`
147
+ CellProofs []hexutil.Bytes `json:"proofs"` // proofs MUST contain exactly CELLS_PER_EXT_BLOB cell proofs.
129
148
}
130
149
131
150
// JSON type overrides for ExecutionPayloadEnvelope.
@@ -327,18 +346,27 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
327
346
}
328
347
329
348
// Add blobs.
330
- bundle := BlobsBundleV1 {
349
+ bundle := BlobsBundle {
331
350
Commitments : make ([]hexutil.Bytes , 0 ),
332
351
Blobs : make ([]hexutil.Bytes , 0 ),
333
352
Proofs : make ([]hexutil.Bytes , 0 ),
334
353
}
335
354
for _ , sidecar := range sidecars {
336
355
for j := range sidecar .Blobs {
337
- bundle .Blobs = append (bundle .Blobs , hexutil . Bytes ( sidecar .Blobs [j ][:]) )
338
- bundle .Commitments = append (bundle .Commitments , hexutil . Bytes ( sidecar .Commitments [j ][:]) )
356
+ bundle .Blobs = append (bundle .Blobs , sidecar .Blobs [j ][:])
357
+ bundle .Commitments = append (bundle .Commitments , sidecar .Commitments [j ][:])
339
358
}
359
+ // - Before the Osaka fork, only version-0 blob transactions should be packed,
360
+ // with the proof length equal to len(blobs).
361
+ //
362
+ // - After the Osaka fork, only version-1 blob transactions should be packed,
363
+ // with the proof length equal to CELLS_PER_EXT_BLOB * len(blobs).
364
+ //
365
+ // Ideally, length validation should be performed based on the bundle version.
366
+ // In practice, this is unnecessary because blob transaction filtering is
367
+ // already done during payload construction.
340
368
for _ , proof := range sidecar .Proofs {
341
- bundle .Proofs = append (bundle .Proofs , hexutil . Bytes ( proof [:]) )
369
+ bundle .Proofs = append (bundle .Proofs , proof [:])
342
370
}
343
371
}
344
372
0 commit comments