Skip to content

Step 0.2/0.3: program swaps with the real buffer addresses - #2

Merged
sense112 merged 2 commits into
cookie/4.1.2from
cookie/4.1-program-swaps
Nov 10, 2026
Merged

sense112 merged 2 commits into
cookie/4.1.2from
cookie/4.1-program-swaps

Conversation

@n4pless

@n4pless n4pless commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Upgrade plan Step 0.2 (buffer keypairs) and Step 0.3 items 1–3 (release code with the real buffer addresses, tests green). Base: cookie/4.1.2 with C1 merged (1f47903).

Commits

  1. 51dbc0b 4.1 program swaps is Sense's plans/4.1/release/0001-cookie-program-swaps.patch from cookie-upgrade-plan 2d4d665, applied unchanged. It contains the token trigger CDJ9yJcf…, the token/stake/stake-v5 swaps from Cookie buffers, hash checks, one swap per program per boundary, and the COOKIE-TOUCHPOINTS rows.
  2. e797bed Step 0.2 is the only new change:
    • The three placeholder declare_id!s in runtime/src/bank/builtins/core_bpf_migration/cookie.rs now hold the real addresses. The doc comment there now says step 0.2; it wrongly said 0.1.
    • cookie_programs/.gitignore keeps the downloaded .so files out of git.
    • A missing program file now says how to download it, instead of a bare unwrap.

Buffer addresses (consensus constants)

Buffer Will hold Address
token_buffer p-token 1.0.0 7anfKyfCz8krv8Jvmg9DLAjS9WvzfDY2XfBJZyLyoYBF
stake_buffer stake 4.0.0 djJonZTCuwfU9hkuntGjLZeXf6bziS76PuwDJUfxqHm
stake_v5_buffer stake 5.0.0 BYeWRbFpEi8wf5UCXypQJ9CvHh3UrfggqF6MYy1UuLCx

The keypairs were made offline on 10 Nov 2026. Wesley holds them in two places off any server, and they are not in this repo.

Proof we hold the keys. Each key signed Cookie 4.1 <name> <address>. Anyone can check this without the key:

solana verify-offchain-signature --signer 7anfKyfCz8krv8Jvmg9DLAjS9WvzfDY2XfBJZyLyoYBF \
  "Cookie 4.1 token-buffer 7anfKyfCz8krv8Jvmg9DLAjS9WvzfDY2XfBJZyLyoYBF" \
  7Z3odzrmyqy1VJhir1p1hZkq2xntXBYhwJB6NuuhR4ToYCFLworcFMNWq4CN8wpeYmzv2t5UNz1xWMet9HpjBRo

solana verify-offchain-signature --signer djJonZTCuwfU9hkuntGjLZeXf6bziS76PuwDJUfxqHm \
  "Cookie 4.1 stake-buffer djJonZTCuwfU9hkuntGjLZeXf6bziS76PuwDJUfxqHm" \
  4rDe6n5WHjZLHEowNZWbgWccFvAdQKjgzff4Rg7msABNgPRBpGxn44SAE6Hq7tPjrALaXxQtRd8UypAb2QYbD6pF

solana verify-offchain-signature --signer BYeWRbFpEi8wf5UCXypQJ9CvHh3UrfggqF6MYy1UuLCx \
  "Cookie 4.1 stake-v5-buffer BYeWRbFpEi8wf5UCXypQJ9CvHh3UrfggqF6MYy1UuLCx" \
  4LKkLafqjWonwVQypP1qyDGAGtGrW4y6FtF71oUU77QHDwV7HiCVCUUQ33Kx89DN3J4ofGXfXdenid6ZEWy2GR3E

A typo in a consensus constant would need a new release, which is why this proof matters.

Tests (WSL, rust 1.95.0)

First download the program files: plans/4.1/scripts/fetch_programs.sh runtime/src/bank/builtins/core_bpf_migration/cookie_programs. All three hashes match.

Command Result
cargo test -p solana-runtime --lib cookie -- --include-ignored 20 passed, including cookie_release_buffers_configured, which now passes (it is the placeholder check)
cargo test -p solana-runtime --lib core_bpf_migration 58 passed, 1 ignored (the placeholder check, run above)
cargo test -p agave-feature-set --features agave-unstable-api 291 passed
cargo clippy -p solana-runtime --lib --tests -- -D warnings clean
cargo clippy -p agave-feature-set --features agave-unstable-api --tests -- -D warnings clean
cargo +nightly fmt -p solana-runtime -p agave-feature-set -- --check clean

