Skip to content

Commit 15504a6

Browse files
merge GetBlobsBundleV1 with GetPayloadV3 per spec update (#121)
1 parent 1ea2f96 commit 15504a6

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

beacon/engine/gen_epe.go

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon/engine/types.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ type payloadAttributesMarshaling struct {
4242
Timestamp hexutil.Uint64
4343
}
4444

45-
// BlobsBundle holds the blobs of an execution payload, to be retrieved separately
45+
// BlobsBundle holds the blobs of an execution payload
4646
type BlobsBundle struct {
47-
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
48-
KZGs []types.KZGCommitment `json:"kzgs" gencodec:"required"`
49-
Blobs []types.Blob `json:"blobs" gencodec:"required"`
47+
KZGs []types.KZGCommitment `json:"kzgs" gencodec:"required"`
48+
Blobs []types.Blob `json:"blobs" gencodec:"required"`
5049
}
5150

5251
//go:generate go run github.com/fjl/gencodec -type ExecutableData -field-override executableDataMarshaling -out gen_ed.go
@@ -87,8 +86,9 @@ type executableDataMarshaling struct {
8786
//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go
8887

8988
type ExecutionPayloadEnvelope struct {
90-
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
91-
BlockValue *big.Int `json:"blockValue" gencodec:"required"`
89+
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
90+
BlockValue *big.Int `json:"blockValue" gencodec:"required"`
91+
BlobsBundle *BlobsBundle `json:"blobsBundle" gencodec:"omitempty"`
9292
}
9393

9494
// JSON type overrides for ExecutionPayloadEnvelope.
@@ -248,18 +248,16 @@ type ExecutionPayloadBodyV1 struct {
248248
}
249249

250250
func BlockToBlobData(block *types.Block) (*BlobsBundle, error) {
251-
blockHash := block.Hash()
252251
blobsBundle := &BlobsBundle{
253-
BlockHash: blockHash,
254-
Blobs: []types.Blob{},
255-
KZGs: []types.KZGCommitment{},
252+
Blobs: []types.Blob{},
253+
KZGs: []types.KZGCommitment{},
256254
}
257255
for i, tx := range block.Transactions() {
258256
if tx.Type() == types.BlobTxType {
259257
versionedHashes, kzgs, blobs, proofs := tx.BlobWrapData()
260258
if len(versionedHashes) != len(kzgs) || len(versionedHashes) != len(blobs) || len(blobs) != len(proofs) {
261259
return nil, fmt.Errorf("tx %d in block %s has inconsistent blobs (%d) / kzgs (%d)"+
262-
" / versioned hashes (%d) / proofs (%d)", i, blockHash, len(blobs), len(kzgs), len(versionedHashes), len(proofs))
260+
" / versioned hashes (%d) / proofs (%d)", i, block.Hash(), len(blobs), len(kzgs), len(versionedHashes), len(proofs))
263261
}
264262

265263
blobsBundle.Blobs = append(blobsBundle.Blobs, blobs...)

eth/catalyst/api.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ var caps = []string{
9292
"engine_newPayloadV3",
9393
"engine_getPayloadBodiesByHashV1",
9494
"engine_getPayloadBodiesByRangeV1",
95-
"engine_getBlobsBundleV1",
9695
}
9796

9897
type ConsensusAPI struct {
@@ -424,20 +423,19 @@ func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID) (*engine.Executi
424423

425424
// GetPayloadV3 returns a cached payload by id.
426425
func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.ExecutionPayloadEnvelope, error) {
427-
return api.GetPayloadV2(payloadID)
428-
}
429-
430-
// GetBlobsBundleV1 returns a bundle of all blob and corresponding KZG commitments by payload id
431-
func (api *ConsensusAPI) GetBlobsBundleV1(payloadID engine.PayloadID) (*engine.BlobsBundle, error) {
432-
log.Trace("Engine API request received", "method", "GetBlobsBundle")
426+
pl, err := api.GetPayloadV2(payloadID)
427+
if err != nil {
428+
return nil, err
429+
}
433430
data, err := api.localBlocks.getBlobsBundle(payloadID)
434431
if err != nil {
435432
return nil, err
436433
}
437434
if data == nil {
438435
return nil, engine.UnknownPayload
439436
}
440-
return data, nil
437+
pl.BlobsBundle = data
438+
return pl, nil
441439
}
442440

443441
// NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.

0 commit comments

Comments
 (0)