From 19d8abb4d6ac792c355e1b66c1b4fe3da766393b Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 23 Apr 2024 13:43:24 +0900 Subject: [PATCH] all: add Codeword to header --- internal/ethapi/api.go | 8 ++++++++ tests/block_test_util.go | 5 +++-- tests/gen_btheader.go | 12 ++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 152a8e70cd..cb1e81716a 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1180,6 +1180,14 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} { result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee) } + if head.Codeword != nil { + result["codeword"] = hexutil.Bytes(head.Codeword) + } + + if head.CodeLength != 0 { + result["codelength"] = hexutil.Uint64(head.CodeLength) + } + return result } diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 6603e1d4d3..b2b67cd0ac 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -86,6 +86,8 @@ type btHeader struct { GasUsed uint64 Timestamp uint64 BaseFeePerGas *big.Int + Codeword []byte + CodeLength uint64 } type btHeaderMarshaling struct { @@ -175,8 +177,7 @@ func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis { } } -/* -See https://github.com/ethereum/tests/wiki/Blockchain-Tests-II +/* See https://github.com/ethereum/tests/wiki/Blockchain-Tests-II Whether a block is valid or not is a bit subtle, it's defined by presence of blockHeader, transactions and uncleHeaders fields. If they are missing, the block is diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go index 7f37a110fa..4746203b41 100644 --- a/tests/gen_btheader.go +++ b/tests/gen_btheader.go @@ -34,6 +34,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) { GasUsed math.HexOrDecimal64 Timestamp math.HexOrDecimal64 BaseFeePerGas *math.HexOrDecimal256 + Codeword hexutil.Bytes + CodeLength math.HexOrDecimal64 } var enc btHeader enc.Bloom = b.Bloom @@ -48,6 +50,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) { enc.TransactionsTrie = b.TransactionsTrie enc.UncleHash = b.UncleHash enc.ExtraData = b.ExtraData + enc.Codeword = b.Codeword + enc.CodeLength = math.HexOrDecimal64(b.GasLimit) enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty) enc.GasLimit = math.HexOrDecimal64(b.GasLimit) enc.GasUsed = math.HexOrDecimal64(b.GasUsed) @@ -76,6 +80,8 @@ func (b *btHeader) UnmarshalJSON(input []byte) error { GasUsed *math.HexOrDecimal64 Timestamp *math.HexOrDecimal64 BaseFeePerGas *math.HexOrDecimal256 + Codeword *hexutil.Bytes + CodeLength *math.HexOrDecimal64 } var dec btHeader if err := json.Unmarshal(input, &dec); err != nil { @@ -117,6 +123,12 @@ func (b *btHeader) UnmarshalJSON(input []byte) error { if dec.ExtraData != nil { b.ExtraData = *dec.ExtraData } + if dec.Codeword != nil { + b.Codeword = *dec.Codeword + } + if dec.CodeLength != nil { + b.CodeLength = uint64(*dec.CodeLength) + } if dec.Difficulty != nil { b.Difficulty = (*big.Int)(dec.Difficulty) }