Skip to content

fix(crypto): harden shielded transaction safety and input validation#10

Open
Federico2014 wants to merge 1 commit intodevelopfrom
fix/shielded-transaction-safety
Open

fix(crypto): harden shielded transaction safety and input validation#10
Federico2014 wants to merge 1 commit intodevelopfrom
fix/shielded-transaction-safety

Conversation

@Federico2014
Copy link
Copy Markdown
Owner

@Federico2014 Federico2014 commented Apr 9, 2026

Summary

  • Fix ineffective timeout protection in VerifyTransferProofcountDownLatch.await() result was never checked, futures now cancelled on timeout
  • Add verification/proving context zero-value checks in VerifyMintProof, VerifyBurnProof, and ZenTransactionBuilder
  • Make UNCOMMITTED static initializer fail-fast instead of silently swallowing ZksnarkException
  • Change insertLeaves() and precompiled contract exception paths to return Pair.of(false, EMPTY_BYTE_ARRAY) to distinguish execution failure from verification failure
  • Remove no-op catch (ZksnarkException e) { throw e; } blocks in SaplingCheckSpendTask, SaplingCheckOutputTask, SaplingCheckBingdingSig, and ZenTransactionBuilder
  • Make JLibrustzcash.INSTANCE final
  • Add gRPC input validation for shielded API key parameters (ivk/ovk/ak/nk must be 32 bytes, contractAddress must be 21 bytes)
  • Fix HTTP ScanShieldedTRC20NotesByIvkServlet.doGet() missing events parameter parsing

Test plan

  • Verify ./gradlew clean build -x test passes
  • Run shielded transaction related tests
  • Verify gRPC endpoints reject invalid key lengths with INVALID_ARGUMENT
  • Verify ScanShieldedTRC20NotesByIvkServlet GET with events parameter works consistently with POST

Summary by cubic

Hardens shielded transaction safety and input validation across gRPC/HTTP and precompiles. Adds fail‑fast checks, proper completion semantics, and clear INVALID_ARGUMENT errors to prevent silent failures.

  • Bug Fixes

    • VerifyTransferProof: enforce latch timeout and cancel futures on timeout.
    • gRPC: validate ivk/ovk/ak/nk (32 bytes) and contractAddress (21 bytes); return INVALID_ARGUMENT; call onCompleted() only on success.
    • HTTP ScanShieldedTRC20NotesByIvk GET: parse events query; validate key and address lengths.
    • Tests: add valid-length inputs and negative tests asserting INVALID_ARGUMENT.
  • Hardening

    • Fail fast on zero/invalid zkSNARK contexts in VerifyMintProof, VerifyBurnProof, ZenTransactionBuilder, and ShieldedTRC20ParametersBuilder.
    • Precompiled contracts: execution failures return Pair.of(false, EMPTY_BYTE_ARRAY) to distinguish from verification failure.
    • UNCOMMITTED static init now throws on ZksnarkException; remove redundant rethrows; make JLibrustzcash.INSTANCE final.

Written for commit 305c6e4. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Hardened zkSNARK verification: clearer failure responses, canceled tasks on timeouts, stricter proving/verification init checks, and simplified verification task behavior.
    • Improved RPC/HTTP handlers: validate ivk/ovk/ak/nk and contract address lengths up front, return INVALID_ARGUMENT early, and emit completion only on success.
  • New Features

    • Optional event filtering for shielded TRC20 note scans via an events query.
  • Tests

    • Added tests asserting invalid-length inputs produce INVALID_ARGUMENT.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Narrowed zkSNARK exception handling, treat librustzcash init failures as errors, enforce explicit failure return values for verifications, simplify Sapling task callables, add strict byte-length validation and early INVALID_ARGUMENT responses for shielded RPCs and TRC20 servlet, and update tests with deterministic keys.

Changes

