Skip to content

CI rehearsal only (do not merge) - #19

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

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

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 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@michael-moffett

Copy link
Copy Markdown
Member Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 2/5

The PR should not be merged until existing mint extensions, confidential settings, and excess lamports survive applicable updates.

Findings

  1. P1 Existing mint extensions disappear ▶
  2. P1 Partial updates clear confidential settings ▶
  3. P1 Mint updates discard excess SOL ▶

Summary

The PR adds surfnet_setMint, Rust and generated TypeScript update types, and tests for plain and confidential Token-2022 mints.

  • Existing mints need safer handling: confidential updates can discard extension data, and any update can discard excess lamports.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["setMint: load or create mint"] --> B["Apply base-field update"]
  B --> C{"confidential supplied?"}
  C -- No --> D["Repack base; retain extension bytes"]
  C -- Yes --> E["Build new data with only ConfidentialTransferMint"]
  D --> F["Replace account balance with rent minimum"]
  E --> F
  F --> G["Write authoritative account update"]
Loading

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

Comment on lines +2035 to +2047
let final_mint_bytes = if let Some(conf) = &confidential {
// The extension lives in a TLV layout the base-only packing
// can't represent, so the account is rewritten from scratch.
let base = match &mint_data {
MintAccount::SplToken2022(base) => *base,
MintAccount::SplToken(_) => {
return Err(Error::invalid_params(
"confidential transfer mints require the Token-2022 program"
.to_string(),
));
}
};
build_confidential_mint_data(&base, conf).map_err(Error::invalid_params)?

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 Existing mint extensions disappear When setMint adds confidential settings to a Token-2022 mint that already has a transfer-fee or other extension, this branch builds new account data containing only the confidential extension. The existing extension is silently removed, so a transfer-fee mint, for example, loses its fee configuration. Preserve the existing extensions or reject the update.

Comment thread crates/core/src/types.rs
Comment on lines +1498 to +1504
.init_extension::<ConfidentialTransferMint>(false)
.map_err(|e| format!("failed to init confidential mint extension: {e}"))?;
ct.authority = authority.map(Into::into).unwrap_or_default();
ct.auto_approve_new_accounts = conf.auto_approve_new_accounts.unwrap_or(true).into();
ct.auditor_elgamal_pubkey = auditor_elgamal_pubkey
.map(|key| PodElGamalPubkey::from(key).into())
.unwrap_or_default();

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 Partial updates clear confidential settings On an already-confidential mint, an update that supplies only autoApproveNewAccounts writes null values over the existing authority and auditor key. This silently discards settings the caller did not ask to change, contrary to setMint’s promise to retain omitted fields. Preserve those fields when updating an existing extension.

account.owner
)));
}
account.lamports = lamports;

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 Mint updates discard excess SOL When an existing mint holds more SOL than the minimum rent balance, even a decimals-only update replaces its balance with that minimum. The excess SOL disappears from the simulated account. Retain the existing balance when it is sufficient, adding lamports only if the updated account needs more rent.

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