Skip to content

Conversation

@febo
Copy link
Contributor

@febo febo commented Sep 11, 2025

Problem

As described on #248, comparing pubkeys with the equality operator (==) might result in "bloated" code, which eventually leads to an increased CU consumption.

Solution

Use the new pubkey_eq helper, which performs the comparison as a sequence of u64 values. This PR also includes a couple of compiler hints likely/unlikely to further improve CUs.

These changes have a positive impact on most instructions:

  • transfer: 79 -> 76
  • transfer_checked: 111 -> 105
  • set_authority: 135 -> 123
  • burn: 133 -> 126
  • burn_checked: 136 -> 129

Note

The baseline for the comparison above is the branch febo/custom-entrypoint (#85).

@febo febo force-pushed the febo/compiler-tweaks branch from 2d3c09b to ed8194b Compare September 11, 2025 14:43
@febo febo changed the base branch from febo/custom-entrypoint to febo/unwrap-lamports September 11, 2025 14:44
@febo febo marked this pull request as ready for review September 11, 2025 17:38
buffalojoec
buffalojoec previously approved these changes Sep 12, 2025
Copy link
Contributor

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Nice Lgtm, just a take-it-or-leave it.

@febo febo force-pushed the febo/unwrap-lamports branch from 599d2b1 to 3b92f39 Compare September 13, 2025 13:53
@febo febo force-pushed the febo/compiler-tweaks branch from 29573a9 to 7bb3225 Compare September 13, 2025 13:55
@febo febo force-pushed the febo/unwrap-lamports branch from 3b92f39 to 20e0ffe Compare September 13, 2025 14:24
@febo febo force-pushed the febo/compiler-tweaks branch from 7bb3225 to 8a588a6 Compare September 13, 2025 14:40
joncinque
joncinque previously approved these changes Sep 15, 2025
@febo febo force-pushed the febo/unwrap-lamports branch from 20e0ffe to 4db31a0 Compare September 15, 2025 13:25
@febo febo force-pushed the febo/compiler-tweaks branch from 8a588a6 to 7da8421 Compare September 15, 2025 13:41
Base automatically changed from febo/unwrap-lamports to main September 15, 2025 13:48
@febo febo dismissed stale reviews from joncinque and buffalojoec September 15, 2025 13:48

The base branch was changed.

@febo febo force-pushed the febo/compiler-tweaks branch from 7da8421 to 7002efd Compare September 15, 2025 13:55
@febo febo requested a review from joncinque September 15, 2025 14:21
@febo febo merged commit 7511655 into main Sep 15, 2025
17 checks passed
@febo febo deleted the febo/compiler-tweaks branch September 15, 2025 16:43
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.

4 participants