Skip to content

Store reclaim_recipient address in the state PDA - #84

Open
kaze-cow wants to merge 19 commits into
mainfrom
kaze/sc-151-state-receiver
Open

Store reclaim_recipient address in the state PDA#84
kaze-cow wants to merge 19 commits into
mainfrom
kaze/sc-151-state-receiver

Conversation

@kaze-cow

@kaze-cow kaze-cow commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Split out of #60 so the state PDA layout change can be reviewed on its own.

Up to now the settlement state PDA has been initialized with no data beyond its discriminator. This adds a single field to it: a reclaim_recipient account, configured once at Initialize time.

Changes

Initialize grows a reclaim_recipient parameter, and its wire format goes from [discriminator=3] (1 byte) to [discriminator=3, reclaim_recipient (32 bytes)] (33 bytes). The state PDA's data area grows to match.

The state body gets the same StateAccount / EncodedStateAccount encode-decode treatment as the other account types in interface/src/data, replacing the bare DISCRIMINATOR constant and decode helper.

Nothing reads reclaim_recipient yet — #60 is what puts it to use, as the account allowed to call ReclaimBuffer and the destination for reclaimed buffer funds.

Out of scope

Authorization, frontrunning prevention of calling Initialize. See #86

How to test

  • Confirm the reclaim_recipient naming and that a single configurable account is the right shape for this role.
  • cargo test --workspace — the initialize integration tests assert the PDA holds exactly the discriminator followed by the configured reclaim_recipient.

🤖 Generated with Claude Code

`Initialize` now takes a `receiver` pubkey and records it verbatim in the
settlement state PDA, growing the account from 1 byte (bare discriminator)
to 33. The body gets the same `StateAccount`/`EncodedStateAccount` encode-
decode treatment as the other account types.

`receiver` is the account that will collect reclaimed buffer funds; nothing
reads it yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kaze-cow
kaze-cow requested a review from a team as a code owner July 30, 2026 09:17
@linear-code

linear-code Bot commented Jul 30, 2026

Copy link
Copy Markdown

SC-151

@fedgiac fedgiac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One major discussion point: how do we plan to initialize the program in the first place? Right now, anyone can front-run our initialization.

Apart from that and some more minor comment, the design looks reasonable.

Also, I think we should update DESIGN.md (minimally!) to explain the role of this new "receiver" account.

Comment thread interface/src/data/state.rs Outdated
Comment thread interface/src/data/state.rs Outdated
Comment thread interface/src/data/state.rs Outdated
Comment thread interface/src/data/state.rs Outdated
Comment thread interface/src/data/state.rs Outdated
Comment thread interface/src/instruction/initialize.rs Outdated
Comment thread programs/settlement/src/initialize.rs Outdated
Comment thread interface/src/instruction/initialize.rs Outdated
Comment thread programs/settlement/tests/initialize.rs Outdated
Comment thread interface/src/instruction/initialize.rs Outdated
kaze-cow and others added 12 commits August 3, 2026 13:46
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
…olana-programs into kaze/sc-151-state-receiver
@kaze-cow
kaze-cow requested a review from fedgiac August 3, 2026 06:15
@kaze-cow kaze-cow changed the title Store a receiver address in the state PDA Store reclaim_recipient address in the state PDA Aug 3, 2026

@fedgiac fedgiac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me and I like the current design, I don't expect further comments after the current ones are addressed.

The "who calls it" discussion is still open but doesn't need to be addressed here (#86 is fine for tracking).

Comment thread interface/src/data/state.rs
Comment thread interface/src/instruction/initialize.rs Outdated
Comment thread DESIGN.md Outdated
Comment thread DESIGN.md Outdated
Comment thread DESIGN.md
Comment thread interface/src/data/state.rs Outdated
kaze-cow and others added 6 commits August 4, 2026 14:13
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
…olana-programs into kaze/sc-151-state-receiver
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kaze-cow
kaze-cow requested a review from fedgiac August 4, 2026 05:24
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.

2 participants