Skip to content

fix(event): decode uint event parameters as unsigned - #24

Open
0xbigapple wants to merge 1 commit into
release_v4.8.3from
fix/event-uint-decode
Open

0xbigapple wants to merge 1 commit into
release_v4.8.3from
fix/event-uint-decode

Conversation

@0xbigapple

@0xbigapple 0xbigapple commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

What does this PR do?

ContractEventParser classified int, uint and trcToken together as INT_NUMBER and decoded all of them as signed two's complement. Any uint256 event parameter with bit 255 set was therefore published as a negative number, in both topicMap (indexed) and dataMap (non-indexed).

This PR adds a UINT_NUMBER type for uint* and trcToken and decodes it with a new DataWord.bigUIntValue helper (new BigInteger(1, bytes)), mirroring the existing DataWord.bigIntValue. Signed decoding is unchanged.

Why are these changes required?

Unlimited TRC20 approvals hit this every day. Mainnet USDT transaction f2e9b6cc2df49316122f28e974b28d1e160bcf49db84a04827b1b49cea38cfb4 (block 87664803) emits Approval(owner, spender, type(uint256).max); the event plugin publishes dataMap.value = "-1" instead of 115792089237316195423570985008687907853269984665640564039457584007913129639935. Every other decoder in the ecosystem, including TronGrid, trident, web3.js and ethers, treats uint256 as unsigned; the java-tron event plugin is the only producer emitting negative values.

A fix for the same defect was proposed in tronprotocol#2297 (2019) but was closed unmerged.

This PR has been tested by:

  • Unit Tests: EventParserTest covers 2^255-1, 2^255 and 2^256-1 for uint256, uint and trcToken through both parseDataBytes and parseTopic, with int256(-1) as the control, plus an end-to-end ContractEventParserAbi case for topicMap and dataMap. The new tests fail on the current release_v4.8.3 head.
  • Manual Testing: on a single-witness private chain, replayed the USDT Approval log above through a contract that emits the same owner, spender and value; the private-chain log topics and data are byte-identical to the mainnet log. With the release_v4.8.3 build the native-queue contractEventTrigger message carried value = "-1"; with this build the same transaction decoded to the positive value on both the realtime path and the version = 1 history replay path, and the two indexed addresses decoded identically on both builds. A second probe contract covering 2^255-1, 2^255, 2^256-1 and int256(-1) gave the same picture.

Follow up

None.

Extra details

Breaking changes (release-note items):

  • uint256 event parameters at or above 2^255 are published as positive decimal strings in topicMap and dataMap. Consumers that compare the decoded value to "-1" to detect an unlimited approval must compare to 115792089237316195423570985008687907853269984665640564039457584007913129639935 instead.
  • event.subscribe.filter.contractTopic matches contractevent triggers against decoded indexed values. A filter written as "-1" for such a parameter must be rewritten as the positive value.

Raw topics and data, contractlog triggers, and all JSON-RPC, HTTP and gRPC responses are unchanged.


Summary by cubic

Fixes uint* and trcToken event parameters being decoded as signed values, publishing uint256 values at or above 2^255 as negative numbers in topicMap and dataMap.

Breaking changes

  • uint256 parameters at or above 2^255 are now published as positive decimal strings, so consumers matching an unlimited approval against "-1" must compare against 115792089237316195423570985008687907853269984665640564039457584007913129639935 instead.
  • event.subscribe.filter.contractTopic filters written for such parameters must use the positive value.

Raw event data and all JSON-RPC, HTTP, and gRPC responses are unchanged.

Written for commit f89f6bc. Summary will update on new commits.

View guided diff Turn on auto-fix

Split uint and trcToken out of INT_NUMBER and decode them with the new
DataWord.bigUIntValue so values with bit 255 set are no longer published
as negative numbers.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f42349e6-79f9-4e4a-a0ae-6fe0de0189ec

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T03:31:17.700390Z f89f6bc PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

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.

1 participant