-
Notifications
You must be signed in to change notification settings - Fork 839
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 <matthew1001@gmail.com>
25d5686
to
335e2da
Compare
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matt Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
468ddd8
to
084c740
Compare
084c740
to
21727e8
Compare
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
|
||
@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 <macfarla.github@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com>
…sactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
ff2bfd6
to
b5cb902
Compare
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
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. |
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: garyschulte <garyschulte@gmail.com>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
* Initial commit with new JSON/RPC method Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update CHANGELOG.md Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update unit tests to check receipts against generated blockchain transactions at runtime. Add getEthSerializedType() utility to TransactionType. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add spec JSON/RPC tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
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