Repository navigation
Conversation
Reject method names outside the Admin API before invoking jsonrpc4j to prevent unknown requests and notifications from growing its static cache. Preserve annotated-name requirements and request ID semantics. Add HTTP and IPC regressions for unknown names, Java aliases, and notification requests. Refs: JT-971
Use real Channel fixtures with stub-only transport contexts so status queries do not retain Mockito invocation histories. Reset the raw peer pool, connection counters, and executor during teardown in ResilienceServiceTest and PeerStatusCheckTest. Cover disconnected-peer cleanup with a regression test. Refs: JT-283
Clear the verified flag whenever raw transaction data is replaced. Verify that changes to references, expiration, both timestamp setters, and fee limits invalidate the transaction ID and signature cache, and reject signatures created for the previous raw data.
| this.transaction = this.transaction.toBuilder().setRawData(rawData).build(); | ||
| // invalidate trxId | ||
| this.id = null; | ||
| setVerified(false); |
There was a problem hiding this comment.
[SHOULD] Invalidate the cached verification result when appending a signature.
Could sign() also call setVerified(false) after appending a signature?
Although the transaction ID remains unchanged, the cached verification result applies to the previous signature list and should no longer be considered valid.
Please also add a regression test verifying that appending a signature preserves the transaction ID, invalidates the cached verification result, and causes the next validation to evaluate the updated signature list.
There was a problem hiding this comment.
This method public void sign(byte[] privateKey) is not invoked by any production code, but call setVerified(false) is more safe. Fixed it in 9b326ce
| // invalidate trxId | ||
| // Cached identity and verification are bound to raw_data. | ||
| this.id = null; | ||
| this.isVerified = false; |
There was a problem hiding this comment.
[SHOULD] Synchronize transaction mutations with signature validation to prevent stale verification results.
Could we have setRawData() and sign() synchronize on the same capsule monitor as validateSignature()?
With the current direct flag writes, an in-flight validation can complete after either mutation and set isVerified back to true, even though the verification result applies to the previous transaction contents.
The existing concurrency test calls setVerified(false) directly. Could we extend the regression coverage to exercise the actual mutation paths, specifically setFeeLimit() and sign(), while signature validation is in progress?
Please verify that the cached verification result is invalidated once both operations have completed.
This would ensure that transaction mutations and signature validation are properly serialized, rather than relying solely on resetting the verification flag.
There was a problem hiding this comment.
Fixed in 20c91bf. setRawData() and sign() now synchronize on the same capsule monitor as validateSignature(). Added concurrency regressions exercising setFeeLimit() and sign() during an in-flight validation. They verify that mutations wait for validation and leave isVerified false after both operations complete. Both tests fail without the synchronization.
| ByteString sig = ByteString.copyFrom(cryptoEngine.Base64toBytes(cryptoEngine | ||
| .signHash(getTransactionId().getBytes()))); | ||
| this.transaction = this.transaction.toBuilder().addSignature(sig).build(); | ||
| this.isVerified = false; |
There was a problem hiding this comment.
[NIT] Could we add a test that verifies a signed capsule, calls sign() again, and asserts that isVerified() becomes false while the transaction ID stays the same? The current test signs before the first validation, so it would still pass if this line were removed.
There was a problem hiding this comment.
Added in 20c91bf. The new test first validates a signed capsule, calls sign() again, and checks that isVerified() becomes false while the transaction ID stays unchanged. It also verifies that the next validation rejects the updated signature list. Confirmed that the test fails if the cache-reset line in sign() is removed.
| } | ||
|
|
||
| private void setRawData(Transaction.raw rawData) { | ||
| private synchronized void setRawData(Transaction.raw rawData) { |
There was a problem hiding this comment.
[SHOULD] Synchronize transaction ID cache population and invalidation.
Could getTransactionId() synchronize on the same capsule monitor as setRawData()?
On a cache miss, getTransactionId() also writes to id. A concurrent caller could finish hashing the previous raw_data after setRawData() has invalidated the cache, repopulating it with a stale transaction ID.
Using the same monitor would serialize cache population and invalidation, ensuring that the cached transaction ID remains consistent with the current raw_data.
Could we also add a concurrency regression test covering this race and verify that the cached transaction ID matches the updated raw_data once both operations complete?
|
[SHOULD, FOLLOW-UP] Document the concurrency contract of As a follow-up, could we document which operations callers may safely perform concurrently on the same For example, Please clarify the supported concurrency guarantees and identify operations that callers must serialize externally. This would avoid implying that |
What does this PR do?
@JsonRpcMethod(required = true)semantics, response IDs, and empty responses for notifications.TransactionCapsule.isVerifiedwhensetRawData()replaces signed transaction data. Add regressions covering reference blocks, expiration, both timestamp setters, and fee limits.ResilienceServiceTestandPeerStatusCheckTestwith ordinary Channel fixtures and stub-only transport contexts. Reset the raw peer pool, connection counters, and executor during teardown, including already-disconnected peers.Why are these changes required?
Unknown Admin method names previously reached jsonrpc4j's unbounded static reflection cache, retaining a new entry for every distinct name even when the request returned
-32601or was a silent notification.A successful signature-verification result applies to the original raw transaction data. Keeping
isVerified = trueafter changing that data lets the same capsule skip verification of the modified transaction.In network tests, repeated status queries accumulated Mockito spy invocation records, while cleanup through the filtered active-peer list left disconnected peers in the static pool .
This PR has been tested by:
Local validation on macOS ARM64 / JDK 17:
Follow up
CI validation across the supported platform matrix.
Extra details
Admin method names are collected from the API interface and its annotations rather than maintained in a separate hard-coded list.