-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add eth_getBlockReceipts() JSON/RPC method #5771
Conversation
|
Signed-off-by: Matthew Whitehead <[email protected]>
25d5686
to
335e2da
Compare
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matt Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
468ddd8
to
084c740
Compare
084c740
to
21727e8
Compare
Signed-off-by: Matthew Whitehead <[email protected]>
Signed-off-by: Matthew Whitehead <[email protected]>
|
||
@Test | ||
public void blockNotFoundForRandomHash() { | ||
/* Valid random hash - should result in block not found (effectively impossible for it to be a valid block) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the risk is low but this still makes me uneasy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah fair point, I'll remove that test for now.
TransactionReceiptResult tx1 = result.getResults().get(0); | ||
assertThat(tx1.getBlockNumber()).isEqualTo("0x1"); | ||
assertThat(tx1.getEffectiveGasPrice()).isEqualTo("0x4a7ebf2e"); | ||
assertThat(tx1.getTo()).isEqualTo("0x6ada2e11049e5fc54fcdf2a97996d9b2aa80fe71"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't want the tx values hard coded in the test since it makes it brittle - eg if you change the BLOCKCHAIN_LENGTH, these tests will fail. you can get the values from the generated blockchain itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final Transaction expectedTx1 = blockchain.getBlockByNumber(BLOCKCHAIN_LENGTH - 1).get().getBody().getTransactions().get(0);
// Check TX1 receipt is correct
TransactionReceiptResult tx1 = result.getResults().get(0);
assertThat(tx1.getBlockNumber()).isEqualTo("0x"+(BLOCKCHAIN_LENGTH-1));
assertThat(tx1.getEffectiveGasPrice()).isNotEmpty();
assertThat(tx1.getType()).isEqualTo(expectedTx1.getType());
assertThat(tx1.getTo()).isEqualTo(expectedTx1.getTo().get().toString());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a good point. I'll make those suggested changes so the test is more reliable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit updates the unit tests as you've suggested @macfarla. I added getEthSerializedType()
to TransactionType
so there is a single place in the codebase where FRONTIER
transactions are mapped from their enum value of 0xf8
to their eth serialized value of 0x00
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also have a look at EthJsonRpcHttpBySpecTest - maybe add some "by spec" tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer. I'd found the graphql spec tests but not spotted general JSON/RPC spec tests. Latest commit adds a variety to cover by hash, by number, and by tag.
...java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java
Outdated
Show resolved
Hide resolved
…sonrpc/internal/methods/EthGetBlockReceiptsTest.java Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]>
Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]>
…sactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <[email protected]>
ff2bfd6
to
b5cb902
Compare
Signed-off-by: Matthew Whitehead <[email protected]>
I think all of the latest comments are addressed @macfarla I'm away for a few days now, feel free to merge if you're happy or if you have more comments I'm happy to take a look when I'm back. |
Signed-off-by: Sally MacFarlane <[email protected]>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <[email protected]> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <[email protected]> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <[email protected]> --------- Signed-off-by: Matthew Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Sally MacFarlane <[email protected]> Co-authored-by: Sally MacFarlane <[email protected]>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <[email protected]> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <[email protected]> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <[email protected]> --------- Signed-off-by: Matthew Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Sally MacFarlane <[email protected]> Co-authored-by: Sally MacFarlane <[email protected]>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <[email protected]> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <[email protected]> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <[email protected]> --------- Signed-off-by: Matthew Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Sally MacFarlane <[email protected]> Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: garyschulte <[email protected]>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <[email protected]> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <[email protected]> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <[email protected]> --------- Signed-off-by: Matthew Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Sally MacFarlane <[email protected]> Co-authored-by: Sally MacFarlane <[email protected]>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <[email protected]> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <[email protected]> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <[email protected]> --------- Signed-off-by: Matthew Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Matt Whitehead <[email protected]> Signed-off-by: Sally MacFarlane <[email protected]> Co-authored-by: Sally MacFarlane <[email protected]>
PR description
Adds
eth_getBlockReceipts
JSON/RPC method as described by Ethereum API specification ethereum/execution-apis#438Notes for PR reviewer & docs:
-32000
error code with messageBlock not found
for such cases. I have done the same with this new JSON/RPC method but welcome any thoughts on this from the PR reviewer.Fixed Issue(s)
Closes #5751