Skip to content

Add buffer reclaim command to the CLI - #204

Open
kaze-cow wants to merge 10 commits into
cli-buffer-createfrom
cli-reclaim-buffer
Open

kaze-cow wants to merge 10 commits into
cli-buffer-createfrom
cli-reclaim-buffer

Conversation

@kaze-cow

@kaze-cow kaze-cow commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds cow buffer reclaim <target> <buffer>[:<max burn>]..., which closes up to 11 buffer PDAs in one transaction, burns whatever they hold up to a per-buffer limit, and sends their rent to target. The CLI image also gets the Solana CLI and bc (#205), which the devops buffer-reclaim script uses.

Motivation

This is used by the reclaim scripts on the devops side. It's the last of the three PRs split out of the original version of this one, stacked on #207 (buffer create), which is stacked on #206 (order reclaim).

Considerations

Older deployments

Buffer and state PDAs are seeded with the <major>.<minor> release, so --settlement-version lets the CLI derive them for a deployment of an older release (e.g. 0.4). The interface gains settlement_seed_for_version for this, and the CLI wraps it in SettlementSeed, which validates the version string.

Burn limits

A buffer holding more than its burn limit is left open and listed instead of failing the batch, since the program would skip it anyway. Any other bad buffer (wrong owner, not at its mint's PDA, not a token account) aborts the whole batch before anything is sent.

Batch size

MAX_BUFFERS = 11 is the worst case: both token programs, and a reclaim authority signing separately from the payer.

How to test

cargo test -p cow-test-cli -p cow-settlement-interface
cargo run -p cow-test-cli -- buffer reclaim --help

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

SC-431

kaze-cow and others added 2 commits October 16, 2026 14:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reclaim-buffers derives PDAs with the solana cli and prices dust with
bc. Adds both
to the cow-cli image (solana v4.0.3, amd64-only since agave has no arm64
linux build) so
  buffer reclaim runs in-cluster.
@kaze-cow kaze-cow changed the title reclaimability in CLI Add buffer reclaim command to the CLI Oct 16, 2026
@kaze-cow
kaze-cow changed the base branch from main to cli-buffer-create October 16, 2026 05:51
@kaze-cow
kaze-cow marked this pull request as ready for review October 19, 2026 06:29
@kaze-cow
kaze-cow requested a review from a team as a code owner October 19, 2026 06:29
Comment thread test-cli/Dockerfile Outdated
Comment on lines +11 to +13
# Buffer reclaim derives PDAs and reads keypairs with the Solana CLI and prices
# dust with bc. Agave ships a prebuilt CLI for x86_64 Linux only, so the Solana
# CLI goes in on amd64 alone; order reclaim needs neither tool.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@glokos out of context, its unclear what this buffer reclaim script is as is commented here in this repo

Maybe better to just indicate here that its "useful to have" the solana toolchain here along with the CLI?

kaze-cow and others added 2 commits October 19, 2026 15:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kaze-cow added a commit that referenced this pull request Oct 19, 2026
# Description

Brings the `cow` CLI Docker image and its `CLI image` workflow into
`main`. This is all @glokos's work: it builds
`ghcr.io/cowprotocol/cow-cli` for amd64 and arm64, then merges both into
one manifest tagged with the sha and branch/tag. The image includes the
Solana CLI and `bc` that the buffer-reclaim script needs.

The first three commits are Assem's original commits from #190 and #205,
cherry-picked unchanged. The last one drops the temporary
`cli-reclaim-buffer` push trigger, which #190 said to remove once the
image landed in `main`.

## Motivation

#190 and #205 were merged into the reclaim stack's branches instead of
`main`, so the image work now shows up inside #206/#207/#204 and makes
them harder to review. Landing it here on its own means those PRs only
show CLI changes once they're rebased.

## Considerations

### Credit

Please **rebase-merge** this PR rather than squash it, so that Assem's
commits land on `main` with him as the author. The trigger commit lists
him as co-author too.

### Parity with the stack

`.github/workflows/cli-image.yml` and `test-cli/Dockerfile` on this
branch are byte-for-byte identical to the versions on
`cli-reclaim-buffer` (#204), so rebasing the stack onto `main`
afterwards should drop these files from its diff.

## How to test

This PR should be the same as those already included in the buffer
reclaim changes we eventually expect to merge:

```
git diff origin/cli-reclaim-buffer -- .github/workflows/cli-image.yml test-cli/Dockerfile   # empty
```

**Once merged**, any branch that contains the workflow file can be built
by hand, via Actions → CLI image → Run workflow (pick the branch under
"Use workflow from") or:

```
gh workflow run cli-image.yml --ref <branch>
```

Unfortunately it doesn't seem to be possible to workflow dispatch until
this is actually merged, but an example of this dockerfile generating a
successful build though CI is [already on its actions
page](https://github.com/cowprotocol/solana-programs/actions/workflows/cli-image.yml).

The image is tagged `cow-cli:<branch>` (slashes become `-`) and
`cow-cli:sha-<short>`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Assem Hasna <assem@cow.fi>
Co-authored-by: Assem Hasna <210342530+glokos@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
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