fix(ethclient): support WithdrawalsHash in Scroll Go SDK (#354)

* added withdrawalsHash to header

* bump version

---------

Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
Richord 2023-06-05 09:52:46 -07:00 committed by GitHub
parent 9b943f3e0b
commit 1f167bd730
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 34 deletions

View file

@ -85,6 +85,10 @@ type Header struct {
// BaseFee was added by EIP-1559 and is ignored in legacy headers.
BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
// Included for Ethereum compatibility in Scroll SDK
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
}
// field type overrides for gencodec

View file

@ -32,6 +32,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
MixDigest common.Hash `json:"mixHash"`
Nonce BlockNonce `json:"nonce"`
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
Hash common.Hash `json:"hash"`
}
var enc Header
@ -51,6 +52,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
enc.MixDigest = h.MixDigest
enc.Nonce = h.Nonce
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
enc.WithdrawalsHash = h.WithdrawalsHash
enc.Hash = h.Hash()
return json.Marshal(&enc)
}
@ -74,6 +76,7 @@ func (h *Header) UnmarshalJSON(input []byte) error {
MixDigest *common.Hash `json:"mixHash"`
Nonce *BlockNonce `json:"nonce"`
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
}
var dec Header
if err := json.Unmarshal(input, &dec); err != nil {
@ -140,5 +143,8 @@ func (h *Header) UnmarshalJSON(input []byte) error {
if dec.BaseFee != nil {
h.BaseFee = (*big.Int)(dec.BaseFee)
}
if dec.WithdrawalsHash != nil {
h.WithdrawalsHash = dec.WithdrawalsHash
}
return nil
}

View file

@ -24,7 +24,7 @@ import (
const (
VersionMajor = 4 // Major version component of the current release
VersionMinor = 0 // Minor version component of the current release
VersionPatch = 2 // Patch version component of the current release
VersionPatch = 3 // Patch version component of the current release
VersionMeta = "sepolia" // Version metadata to append to the version string
)