cargo +nightly fmt --all --check reports diffs only in syscalls/. Those files are upstream and unchanged here; the diffs come from a newer nightly rustfmt, and the merged base shows them too.

One thing to decide: write the buffers early

In 4.1.2, solana program write-buffer creates the buffer with the system CreateAccount. That refuses an address that already holds any lamports (AccountAlreadyInUse). Once these addresses are known, anyone could send 1 lamport to one of them and make the normal command fail.

This is not fatal. System Allocate and Assign only need the buffer key's signature, so a small script could still build the buffer. Even so, the simple fix is to do step 0.7 soon after this merges, before the release reaches operators. The plan already allows this: nothing reads a buffer before its step, and the only ordering rule is "written before the step that uses it". Cost is about 3.6 COOK of rent, and the buffer authority then moves to vault 3.

After merge

  • Plan repo: step 0.3's base becomes cookie/4.1.2 with this PR, instead of applying the patch file. Record step 0.2 as done with these addresses.
  • Step 0.3 item 4: clean build and tag. Step 0.5: rollout, one validator at a time.

🤖 Generated with Claude Code

sense112 and others added 2 commits November 10, 2026 21:46
…fers

The release patch from cookiechain/cookie-upgrade-plan
(plans/4.1/release/0001-cookie-program-swaps.patch at 2d4d665), applied
unchanged on top of C1:

- Cookie token trigger CDJ9yJcfcJ2QkHaYhseA7jtihbhmNsBK46tZAJGsN9Xg,
  declared in feature-set/src/cookie.rs and chained into FEATURE_NAMES.
- Token: loader v2 to upgradeable p-token 1.0.0 when the trigger goes live.
- Stake: loader v2 to upgradeable stake 4.0.0 with SIMD-0196, then stake
  5.0.0 with the v5 feature, read from Cookie buffers instead of upstream's.
- Every swap refuses a buffer whose code does not match the expected hash.
- One swap per program per boundary.

Buffer addresses are still placeholders here; the next commit sets them.

Co-Authored-By: n4pless <noobieless@tutanota.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan step 0.2 created the buffer keypairs on 10 Nov 2026 (offline; the
key files are not in this repository). Their addresses replace the
placeholders, so cookie_release_buffers_configured now passes:

- token (p-token 1.0.0):      7anfKyfCz8krv8Jvmg9DLAjS9WvzfDY2XfBJZyLyoYBF
- stake (stake 4.0.0):        djJonZTCuwfU9hkuntGjLZeXf6bziS76PuwDJUfxqHm
- stake v5 (stake 5.0.0):     BYeWRbFpEi8wf5UCXypQJ9CvHh3UrfggqF6MYy1UuLCx

The buffers themselves are written at step 0.7. Until then nothing exists
at these addresses and the release behaves like 4.1.2.

Also: the program files the tests read are ignored by git (a .gitignore
inside cookie_programs/), and a missing file now says how to download it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@n4pless
n4pless requested a review from sense112 November 10, 2026 19:49
@sense112
sense112 merged commit e70c074 into cookie/4.1.2 Nov 10, 2026
1 check passed
@n4pless

n4pless commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Step 0.7 is done (10 Nov 2026). This settles the "write the buffers early" question, so the lamport-griefing window is closed.

The faucet paid 3.58 COOK in rent plus about 0.003 COOK in fees. Each buffer was downloaded back and compared byte for byte with the release file before its authority was handed over.

cookie_audit.py programs:

Buffer Holds Authority
7anfKyfCz8krv8Jvmg9DLAjS9WvzfDY2XfBJZyLyoYBF p-token 1.0.0 vault 3 AEMq4AZi…
djJonZTCuwfU9hkuntGjLZeXf6bziS76PuwDJUfxqHm stake 4.0.0 vault 3
BYeWRbFpEi8wf5UCXypQJ9CvHh3UrfggqF6MYy1UuLCx stake 5.0.0 vault 3

Nothing reads these until steps 1–3, and only the multisig can now change or close them.

@sense112
sense112 deleted the cookie/4.1-program-swaps branch November 10, 2026 20:21
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