Cohort / File(s) Summary
zkSNARK verification & context init
actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java, framework/src/main/java/org/tron/core/zen/ZenTransactionBuilder.java
Replaced broad catch (Throwable) with catch (ZksnarkException) or removed redundant rethrows; treat librustzcash*CtxInit() returning 0 as failure (throw/early return); adjusted verification fallback returns to explicit failure values (false / empty bytes).
Sapling verification tasks
actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java (Sapling*Task classes)
Refactored callables to return JLibrustzcash verification results directly from try blocks; removed intermediate result variables and redundant catch-and-rethrow blocks.
VerifyTransferProof concurrency behavior
actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java
On CountDownLatch timeout, cancels submitted futures and returns immediately; changed final/fallback returns after failures to explicit failure values (false / empty bytes).
JLibrustzcash singleton
chainbase/src/main/java/org/tron/common/zksnark/JLibrustzcash.java
Made the singleton holder INSTANCE private static final.
Shielded RPC input validation & ordering
framework/src/main/java/org/tron/core/services/RpcApiService.java, framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java
Copy request keys into local byte[], validate exact lengths (ivk/ovk/ak/nk = 32 bytes; TRC20 contract address = 21 bytes); on invalid length call responseObserver.onError(Status.INVALID_ARGUMENT...) and return; move onCompleted() to success path; servlet parses optional events JSON array and supplies events list to wallet call.
Tests: deterministic dummy keys for shielded RPCs
framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java
Tests now construct deterministic 32-byte dummy keys and 21-byte dummy TRC20 contract addresses; added negative tests asserting INVALID_ARGUMENT for invalid-length inputs.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PrecompiledContracts
    participant ExecutorService
    participant SaplingTask
    participant JLibrustzcash
    Client->>PrecompiledContracts: submit VerifyTransferProof request
    PrecompiledContracts->>ExecutorService: submit SaplingTask instances
    ExecutorService->>SaplingTask: run task (concurrently)
    SaplingTask->>JLibrustzcash: call verification function
    JLibrustzcash-->>SaplingTask: return verification result
    SaplingTask-->>ExecutorService: complete future
    ExecutorService-->>PrecompiledContracts: signal via CountDownLatch
    alt timeout occurs
      PrecompiledContracts->>ExecutorService: cancel all futures
      PrecompiledContracts-->>Client: return failure (empty bytes / false)
    else all tasks complete
      PrecompiledContracts-->>Client: aggregate results and return success/failure bytes
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I checked each byte and nibbled errors away,
I hopped through futures when latches went astray,
I sniffed the Zksnark context until it stayed right,
Events and keys lined up neat and tight,
Now proofs bound along in the warm verification light.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% 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
Title check ✅ Passed The title 'fix(crypto): harden shielded transaction safety and input validation' directly and accurately summarizes the main changes: cryptographic safety improvements (fail-fast error handling, context checks) and input validation (key/address length validation) for shielded transactions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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-transaction-safety

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

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
framework/src/main/java/org/tron/core/services/RpcApiService.java (1)

663-681: ⚠️ Potential issue | 🟠 Major

Return immediately after onError() in the WalletSolidityApi scan handlers.

The gRPC Java StreamObserver contract specifies that onCompleted() and onError() are mutually exclusive terminal events—both may be called at most once and, if called, must be the last method invoked on that observer. These methods currently fall through to onCompleted() after catching exceptions and calling onError(), violating this contract. Add return; after each onError(...) call, matching the pattern already used in the corresponding WalletApi implementations.

Also applies to: 685-707, 711-728, 742-772, 776-801

🤖 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 663 - 681, The RPC handlers (e.g., RpcApiService.scanNoteByIvk) call
responseObserver.onError(...) but then continue and call
responseObserver.onCompleted(), violating the StreamObserver contract; update
each scan handler to return immediately after any responseObserver.onError(...)
call (add a plain return; after the onError call), including the ones that catch
exceptions and the ivk length validation branch, so that onCompleted() is never
invoked after onError; identify locations by method names like scanNoteByIvk and
the use of getRunTimeException to locate all similar handlers and apply the same
fix.
🧹 Nitpick comments (1)
framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java (1)

73-86: Add the same key/address length checks on the HTTP GET path.

doGet() now forwards ivk/ak/nk/shielded_TRC20_contract_address straight to wallet.scanShieldedTRC20NotesByIvk(...), while framework/src/main/java/org/tron/core/services/RpcApiService.java:742-761 rejects malformed 32-byte/21-byte inputs before reaching the wallet. Reusing that guard here would keep GET from entering the zk path with bad inputs and make transport behavior consistent.

