Skip to content

CI rehearsal only (do not merge) - #21

Closed
michael-moffett wants to merge 1 commit into
mainfrom
surfpool-706-setmint-a5
Closed

michael-moffett wants to merge 1 commit into
mainfrom
surfpool-706-setmint-a5

Conversation

@michael-moffett

Copy link
Copy Markdown
Member

Fork CI only. Do not merge.

Add a `surfnet_setMint` cheatcode that creates or patches a mint, optionally writing the Token-2022 `ConfidentialTransferMint` extension (authority, auditor ElGamal pubkey, auto-approve).

Lead 3 of : builders must fork a mainnet mint today because there is no way to spin up a confidential-capable mint with a chosen auditor and decimals.
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

This PR should not be merged until existing extended mints can be updated and plain mint updates enforce the requested token program.

Findings

  1. P1 Wrong mint marker offset ▶
  2. P1 Plain updates ignore mint ownership ▶
  3. P2 Configured auditor cannot be removed ▶

Summary

This PR adds surfnet_setMint to create or update SPL Token and Token-2022 mints, including confidential-transfer configuration, and exposes it through the Node SDK.

  • Existing extended mints cannot reliably gain the confidential extension because the builder clears the wrong account-type byte.
  • Plain updates do not enforce the requested token program against an existing mint’s owner.
  • The update shape cannot remove an auditor after one has been configured.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["surfnet_setMint"] --> B{"Mint exists?"}
  B -- No --> C["Create initialized mint"]
  B -- Yes --> D["Read existing mint"]
  C --> E["Apply base updates"]
  D --> E
  E --> F{"Confidential update?"}
  F -- Yes --> G["Build Token-2022 extension bytes"]
  F -- No --> H["Preserve extension tail"]
  G --> I["Top up rent and write"]
  H --> I
Loading

Reviews (1) · Last reviewed commit: "feat(core): surfnet_setMint cheatcode wi..."

Comment thread crates/core/src/types.rs
Comment on lines +1487 to +1489
if let Some(account_type) = buffer.get_mut(spl_token_2022_interface::state::Account::LEN) {
*account_type = 0;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Wrong mint marker offset When setMint adds confidential support to a Token-2022 mint that already has extensions, this clears byte 165 instead of the mint’s account-type byte at offset 82. The existing marker remains set, so unpack_uninitialized rejects the buffer and the update fails.

Suggested change
if let Some(account_type) = buffer.get_mut(spl_token_2022_interface::state::Account::LEN) {
*account_type = 0;
}
if let Some(account_type) = buffer.get_mut(spl_token_2022_interface::state::Mint::LEN) {
*account_type = 0;
}

Comment on lines +2064 to +2069
if confidential.is_some() && account.owner != token_program_id {
return Err(Error::invalid_params(format!(
"mint {mint} is owned by {}, not the Token-2022 program",
account.owner
)));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Plain updates ignore mint ownership If a caller omits tokenProgram while updating an existing Token-2022 mint, setMint selects the legacy SPL Token program but skips the owner check because the update is not confidential. It reports success and rewrites the mint while leaving its Token-2022 owner unchanged, hiding the program mismatch from callers that subsequently use the requested program.

Comment thread crates/types/src/types.rs
#[cfg_attr(
feature = "ts-bindings",
derive(ts_rs::TS),
ts(export, optional_fields)

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 Configured auditor cannot be removed Once an auditor key is set, omitting auditorElgamalPubkey keeps it and supplying a value only replaces it with another key. The update has no way to restore the supported no-auditor state, so callers cannot remove an auditor through setMint.

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