Skip to content

fix(crypto): remove unused topicsList from shielded TRC20 APIs#3

Closed
Federico2014 wants to merge 1 commit intodevelopfrom
fix/shielded-log-cleanup
Closed

fix(crypto): remove unused topicsList from shielded TRC20 APIs#3
Federico2014 wants to merge 1 commit intodevelopfrom
fix/shielded-log-cleanup

Conversation

@Federico2014
Copy link
Copy Markdown
Owner

@Federico2014 Federico2014 commented Apr 1, 2026

What does this PR do?

This PR removes the unused topicsList parameter from shielded TRC20 log APIs.

Changes:

  • Remove ProtocolStringList topicsList parameter from getShieldedTRC20LogType() method
  • Simplify the log type detection logic to use direct topic bytes comparison
  • Mark events field as deprecated in IvkDecryptTRC20Parameters and OvkDecryptTRC20Parameters
  • Add warning logs when deprecated events field is provided
  • Update related tests and remove unused imports

Why are these changes required?

The topicsList parameter was never used in the actual logic. The method always used the topics from the log itself. This change:

  • Removes unnecessary API complexity
  • Simplifies the code
  • Maintains backward compatibility by deprecating the field instead of removing it

This PR has been tested by:

  • Unit Tests
    • ./gradlew framework:test --tests org.tron.core.WalletMockTest
    • ./gradlew framework:test --tests org.tron.core.ShieldedTRC20BuilderTest

Summary by cubic

Removes the unused topicsList from shielded TRC20 log APIs and simplifies log type detection to direct topic-bytes comparison. Deprecates the events fields in decrypt parameters and logs a warning when they’re sent, without changing behavior.

  • Refactors

    • Removed topicsList from internal methods and RPC/HTTP paths; APIs now ignore events.
    • Switched to direct topic-bytes matching in log type detection.
    • Marked events as deprecated in proto and added warning logs when present.
    • Updated tests and cleaned up unused imports.
  • Migration

    • No breaking changes. Clients can stop sending events; it is ignored.
    • Regenerate protobuf stubs to get the deprecated marker if needed.

Written for commit 09bdc09. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • Deprecated Features

    • Shielded TRC20 note scan events parameter is now deprecated and will be ignored.
  • API Changes

    • Updated shielded TRC20 note scanning methods by removing the events parameter from method signatures.
  • Improvements

    • Simplified log-type detection logic for shielded TRC20 transactions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

The changes remove the topicsList/ProtocolStringList parameter from Wallet's shielded TRC20 note scanning methods across multiple layers (core Wallet API, RPC services, HTTP servlets, and tests). The events field in protobuf messages is marked as deprecated, with deprecation warnings logged at call sites that still provide this parameter.

Changes

Cohort / File(s) Summary
Wallet Core API
framework/src/main/java/org/tron/core/Wallet.java
Removed ProtocolStringList topicsList parameter from getShieldedTRC20LogType, queryTRC20NoteByIvk, scanShieldedTRC20NotesByIvk, and scanShieldedTRC20NotesByOvk methods. Simplified log-type classification to rely solely on precomputed topic byte hashes.
RPC API Services
framework/src/main/java/org/tron/core/services/RpcApiService.java
Removed events parameter from wallet method calls. Added deprecation warnings in scanShieldedTRC20NotesByIvk and scanShieldedTRC20NotesByOvk handlers (both WalletApi and WalletSolidityApi variants) when events field is non-empty.
HTTP Servlets
framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java, framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByOvkServlet.java
Removed trailing events argument from wallet method calls. Added deprecation warnings for non-empty eventsList in both doPost and servlet logic. Removed unused Collectors import.
Test Updates
framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java, framework/src/test/java/org/tron/core/WalletMockTest.java
Updated test method invocations and reflective calls to match new signatures without the topicsList/events parameter. Removed unused protobuf type imports and local topicsList construction in test methods.
Protobuf Schema
protocol/src/main/protos/api/api.proto
Marked events field as deprecated in IvkDecryptTRC20Parameters (field 7) and OvkDecryptTRC20Parameters (field 5).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hopping through shielded notes with lighter feet,
The topics list has made its retreat!
With warnings sung for events of old,
Our cleaner signatures shine bright and bold.
A whisker-whisker of deprecation's grace! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing the unused topicsList parameter from shielded TRC20 APIs, which is the central focus of this pull request across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/shielded-log-cleanup

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 7 files

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
framework/src/main/java/org/tron/core/services/RpcApiService.java (1)

724-726: Throttle these new deprecation warnings.

These are public RPC paths. If older clients keep sending events, a WARN on every request will get noisy fast and hide real failures. A once-per-process or rate-limited helper would keep the migration hint without turning it into log spam, and the same helper can be reused by the HTTP servlets.

Also applies to: 747-749, 2416-2418, 2444-2446

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/src/main/java/org/tron/core/services/RpcApiService.java` around
lines 724 - 726, Replace the direct logger.warn calls for the deprecated
"events" field with a rate-limited/once-per-process deprecation helper so logs
aren't spammed; add a small reusable utility (e.g.,
DeprecationLogger.warnOnce(key, message) or RateLimitedLogger.warn(key, message,
intervalMillis)) that uses a static ConcurrentHashMap<String,
AtomicLong/Boolean> to track last-warning times or whether a key was already
logged, then call that helper from RpcApiService where you currently call
logger.warn("'events' field in IvkDecryptTRC20Parameters is deprecated and
ignored") (and the analogous sites handling the same deprecation) so the message
is emitted only once or at a controlled rate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@framework/src/main/java/org/tron/core/services/RpcApiService.java`:
- Around line 724-726: Replace the direct logger.warn calls for the deprecated
"events" field with a rate-limited/once-per-process deprecation helper so logs
aren't spammed; add a small reusable utility (e.g.,
DeprecationLogger.warnOnce(key, message) or RateLimitedLogger.warn(key, message,
intervalMillis)) that uses a static ConcurrentHashMap<String,
AtomicLong/Boolean> to track last-warning times or whether a key was already
logged, then call that helper from RpcApiService where you currently call
logger.warn("'events' field in IvkDecryptTRC20Parameters is deprecated and
ignored") (and the analogous sites handling the same deprecation) so the message
is emitted only once or at a controlled rate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4244d416-87e5-46d0-b8ec-92d11e3e1842

📥 Commits

Reviewing files that changed from the base of the PR and between 09127ab and 09bdc09.

📒 Files selected for processing (7)
  • framework/src/main/java/org/tron/core/Wallet.java
  • framework/src/main/java/org/tron/core/services/RpcApiService.java
  • framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java
  • framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByOvkServlet.java
  • framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java
  • framework/src/test/java/org/tron/core/WalletMockTest.java
  • protocol/src/main/protos/api/api.proto

@Federico2014 Federico2014 changed the title fix(crypto): remove unused topicsList from shielded TRC20 log APIs fix(crypto): remove unused topicsList from shielded TRC20 APIs Apr 1, 2026
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