Skip to content

feat(jsonrpc): add blockTimestamp to logs and receipts#6671

Open
0xbigapple wants to merge 3 commits intotronprotocol:developfrom
0xbigapple:feature/jsonrpc-timestamp
Open

feat(jsonrpc): add blockTimestamp to logs and receipts#6671
0xbigapple wants to merge 3 commits intotronprotocol:developfrom
0xbigapple:feature/jsonrpc-timestamp

Conversation

@0xbigapple
Copy link
Copy Markdown
Collaborator

What does this PR do?
Adds the blockTimestamp field to the log objects returned by JSON-RPC event and receipt query interfaces, aligning the TRON JSON-RPC implementation with the Ethereum execution-apis specification. close #6617

Specifically, it updates:

  1. LogFilterElement (used in eth_getLogs, eth_getFilterLogs, eth_getFilterChanges(about log/event filter)) to include blockTimestamp.
  2. TransactionLog within TransactionReceipt (used in eth_getTransactionReceipt, eth_getBlockReceipts) to include blockTimestamp.

The timestamp is extracted from the corresponding TransactionInfo's blockTimeStamp, divided by 1000 to convert to seconds, and returned as a hexadecimal string (e.g., "0x3e8").

Why are these changes required?
To maintain compatibility with the evolving Ethereum JSON-RPC API standards. Adding the block generation timestamp directly to the log objects enables developers and dApps to process event streams with precise time context without needing to perform secondary eth_getBlockByHash/Number queries, significantly reducing network overhead and improving client efficiency.

This PR has been tested by:

  • Unit Tests:
    • Added assertions in LogMatchExactlyTest.java to verify blockTimestamp in LogFilterElement.
    • Added assertions in TransactionReceiptTest.java to verify blockTimestamp in TransactionReceipt.TransactionLog.
  • Manual Testing: N/A

Follow up

Extra details

@0xbigapple 0xbigapple force-pushed the feature/jsonrpc-timestamp branch from 92d7b71 to b3c6ccb Compare April 14, 2026 05:12
Copy link
Copy Markdown
Collaborator

@bladehan1 bladehan1 left a comment

Choose a reason for hiding this comment

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

See review, comments

Comment thread framework/src/main/java/org/tron/core/services/jsonrpc/TronJsonRpc.java Outdated
@waynercheung
Copy link
Copy Markdown
Collaborator

[SHOULD] The implementation looks good and I’m comfortable approving it. One follow-up I’d still recommend is adding direct API-level coverage for eth_getFilterLogs and eth_getFilterChanges in JsonrpcServiceTest, so the test surface fully matches the public APIs listed in the PR scope.

@0xbigapple
Copy link
Copy Markdown
Collaborator Author

[SHOULD] The implementation looks good and I’m comfortable approving it. One follow-up I’d still recommend is adding direct API-level coverage for eth_getFilterLogs and eth_getFilterChanges in JsonrpcServiceTest, so the test surface fully matches the public APIs listed in the PR scope.

Thanks for the follow-up. Since eth_getFilterLogs and eth_getFilterChanges share the same underlying code path as this change, the positive-path test on eth_getLogs already covers the shared logic including blockTimestamp validation. Adding full API-level tests for those two endpoints is beyond the scope of this change, as they didn't have tests before this PR either. That said, I think it would be great to have a dedicated tracking issue to cover API-level tests for all JSON-RPC endpoints holistically, not just these two.

@lvs0075 lvs0075 requested a review from 317787106 April 16, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add blockTimestamp to JSON-RPC log objects to improve efficiency

6 participants