From e247123644018d4a1f87e613a2559fe698fbd139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Wed, 5 Mar 2025 08:52:36 +0100 Subject: [PATCH 1/3] fix: Add RequestHash header field for SDK compatibility --- core/types/block.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ params/version.go | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/core/types/block.go b/core/types/block.go index 28b81244b490..5569b7ee3012 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -115,6 +115,9 @@ type Header struct { // Included for Ethereum compatibility in Scroll SDK ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"` + // RequestsHash was added by EIP-7685 and is ignored in legacy headers. + RequestsHash *common.Hash `json:"requestsHash" rlp:"optional"` + // Hacky: used internally to mark the header as requested by the downloader at the deliver queue. // Note: This is only used internally to mark a previously requested block, it is not included // in db, on the network wire protocol, or in RPC responses. @@ -314,6 +317,26 @@ func CopyHeader(h *Header) *Header { cpy.BlockSignature = make([]byte, len(h.BlockSignature)) copy(cpy.BlockSignature, h.BlockSignature) } + if h.WithdrawalsHash != nil { + cpy.WithdrawalsHash = new(common.Hash) + *cpy.WithdrawalsHash = *h.WithdrawalsHash + } + if h.ExcessBlobGas != nil { + cpy.ExcessBlobGas = new(uint64) + *cpy.ExcessBlobGas = *h.ExcessBlobGas + } + if h.BlobGasUsed != nil { + cpy.BlobGasUsed = new(uint64) + *cpy.BlobGasUsed = *h.BlobGasUsed + } + if h.ParentBeaconRoot != nil { + cpy.ParentBeaconRoot = new(common.Hash) + *cpy.ParentBeaconRoot = *h.ParentBeaconRoot + } + if h.RequestsHash != nil { + cpy.RequestsHash = new(common.Hash) + *cpy.RequestsHash = *h.RequestsHash + } return &cpy } @@ -377,6 +400,27 @@ func (b *Block) BaseFee() *big.Int { return new(big.Int).Set(b.header.BaseFee) } +func (b *Block) BeaconRoot() *common.Hash { return b.header.ParentBeaconRoot } +func (b *Block) RequestsHash() *common.Hash { return b.header.RequestsHash } + +func (b *Block) ExcessBlobGas() *uint64 { + var excessBlobGas *uint64 + if b.header.ExcessBlobGas != nil { + excessBlobGas = new(uint64) + *excessBlobGas = *b.header.ExcessBlobGas + } + return excessBlobGas +} + +func (b *Block) BlobGasUsed() *uint64 { + var blobGasUsed *uint64 + if b.header.BlobGasUsed != nil { + blobGasUsed = new(uint64) + *blobGasUsed = *b.header.BlobGasUsed + } + return blobGasUsed +} + func (b *Block) Header() *Header { return CopyHeader(b.header) } // Body returns the non-header content of the block. diff --git a/params/version.go b/params/version.go index 1e641d4b5722..6badac58f821 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 8 // Minor version component of the current release - VersionPatch = 20 // Patch version component of the current release + VersionPatch = 21 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) From f1e523a142b4d127f0c32db9425a599791fdb783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Wed, 5 Mar 2025 09:07:57 +0100 Subject: [PATCH 2/3] wip: disable new fields --- core/types/block.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/types/block.go b/core/types/block.go index 5569b7ee3012..fa87ab0f76ba 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -92,12 +92,12 @@ type Header struct { // BlockSignature was added by EuclidV2 to make Extra empty and is ignored during hashing. // This field is stored in db but not included in messages sent on the network wire protocol, // or in RPC responses. See also `PrepareForNetwork` and `PrepareFromNetwork`. - BlockSignature []byte `json:"-" rlp:"optional"` + BlockSignature []byte `json:"-" rlp:"-"` // IsEuclidV2 was added by EuclidV2 to make Extra empty and is ignored during hashing. // This field is stored in db but not included in messages sent on the network wire protocol, // or in RPC responses. See also `PrepareForNetwork` and `PrepareFromNetwork`. - IsEuclidV2 bool `json:"-" rlp:"optional"` + IsEuclidV2 bool `json:"-" rlp:"-"` // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. // Included for Ethereum compatibility in Scroll SDK From 57148478e950234b9204f1fc64ae9a9e53e021ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Wed, 5 Mar 2025 09:43:31 +0100 Subject: [PATCH 3/3] gencodec --- core/types/block.go | 2 ++ core/types/gen_header_json.go | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/types/block.go b/core/types/block.go index fa87ab0f76ba..76a4b26e261c 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -134,6 +134,8 @@ type headerMarshaling struct { Extra hexutil.Bytes BaseFee *hexutil.Big Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON + BlobGasUsed *hexutil.Uint64 + ExcessBlobGas *hexutil.Uint64 } // Hash returns the block hash of the header, which is simply the keccak256 hash of its diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index 0a7a5d9b9673..07f985175292 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -32,11 +32,15 @@ func (h Header) MarshalJSON() ([]byte, error) { MixDigest common.Hash `json:"mixHash"` Nonce BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` + BlockSignature []byte `json:"-" rlp:"-"` + IsEuclidV2 bool `json:"-" rlp:"-"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` - Hash common.Hash `json:"hash"` BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"` ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"` + RequestsHash *common.Hash `json:"requestsHash" rlp:"optional"` + Requested bool `json:"-" rlp:"-"` + Hash common.Hash `json:"hash"` } var enc Header enc.ParentHash = h.ParentHash @@ -55,11 +59,15 @@ func (h Header) MarshalJSON() ([]byte, error) { enc.MixDigest = h.MixDigest enc.Nonce = h.Nonce enc.BaseFee = (*hexutil.Big)(h.BaseFee) + enc.BlockSignature = h.BlockSignature + enc.IsEuclidV2 = h.IsEuclidV2 enc.WithdrawalsHash = h.WithdrawalsHash - enc.Hash = h.Hash() enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed) enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas) enc.ParentBeaconRoot = h.ParentBeaconRoot + enc.RequestsHash = h.RequestsHash + enc.Requested = h.Requested + enc.Hash = h.Hash() return json.Marshal(&enc) } @@ -82,10 +90,14 @@ func (h *Header) UnmarshalJSON(input []byte) error { MixDigest *common.Hash `json:"mixHash"` Nonce *BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` + BlockSignature []byte `json:"-" rlp:"-"` + IsEuclidV2 *bool `json:"-" rlp:"-"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"` ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"` + RequestsHash *common.Hash `json:"requestsHash" rlp:"optional"` + Requested *bool `json:"-" rlp:"-"` } var dec Header if err := json.Unmarshal(input, &dec); err != nil { @@ -151,6 +163,12 @@ func (h *Header) UnmarshalJSON(input []byte) error { if dec.BaseFee != nil { h.BaseFee = (*big.Int)(dec.BaseFee) } + if dec.BlockSignature != nil { + h.BlockSignature = dec.BlockSignature + } + if dec.IsEuclidV2 != nil { + h.IsEuclidV2 = *dec.IsEuclidV2 + } if dec.WithdrawalsHash != nil { h.WithdrawalsHash = dec.WithdrawalsHash } @@ -163,5 +181,11 @@ func (h *Header) UnmarshalJSON(input []byte) error { if dec.ParentBeaconRoot != nil { h.ParentBeaconRoot = dec.ParentBeaconRoot } + if dec.RequestsHash != nil { + h.RequestsHash = dec.RequestsHash + } + if dec.Requested != nil { + h.Requested = *dec.Requested + } return nil }