Skip to content

Conversation

cavemanloverboy
Copy link
Contributor

@cavemanloverboy cavemanloverboy commented Aug 21, 2025

Problem

Currently, both amount and lamports are validated during a transfer involving native accounts. Since amount is already validated, it is not strictly necessary to validate lamports as well.

Solution

Use unchecked operations when manipulating lamport values, which reduces CU consumption.

@cavemanloverboy
Copy link
Contributor Author

if there is an infinite SOL mint bug on solana, this would break backwards compatibility fyi

you'd get a issue regarding non-conservation of lamports instead of overflow error

@febo
Copy link
Contributor

febo commented Aug 22, 2025

we double check that the protocol has an explicit u64::MAX limit for the total amount of lamports in a cluster.

https://github.com/anza-xyz/agave/blob/83d40ef2be8ed0a63bbf9346d3746006da4778c5/runtime/src/bank.rs#L764

@febo febo requested a review from joncinque August 22, 2025 09:59
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@febo febo merged commit 27992e4 into solana-program:main Aug 26, 2025
17 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.

3 participants