From 87b18ec83d49cf703d011dc53385e769ff460dfe Mon Sep 17 00:00:00 2001 From: 0xHansLee Date: Wed, 31 Jan 2024 22:08:22 +0900 Subject: [PATCH] fix: add blob related things to rpc header With dencun upgrade, blob related fields are added to block header. Accordingly, those should be added. Without this, the validation of block header when starting node is failed. --- op-service/sources/types.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/op-service/sources/types.go b/op-service/sources/types.go index 585109e10..25cea7ca5 100644 --- a/op-service/sources/types.go +++ b/op-service/sources/types.go @@ -136,7 +136,16 @@ type rpcHeader struct { BaseFee *hexutil.Big `json:"baseFeePerGas"` // WithdrawalsRoot was added by EIP-4895 and is ignored in legacy headers. - WithdrawalsRoot *common.Hash `json:"withdrawalsRoot"` + WithdrawalsRoot *common.Hash `json:"withdrawalsRoot,omitempty"` + + // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. + BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed,omitempty"` + + // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. + ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas,omitempty"` + + // ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers. + ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot,omitempty"` // untrusted info included by RPC, may have to be checked Hash common.Hash `json:"hash"` @@ -189,6 +198,10 @@ func (hdr *rpcHeader) createGethHeader() *types.Header { Nonce: hdr.Nonce, BaseFee: (*big.Int)(hdr.BaseFee), WithdrawalsHash: hdr.WithdrawalsRoot, + // Cancun + BlobGasUsed: (*uint64)(hdr.BlobGasUsed), + ExcessBlobGas: (*uint64)(hdr.ExcessBlobGas), + ParentBeaconRoot: hdr.ParentBeaconRoot, } }