Skip to content

docs: note that Execute.amount is u64::MAX for confidential transfers - #156

Merged
joncinque merged 2 commits into
solana-program:mainfrom
pwsaragossy:docs/confidential-transfer-amount-sentinel
Sep 3, 2026
Merged

docs: note that Execute.amount is u64::MAX for confidential transfers#156
joncinque merged 2 commits into
solana-program:mainfrom
pwsaragossy:docs/confidential-transfer-amount-sentinel

Conversation

@pwsaragossy

Copy link
Copy Markdown
Contributor

The doc on TransferHookInstruction::Execute.amount reads "Amount of tokens to transfer". On the confidential-transfer path that is not accurate: Token-2022 passes u64::MAX, because the amount is encrypted and unavailable to the program.

https://github.com/solana-program/token-2022/blob/6d87d47d6bbd/program/src/extension/confidential_transfer/processor.rs#L826-L836

The convention is deliberate and there is a comment at the call site. Nothing on the receiving side says so — u64::MAX does not appear anywhere in this repository. A hook implementing amount-based policy reads this field's documentation and has no reason to expect a sentinel.

The consequence depends on how the policy is written:

  • a per-transfer cap (amount > limit) rejects every confidential transfer, at any size
  • an accumulator (total + amount) overflows; with overflow-checks off, Cargo's release default, it wraps and the check silently passes

Documentation only, no behavior change.

Reproduced against a pinned commit using upstream's own tests, unmodified — the only change is an instrumented hook that reports the amount it was handed: https://github.com/pwsaragossy/t22-conformance

The doc on `TransferHookInstruction::Execute.amount` reads "Amount of tokens to
transfer". On the confidential-transfer path Token-2022 passes `u64::MAX`
instead, because the amount is encrypted and unavailable to the program.

The convention is deliberate and commented at the call site, but nothing on the
receiving side records it — `u64::MAX` appears nowhere in this repository. A
hook implementing amount-based policy reads this field's documentation and has
no reason to expect a sentinel.

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

Thanks for your contribution! Just a little bit to trim, then it's good to go on my side

Comment thread interface/src/instruction.rs Outdated

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

Applied suggestion, landing

@joncinque
joncinque merged commit e384343 into solana-program:main Sep 3, 2026
25 checks passed
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