Skip to content

Commit

Permalink
add option for blockHash per EIP-1898 (#326)
Browse files Browse the repository at this point in the history
* add option for blockHash per EIP-1898

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* eth_getCode included

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* add tests

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com>
  • Loading branch information
macfarla and lightclient authored Jan 9, 2023
1 parent d072d08 commit 0cfb63a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/eth/execute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- name: Block
required: false
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
$ref: '#/components/schemas/BlockNumberOrTagOrHash'
result:
name: Return data
schema:
Expand Down
10 changes: 5 additions & 5 deletions src/eth/state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- name: Block
required: false
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
$ref: '#/components/schemas/BlockNumberOrTagOrHash'
result:
name: Balance
schema:
Expand All @@ -27,7 +27,7 @@
- name: Block
required: false
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
$ref: '#/components/schemas/BlockNumberOrTagOrHash'
result:
name: Value
schema:
Expand All @@ -42,7 +42,7 @@
- name: Block
required: false
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
$ref: '#/components/schemas/BlockNumberOrTagOrHash'
result:
name: Transaction count
schema:
Expand All @@ -57,7 +57,7 @@
- name: Block
required: false
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
$ref: '#/components/schemas/BlockNumberOrTagOrHash'
result:
name: Bytecode
schema:
Expand All @@ -79,7 +79,7 @@
- name: Block
required: true
schema:
$ref: '#/components/schemas/BlockNumberOrTag'
$ref: '#/components/schemas/BlockNumberOrTagOrHash'
result:
name: Account
schema:
Expand Down
21 changes: 21 additions & 0 deletions src/schemas/block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,34 @@ BlockTag:
- latest
- pending
description: '`earliest`: The lowest numbered block the client has available; `finalized`: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; `safe`: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; `latest`: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions; `pending`: A sample next block built by the client on top of `latest` and containing the set of transactions usually taken from local mempool. Before the merge transition is finalized, any call querying for `finalized` or `safe` block MUST be responded to with `-39001: Unknown block` error'
BlockHash:
title: Block hash
type: object
required:
- blockHash
properties:
blockHash:
title: Block hash
$ref: '#/components/schemas/hash32'
requireCanonical:
title: Require canonical
type: boolean
BlockNumberOrTag:
title: Block number or tag
oneOf:
- title: Block number
$ref: '#/components/schemas/uint'
- title: Block tag
$ref: '#/components/schemas/BlockTag'
BlockNumberOrTagOrHash:
title: Block number or tag, or block hash
oneOf:
- title: Block number
$ref: '#/components/schemas/uint'
- title: Block tag
$ref: '#/components/schemas/BlockTag'
- title: Block hash
$ref: '#/components/schemas/BlockHash'
BadBlock:
title: Bad block
type: object
Expand Down
2 changes: 2 additions & 0 deletions tests/eth_getBalance/get-balance-blockhash.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":9,"method":"eth_getBalance","params":["0xaa00000000000000000000000000000000000000","0x2ce0e9a8a0b33d45aeb70cf6878d2943deddcf6600e06b84546eaf0a0d2b9643"]}
<< {"jsonrpc":"2.0","id":9,"result":"0x1"}
2 changes: 2 additions & 0 deletions tests/eth_getProof/get-account-proof-blockhash.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":2,"method":"eth_getProof","params":["0xaa00000000000000000000000000000000000000",[],"0x1ec8dde1f5bd29b8fb4c206d6c23924f0b6681951ca90653689995c0c59ffa6f"]}
<< {"jsonrpc":"2.0","id":2,"result":{"address":"0xaa00000000000000000000000000000000000000","accountProof":["0xf8718080808080a0bc55bb35324913804e0799a4c50de66f54fefa67937210939e48cbd1cfa702c580a0457ae8d978cd387f5332f978f5653226588b6cc76a355fc5977cd4325ffcff78a053382cdfd5e86005e120dfe636ad4c4a83bd28857e463f23308c8c3cf94c3c3a8080808080808080","0xf869a0335649db80be637d281db0cc5896b0ff9869d08379a80fdc38dd073bba633949b846f8440101a08afc95b7d18a226944b9c2070b6bda1c3a36afcc3730429d47579c94b9fe5850a0ce92c756baff35fa740c3557c1a971fd24d2d35b7c8e067880d50cd86bb0bc99"],"balance":"0x1","codeHash":"0xce92c756baff35fa740c3557c1a971fd24d2d35b7c8e067880d50cd86bb0bc99","nonce":"0x1","storageHash":"0x8afc95b7d18a226944b9c2070b6bda1c3a36afcc3730429d47579c94b9fe5850","storageProof":[]}}

0 comments on commit 0cfb63a

Please sign in to comment.