feat(jsonrpc): add blockTimestamp to logs and receipts#10
feat(jsonrpc): add blockTimestamp to logs and receipts#100xbigapple wants to merge 1 commit intodevelopfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 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".
framework/src/main/java/org/tron/core/services/jsonrpc/filters/LogMatch.java
Show resolved
Hide resolved
There was a problem hiding this comment.
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.TransactionLogto includeblockTimestampderived fromTransactionInfo.blockTimeStamp(ms → seconds) and encoded as hex quantity. - Update log matching to propagate transaction timestamps into
LogFilterElement. - Add/extend unit tests to assert
blockTimestampon 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.
framework/src/main/java/org/tron/core/services/jsonrpc/filters/LogMatch.java
Show resolved
Hide resolved
11db78c to
797fa3b
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
framework/src/main/java/org/tron/core/services/jsonrpc/types/TransactionReceipt.java
Show resolved
Hide resolved
58aa3b6 to
96b0801
Compare
There was a problem hiding this comment.
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.
What does this PR do?
Adds the
blockTimestampfield 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:
LogFilterElement(used ineth_getLogs,eth_getFilterLogs,eth_getFilterChanges) to includeblockTimestamp.TransactionLogwithinTransactionReceipt(used ineth_getTransactionReceipt,eth_getBlockReceipts) to includeblockTimestamp.The timestamp is extracted from the corresponding
TransactionInfo'sblockTimeStamp, 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/Numberqueries, significantly reducing network overhead and improving client efficiency.This PR has been tested by:
LogMatchExactlyTest.javato verifyblockTimestampinLogFilterElement.TransactionReceiptTest.javato verifyblockTimestampinTransactionReceipt.TransactionLog.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
blockTimestampadded toLogFilterElementforeth_getLogs,eth_getFilterLogs, andeth_getFilterChanges.blockTimestampadded toTransactionReceipt.TransactionLogforeth_getTransactionReceiptandeth_getBlockReceipts.TransactionInfo.blockTimeStamp, converted to seconds, returned as hex. Additive and backward compatible.Bug Fixes
blockTimestampinequals()andhashCode()forLogFilterElementto ensure stable comparisons and hashing.Written for commit 96b0801. Summary will update on new commits.