all: add Codeword to header

This commit is contained in:
Your Name 2024-04-23 13:43:24 +09:00
parent 2b9f9285d2
commit 19d8abb4d6
3 changed files with 23 additions and 2 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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)
}