Possible direction
-      GrpcAPI.DecryptNotesTRC20 notes = wallet
+      byte[] contractAddressBytes = ByteArray.fromHexString(contractAddress);
+      byte[] ivkBytes = ByteArray.fromHexString(ivk);
+      byte[] akBytes = ByteArray.fromHexString(ak);
+      byte[] nkBytes = ByteArray.fromHexString(nk);
+      if (ivkBytes.length != 32 || akBytes.length != 32 || nkBytes.length != 32) {
+        throw new IllegalArgumentException("ivk, ak, nk must each be 32 bytes");
+      }
+      if (contractAddressBytes.length != 21) {
+        throw new IllegalArgumentException("contractAddress must be 21 bytes");
+      }
+
+      GrpcAPI.DecryptNotesTRC20 notes = wallet
           .scanShieldedTRC20NotesByIvk(startNum, endNum,
-              ByteArray.fromHexString(contractAddress), ByteArray.fromHexString(ivk),
-              ByteArray.fromHexString(ak), ByteArray.fromHexString(nk),
+              contractAddressBytes, ivkBytes, akBytes, nkBytes,
               builder.getEventsList());
🤖 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/http/ScanShieldedTRC20NotesByIvkServlet.java`
around lines 73 - 86, In ScanShieldedTRC20NotesByIvkServlet.doGet(), add the
same input length validation used in RpcApiService for
shielded_TRC20_contract_address (21-byte) and ivk/ak/nk (32-byte) before calling
wallet.scanShieldedTRC20NotesByIvk; verify the hex strings decode to the
expected byte lengths (or that their hex length equals 42/64 chars respectively)
and return the same error/response path on failure so malformed inputs are
rejected early and behavior matches RpcApiService.java; perform these checks
immediately after reading request parameters and before building
IvkDecryptTRC20Parameters or invoking scanShieldedTRC20NotesByIvk.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@framework/src/main/java/org/tron/core/services/RpcApiService.java`:
- Around line 663-681: The RPC handlers (e.g., RpcApiService.scanNoteByIvk) call
responseObserver.onError(...) but then continue and call
responseObserver.onCompleted(), violating the StreamObserver contract; update
each scan handler to return immediately after any responseObserver.onError(...)
call (add a plain return; after the onError call), including the ones that catch
exceptions and the ivk length validation branch, so that onCompleted() is never
invoked after onError; identify locations by method names like scanNoteByIvk and
the use of getRunTimeException to locate all similar handlers and apply the same
fix.

---

Nitpick comments:
In
`@framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java`:
- Around line 73-86: In ScanShieldedTRC20NotesByIvkServlet.doGet(), add the same
input length validation used in RpcApiService for
shielded_TRC20_contract_address (21-byte) and ivk/ak/nk (32-byte) before calling
wallet.scanShieldedTRC20NotesByIvk; verify the hex strings decode to the
expected byte lengths (or that their hex length equals 42/64 chars respectively)
and return the same error/response path on failure so malformed inputs are
rejected early and behavior matches RpcApiService.java; perform these checks
immediately after reading request parameters and before building
IvkDecryptTRC20Parameters or invoking scanShieldedTRC20NotesByIvk.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9330320d-b583-4579-8e1e-4c07de4e4aff

📥 Commits

Reviewing files that changed from the base of the PR and between 3ab5adf and a87c625.

📒 Files selected for processing (5)
  • actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java
  • chainbase/src/main/java/org/tron/common/zksnark/JLibrustzcash.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/zen/ZenTransactionBuilder.java

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 5 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/test/java/org/tron/core/services/RpcApiServicesTest.java (1)

545-553: Add explicit negative-path coverage for length validation.

These inputs now cover the valid path, but there’s still no assertion here that invalid lengths are rejected. Adding one failure-case test would better lock in the new safety behavior.

[tags]

