Skip to content

Commit 2e30b30

Browse files
authored
🚑️ Fix JSON field requestsHash naming of ethereum/rpc.Header (#87)
🚑️ Fix JSON field naming of `ethereum/rpc.Header`
1 parent 5c1259a commit 2e30b30

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

ethereum/rpc/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Header struct {
3232
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed,omitempty"`
3333
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas,omitempty"`
3434
ParentBeaconRoot *gethcommon.Hash `json:"parentBeaconBlockRoot,omitempty"`
35-
RequestsRoot *gethcommon.Hash `json:"requestsRoot,omitempty"`
35+
RequestsHash *gethcommon.Hash `json:"requestsHash,omitempty"`
3636
Hash gethcommon.Hash `json:"hash"`
3737
}
3838

@@ -56,7 +56,7 @@ func (h *Header) Header() *gethtypes.Header {
5656
BaseFee: (*big.Int)(h.BaseFee),
5757
WithdrawalsHash: h.WithdrawalsRoot,
5858
ParentBeaconRoot: h.ParentBeaconRoot,
59-
RequestsHash: h.RequestsRoot,
59+
RequestsHash: h.RequestsHash,
6060
}
6161

6262
if h.BlobGasUsed != nil {
@@ -89,7 +89,7 @@ func (h *Header) FromHeader(header *gethtypes.Header) *Header {
8989
h.BaseFee = (*hexutil.Big)(header.BaseFee)
9090
h.WithdrawalsRoot = header.WithdrawalsHash
9191
h.ParentBeaconRoot = header.ParentBeaconRoot
92-
h.RequestsRoot = header.RequestsHash
92+
h.RequestsHash = header.RequestsHash
9393

9494
if header.BlobGasUsed != nil {
9595
h.BlobGasUsed = (*hexutil.Uint64)(header.BlobGasUsed)

ethereum/rpc/types_test.go

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,40 @@ import (
99
gethcommon "github.com/ethereum/go-ethereum/common"
1010
"github.com/ethereum/go-ethereum/common/hexutil"
1111
gethtypes "github.com/ethereum/go-ethereum/core/types"
12+
"github.com/kkrt-labs/go-utils/common"
1213
"github.com/stretchr/testify/assert"
1314
"github.com/stretchr/testify/require"
1415
)
1516

1617
func TestRPCHeader(t *testing.T) {
1718
header := &gethtypes.Header{
18-
ParentHash: gethcommon.Hash{},
19-
UncleHash: gethcommon.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
20-
ReceiptHash: gethcommon.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
21-
TxHash: gethcommon.HexToHash("0x661a9febcfa8f1890af549b874faf9fa274aede26ef489d9db0b25daa569450e"),
22-
Number: big.NewInt(100),
23-
GasLimit: 1000,
24-
GasUsed: 10000,
25-
Time: 1000,
26-
Difficulty: big.NewInt(100),
27-
Extra: hexutil.MustDecode("0xabcd"),
28-
Bloom: gethtypes.Bloom{},
29-
Coinbase: gethcommon.HexToAddress("0x5E0c840B55d49377070e131ed93B69393218C444"),
30-
MixDigest: gethcommon.Hash{},
31-
Nonce: gethtypes.EncodeNonce(25),
32-
Root: gethcommon.Hash{},
19+
ParentHash: gethcommon.Hash{},
20+
UncleHash: gethcommon.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
21+
ReceiptHash: gethcommon.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
22+
TxHash: gethcommon.HexToHash("0x661a9febcfa8f1890af549b874faf9fa274aede26ef489d9db0b25daa569450e"),
23+
Number: big.NewInt(100),
24+
GasLimit: 1000,
25+
GasUsed: 10000,
26+
Time: 1000,
27+
Difficulty: big.NewInt(100),
28+
Extra: hexutil.MustDecode("0xabcd"),
29+
Bloom: gethtypes.Bloom{},
30+
Coinbase: gethcommon.HexToAddress("0x5E0c840B55d49377070e131ed93B69393218C444"),
31+
MixDigest: gethcommon.Hash{},
32+
Nonce: gethtypes.EncodeNonce(25),
33+
Root: gethcommon.Hash{},
34+
BaseFee: big.NewInt(100),
35+
WithdrawalsHash: common.Ptr(gethcommon.Hash{}),
36+
BlobGasUsed: common.Ptr(uint64(8)),
37+
ExcessBlobGas: common.Ptr(uint64(9)),
38+
ParentBeaconRoot: common.Ptr(gethcommon.HexToHash("0xeacd31ced729baf258bd42cdbd42617ad326b0c64ac2079f97c072d8c086c27f")),
39+
RequestsHash: common.Ptr(gethcommon.HexToHash("0xc420b56fcdd9edfe80e9fc11d773cb48793778f46216963bc418133579e6963b")),
3340
}
3441

3542
rpcHeader := new(Header).FromHeader(header)
3643
assert.Equal(t, header.Hash(), rpcHeader.Hash)
3744

38-
b, err := json.Marshal(rpcHeader)
45+
b, err := json.Marshal(header)
3946
require.NoError(t, err)
4047

4148
rpcHeader2 := new(Header)

0 commit comments

Comments
 (0)