Skip to content

Commit 8e43f27

Browse files
authored
Add eth_getProof spec (#260)
* add eth_getProof spec * add merkle to wordlist * few fixes * more fixes, relax fixed length requirement on bytes32 and has32 * add eth_getProof tests * regenerate tests with correct account target * more accurate integer widths * allow 0x0 in uint64
1 parent 0b965fb commit 8e43f27

File tree

10 files changed

+101
-5
lines changed

10 files changed

+101
-5
lines changed

src/eth/state.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,25 @@
6565
name: Bytecode
6666
schema:
6767
$ref: '#/components/schemas/bytes'
68+
- name: eth_getProof
69+
summary: Returns the merkle proof for a given account and optionally some storage keys.
70+
params:
71+
- name: Address
72+
required: true
73+
schema:
74+
$ref: '#/components/schemas/address'
75+
- name: StorageKeys
76+
required: true
77+
schema:
78+
title: Storage keys
79+
type: array
80+
items:
81+
$ref: '#/components/schemas/hash32'
82+
- name: Block
83+
required: true
84+
schema:
85+
$ref: '#/components/schemas/BlockNumberOrTag'
86+
result:
87+
name: Account
88+
schema:
89+
$ref: '#/components/schemas/AccountProof'

src/schemas/base-types.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bytes8:
2222
bytes32:
2323
title: 32 hex encoded bytes
2424
type: string
25-
pattern: ^0x[0-9a-f]{64}$
25+
pattern: ^0x([0-9a-f][0-9a-f]){0,32}$
2626
bytes256:
2727
title: 256 hex encoded bytes
2828
type: string
@@ -35,11 +35,15 @@ uint:
3535
title: hex encoded unsigned integer
3636
type: string
3737
pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
38+
uint64:
39+
title: hex encoded unsigned integer
40+
type: string
41+
pattern: ^0x([1-9a-f][0-9a-f]{0,31})|0$
3842
uint256:
3943
title: hex encoded unsigned integer
4044
type: string
41-
pattern: ^0x[0-9a-f]{64}$
45+
pattern: ^0x[0-9a-f]{0,64}$
4246
hash32:
4347
title: 32 byte hex value
4448
type: string
45-
pattern: ^0x[0-9a-f]{64}$
49+
pattern: ^0x([0-9a-f][0-9a-f]){0,32}$

src/schemas/state.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
AccountProof:
2+
title: Account proof
3+
type: object
4+
required:
5+
- address
6+
- accountProof
7+
- balance
8+
- codeHash
9+
- nonce
10+
- storageHash
11+
- storageProof
12+
properties:
13+
address:
14+
title: address
15+
$ref: '#/components/schemas/address'
16+
accountProof:
17+
title: accountProof
18+
type: array
19+
items:
20+
$ref: '#/components/schemas/bytes'
21+
balance:
22+
title: balance
23+
$ref: '#/components/schemas/uint256'
24+
codeHash:
25+
title: codeHash
26+
$ref: '#/components/schemas/hash32'
27+
nonce:
28+
title: nonce
29+
$ref: '#/components/schemas/uint64'
30+
storageHash:
31+
title: storageHash
32+
$ref: '#/components/schemas/hash32'
33+
storageProof:
34+
title: storageProof
35+
type: array
36+
items:
37+
$ref: '#/components/schemas/StorageProof'
38+
StorageProof:
39+
title: Storage proof
40+
type: object
41+
required:
42+
- key
43+
- value
44+
- proof
45+
properties:
46+
key:
47+
title: key
48+
$ref: '#/components/schemas/hash32'
49+
value:
50+
title: value
51+
$ref: '#/components/schemas/uint256'
52+
proof:
53+
title: proof
54+
type: array
55+
items:
56+
$ref: '#/components/schemas/bytes'

tests/chain.rlp

0 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
>> {"jsonrpc":"2.0","id":3,"method":"eth_getBlockByNumber","params":["0x2",true]}
2-
<< {"jsonrpc":"2.0","id":3,"result":{"baseFeePerGas":"0x2db08786","difficulty":"0x20000","extraData":"0x","gasLimit":"0x4c4b40","gasUsed":"0x5208","hash":"0x8b21a4d87bf85d7ca0c3246c4614f0aa52830e8cb7269bb15aeed5dd8381a472","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","mixHash":"0xccccb39e7b45085a4856f2981160e15d38c1f6eec387b28785b5888a254f7590","nonce":"0x380ad30e24588170","number":"0x2","parentHash":"0x8654633e8c5d422d5dfa79ff9a07a467d650fca786cfd38b69c157e2d4e7eb22","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x26c","stateRoot":"0x730a6f5dbff0b86dd73ff3f2ba05e0e117129514002c742c716e88ee64426019","timestamp":"0x14","totalDifficulty":"0x40001","transactions":[{"blockHash":"0x8b21a4d87bf85d7ca0c3246c4614f0aa52830e8cb7269bb15aeed5dd8381a472","blockNumber":"0x2","from":"0x658bdf435d810c91414ec09147daa6db62406379","gas":"0x5208","gasPrice":"0x2db08786","hash":"0x7603a79471ee4ec11532a908d57a13ade4795d5c64c0ef1b7cea452c77859a8b","input":"0x","nonce":"0x1","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa96","r":"0x8970676a591fb2be4f71e4579ae4fba8f39076796b6a971f3b9266bfb0beda0","s":"0x1e4c79bd916d3f56f87ce59443c521280cf1bea83832c957870b14332f16b932"}],"transactionsRoot":"0x2fb4fd1c080aed4da105cdd18757e31742a496f27319d54b8e3e393fea41a736","uncles":[]}}
2+
<< {"jsonrpc":"2.0","id":3,"result":{"baseFeePerGas":"0x2db08786","difficulty":"0x20000","extraData":"0x","gasLimit":"0x4c4b40","gasUsed":"0x5208","hash":"0x5f51f456295441f9414970e0d91018b8cfc8a431367c9ddcfb964b5e8374d97e","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","mixHash":"0xd0cc28a3fe975d7812825c5850a2a9c9d0d99a96c7402fd7a099811bba0adfe1","nonce":"0x574a4e8f21d29cd1","number":"0x2","parentHash":"0x10738a73bd29f6755839152fa32e6cab14d84b31c69d32276f5503cf3b3628d1","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x26c","stateRoot":"0xa11b4c086e91defd929b062c76da4815e75aa87a7c7cc1ba2d81fab5065bb40d","timestamp":"0x14","totalDifficulty":"0x40001","transactions":[{"blockHash":"0x5f51f456295441f9414970e0d91018b8cfc8a431367c9ddcfb964b5e8374d97e","blockNumber":"0x2","from":"0x658bdf435d810c91414ec09147daa6db62406379","gas":"0x5208","gasPrice":"0x2db08786","hash":"0x7603a79471ee4ec11532a908d57a13ade4795d5c64c0ef1b7cea452c77859a8b","input":"0x","nonce":"0x1","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa96","r":"0x8970676a591fb2be4f71e4579ae4fba8f39076796b6a971f3b9266bfb0beda0","s":"0x1e4c79bd916d3f56f87ce59443c521280cf1bea83832c957870b14332f16b932"}],"transactionsRoot":"0x2fb4fd1c080aed4da105cdd18757e31742a496f27319d54b8e3e393fea41a736","uncles":[]}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
>> {"jsonrpc":"2.0","id":2,"method":"eth_getBlockByNumber","params":["0x0",true]}
2-
<< {"jsonrpc":"2.0","id":2,"result":{"baseFeePerGas":"0x3b9aca00","difficulty":"0x1","extraData":"0x","gasLimit":"0x4c4b40","gasUsed":"0x0","hash":"0x4fdbf686aa0f43f0e8445bd047c42edd208e5a0d653f5cb8742160a163053c54","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","number":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1fd","stateRoot":"0x21b036e39374a278109134aa04d153e16999e838316561a114a563d6ff9e6707","timestamp":"0x0","totalDifficulty":"0x1","transactions":[],"transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","uncles":[]}}
2+
<< {"jsonrpc":"2.0","id":2,"result":{"baseFeePerGas":"0x3b9aca00","difficulty":"0x1","extraData":"0x","gasLimit":"0x4c4b40","gasUsed":"0x0","hash":"0x0c3e1714ef711da1150e2cd2a3fe561c14023246bb5a43bd5d8470a88f51d3ab","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","number":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1fd","stateRoot":"0x047563f23a159598622ab8819d88e0aca94cf5cc92fa6ae45cc4ccb6fa87351d","timestamp":"0x0","totalDifficulty":"0x1","transactions":[],"transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","uncles":[]}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>> {"jsonrpc":"2.0","id":5,"method":"eth_getProof","params":["0xaa00000000000000000000000000000000000000",["0x01"],"0x3"]}
2+
<< {"jsonrpc":"2.0","id":5,"result":{"address":"0xaa00000000000000000000000000000000000000","accountProof":["0xf8718080808080a0c00495e5033c7515e8873ad194ed58261fbb8370ddac6ed641c3fc5e9361175c80a054ce42bae14d637d9328d46bd0fbebb8121808e2702a5e073e9248df6c9c46b0a0f81ae66fafcda39922df492e29e2fab19d7f66cc20865addd5b9a4f7af14ba348080808080808080","0xf869a0335649db80be637d281db0cc5896b0ff9869d08379a80fdc38dd073bba633949b846f8440101a002ad600f031449f2b67a245c683461817612b337fffb1e9805f9b17c8b10a106a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"],"balance":"0x1","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x1","storageHash":"0x02ad600f031449f2b67a245c683461817612b337fffb1e9805f9b17c8b10a106","storageProof":[{"key":"0x01","value":"0x0","proof":["0xf851808080a0ce028e108cf5c832b0a9afd3ed101183857b3b9ddaea5670c4f09b62e4d38d05a0de3ecad66628a5743ed089e3a35ebeedc25a922fb0ac346304613403911c18e0808080808080808080808080"]}]}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>> {"jsonrpc":"2.0","id":4,"method":"eth_getProof","params":["0xaa00000000000000000000000000000000000000",[],"0x3"]}
2+
<< {"jsonrpc":"2.0","id":4,"result":{"address":"0xaa00000000000000000000000000000000000000","accountProof":["0xf8718080808080a0c00495e5033c7515e8873ad194ed58261fbb8370ddac6ed641c3fc5e9361175c80a054ce42bae14d637d9328d46bd0fbebb8121808e2702a5e073e9248df6c9c46b0a0f81ae66fafcda39922df492e29e2fab19d7f66cc20865addd5b9a4f7af14ba348080808080808080","0xf869a0335649db80be637d281db0cc5896b0ff9869d08379a80fdc38dd073bba633949b846f8440101a002ad600f031449f2b67a245c683461817612b337fffb1e9805f9b17c8b10a106a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"],"balance":"0x1","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x1","storageHash":"0x02ad600f031449f2b67a245c683461817612b337fffb1e9805f9b17c8b10a106","storageProof":[]}}

tests/genesis.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
"alloc": {
2828
"658bdf435d810c91414ec09147daa6db62406379": {
2929
"balance": "0x487a9a304539440000"
30+
},
31+
"aa00000000000000000000000000000000000000": {
32+
"storage": {
33+
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000",
34+
"0x0100000000000000000000000000000000000000000000000000000000000000": "0x0100000000000000000000000000000000000000000000000000000000000000",
35+
"0x0200000000000000000000000000000000000000000000000000000000000000": "0x0200000000000000000000000000000000000000000000000000000000000000"
36+
},
37+
"balance": "0x1",
38+
"nonce": "0x1"
3039
}
3140
},
3241
"number": "0x0",

wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ethereum
1111
interop
1212
json
1313
mempool
14+
merkle
1415
npm
1516
ommers
1617
openrpc

0 commit comments

Comments
 (0)