Skip to content

feat(jsonrpc): implement eth_getBlockReceipts #6379

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

Open
wants to merge 12 commits into
base: release_v4.8.1
Choose a base branch
from

Conversation

0xbigapple
Copy link

What does this PR do?
Implement eth_getBlockReceipts method, from #5910
Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

@kuny0707 kuny0707 moved this to In Review in java-tron Jul 2, 2025
@kuny0707 kuny0707 linked an issue Jul 2, 2025 that may be closed by this pull request
long cumulativeGas = 0;
long cumulativeLogCount = 0;

for (int index = 0; index < infoList.getTransactionInfoCount(); index++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest judging the size of the list as empty and then recycling it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest judging the size of the list as empty and then recycling it.

Hi, If the list is empty, the loop condition index < 0 will skip the loop entirely and return null

TransactionInfo info = infoList.getTransactionInfo(index);
ResourceReceipt resourceReceipt = info.getReceipt();

if (info.getId().equals(txId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check if info.getId() is null.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check if info.getId() is null.

Thank you for your suggestion. Adding null checks can improve code robustness, but I believe TransactionInfo objects should contain valid IDs. A null ID typically indicates data corruption or a system error, which points to serious issues in java-tron. In most cases, this is an unnecessary check, and adding it in every loop will increase overhead.

throws JsonRpcInvalidParamsException, JsonRpcInternalException {
Block block = wallet.getByJsonBlockId(blockNumOrTag);
if (block == null) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return null or empty list?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with ethereum eth_getBlockReceipts logic, return null for blocks that are not found.

long cumulativeGas = 0;
long cumulativeLogCount = 0;

for (int index = 0; index < transactionInfoList.getTransactionInfoCount(); index++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check if the transactionInfoList is empty. If it is empty, it can be returned directly without going down.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, If the transactionInfoList is empty, the loop condition index < 0 will skip the loop entirely and return receipts which is empty ArrayList<>()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Implement eth_getBlockReceipts method
7 participants