From 7db96f1a38ce331c4a6139c40b0f553797388500 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 13 Mar 2024 23:28:53 +0100 Subject: [PATCH] beacon/types: set ParentBeaconRoot in payload conversion --- beacon/types/beacon_block.go | 4 ++-- beacon/types/exec_payload.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/beacon/types/beacon_block.go b/beacon/types/beacon_block.go index 1893ef652c..370152114a 100644 --- a/beacon/types/beacon_block.go +++ b/beacon/types/beacon_block.go @@ -84,9 +84,9 @@ func (b *BeaconBlock) Slot() uint64 { func (b *BeaconBlock) ExecutionPayload() (*types.Block, error) { switch obj := b.blockObj.(type) { case *capella.BeaconBlock: - return convertPayload(&obj.Body.ExecutionPayload) + return convertPayload(&obj.Body.ExecutionPayload, &obj.ParentRoot) case *deneb.BeaconBlock: - return convertPayload(&obj.Body.ExecutionPayload) + return convertPayload(&obj.Body.ExecutionPayload, &obj.ParentRoot) default: panic(fmt.Errorf("unsupported block type %T", b.blockObj)) } diff --git a/beacon/types/exec_payload.go b/beacon/types/exec_payload.go index 08bd4323ad..604de288d2 100644 --- a/beacon/types/exec_payload.go +++ b/beacon/types/exec_payload.go @@ -34,7 +34,7 @@ type payloadType interface { } // convertPayload converts a beacon chain execution payload to types.Block. -func convertPayload[T payloadType](payload T) (*types.Block, error) { +func convertPayload[T payloadType](payload T, parentRoot *zrntcommon.Root) (*types.Block, error) { var ( header types.Header transactions []*types.Transaction @@ -52,7 +52,7 @@ func convertPayload[T payloadType](payload T) (*types.Block, error) { withdrawals = convertWithdrawals(p.Withdrawals, &header) expectedHash = p.BlockHash case *deneb.ExecutionPayload: - convertDenebHeader(p, &header) + convertDenebHeader(p, common.Hash(*parentRoot), &header) transactions, err = convertTransactions(p.Transactions, &header) if err != nil { return nil, err @@ -92,7 +92,7 @@ func convertCapellaHeader(payload *capella.ExecutionPayload, h *types.Header) { h.BaseFee = (*uint256.Int)(&payload.BaseFeePerGas).ToBig() } -func convertDenebHeader(payload *deneb.ExecutionPayload, h *types.Header) { +func convertDenebHeader(payload *deneb.ExecutionPayload, parentRoot common.Hash, h *types.Header) { // note: h.TxHash is set in convertTransactions h.ParentHash = common.Hash(payload.ParentHash) h.UncleHash = types.EmptyUncleHash @@ -112,7 +112,7 @@ func convertDenebHeader(payload *deneb.ExecutionPayload, h *types.Header) { // new in deneb h.BlobGasUsed = (*uint64)(&payload.BlobGasUsed) h.ExcessBlobGas = (*uint64)(&payload.ExcessBlobGas) - // TODO: h.ParentBeaconRoot + h.ParentBeaconRoot = &parentRoot } func convertTransactions(list zrntcommon.PayloadTransactions, execHeader *types.Header) ([]*types.Transaction, error) {