Skip to content

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

Open
0xbigapple wants to merge 1 commit intodevelopfrom
feature/jsonrpc-timestamp
Open

feat(jsonrpc): add blockTimestamp to logs and receipts#10
0xbigapple wants to merge 1 commit intodevelopfrom
feature/jsonrpc-timestamp

Conversation

@0xbigapple
Copy link
Copy Markdown
Owner

@0xbigapple 0xbigapple commented Apr 1, 2026

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 (specifically EIP PR #639).

Specifically, it updates:

  1. LogFilterElement (used in eth_getLogs, eth_getFilterLogs, eth_getFilterChanges) 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


Summary by cubic

Add blockTimestamp to JSON-RPC log objects and transaction receipts so clients can get event times without extra block lookups. Also include this field in equality and hashing to keep comparisons correct.

  • New Features

    • blockTimestamp added to LogFilterElement for eth_getLogs, eth_getFilterLogs, and eth_getFilterChanges.
    • blockTimestamp added to TransactionReceipt.TransactionLog for eth_getTransactionReceipt and eth_getBlockReceipts.
    • Sourced from TransactionInfo.blockTimeStamp, converted to seconds, returned as hex. Additive and backward compatible.
  • Bug Fixes

    • Include blockTimestamp in equals() and hashCode() for LogFilterElement to ensure stable comparisons and hashing.

Written for commit 96b0801. Summary will update on new commits.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87e2205f-7254-4661-8cf3-f78a7e5d0752

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/jsonrpc-timestamp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11db78cd11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds blockTimestamp to JSON-RPC log objects and receipt logs to align TRON’s JSON-RPC responses with the Ethereum execution-apis update (EIP PR tronprotocol#639), so clients can read event time context without extra block lookups.

Changes:

  • Extend TransactionReceipt.TransactionLog to include blockTimestamp derived from TransactionInfo.blockTimeStamp (ms → seconds) and encoded as hex quantity.
  • Update log matching to propagate transaction timestamps into LogFilterElement.
  • Add/extend unit tests to assert blockTimestamp on both receipt logs and filter log elements.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
framework/src/main/java/org/tron/core/services/jsonrpc/types/TransactionReceipt.java Adds blockTimestamp to receipt log entries and populates it from TransactionInfo.
framework/src/main/java/org/tron/core/services/jsonrpc/filters/LogMatch.java Attempts to pass transaction blockTimeStamp into LogFilterElement creation.
framework/src/test/java/org/tron/core/services/jsonrpc/TransactionReceiptTest.java Adds blockTimeStamp fixture data and asserts blockTimestamp on receipt logs.
framework/src/test/java/org/tron/core/jsonrpc/LogMatchExactlyTest.java Adds blockTimeStamp fixture data and asserts blockTimestamp on LogFilterElement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants