Skip to content

fix: Add RequestHash header field for SDK compatibility #1133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -131,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
Expand Down Expand Up @@ -314,6 +319,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
}

Expand Down Expand Up @@ -377,6 +402,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.
Expand Down
28 changes: 26 additions & 2 deletions core/types/gen_header_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Loading