Skip to content

Commit

Permalink
lang: Add accounts by reference (#2656)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aursen authored Oct 11, 2023
1 parent 243ab75 commit dcafb78
Show file tree
Hide file tree
Showing 24 changed files with 317 additions and 322 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The minor version will be incremented upon a breaking change and the patch versi

### Features

- lang: Change all accounts to have a reference to `AccountInfo` ([#2656](https://github.com/coral-xyz/anchor/pull/2656)).
- lang: Add `get_lamports`, `add_lamports` and `sub_lamports` methods for all account types ([#2552](https://github.com/coral-xyz/anchor/pull/2552)).
- client: Add a helper struct `DynSigner` to simplify use of `Client<C> where <C: Clone + Deref<Target = impl Signer>>` with Solana clap CLI utils that loads `Signer` as `Box<dyn Signer>` ([#2550](https://github.com/coral-xyz/anchor/pull/2550)).
- lang: Allow CPI calls matching an interface without pinning program ID ([#2559](https://github.com/coral-xyz/anchor/pull/2559)).
Expand Down
7 changes: 4 additions & 3 deletions bench/BINARY_SIZE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ The programs and their tests are located in [/tests/bench](https://github.com/co

Solana version: 1.17.0

| Program | Binary Size | +/- |
| ------- | ----------- | ----------------------- |
| bench | 1,049,608 | 🟢 **-104,128 (9.03%)** |
| Program | Binary Size | +/- |
| ------- | ----------- | ------------------------ |
| bench | 764,032 | 🟢 **-389,704 (33.78%)** |

### Notable changes

- Change all accounts to have a reference to `AccountInfo` ([#2656](https://github.com/coral-xyz/anchor/pull/2656)).
- `Box` the `anchor_lang::Result` error variants ([#2600](https://github.com/coral-xyz/anchor/pull/2600)).

---
Expand Down
166 changes: 83 additions & 83 deletions bench/COMPUTE_UNITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,89 +22,89 @@ Solana version: 1.17.0
| accountInfo2 | 824 | 🟢 **-651 (44.14%)** |
| accountInfo4 | 1,319 | 🟢 **-645 (32.84%)** |
| accountInfo8 | 2,531 | 🟢 **-1,310 (34.11%)** |
| accountEmptyInit1 | 5,521 | 🟢 **-296 (5.09%)** |
| accountEmpty1 | 777 | 🟢 **-372 (32.38%)** |
| accountEmptyInit2 | 10,111 | 🟢 **-291 (2.80%)** |
| accountEmpty2 | 1,207 | 🟢 **-547 (31.19%)** |
| accountEmptyInit4 | 19,044 | 🟢 **-464 (2.38%)** |
| accountEmpty4 | 2,074 | 🟢 **-466 (18.35%)** |
| accountEmptyInit8 | 37,265 | - |
| accountEmpty8 | 3,967 | 🟢 **-1,049 (20.91%)** |
| accountSizedInit1 | 5,626 | 🟢 **-298 (5.03%)** |
| accountSized1 | 786 | 🟢 **-428 (35.26%)** |
| accountSizedInit2 | 10,322 | 🟢 **-358 (3.35%)** |
| accountSized2 | 1,234 | 🟢 **-639 (34.12%)** |
| accountSizedInit4 | 19,462 | 🟢 **-508 (2.54%)** |
| accountSized4 | 2,135 | 🟢 **-627 (22.70%)** |
| accountSizedInit8 | 38,122 | - |
| accountSized8 | 4,104 | 🟢 **-1,249 (23.33%)** |
| accountUnsizedInit1 | 5,742 | 🟢 **-310 (5.12%)** |
| accountUnsized1 | 821 | 🟢 **-517 (38.64%)** |
| accountUnsizedInit2 | 10,551 | 🟢 **-378 (3.46%)** |
| accountUnsized2 | 1,312 | 🟢 **-466 (26.21%)** |
| accountUnsizedInit4 | 19,927 | 🟢 **-412 (2.03%)** |
| accountUnsized4 | 2,315 | 🟢 **-821 (26.18%)** |
| accountUnsizedInit8 | 38,699 | 🟢 **-397 (1.02%)** |
| accountUnsized8 | 4,456 | 🟢 **-1,496 (25.13%)** |
| boxedAccountEmptyInit1 | 5,452 | 🟢 **-582 (9.65%)** |
| boxedAccountEmpty1 | 866 | 🟢 **-22 (2.48%)** |
| boxedAccountEmptyInit2 | 10,051 | 🟢 **-582 (5.47%)** |
| boxedAccountEmpty2 | 1,377 | 🟢 **-24 (1.71%)** |
| boxedAccountEmptyInit4 | 19,030 | 🟢 **-281 (1.46%)** |
| boxedAccountEmpty4 | 2,396 | 🟢 **-28 (1.16%)** |
| boxedAccountEmptyInit8 | 37,136 | - |
| boxedAccountEmpty8 | 4,472 | 🟢 **-187 (4.01%)** |
| boxedAccountSizedInit1 | 5,546 | 🟢 **-584 (9.53%)** |
| boxedAccountSized1 | 895 | 🟢 **-22 (2.40%)** |
| boxedAccountSizedInit2 | 10,242 | 🟢 **-586 (5.41%)** |
| boxedAccountSized2 | 1,439 | 🟢 **-24 (1.64%)** |
| boxedAccountSizedInit4 | 19,414 | 🟢 **-289 (1.47%)** |
| boxedAccountSized4 | 2,515 | 🟢 **-28 (1.10%)** |
| boxedAccountSizedInit8 | 37,919 | - |
| boxedAccountSized8 | 4,711 | 🟢 **-187 (3.82%)** |
| boxedAccountUnsizedInit1 | 5,823 | 🟢 **-417 (6.68%)** |
| boxedAccountUnsized1 | 950 | 🟢 **-22 (2.26%)** |
| boxedAccountUnsizedInit2 | 10,621 | 🟢 **-427 (3.86%)** |
| boxedAccountUnsized2 | 1,549 | 🟢 **-21 (1.34%)** |
| boxedAccountUnsizedInit4 | 19,825 | 🟢 **-313 (1.55%)** |
| boxedAccountUnsized4 | 2,737 | 🟢 **-31 (1.12%)** |
| boxedAccountUnsizedInit8 | 38,791 | 🟢 **-9 (0.02%)** |
| boxedAccountUnsized8 | 5,207 | 🟢 **-140 (2.62%)** |
| boxedInterfaceAccountMint1 | 2,137 | 🟢 **-159 (6.93%)** |
| boxedInterfaceAccountMint2 | 3,849 | 🟢 **-280 (6.78%)** |
| boxedInterfaceAccountMint4 | 7,215 | 🟢 **-568 (7.30%)** |
| boxedInterfaceAccountMint8 | 14,044 | 🟢 **-1,237 (8.10%)** |
| boxedInterfaceAccountToken1 | 2,066 | 🔴 **+43 (2.13%)** |
| boxedInterfaceAccountToken2 | 3,706 | 🔴 **+124 (3.46%)** |
| boxedInterfaceAccountToken4 | 6,932 | 🔴 **+240 (3.59%)** |
| boxedInterfaceAccountToken8 | 13,477 | 🔴 **+379 (2.89%)** |
| interfaceAccountMint1 | 2,313 | 🟢 **-51 (2.16%)** |
| interfaceAccountMint2 | 4,270 | 🟢 **-760 (15.11%)** |
| interfaceAccountMint4 | 8,185 | 🟢 **-1,618 (16.51%)** |
| interfaceAccountMint8 | 16,007 | 🟢 **-2,393 (13.01%)** |
| interfaceAccountToken1 | 2,059 | 🟢 **-32 (1.53%)** |
| interfaceAccountToken2 | 3,958 | 🔴 **+10 (0.25%)** |
| interfaceAccountToken4 | 7,816 | 🔴 **+269 (3.56%)** |
| interface1 | 691 | 🟢 **-368 (34.75%)** |
| interface2 | 940 | 🟢 **-539 (36.44%)** |
| interface4 | 1,450 | 🟢 **-450 (23.68%)** |
| interface8 | 2,605 | 🟢 **-1,041 (28.55%)** |
| program1 | 685 | 🟢 **-368 (34.95%)** |
| program2 | 928 | 🟢 **-539 (36.74%)** |
| program4 | 1,428 | 🟢 **-450 (23.96%)** |
| program8 | 2,557 | 🟢 **-1,041 (28.93%)** |
| signer1 | 621 | 🟢 **-397 (39.00%)** |
| signer2 | 895 | 🟢 **-589 (39.69%)** |
| signer4 | 1,455 | 🟢 **-529 (26.66%)** |
| signer8 | 2,721 | 🟢 **-1,159 (29.87%)** |
| systemAccount1 | 675 | 🟢 **-397 (37.03%)** |
| systemAccount2 | 1,001 | 🟢 **-589 (37.04%)** |
| systemAccount4 | 1,666 | 🟢 **-529 (24.10%)** |
| systemAccount8 | 3,146 | 🟢 **-1,159 (26.92%)** |
| uncheckedAccount1 | 583 | 🟢 **-431 (42.50%)** |
| uncheckedAccount2 | 824 | 🟢 **-651 (44.14%)** |
| uncheckedAccount4 | 1,320 | 🟢 **-645 (32.82%)** |
| uncheckedAccount8 | 2,531 | 🟢 **-1,310 (34.11%)** |
| accountEmptyInit1 | 5,099 | 🟢 **-718 (12.34%)** |
| accountEmpty1 | 708 | 🟢 **-441 (38.38%)** |
| accountEmptyInit2 | 9,676 | 🟢 **-726 (6.98%)** |
| accountEmpty2 | 1,064 | 🟢 **-690 (39.34%)** |
| accountEmptyInit4 | 18,477 | 🟢 **-1,031 (5.29%)** |
| accountEmpty4 | 1,766 | 🟢 **-774 (30.47%)** |
| accountEmptyInit8 | 36,113 | 🟢 **-1,152 (3.09%)** |
| accountEmpty8 | 3,179 | 🟢 **-1,837 (36.62%)** |
| accountSizedInit1 | 5,187 | 🟢 **-737 (12.44%)** |
| accountSized1 | 732 | 🟢 **-482 (39.70%)** |
| accountSizedInit2 | 9,851 | 🟢 **-829 (7.76%)** |
| accountSized2 | 1,106 | 🟢 **-767 (40.95%)** |
| accountSizedInit4 | 18,876 | 🟢 **-1,094 (5.48%)** |
| accountSized4 | 1,863 | 🟢 **-899 (32.55%)** |
| accountSizedInit8 | 36,832 | 🟢 **-1,290 (3.38%)** |
| accountSized8 | 3,374 | 🟢 **-1,979 (36.97%)** |
| accountUnsizedInit1 | 5,275 | 🟢 **-777 (12.84%)** |
| accountUnsized1 | 759 | 🟢 **-579 (43.27%)** |
| accountUnsizedInit2 | 10,090 | 🟢 **-839 (7.68%)** |
| accountUnsized2 | 1,168 | 🟢 **-610 (34.31%)** |
| accountUnsizedInit4 | 19,281 | 🟢 **-1,058 (5.20%)** |
| accountUnsized4 | 2,000 | 🟢 **-1,136 (36.22%)** |
| accountUnsizedInit8 | 37,378 | 🟢 **-1,718 (4.39%)** |
| accountUnsized8 | 3,667 | 🟢 **-2,285 (38.39%)** |
| boxedAccountEmptyInit1 | 5,145 | 🟢 **-889 (14.73%)** |
| boxedAccountEmpty1 | 745 | 🟢 **-143 (16.10%)** |
| boxedAccountEmptyInit2 | 9,769 | 🟢 **-864 (8.13%)** |
| boxedAccountEmpty2 | 1,136 | 🟢 **-265 (18.92%)** |
| boxedAccountEmptyInit4 | 18,661 | 🟢 **-650 (3.37%)** |
| boxedAccountEmpty4 | 1,913 | 🟢 **-511 (21.08%)** |
| boxedAccountEmptyInit8 | 36,488 | 🟢 **-648 (1.74%)** |
| boxedAccountEmpty8 | 3,500 | 🟢 **-1,159 (24.88%)** |
| boxedAccountSizedInit1 | 5,222 | 🟢 **-908 (14.81%)** |
| boxedAccountSized1 | 767 | 🟢 **-150 (16.36%)** |
| boxedAccountSizedInit2 | 9,925 | 🟢 **-903 (8.34%)** |
| boxedAccountSized2 | 1,183 | 🟢 **-280 (19.14%)** |
| boxedAccountSizedInit4 | 18,973 | 🟢 **-730 (3.71%)** |
| boxedAccountSized4 | 2,002 | 🟢 **-541 (21.27%)** |
| boxedAccountSizedInit8 | 37,111 | 🟢 **-808 (2.13%)** |
| boxedAccountSized8 | 3,682 | 🟢 **-1,216 (24.83%)** |
| boxedAccountUnsizedInit1 | 5,304 | 🟢 **-936 (15.00%)** |
| boxedAccountUnsized1 | 797 | 🟢 **-175 (18.00%)** |
| boxedAccountUnsizedInit2 | 10,089 | 🟢 **-959 (8.68%)** |
| boxedAccountUnsized2 | 1,246 | 🟢 **-324 (20.64%)** |
| boxedAccountUnsizedInit4 | 19,303 | 🟢 **-835 (4.15%)** |
| boxedAccountUnsized4 | 2,135 | 🟢 **-633 (22.87%)** |
| boxedAccountUnsizedInit8 | 37,770 | 🟢 **-1,030 (2.65%)** |
| boxedAccountUnsized8 | 3,948 | 🟢 **-1,399 (26.16%)** |
| boxedInterfaceAccountMint1 | 2,085 | 🟢 **-211 (9.19%)** |
| boxedInterfaceAccountMint2 | 3,726 | 🟢 **-403 (9.76%)** |
| boxedInterfaceAccountMint4 | 6,991 | 🟢 **-792 (10.18%)** |
| boxedInterfaceAccountMint8 | 13,562 | 🟢 **-1,719 (11.25%)** |
| boxedInterfaceAccountToken1 | 2,015 | 🟢 **-8 (0.40%)** |
| boxedInterfaceAccountToken2 | 3,585 | 🔴 **+3 (0.08%)** |
| boxedInterfaceAccountToken4 | 6,712 | 🔴 **+20 (0.30%)** |
| boxedInterfaceAccountToken8 | 13,003 | 🟢 **-95 (0.73%)** |
| interfaceAccountMint1 | 2,174 | 🟢 **-190 (8.04%)** |
| interfaceAccountMint2 | 4,057 | 🟢 **-973 (19.34%)** |
| interfaceAccountMint4 | 7,823 | 🟢 **-1,980 (20.20%)** |
| interfaceAccountMint8 | 15,357 | 🟢 **-3,043 (16.54%)** |
| interfaceAccountToken1 | 2,101 | 🔴 **+10 (0.48%)** |
| interfaceAccountToken2 | 3,909 | 🟢 **-39 (0.99%)** |
| interfaceAccountToken4 | 7,522 | 🟢 **-25 (0.33%)** |
| interface1 | 630 | 🟢 **-429 (40.51%)** |
| interface2 | 813 | 🟢 **-666 (45.03%)** |
| interface4 | 1,174 | 🟢 **-726 (38.21%)** |
| interface8 | 1,905 | 🟢 **-1,741 (47.75%)** |
| program1 | 630 | 🟢 **-423 (40.17%)** |
| program2 | 813 | 🟢 **-654 (44.58%)** |
| program4 | 1,176 | 🟢 **-702 (37.38%)** |
| program8 | 1,905 | 🟢 **-1,693 (47.05%)** |
| signer1 | 564 | 🟢 **-454 (44.60%)** |
| signer2 | 776 | 🟢 **-708 (47.71%)** |
| signer4 | 1,195 | 🟢 **-789 (39.77%)** |
| signer8 | 2,035 | 🟢 **-1,845 (47.55%)** |
| systemAccount1 | 618 | 🟢 **-454 (42.35%)** |
| systemAccount2 | 882 | 🟢 **-708 (44.53%)** |
| systemAccount4 | 1,406 | 🟢 **-789 (35.95%)** |
| systemAccount8 | 2,460 | 🟢 **-1,845 (42.86%)** |
| uncheckedAccount1 | 546 | 🟢 **-468 (46.15%)** |
| uncheckedAccount2 | 738 | 🟢 **-737 (49.97%)** |
| uncheckedAccount4 | 1,115 | 🟢 **-850 (43.26%)** |
| uncheckedAccount8 | 1,877 | 🟢 **-1,964 (51.13%)** |

### Notable changes

Expand Down
Loading

1 comment on commit dcafb78

@vercel
Copy link

@vercel vercel bot commented on dcafb78 Oct 11, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

anchor-docs – ./

www.anchor-lang.com
anchor-docs-200ms.vercel.app
anchor-lang.com
anchor-docs-git-master-200ms.vercel.app

Please sign in to comment.