diff --git a/beacon/engine/gen_epe.go b/beacon/engine/gen_epe.go index cc66cef6cd3e..d3fa102cd31f 100644 --- a/beacon/engine/gen_epe.go +++ b/beacon/engine/gen_epe.go @@ -15,20 +15,23 @@ var _ = (*executionPayloadEnvelopeMarshaling)(nil) // MarshalJSON marshals as JSON. func (e ExecutionPayloadEnvelope) MarshalJSON() ([]byte, error) { type ExecutionPayloadEnvelope struct { - ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` - BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` + ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` + BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` + BlobsBundle *BlobsBundle `json:"blobsBundle" gencodec:"omitempty"` } var enc ExecutionPayloadEnvelope enc.ExecutionPayload = e.ExecutionPayload enc.BlockValue = (*hexutil.Big)(e.BlockValue) + enc.BlobsBundle = e.BlobsBundle return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. func (e *ExecutionPayloadEnvelope) UnmarshalJSON(input []byte) error { type ExecutionPayloadEnvelope struct { - ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` - BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` + ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` + BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` + BlobsBundle *BlobsBundle `json:"blobsBundle" gencodec:"omitempty"` } var dec ExecutionPayloadEnvelope if err := json.Unmarshal(input, &dec); err != nil { @@ -42,5 +45,8 @@ func (e *ExecutionPayloadEnvelope) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'blockValue' for ExecutionPayloadEnvelope") } e.BlockValue = (*big.Int)(dec.BlockValue) + if dec.BlobsBundle != nil { + e.BlobsBundle = dec.BlobsBundle + } return nil } diff --git a/beacon/engine/types.go b/beacon/engine/types.go index cc806d1a005c..176185a8f0a5 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -42,11 +42,10 @@ type payloadAttributesMarshaling struct { Timestamp hexutil.Uint64 } -// BlobsBundle holds the blobs of an execution payload, to be retrieved separately +// BlobsBundle holds the blobs of an execution payload type BlobsBundle struct { - BlockHash common.Hash `json:"blockHash" gencodec:"required"` - KZGs []types.KZGCommitment `json:"kzgs" gencodec:"required"` - Blobs []types.Blob `json:"blobs" gencodec:"required"` + KZGs []types.KZGCommitment `json:"kzgs" gencodec:"required"` + Blobs []types.Blob `json:"blobs" gencodec:"required"` } //go:generate go run github.com/fjl/gencodec -type ExecutableData -field-override executableDataMarshaling -out gen_ed.go @@ -87,8 +86,9 @@ type executableDataMarshaling struct { //go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go type ExecutionPayloadEnvelope struct { - ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` - BlockValue *big.Int `json:"blockValue" gencodec:"required"` + ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` + BlockValue *big.Int `json:"blockValue" gencodec:"required"` + BlobsBundle *BlobsBundle `json:"blobsBundle" gencodec:"omitempty"` } // JSON type overrides for ExecutionPayloadEnvelope. @@ -248,18 +248,16 @@ type ExecutionPayloadBodyV1 struct { } func BlockToBlobData(block *types.Block) (*BlobsBundle, error) { - blockHash := block.Hash() blobsBundle := &BlobsBundle{ - BlockHash: blockHash, - Blobs: []types.Blob{}, - KZGs: []types.KZGCommitment{}, + Blobs: []types.Blob{}, + KZGs: []types.KZGCommitment{}, } for i, tx := range block.Transactions() { if tx.Type() == types.BlobTxType { versionedHashes, kzgs, blobs, proofs := tx.BlobWrapData() if len(versionedHashes) != len(kzgs) || len(versionedHashes) != len(blobs) || len(blobs) != len(proofs) { return nil, fmt.Errorf("tx %d in block %s has inconsistent blobs (%d) / kzgs (%d)"+ - " / versioned hashes (%d) / proofs (%d)", i, blockHash, len(blobs), len(kzgs), len(versionedHashes), len(proofs)) + " / versioned hashes (%d) / proofs (%d)", i, block.Hash(), len(blobs), len(kzgs), len(versionedHashes), len(proofs)) } blobsBundle.Blobs = append(blobsBundle.Blobs, blobs...) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 49b3c37308f4..b89c6b492a41 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -92,7 +92,6 @@ var caps = []string{ "engine_newPayloadV3", "engine_getPayloadBodiesByHashV1", "engine_getPayloadBodiesByRangeV1", - "engine_getBlobsBundleV1", } type ConsensusAPI struct { @@ -424,12 +423,10 @@ func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID) (*engine.Executi // GetPayloadV3 returns a cached payload by id. func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.ExecutionPayloadEnvelope, error) { - return api.GetPayloadV2(payloadID) -} - -// GetBlobsBundleV1 returns a bundle of all blob and corresponding KZG commitments by payload id -func (api *ConsensusAPI) GetBlobsBundleV1(payloadID engine.PayloadID) (*engine.BlobsBundle, error) { - log.Trace("Engine API request received", "method", "GetBlobsBundle") + pl, err := api.GetPayloadV2(payloadID) + if err != nil { + return nil, err + } data, err := api.localBlocks.getBlobsBundle(payloadID) if err != nil { return nil, err @@ -437,7 +434,8 @@ func (api *ConsensusAPI) GetBlobsBundleV1(payloadID engine.PayloadID) (*engine.B if data == nil { return nil, engine.UnknownPayload } - return data, nil + pl.BlobsBundle = data + return pl, nil } // NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.