Proposed test addition
+  `@Test`
+  public void testScanShieldedTRC20NotesByIvkRejectsInvalidLengths() {
+    IvkDecryptTRC20Parameters invalid = IvkDecryptTRC20Parameters.newBuilder()
+        .setStartBlockIndex(1)
+        .setEndBlockIndex(10)
+        .setIvk(ByteString.copyFrom(new byte[31]))
+        .setAk(ByteString.copyFrom(new byte[32]))
+        .setNk(ByteString.copyFrom(new byte[32]))
+        .setShieldedTRC20ContractAddress(ByteString.copyFrom(new byte[20]))
+        .build();
+
+    try {
+      blockingStubFull.scanShieldedTRC20NotesByIvk(invalid);
+      Assert.fail("Expected invalid-length request to be rejected");
+    } catch (Exception e) {
+      Assert.assertTrue(e.getMessage().contains("INVALID_ARGUMENT"));
+    }
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java`
around lines 545 - 553, Add a negative-path unit test in RpcApiServicesTest that
verifies IvkDecryptTRC20Parameters rejects invalid-length fields: build
parameter instances where ivk/ak/nk are not 32 bytes (e.g., 31 or 33 bytes) and
shieldedTRC20ContractAddress is not 21 bytes, then assert the expected
validation failure/exception when calling the code under test (use the same
IvkDecryptTRC20Parameters builder pattern shown with dummyKey32/dummyAddr21 but
with wrong-length byte arrays) so the test covers explicit length-validation
failure cases.
🤖 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/test/java/org/tron/core/services/RpcApiServicesTest.java`:
- Around line 545-553: Add a negative-path unit test in RpcApiServicesTest that
verifies IvkDecryptTRC20Parameters rejects invalid-length fields: build
parameter instances where ivk/ak/nk are not 32 bytes (e.g., 31 or 33 bytes) and
shieldedTRC20ContractAddress is not 21 bytes, then assert the expected
validation failure/exception when calling the code under test (use the same
IvkDecryptTRC20Parameters builder pattern shown with dummyKey32/dummyAddr21 but
with wrong-length byte arrays) so the test covers explicit length-validation
failure cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 88fb39c1-d14b-4fbd-9dc4-f4d06f3b0250

📥 Commits

Reviewing files that changed from the base of the PR and between a87c625 and 305e199.

📒 Files selected for processing (3)
  • framework/src/main/java/org/tron/core/services/RpcApiService.java
  • framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java
  • framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java
  • framework/src/main/java/org/tron/core/services/RpcApiService.java

@Federico2014
Copy link
Copy Markdown
Owner Author

Both findings from the initial review are addressed in 305e199:

  1. StreamObserver contract violation (Major): Moved onCompleted() inside the try block after onNext() for all 6 shielded scan handlers in WalletSolidityApi, so onError() and onCompleted() are now mutually exclusive.

  2. HTTP GET input validation (Nitpick): Added ivk/ak/nk (32-byte) and contractAddress (21-byte) length checks in ScanShieldedTRC20NotesByIvkServlet.doGet(), consistent with the gRPC layer.

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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java">

<violation number="1" location="framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java:587">
P2: Assert the gRPC status code directly instead of matching exception message text, which is brittle and not API-stable.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java (1)

610-626: Add direct tests for invalid TRC20 contractAddress length.

Current TRC20 negative tests only exercise bad key-length branches. Add dedicated invalid shieldedTRC20ContractAddress length tests so that validation path is explicitly locked.

Suggested follow-up tests
+  `@Test`
+  public void testScanShieldedTRC20NotesByIvkRejectsInvalidContractAddressLength() {
+    IvkDecryptTRC20Parameters message = IvkDecryptTRC20Parameters.newBuilder()
+        .setStartBlockIndex(1)
+        .setEndBlockIndex(10)
+        .setIvk(ByteString.copyFrom(new byte[32]))
+        .setAk(ByteString.copyFrom(new byte[32]))
+        .setNk(ByteString.copyFrom(new byte[32]))
+        .setShieldedTRC20ContractAddress(ByteString.copyFrom(new byte[20]))
+        .build();
+    try {
+      blockingStubFull.scanShieldedTRC20NotesByIvk(message);
+      Assert.fail("Expected INVALID_ARGUMENT");
+    } catch (StatusRuntimeException e) {
+      Assert.assertEquals(Status.Code.INVALID_ARGUMENT, e.getStatus().getCode());
+    }
+  }
+
+  `@Test`
+  public void testScanShieldedTRC20NotesByOvkRejectsInvalidContractAddressLength() {
+    OvkDecryptTRC20Parameters message = OvkDecryptTRC20Parameters.newBuilder()
+        .setStartBlockIndex(1)
+        .setEndBlockIndex(10)
+        .setOvk(ByteString.copyFrom(new byte[32]))
+        .setShieldedTRC20ContractAddress(ByteString.copyFrom(new byte[20]))
+        .build();
+    try {
+      blockingStubFull.scanShieldedTRC20NotesByOvk(message);
+      Assert.fail("Expected INVALID_ARGUMENT");
+    } catch (StatusRuntimeException e) {
+      Assert.assertEquals(Status.Code.INVALID_ARGUMENT, e.getStatus().getCode());
+    }
+  }

Also applies to: 628-642

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

In `@framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java`
around lines 610 - 626, Add dedicated negative tests in RpcApiServicesTest to
assert that passing an invalid-length shieldedTRC20ContractAddress yields
INVALID_ARGUMENT: for the existing
testScanShieldedTRC20NotesByIvkRejectsInvalidLength create/modify the
IvkDecryptTRC20Parameters construction to
setShieldedTRC20ContractAddress(ByteString.copyFrom(new byte[21])) (or any
length != expected 20) and call blockingStubFull.scanShieldedTRC20NotesByIvk,
catching StatusRuntimeException and asserting Status.Code.INVALID_ARGUMENT; do
the same for the companion test that targets the OVK path (the test around lines
628-642) using the corresponding OvkDecryptTRC20Parameters and
blockingStubFull.scanShieldedTRC20NotesByOvk to lock the validation path for
contract address length.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java`:
- Around line 10-13: Reorder the gRPC import block so it matches the project's
Checkstyle ordering: group and alphabetize the gRPC imports
(io.grpc.ManagedChannel, io.grpc.ManagedChannelBuilder, io.grpc.Status,
io.grpc.StatusRuntimeException) in the import section; replace the current order
with the alphabetized sequence so Checkstyle passes.

---

Nitpick comments:
In `@framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java`:
- Around line 610-626: Add dedicated negative tests in RpcApiServicesTest to
assert that passing an invalid-length shieldedTRC20ContractAddress yields
INVALID_ARGUMENT: for the existing
testScanShieldedTRC20NotesByIvkRejectsInvalidLength create/modify the
IvkDecryptTRC20Parameters construction to
setShieldedTRC20ContractAddress(ByteString.copyFrom(new byte[21])) (or any
length != expected 20) and call blockingStubFull.scanShieldedTRC20NotesByIvk,
catching StatusRuntimeException and asserting Status.Code.INVALID_ARGUMENT; do
the same for the companion test that targets the OVK path (the test around lines
628-642) using the corresponding OvkDecryptTRC20Parameters and
blockingStubFull.scanShieldedTRC20NotesByOvk to lock the validation path for
contract address length.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a76ecd2a-e205-4d2c-bd33-db15c52dc065

📥 Commits

Reviewing files that changed from the base of the PR and between 495e25f and 2e13d33.

📒 Files selected for processing (1)
  • framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java

@Federico2014 Federico2014 force-pushed the fix/shielded-transaction-safety branch from b2fff12 to ac26b51 Compare April 9, 2026 11:56
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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@framework/src/main/java/org/tron/core/zen/ZenTransactionBuilder.java`:
- Around line 140-142: After calling
JLibrustzcash.librustzcashSaplingProvingCtxInit() in
ShieldedTRC20ParametersBuilder (where ctx is assigned), add the same defensive
check used in ZenTransactionBuilder: if ctx == 0 then throw a
ZksnarkException("Failed to initialize proving context"); this ensures
ShieldedTRC20ParametersBuilder (the method that calls
JLibrustzcash.librustzcashSaplingProvingCtxInit()) validates the native context
before proceeding and avoids undefined behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea189945-c312-4305-8a30-18b113cbc3ad

📥 Commits

Reviewing files that changed from the base of the PR and between 2e13d33 and ac26b51.

📒 Files selected for processing (6)
  • actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java
  • chainbase/src/main/java/org/tron/common/zksnark/JLibrustzcash.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/zen/ZenTransactionBuilder.java
  • framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java
✅ Files skipped from review due to trivial changes (2)
  • chainbase/src/main/java/org/tron/common/zksnark/JLibrustzcash.java
  • framework/src/main/java/org/tron/core/services/RpcApiService.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • framework/src/test/java/org/tron/core/services/RpcApiServicesTest.java
  • framework/src/main/java/org/tron/core/services/http/ScanShieldedTRC20NotesByIvkServlet.java

@Federico2014 Federico2014 force-pushed the fix/shielded-transaction-safety branch from ac26b51 to 305c6e4 Compare April 9, 2026 12:07
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