Repository navigation
fix(framework): harden admin RPC, signature caching and peer tests #7137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release_v4.8.3
Are you sure you want to change the base?
Changes from all commits
970e40e
a87e433
178312f
9b326ce
20c91bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -586,11 +586,12 @@ private Sha256Hash getRawHash() { | |
| return Sha256Hash.of(this.transaction.getRawData().toByteArray()); | ||
| } | ||
|
|
||
| public void sign(byte[] privateKey) { | ||
| public synchronized void sign(byte[] privateKey) { | ||
| SignInterface cryptoEngine = SignUtils.fromPrivate(privateKey); | ||
| ByteString sig = ByteString.copyFrom(cryptoEngine.Base64toBytes(cryptoEngine | ||
| .signHash(getTransactionId().getBytes()))); | ||
| this.transaction = this.transaction.toBuilder().addSignature(sig).build(); | ||
| this.isVerified = false; | ||
| } | ||
|
|
||
| private static void checkPermission(int permissionId, Permission permission, Transaction.Contract contract) throws PermissionException { | ||
|
|
@@ -690,10 +691,11 @@ public Sha256Hash getTransactionId() { | |
| return this.id; | ||
| } | ||
|
|
||
| private void setRawData(Transaction.raw rawData) { | ||
| private synchronized void setRawData(Transaction.raw rawData) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [SHOULD] Synchronize transaction ID cache population and invalidation. Could On a cache miss, Using the same monitor would serialize cache population and invalidation, ensuring that the cached transaction ID remains consistent with the current Could we also add a concurrency regression test covering this race and verify that the cached transaction ID matches the updated |
||
| this.transaction = this.transaction.toBuilder().setRawData(rawData).build(); | ||
| // invalidate trxId | ||
| // Cached identity and verification are bound to raw_data. | ||
| this.id = null; | ||
| this.isVerified = false; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [SHOULD] Synchronize transaction mutations with signature validation to prevent stale verification results. Could we have With the current direct flag writes, an in-flight validation can complete after either mutation and set The existing concurrency test calls 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 20c91bf. |
||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[NIT] Could we add a test that verifies a signed capsule, calls
sign()again, and asserts thatisVerified()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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 20c91bf. The new test first validates a signed capsule, calls
sign()again, and checks thatisVerified()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 insign()is removed.