Conversation
|
/crush_fast AI review started. |
Advanced AI Review
Click to expand reviewI'll review these changes by examining the full context of the code. Let me first look at the relevant sections of the Issue 1: No logging for decryption failures
🟡 Medium importance, high confidence Location: The issue description states:
And:
However, the new code does not log anything when decryption fails for V2 requests. When // Lines 1532-1539
if (Array.isArray(context) && context[0] !== originatingContractID) {
logEvtError(
message,
'Ignoring OP_KEY_REQUEST because it is signed by the wrong contract',
originatingContractID + ' !== ' + context[0]
)
return
}The misleading error is correctly avoided, but there's no replacement logging for the decryption failure case. This could make debugging difficult when investigating why a key request wasn't processed. Suggested improvement: // Used as a proxy to tell whether a request could be decrypted
const context = v.replyWith.context
if (Array.isArray(context)) {
if (context[0] !== originatingContractID) {
logEvtError(
message,
'Ignoring OP_KEY_REQUEST because it is signed by the wrong contract',
originatingContractID + ' !== ' + context[0]
)
return
}
} else {
// V1: Note that this branch applies to V1 requests as well, which will be removed
// in a future version. V2 requests should always have a context if properly decrypted.
logEvtError(
message,
'Ignoring OP_KEY_REQUEST because it could not be decrypted',
'No context available for message at height ' + message.height()
)
// Continue to store for record-keeping, but don't attempt to respond
}Issue 2: Missing V1-specific comment
⚪️ Low importance, high confidence Location: The issue summary states:
The new comment explains that // Used as a proxy to tell whether a request could be decrypted
const context = v.replyWith.contextWhile the logic correctly handles both versions, a clarifying comment would help future maintainers understand the V1 behavior before its removal. Suggested improvement: // Used as a proxy to tell whether a request could be decrypted.
// For V1: outer layer decryption failure results in undefined context
// For V2: inner layer decryption failure results in undefined context
// Note: V1 support is planned for removal
const context = v.replyWith.contextSummaryThe core fix correctly addresses the misleading error message issue by changing the condition from: // Old: data && (!Array.isArray(context) || context[0] !== originatingContractID)
// New: Array.isArray(context) && context[0] !== originatingContractIDThis ensures the "wrong contract" error is only logged when The 3-element Review generated using |
There was a problem hiding this comment.
Pull request overview
This PR aims to improve error handling and logging around processing OP_KEY_REQUEST messages that cannot be decrypted (notably V2 cases), addressing incorrect “wrong contract” reporting and tightening when follow-up response work is scheduled.
Changes:
- Adjust
OP_KEY_REQUESThandling to avoid treating undecryptable V2 requests as “wrong contract,” and add extra mismatch detail to the log when that condition occurs. - Gate post-sync key-request responding based on the presence of request “context” rather than
data. - Bump package version to
1.4.2(and update lockfile / dist outputs accordingly).
Reviewed changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/internals.ts |
Refines OP_KEY_REQUEST context checks and when respondToAllKeyRequests is scheduled. |
package.json |
Version bump to 1.4.2. |
package-lock.json |
Lockfile updated for version bump and transitive dependency resolution (includes flatted change). |
dist/esm/internals.mjs |
Built ESM output reflecting internals.ts changes. |
dist/cjs/internals.cjs |
Built CJS output reflecting internals.ts changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #64