fix(crypto): deprecate events field in shielded TRC20 scan APIs#6683
fix(crypto): deprecate events field in shielded TRC20 scan APIs#6683Federico2014 wants to merge 1 commit intotronprotocol:developfrom
Conversation
| @@ -722,18 +721,22 @@ public void isSpend(NoteParameters request, StreamObserver<SpendResult> response | |||
| @Override | |||
| public void scanShieldedTRC20NotesByIvk(IvkDecryptTRC20Parameters request, | |||
| StreamObserver<DecryptNotesTRC20> responseObserver) { | |||
There was a problem hiding this comment.
Really clean approach to the deprecation — rejecting early before any business logic runs is exactly the right pattern for deprecated fields!
Minor observation: the same events field check appears 8 times across this file and the two servlets (4 in RpcApiService + 2 in each servlet). Would it be worth extracting a tiny static helper like rejectIfEventsPresent(ProtocolStringList events) to keep the rejection message and logic in one place? If the error message ever needs updating, a single change point would be nice. Totally fine as-is though — it's a straightforward guard clause.
| Util.processError(e, response); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Love that both doGet and doPost are covered — easy to forget the GET handler in servlet deprecation work!
One subtle difference I noticed: in doPost, the check is !ivkDecryptTRC20Parameters.getEventsList().isEmpty() (protobuf list non-empty), while in doGet, the check is request.getParameter("events") != null. The doGet version will also reject ?events= (empty string), which is slightly stricter than the protobuf-based check. This is probably the right call for a deprecation, but wanted to flag in case the distinction matters for client compatibility.
What does this PR do?
Deprecates the
eventsfield in shielded TRC20 scan API requests and removes server-side log-type filtering.eventsfield as[deprecated = true]inIvkDecryptTRC20ParametersandOvkDecryptTRC20Parametersrequest messages inapi.protoINVALID_ARGUMENT, HTTP returns 400 when the deprecatedeventsfield is populatedtopicListparameter from internal method signatures inWallet,RpcApiService, and HTTP servlet handlers (ScanShieldedTRC20NotesByIvkServlet,ScanShieldedTRC20NotesByOvkServlet)Why are these changes required?
The
eventsfield allowed callers to filter shielded TRC20 event classes by passing user-controlled log topic strings that were hashed and matched server-side. This was an unnecessary attack surface — callers should always scan all log types and filter client-side. Removing the field simplifies the API contract and eliminates potential information leakage through selective scanning.scanShieldedTRC20NotesByIvk/Ovk— theeventsrequest field is now rejected outright (INVALID_ARGUMENTon gRPC, HTTP 400). Clients still sending the field must remove it. Clients that relied on the field to limit scan scope will now receive results for all log types.This PR has been tested by:
RpcApiServicesTest,WalletMockTest,ShieldedTRC20BuilderTest./gradlew clean build)Follow up
No consensus logic or on-chain state transitions affected.
Extra details