Skip to content

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

Open
0xbigapple wants to merge 1 commit intotronprotocol:developfrom
0xbigapple:feature/jsonrpc-timestamp
Open

feat(jsonrpc): add blockTimestamp to logs and receipts#6671
0xbigapple wants to merge 1 commit 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

@github-actions github-actions bot requested a review from bladehan1 April 9, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant