Repository navigation
fix(kotlin-sdk): refuse address types wider than a byte and document the address top-up outcomes - #5906
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit a4c762c) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (queue backlog)
The Kotlin/JNI external identity top-up path is correctly layered and preserves Rust ownership of validation, signing, lifecycle handling, and balance reconciliation. One input-marshalling bug remains: invalid Kotlin address types can be silently truncated into valid types before reaching Rust validation.
🟡 1 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Reject invalid address types before encoding funding inputs
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:69
FundingInput.addressType is an unconstrained Int, but DataOutputStream.writeByte retains only the low eight bits. An input with addressType = 256 is therefore encoded as 0 and decoded by JNI as P2PKH; addressType = 257 becomes 1 and is decoded as P2SH. The Rust funding_rows validator cannot recover the original value, so the external top-up can sign and spend against a different address type than the Kotlin caller supplied. Validate that addressType is exactly 0 or 1 before encoding, preferably in FundingInput.init so every use of this wire model is protected.
init {
require(addressType == 0 || addressType == 1) {
"FundingInput.addressType must be 0 (P2PKH) or 1 (P2SH), got $addressType"
}
require(hash.size == 20) { "FundingInput.hash must be 20 bytes, got ${hash.size}" }
require(credits > 0) { "FundingInput.credits must be positive, got $credits" }
}
source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, security-auditor)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — This is a contained Kotlin-to-JNI feature addition that crosses an FFI boundary and initiates an external identity top-up, but it does not change the Rust funds-handling logic itself or meet the critical-tier bar for a large intricate change to that critical surface. - Phase 1 reviewers: not run (skipped for throughput: 19 PRs queued, above the 10 limit)
- Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:69: Reject invalid address types before encoding funding inputs
`FundingInput.addressType` is an unconstrained `Int`, but `DataOutputStream.writeByte` retains only the low eight bits. An input with `addressType = 256` is therefore encoded as `0` and decoded by JNI as P2PKH; `addressType = 257` becomes `1` and is decoded as P2SH. The Rust `funding_rows` validator cannot recover the original value, so the external top-up can sign and spend against a different address type than the Kotlin caller supplied. Validate that `addressType` is exactly `0` or `1` before encoding, preferably in `FundingInput.init` so every use of this wire model is protected.
9111d54 to
1a2d6bf
Compare
b73cec9 to
83b4d57
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The new Kotlin binding delegates the payment to the existing Rust wallet composite, but its public signer parameter can outlive the manager that owns it, and both top-up KDocs overstate what cancellation-safe result delivery guarantees. The head conflicts with the current stacked base in credits.rs and PARITY_SUMMARY.md; preserve the base’s empty-input forwarding and regenerate the summary from the merged manifest. No build or test check is listed for this head, and the review check is pending.
🔴 1 blocking | 🟡 2 suggestion(s)
2 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Bind the signer borrow to the manager whose teardown gate is held
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:311-318
PlatformWalletManager constructs this facade with its own teardown gate, but this method accepts a signer pointer independently. After a manager replacement, a cached signer handle from the previous manager can reach JNI through the new facade. The previous manager waits only for its own gate before freeing the signer; the new gate cannot protect that borrow. The FFI checks for null, then dereferences the handle as a VTableSigner on its worker. Have the new API obtain the manager-owned signer inside the matching gate, as shieldedShieldToRecipient does. If callers need custom signers, accept an owner that can hold the signer live through the native call instead of a raw Long.
source: gpt-6.2-astra (phase2-reviewer: general)
🟡 Suggestion: Reject invalid address types before encoding funding inputs
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:70
The external top-up reuses FundingInput.encode, where writeByte discards all but the low eight bits of the public Int. A value of 256 reaches funding_rows as 0, so Rust interprets the hash as P2PKH instead of rejecting the input. Check that the value fits the wire u8 before writing it, as the withdrawal encoder does. Rust should remain the only layer that decides which byte tags are supported.
require(input.addressType in 0..255) { "FundingInput.addressType must fit in a byte" }
dos.writeByte(input.addressType)
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This change modifies Kotlin and Rust JNI code that initiates external identity credit transfers and handles cancellation, broadcasting, and retry outcomes, directly affecting funds movement through a cross-language boundary. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:311-318: Bind the signer borrow to the manager whose teardown gate is held
`PlatformWalletManager` constructs this facade with its own teardown gate, but this method accepts a signer pointer independently. After a manager replacement, a cached signer handle from the previous manager can reach JNI through the new facade. The previous manager waits only for its own gate before freeing the signer; the new gate cannot protect that borrow. The FFI checks for null, then dereferences the handle as a `VTableSigner` on its worker. Have the new API obtain the manager-owned signer inside the matching gate, as `shieldedShieldToRecipient` does. If callers need custom signers, accept an owner that can hold the signer live through the native call instead of a raw `Long`.
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:70: Reject invalid address types before encoding funding inputs
The external top-up reuses `FundingInput.encode`, where `writeByte` discards all but the low eight bits of the public `Int`. A value of `256` reaches `funding_rows` as `0`, so Rust interprets the hash as P2PKH instead of rejecting the input. Check that the value fits the wire `u8` before writing it, as the withdrawal encoder does. Rust should remain the only layer that decides which byte tags are supported.
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:302-305: Tell callers when they must record a completed top-up
`opReturningCompletedResult` delivers the balance to the immediate caller but leaves the coroutine cancelled. A caller that then switches dispatchers to record success can be cancelled before the write, leaving the payment completed but unrecorded. The regression test records the result with `received.complete(...)` without suspending. Replace the unconditional guarantee here and in the managed top-up KDoc with an instruction to handle the result before the next cancellable suspension.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Preserve completed results for other identity-funded sends —
IdentityCredits.transferToAddressesstill uses plaingate.oparound a blocking JNI payment. Cancellation on the return dispatch can discard a completed transfer’s result, and retrying initiates a new payment. This identity-funded send is unchanged by the address-funded top-up PR.- Follow-up: Review the remaining identity-funded sends in a follow-up PR and test completed-result delivery for fresh payments separately from recovery of existing asset locks.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix. |
83b4d57 to
18fc72a
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The external route remains a thin delegation to the Rust wallet, and the supplied Kotlin emulator and Rust workspace checks passed. The current head still has a signer lifetime vulnerability, a lossy funding-input encoding path, incomplete cancellation guidance, and a cancellation-test cleanup race; the real JNI smoke test also stops before exercising the new export's FFI error path.
🔴 1 blocking | 🟡 2 suggestion(s)
2 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Bind the signer borrow to the manager whose teardown gate is held
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:311-318
IdentityCredits holds the teardown gate of the manager that constructed it, but this method forwards any caller-supplied raw signerHandle. If a signer from manager B is passed through manager A's facade, closing B drains B's gate and frees its signer while A's gate still allows the JNI call to run. The FFI then borrows the freed pointer as a VTableSigner; wallet-generation checks protect the wallet handle, not the signer allocation. Resolve the manager-owned signer inside the gate that protects the call, or use an owner-aware signer borrow that remains alive through JNI.
source: muse-spark-1.3-contributor (phase1-reviewer: rust-quality); gpt-6.2-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, security-auditor)
🟡 Suggestion: Reject invalid address types before encoding funding inputs
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:70
FundingInput.addressType is an Int, but DataOutputStream.writeByte silently retains only its low eight bits. Values such as 256 and 257 therefore reach Rust as address types 0 and 1, so the Rust validator cannot reject the original malformed value and the request can operate on a different funding-address type than the caller supplied. Add a wire-width check in the shared encoder, while leaving validation of which representable tags are supported to Rust.
require(input.addressType in 0..0xFF) {
"FundingInput.addressType must fit in an unsigned byte, got ${input.addressType}"
}
dos.writeByte(input.addressType)
source: muse-spark-1.3-contributor (phase1-reviewer: rust-quality); gpt-6.2-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality)
Still open from earlier rounds (1)
- 🟡 Suggestion: Tell callers when they must record a completed top-up —
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:302-305(thread)
Follow-up candidates (optional) (2)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: Release the simulated native call when the start assertion fails
packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/credits/ExternalIdentityTopUpTest.kt:97-100
If the five-second startup wait fails just as the worker enters the fake native call, the assertion throws before release.countDown(). The worker can then block forever in CountDownLatch.await() because coroutine cancellation does not interrupt it, and runBlocking waits for the child instead of reporting the assertion failure. Put cancellation and latch release in finally; apply the same structure to the managed cancellation test at lines 103-106.
try {
assertTrue("native top-up never started", entered.await(5, TimeUnit.SECONDS))
} finally {
call.cancel()
release.countDown()
}
withTimeout(5_000) { call.join() }
source: gpt-6.2-sol (phase2-reviewer: general)
🟡 Suggestion: Exercise FFI error propagation through the real JNI bridge
packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt:186-196
The smoke test uses a 31-byte identity ID, so JNI returns from read_id32 before decoding the inputs blob, invoking the new platform-wallet export, or calling take_pwffi_error. The JVM tests inject native failures and therefore cannot catch a regression in those new JNI steps. Add a valid 32-byte ID and a deterministic native rejection, such as a null signer, then assert its mapped error code.
val error = assertThrows(DashSDKException::class.java) {
CreditsNative.topUpExternalIdentityFromAddresses(
0L,
ByteArray(32),
FundingInput.encode(emptyList()),
0L,
)
}
assertEquals(1003, error.code)
source: gpt-6.2-sol (phase2-reviewer: rust-quality)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The new JNI binding and the cancellation behavior change for both top-up methods warrant review, but the diff does not change the underlying funds-movement or signing logic. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Code unchanged since the last final review (
83b4d572): 2 new suggestion(s) listed as follow-up candidates, not posted inline - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:311-318: Bind the signer borrow to the manager whose teardown gate is held
`IdentityCredits` holds the teardown gate of the manager that constructed it, but this method forwards any caller-supplied raw `signerHandle`. If a signer from manager B is passed through manager A's facade, closing B drains B's gate and frees its signer while A's gate still allows the JNI call to run. The FFI then borrows the freed pointer as a `VTableSigner`; wallet-generation checks protect the wallet handle, not the signer allocation. Resolve the manager-owned signer inside the gate that protects the call, or use an owner-aware signer borrow that remains alive through JNI.
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:70: Reject invalid address types before encoding funding inputs
`FundingInput.addressType` is an `Int`, but `DataOutputStream.writeByte` silently retains only its low eight bits. Values such as 256 and 257 therefore reach Rust as address types 0 and 1, so the Rust validator cannot reject the original malformed value and the request can operate on a different funding-address type than the caller supplied. Add a wire-width check in the shared encoder, while leaving validation of which representable tags are supported to Rust.
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:302-305: Tell callers when they must record a completed top-up
(carried; thread: https://github.com/dashpay/platform/pull/5906#discussion_r4636973474)
Out-of-scope follow-up suggestions (2)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Persist unresolved top-up outcomes across re-entry and restart — The external route exposes the existing unconfirmed outcome, but the wallet still does not durably retain the inputs or a pending operation that can be resolved after a host loses the returned result. A retry after re-entry can therefore submit a second payment whose first broadcast is still uncertain.
- transferToAddresses still drops a completed transfer on cancellation — Dropped as outside this PR's responsibility: the transfer method and its gate.op behavior are pre-existing and unchanged, while this PR specifically changes the two address top-up methods. The related durable pending-operation problem is tracked separately.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix. |
18fc72a to
64839cb
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 2 blockers
- The external top-up branch no longer merges into v5.2-dev —
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:257-269(new)
Impact: Maintainers cannot merge the reviewed head intov5.2-devdespite its passing build and test checks. - Bind the signer borrow to the manager whose teardown gate is held —
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:316-328(carried)
Impact: An Android app can crash in native code if it submits a top-up through a replacement wallet manager while retaining the previous manager's signer handle.
New on this head: This revision of the Kotlin external identity top-up binding rejects funding address types that cannot fit in the wire byte, clarifies cancellation handling for both top-ups, and refreshes the parity summary. On the reviewed head, the Kotlin SDK emulator build and tests and the Rust workspace tests passed; PR Hygiene and PastaClaw review were pending.
🔴 2 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Bind the signer borrow to the manager whose teardown gate is held
Impact: An Android app can crash in native code if it submits a top-up through a replacement wallet manager while retaining the previous manager's signer handle.
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:316-328
A top-up can dereference a freed signer even when its funding wallet is valid. WalletManagerStore publishes a replacement before closing the previous manager. If an app submits a pending top-up with the new manager's facade and wallet but a signer handle captured before replacement, the call holds only the new manager's gate. The previous manager drains its own gate before freeing the signer, and JNI forwards the supplied handle unchanged to identity_top_up.rs:246–273, where the worker borrows it without retaining it. The linked Android caller takes the facade and signer from the same manager and is protected as written, but the public method does not enforce that pairing. Resolve the signer from the facade's owning manager inside its gate and hold the gate until JNI returns; apply the same ownership rule to the unified entry point if it replaces this method.
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The diff adds a Kotlin-to-JNI binding and changes cancellation behavior for both top-up calls, but leaves the underlying funds-movement and signing logic unchanged. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: models 0% left),glm-5.3-flash(not used above high effort; tier asks max) - New since the last final review (
18fc72a3): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:316-328: Bind the signer borrow to the manager whose teardown gate is held
Impact: An Android app can crash in native code if it submits a top-up through a replacement wallet manager while retaining the previous manager's signer handle.
A top-up can dereference a freed signer even when its funding wallet is valid. `WalletManagerStore` publishes a replacement before closing the previous manager. If an app submits a pending top-up with the new manager's facade and wallet but a signer handle captured before replacement, the call holds only the new manager's gate. The previous manager drains its own gate before freeing the signer, and JNI forwards the supplied handle unchanged to `identity_top_up.rs:246–273`, where the worker borrows it without retaining it. The linked Android caller takes the facade and signer from the same manager and is protected as written, but the public method does not enforce that pairing. Resolve the signer from the facade's owning manager inside its gate and hold the gate until JNI returns; apply the same ownership rule to the unified entry point if it replaces this method.
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/credits/IdentityCredits.kt:257-269: The external top-up branch no longer merges into v5.2-dev
Impact: Maintainers cannot merge the reviewed head into `v5.2-dev` despite its passing build and test checks.
The current target tip cannot merge this head cleanly. After this branch rebased, #5929 (`59fd81f181fc`) added `topUpIdentityFromAddresses` for both managed and external recipients, preserved completed results after cancellation, and marked Kotlin external top-ups supported. Git reports conflicts in `IdentityCredits.kt`, including the revised cancellation KDoc, as well as in `credits.rs` and `sdk-parity-manifest.json`. Rebase onto #5929 and carry the stronger cancellation guidance onto the unified API. The linked Android change already calls the external-only name, so update that caller or preserve the name as a Kotlin alias rather than maintaining a second JNI bridge.
_Confirmed by an independent pass: When a maintainer tries to merge PR #5906 at 64839cb199 into the current v5.2-dev tip, 59fd81f181fc, Git reports content conflicts in IdentityCredits.kt, credits.rs, and sdk-parity-manifest.json. GitHub marks this exact head CONFLICTING, so it cannot land until those conflicts are resolved._
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
64839cb to
e856de5
Compare
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: The rebased PR drops the separate Kotlin external top-up binding in favor of the any-identity binding already on v5.2-dev. It rejects recipient address types that cannot fit in one byte, documents top-up outcomes and cancellation, and adds regression tests. The Kotlin SDK build, x86_64 emulator tests, and parity check passed; PR Hygiene and the review check remain pending.
🟡 1 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.2-sol(effort low) — The only production behavior change is two constructor range checks that prevent silent byte truncation; the rest documents and tests existing behavior. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 51% left, weekly 43% left; passed overgemini-3.8-flash-high(lane failed) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.2-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt:179-197: The JNI smoke test still passes if the any-identity call uses the managed-only export
Impact: If JNI is wired to the managed-only export, SDK callers lose the ability to top up identities outside their wallet while this emulator test still passes.
The smoke test proves that the Kotlin symbol binds and that a native error reaches Kotlin, but not that JNI selected the intended export. The new null-signer probe reaches the Rust FFI, where both exports use the same `address_top_up` helper and return `ErrorNullPointer` before checking which route was selected. The JVM error-mapping tests inject their own bridges, so they cannot distinguish the exports either. Name and document this as a linkage and error-propagation test, or add a JNI case with a valid signer and a Platform identity that the wallet does not manage so the two routes produce different outcomes.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…e does not fit a byte CreditOutput and FundRecipient are written to their native blobs with DataOutputStream.writeByte, which keeps only the low 8 bits, so an addressType of 256 reached Rust as 0 (P2PKH) and the credits went to an address the caller did not name. Both now refuse a value outside 0..255 when constructed, as FundingInput and the withdrawal input already do. Which byte values are supported stays Rust's decision. Raised as an out-of-scope follow-up in the review of #5929. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… of any identity - KDoc on topUpIdentityFromAddresses lists the outcomes a caller must tell apart: unknown identity (NotFound), failed lookup (IdentityLookupFailed, retryable), unproved top-up (TransactionBroadcastUnconfirmed: keep it pending, never resubmit; nonce refusals land here too) and a wallet removed before send (PlatformWallet.NotFound). It also says a cancelled caller that receives a completed balance stays cancelled and must record the result before its next cancellable suspension. The deprecated managed route notes its NotFound and IdentityBalanceUnavailable differences. - IdentityAddressTopUpTest pins those mappings (7, 80, 20, 98; 58 on the deprecated route), that empty inputs are left to Rust, and releases the simulated native call in a finally block so a failed start assertion cannot hang the cancellation test. - FfiSmokeTest checks the topUpIdentityFromAddresses JNI symbol reaches its export and maps its error: a null signer surfaces as PLATFORM_WALLET_CODE_OFFSET + 3 (ErrorNullPointer). Co-Authored-By: Claude Opus 5.5 <[email protected]>
e856de5 to
a4c762c
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This rebase keeps the Kotlin address-type byte-width guards and top-up outcome documentation unchanged, and renames the JNI smoke test to clarify that it checks linkage and native error propagation, not export selection. The Kotlin SDK build and x86_64 emulator tests passed on this head; no code checks failed, and PastaClaw review and PR Hygiene remain pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.2-sol(effort low) — The only production behavior change is a straightforward byte-range check in two Kotlin constructors; the rest is documentation and tests. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(zai below 15% reserve: 5h 93% left, weekly 5% left) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.2-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
|
/self-reviewed |
Issue being fixed or feature implemented
#5929 merged the Kotlin top-up of any identity (
IdentityCredits.topUpIdentityFromAddresses), so the separate external binding this PR used to add is no longer needed. This PR keeps the three parts #5929 does not cover:ManagedPlatformWallet.CreditOutputandFundRecipientare written to their native blobs withDataOutputStream.writeByte, which keeps only the low 8 bits. AnaddressTypeof 256 reaches Rust as 0 (P2PKH), so credits go to an address the caller did not name. feat(platform-wallet): one address top-up for any identity #5929 added the check toFundingInputonly, and the withdrawal input already had one.What was done?
CreditOutputandFundRecipientrefuse anaddressTypeoutside 0..255 when constructed, the way feat(platform-wallet): one address top-up for any identity #5929 didFundingInput. Which byte values are supported stays Rust's decision.IdentityCredits.topUpIdentityFromAddressesnames the outcomes a caller must tell apart:NotFound(7): Platform does not know the identity; nothing was sent.PlatformWallet.IdentityLookupFailed(80): the lookup failed; nothing was sent, and the call can be retried.PlatformWallet.TransactionBroadcastUnconfirmed(20): the top-up may have executed. Do not resubmit it and keep it pending (Bind affected-state proofs to transition execution #4270). A nonce refusal is reported as 20, never 21.PlatformWallet.NotFound(98): the wallet was removed or re-created before anything was sent.topUpFromAddressesnotes its two differences:NotFoundmeans the wallet does not manage the identity, and no balance from Platform is the retryableIdentityBalanceUnavailable(58).No Rust, FFI, JNI or Swift changes, no new error codes, no parity changes.
How Has This Been Tested?
IdentityAddressTopUpTest(JVM, 6 tests):IdentityBalanceUnavailableon the deprecated route;finally.CreditOutputTest(new, 2 tests) andFundFromAssetLockRecipientTest(one new test): −1, 256, 257 andInt.MAX_VALUEare refused; 0, 1 and 255 are accepted, and 255 is encoded as 255.FfiSmokeTest.identityTopUpFromAddressesLinksAndPropagatesNativeErrors(instrumented): calls the realtopUpIdentityFromAddresseswith a 32-byte id, one funding row and a null signer. The export refuses the null signer before reading any handle, and Kotlin receivesPLATFORM_WALLET_CODE_OFFSET + 3(ErrorNullPointer). This proves the symbol links, the JNI decoding works and the error mapping holds. It does not prove which export JNI calls: the any-identity and managed-only exports share the helper that makes this check, so its KDoc says so.FfiSmokeTestpasses 25/25 on an x86_64 emulator (Android 16) against abuild_android.sh --abi x86_64library built from this branch.python3 scripts/check_sdk_parity_manifest.py: OK.e856de5f89, before the latest rebase): no findings. thepastaclaw approvede856de5f89; its one suggestion (the smoke test does not prove the export route) is taken as the rename and KDoc above.Breaking Changes
None for valid callers. Building a
CreditOutputorFundRecipientwith anaddressTypeoutside 0..255 now throwsIllegalArgumentException; before, the value was silently truncated to another address type.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
a4c762cWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.