Skip to content

feat(l2ps): return the stored ciphertext with getL2PSHistory rows - #1033

Open
pallytin88 wants to merge 1 commit into
kynesyslabs:stabilisationfrom
pallytin88:l2ps/history-content
Open

pallytin88 wants to merge 1 commit into
kynesyslabs:stabilisationfrom
pallytin88:l2ps/history-content

Conversation

@pallytin88

@pallytin88 pallytin88 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

getL2PSHistory decrypts each stored payload for a reader who proved ownership of a subnet address, but only surfaces the message string from it. A member whose transactions carry a structured payload (we put a signed DACS-3 channel envelope under data[1]) cannot read it back through history.

This returns the row's encrypted_payload next to execution_message. One field on the history row; no new decryption on the node.

Why this shape

An earlier revision of this PR had the node decrypt and return content. A reviewer pointed out that the history signature proves the reader to the node, not the node to the reader, so a client that trusts a plaintext content field from whatever host it was pointed at is trusting the wrong party. Returning the ciphertext instead lets the member decrypt with the key it already holds and verify the decrypted hash against the row. The encrypted_payload is the same ciphertext the unauthenticated subnet listing (getL2PSTransactions) already serves, so the authenticated read exposes nothing new.

Tests

bun test src/libs/l2ps/historyPayload.test.ts src/libs/network/handlers/l2psHandlers.test.ts: pass. The pre-existing eslint naming-convention errors in l2psHandlers.ts are not from this change.

Context

This is the one local patch our self-hosted stabilisation node runs for the SuperColony private-RFQ showcase (DACS-3 negotiation over an L2PS subnet; only commitment hash and payment on the public testnet). Two external testers completed settled deals through it on 2026-10-09; the client side decrypts history locally as of pallytin88/dacs-rfq.

Filed by SuperColony; findings verified by parallel AUDITOR/DETECTIVE/ANALYST byte-verification.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KuxqrwyA8kuyT1ZJLUWZWo

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 88bec511-a8e3-44a6-b5a9-158120d8e3c3

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The patch appears safe to merge; the remaining SDK type gap is non-blocking.

Fix All in Claude CodeFindings

  1. P2 SDK type omits content ▶
Fix with agent prompt
### Issue 1
src/libs/network/handlers/l2psHandlers.ts:undefined-251
The node now returns `content`, but the SDK's [`L2PSHistoryEntry`](https://github.com/kynesyslabs/sdks/blob/HEAD/src/l2ps/history.ts#L15-L34) does not declare it. `getL2PSHistory` returns `Promise<L2PSHistoryPage>`, so TypeScript callers cannot access `row.content` without a cast even though the field reaches them at runtime. Coordinate a matching SDK type update, allowing the field to be absent when talking to older nodes.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The current patch adds stored encrypted_payload to account-history rows, rather than the decrypted content described in the PR text.

  • History rows include their stored encrypted payload.

Reviews (2) · Last reviewed commit: "feat(l2ps): return the stored ciphertext..." · Reviewed by Greptile

timestamp: tx.timestamp?.toString() || "0",
l1_block_number: tx.l1_block_number,
execution_message: messages[index],
content: contents[index],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 SDK type omits content

The node now returns content, but the SDK's L2PSHistoryEntry does not declare it. getL2PSHistory returns Promise<L2PSHistoryPage>, so TypeScript callers cannot access row.content without a cast even though the field reaches them at runtime. Coordinate a matching SDK type update, allowing the field to be absent when talking to older nodes.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/libs/network/handlers/l2psHandlers.ts
Line: 251

Comment:
**SDK type omits content**

The node now returns `content`, but the SDK's [`L2PSHistoryEntry`](https://github.com/kynesyslabs/sdks/blob/HEAD/src/l2ps/history.ts#L15-L34) does not declare it. `getL2PSHistory` returns `Promise<L2PSHistoryPage>`, so TypeScript callers cannot access `row.content` without a cast even though the field reaches them at runtime. Coordinate a matching SDK type update, allowing the field to be absent when talking to older nodes.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

getL2PSHistory decrypts each stored payload for a reader who proved
ownership of a subnet address, but only surfaces the `message` string
from it. A member whose transactions carry a structured payload (a
signed channel envelope under `data[1]`) cannot read it back at all.

Return the row's `encrypted_payload` next to `execution_message`. That
is the same ciphertext the unauthenticated subnet listing already
serves, so nothing new is exposed; a member holding the subnet key
decrypts it locally and checks the decrypted hash against the row,
instead of trusting a plaintext handed back by the node. The node
itself decrypts nothing more than it did before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KuxqrwyA8kuyT1ZJLUWZWo
@pallytin88
pallytin88 force-pushed the l2ps/history-content branch from 79bf5d5 to 970c315 Compare October 9, 2026 20:49
@pallytin88 pallytin88 changed the title feat(l2ps): return decrypted content with getL2PSHistory rows feat(l2ps): return the stored ciphertext with getL2PSHistory rows Oct 9, 2026
pallytin88 added a commit to pallytin88/dacs-rfq that referenced this pull request Oct 9, 2026
…yption, settlement binding, resumable approval, shared L2PS lock, auto-approve cap, CORS)

Findings from a private peer read of this package and kynesyslabs/node#1033,
each verified against the code and fixed here:

1. register.mts keeps only the host sealed into the credential; a host named
   by the clear-text status response is ignored (logged), and REGISTER_URL
   must be https:// off loopback. The L2PS client decrypts history locally
   from the row's stored ciphertext with the subnet key and checks the
   decrypted hash against the row; a `content` field from the node is never
   used (node#1033 now returns `encrypted_payload` instead of plaintext).
2. Terminal absence binds the failed transfer to the reservation: this payer,
   this payee, this amount. reconcile refuses an operator hash that differs
   from the remembered one, reports a chain-confirmed transfer as settled and
   never releases it, and writes evidence only after the chain check.
3. Settled authentication requires `amount` to equal the reserved amount and,
   when native-send args are present, those to name the same payee and
   amount (an OR between the two used to pass).
4. Approval records the minted subnet before funding and the signed funding
   hash before the broadcast (store.beginProvision / beginFunding; funder
   signs first and calls back). An approval interrupted after the broadcast
   resumes with the same subnet and never funds twice.
5. One lock per L2PS demos instance, shared by every subnet client and the
   tester funder, so no two broadcasts on that account take the same nonce.
6. The showcase viewer no longer sends access-control-allow-origin: *.
7. REGISTRATION_AUTO_APPROVE=all is bounded by REGISTRATION_AUTO_APPROVE_MAX
   (default 20); later requests wait for the operator.

Tests: 108 (6 new) covering the strict amount match, the bound terminal
absence and reconcile refusals, resumable approval, the cap, and local
decryption against the SDK's own ciphertext (outer-tx and bare shapes,
other key, other subnet, hash mismatch, node plaintext ignored).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KuxqrwyA8kuyT1ZJLUWZWo
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