diff --git a/bench/COMPUTE_UNITS.md b/bench/COMPUTE_UNITS.md index 3e1f717213..5eaed7364d 100644 --- a/bench/COMPUTE_UNITS.md +++ b/bench/COMPUTE_UNITS.md @@ -11,91 +11,91 @@ The programs and their tests are located in [/tests/bench](https://github.com/co ## [Unreleased] -| Instruction | Compute Units | +/- | -| --------------------------- | ------------- | --- | -| accountEmptyInit1 | 5958 | - | -| accountEmpty1 | 1090 | - | -| accountEmptyInit2 | 10583 | - | -| accountEmpty2 | 1852 | - | -| accountEmptyInit4 | 19557 | - | -| accountEmpty4 | 2646 | - | -| accountEmptyInit8 | 37541 | - | -| accountEmpty8 | 5043 | - | -| accountSizedInit1 | 6063 | - | -| accountSized1 | 1135 | - | -| accountSizedInit2 | 10783 | - | -| accountSized2 | 1966 | - | -| accountSizedInit4 | 19975 | - | -| accountSized4 | 2787 | - | -| accountSizedInit8 | 38381 | - | -| accountSized8 | 5359 | - | -| accountUnsizedInit1 | 6193 | - | -| accountUnsized1 | 1243 | - | -| accountUnsizedInit2 | 11042 | - | -| accountUnsized2 | 1893 | - | -| accountUnsizedInit4 | 20495 | - | -| accountUnsized4 | 3104 | - | -| accountUnsizedInit8 | 39419 | - | -| accountUnsized8 | 6051 | - | -| boxedAccountEmptyInit1 | 6160 | - | -| boxedAccountEmpty1 | 976 | - | -| boxedAccountEmptyInit2 | 10784 | - | -| boxedAccountEmpty2 | 1499 | - | -| boxedAccountEmptyInit4 | 19500 | - | -| boxedAccountEmpty4 | 2530 | - | -| boxedAccountEmptyInit8 | 37415 | - | -| boxedAccountEmpty8 | 4780 | - | -| boxedAccountSizedInit1 | 6256 | - | -| boxedAccountSized1 | 1003 | - | -| boxedAccountSizedInit2 | 10975 | - | -| boxedAccountSized2 | 1554 | - | -| boxedAccountSizedInit4 | 19884 | - | -| boxedAccountSized4 | 2642 | - | -| boxedAccountSizedInit8 | 38182 | - | -| boxedAccountSized8 | 5003 | - | -| boxedAccountUnsizedInit1 | 6374 | - | -| boxedAccountUnsized1 | 1069 | - | -| boxedAccountUnsizedInit2 | 11211 | - | -| boxedAccountUnsized2 | 1679 | - | -| boxedAccountUnsizedInit4 | 20351 | - | -| boxedAccountUnsized4 | 2899 | - | -| boxedAccountUnsizedInit8 | 39118 | - | -| boxedAccountUnsized8 | 5517 | - | -| boxedInterfaceAccountMint1 | 2299 | - | -| boxedInterfaceAccountMint2 | 4053 | - | -| boxedInterfaceAccountMint4 | 7538 | - | -| boxedInterfaceAccountMint8 | 14699 | - | -| boxedInterfaceAccountToken1 | 1737 | - | -| boxedInterfaceAccountToken2 | 2928 | - | -| boxedInterfaceAccountToken4 | 5291 | - | -| boxedInterfaceAccountToken8 | 10205 | - | -| interfaceAccountMint1 | 2530 | - | -| interfaceAccountMint2 | 4726 | - | -| interfaceAccountMint4 | 9431 | - | -| interfaceAccountMint8 | 17709 | - | -| interfaceAccountToken1 | 1755 | - | -| interfaceAccountToken2 | 3211 | - | -| interfaceAccountToken4 | 6006 | - | -| interface1 | 999 | - | -| interface2 | 1574 | - | -| interface4 | 1996 | - | -| interface8 | 3651 | - | -| program1 | 999 | - | -| program2 | 1573 | - | -| program4 | 1998 | - | -| program8 | 3651 | - | -| signer1 | 958 | - | -| signer2 | 1576 | - | -| signer4 | 2079 | - | -| signer8 | 3895 | - | -| systemAccount1 | 1013 | - | -| systemAccount2 | 1686 | - | -| systemAccount4 | 2298 | - | -| systemAccount8 | 4336 | - | -| uncheckedAccount1 | 953 | - | -| uncheckedAccount2 | 1567 | - | -| uncheckedAccount4 | 2060 | - | -| uncheckedAccount8 | 3855 | - | +| Instruction | Compute Units | +/- | +| --------------------------- | ------------- | ------------- | +| accountEmptyInit1 | 6246 | 🔴 **+4.83%** | +| accountEmpty1 | 1090 | - | +| accountEmptyInit2 | 11090 | 🔴 **+4.88%** | +| accountEmpty2 | 1852 | - | +| accountEmptyInit4 | 20579 | 🔴 **+5.23%** | +| accountEmpty4 | 2646 | - | +| accountEmptyInit8 | 39582 | 🔴 **+5.44%** | +| accountEmpty8 | 5043 | - | +| accountSizedInit1 | 6353 | 🔴 **+4.78%** | +| accountSized1 | 1135 | - | +| accountSizedInit2 | 11301 | 🔴 **+4.80%** | +| accountSized2 | 1966 | - | +| accountSizedInit4 | 21000 | 🔴 **+5.13%** | +| accountSized4 | 2787 | - | +| accountSizedInit8 | 40422 | 🔴 **+5.32%** | +| accountSized8 | 5359 | - | +| accountUnsizedInit1 | 6482 | 🔴 **+4.67%** | +| accountUnsized1 | 1243 | - | +| accountUnsizedInit2 | 11560 | 🔴 **+4.69%** | +| accountUnsized2 | 1893 | - | +| accountUnsizedInit4 | 21519 | 🔴 **+5.00%** | +| accountUnsized4 | 3104 | - | +| accountUnsizedInit8 | 41461 | 🔴 **+5.18%** | +| accountUnsized8 | 6051 | - | +| boxedAccountEmptyInit1 | 6447 | 🔴 **+4.66%** | +| boxedAccountEmpty1 | 976 | - | +| boxedAccountEmptyInit2 | 11292 | 🔴 **+4.71%** | +| boxedAccountEmpty2 | 1499 | - | +| boxedAccountEmptyInit4 | 20521 | 🔴 **+5.24%** | +| boxedAccountEmpty4 | 2530 | - | +| boxedAccountEmptyInit8 | 39456 | 🔴 **+5.46%** | +| boxedAccountEmpty8 | 4780 | - | +| boxedAccountSizedInit1 | 6544 | 🔴 **+4.60%** | +| boxedAccountSized1 | 1003 | - | +| boxedAccountSizedInit2 | 11485 | 🔴 **+4.65%** | +| boxedAccountSized2 | 1554 | - | +| boxedAccountSizedInit4 | 20904 | 🔴 **+5.13%** | +| boxedAccountSized4 | 2642 | - | +| boxedAccountSizedInit8 | 40224 | 🔴 **+5.35%** | +| boxedAccountSized8 | 5003 | - | +| boxedAccountUnsizedInit1 | 6661 | 🔴 **+4.50%** | +| boxedAccountUnsized1 | 1069 | - | +| boxedAccountUnsizedInit2 | 11720 | 🔴 **+4.54%** | +| boxedAccountUnsized2 | 1679 | - | +| boxedAccountUnsizedInit4 | 21372 | 🔴 **+5.02%** | +| boxedAccountUnsized4 | 2899 | - | +| boxedAccountUnsizedInit8 | 41159 | 🔴 **+5.22%** | +| boxedAccountUnsized8 | 5517 | - | +| boxedInterfaceAccountMint1 | 2299 | - | +| boxedInterfaceAccountMint2 | 4053 | - | +| boxedInterfaceAccountMint4 | 7538 | - | +| boxedInterfaceAccountMint8 | 14699 | - | +| boxedInterfaceAccountToken1 | 1737 | - | +| boxedInterfaceAccountToken2 | 2928 | - | +| boxedInterfaceAccountToken4 | 5291 | - | +| boxedInterfaceAccountToken8 | 10205 | - | +| interfaceAccountMint1 | 2530 | - | +| interfaceAccountMint2 | 4726 | - | +| interfaceAccountMint4 | 9431 | - | +| interfaceAccountMint8 | 17709 | - | +| interfaceAccountToken1 | 1755 | - | +| interfaceAccountToken2 | 3211 | - | +| interfaceAccountToken4 | 6006 | - | +| interface1 | 999 | - | +| interface2 | 1574 | - | +| interface4 | 1996 | - | +| interface8 | 3651 | - | +| program1 | 999 | - | +| program2 | 1573 | - | +| program4 | 1998 | - | +| program8 | 3651 | - | +| signer1 | 958 | - | +| signer2 | 1576 | - | +| signer4 | 2079 | - | +| signer8 | 3895 | - | +| systemAccount1 | 1013 | - | +| systemAccount2 | 1686 | - | +| systemAccount4 | 2298 | - | +| systemAccount8 | 4336 | - | +| uncheckedAccount1 | 953 | - | +| uncheckedAccount2 | 1567 | - | +| uncheckedAccount4 | 2060 | - | +| uncheckedAccount8 | 3855 | - | ### Notable changes @@ -105,6 +105,10 @@ The programs and their tests are located in [/tests/bench](https://github.com/co | Instruction | Compute Units | +/- | | --------------------------- | ------------- | --- | +| accountInfo1 | 954 | N/A | +| accountInfo2 | 1567 | N/A | +| accountInfo4 | 2059 | N/A | +| accountInfo8 | 3856 | N/A | | accountEmptyInit1 | 5958 | N/A | | accountEmpty1 | 1090 | N/A | | accountEmptyInit2 | 10574 | N/A | diff --git a/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs b/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs index 29d32bac7b..8afdb7c335 100644 --- a/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs +++ b/examples/tutorial/basic-3/programs/puppet-master/src/lib.rs @@ -12,7 +12,7 @@ mod puppet_master { pub fn pull_strings(ctx: Context, data: u64) -> anchor_lang::Result<()> { let cpi_program = ctx.accounts.puppet_program.to_account_info(); let cpi_accounts = SetData { - puppet: ctx.accounts.puppet.to_account_info(), + puppet: ctx.accounts.puppet.to_account_info().into(), }; let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); puppet::cpi::set_data(cpi_ctx, data) diff --git a/lang/src/accounts/boxed.rs b/lang/src/accounts/boxed.rs index f956fe22e4..61763071a7 100644 --- a/lang/src/accounts/boxed.rs +++ b/lang/src/accounts/boxed.rs @@ -59,6 +59,6 @@ impl<'info, T: AccountsClose<'info>> AccountsClose<'info> for Box { impl<'info, T: Into>> From> for UncheckedAccount<'info> { fn from(value: Box) -> Self { - value.into() + T::into(*value) } } diff --git a/tests/bench/bench.json b/tests/bench/bench.json index db5e01afdb..3efc655c61 100644 --- a/tests/bench/bench.json +++ b/tests/bench/bench.json @@ -1,6 +1,10 @@ { "0.27.0": { "computeUnits": { + "accountInfo1": 954, + "accountInfo2": 1567, + "accountInfo4": 2059, + "accountInfo8": 3856, "accountEmptyInit1": 5958, "accountEmpty1": 1090, "accountEmptyInit2": 10574, @@ -88,53 +92,53 @@ }, "unreleased": { "computeUnits": { - "accountEmptyInit1": 5958, + "accountEmptyInit1": 6246, "accountEmpty1": 1090, - "accountEmptyInit2": 10583, + "accountEmptyInit2": 11090, "accountEmpty2": 1852, - "accountEmptyInit4": 19557, + "accountEmptyInit4": 20579, "accountEmpty4": 2646, - "accountEmptyInit8": 37541, + "accountEmptyInit8": 39582, "accountEmpty8": 5043, - "accountSizedInit1": 6063, + "accountSizedInit1": 6353, "accountSized1": 1135, - "accountSizedInit2": 10783, + "accountSizedInit2": 11301, "accountSized2": 1966, - "accountSizedInit4": 19975, + "accountSizedInit4": 21000, "accountSized4": 2787, - "accountSizedInit8": 38381, + "accountSizedInit8": 40422, "accountSized8": 5359, - "accountUnsizedInit1": 6193, + "accountUnsizedInit1": 6482, "accountUnsized1": 1243, - "accountUnsizedInit2": 11042, + "accountUnsizedInit2": 11560, "accountUnsized2": 1893, - "accountUnsizedInit4": 20495, + "accountUnsizedInit4": 21519, "accountUnsized4": 3104, - "accountUnsizedInit8": 39419, + "accountUnsizedInit8": 41461, "accountUnsized8": 6051, - "boxedAccountEmptyInit1": 6160, + "boxedAccountEmptyInit1": 6447, "boxedAccountEmpty1": 976, - "boxedAccountEmptyInit2": 10784, + "boxedAccountEmptyInit2": 11292, "boxedAccountEmpty2": 1499, - "boxedAccountEmptyInit4": 19500, + "boxedAccountEmptyInit4": 20521, "boxedAccountEmpty4": 2530, - "boxedAccountEmptyInit8": 37415, + "boxedAccountEmptyInit8": 39456, "boxedAccountEmpty8": 4780, - "boxedAccountSizedInit1": 6256, + "boxedAccountSizedInit1": 6544, "boxedAccountSized1": 1003, - "boxedAccountSizedInit2": 10975, + "boxedAccountSizedInit2": 11485, "boxedAccountSized2": 1554, - "boxedAccountSizedInit4": 19884, + "boxedAccountSizedInit4": 20904, "boxedAccountSized4": 2642, - "boxedAccountSizedInit8": 38182, + "boxedAccountSizedInit8": 40224, "boxedAccountSized8": 5003, - "boxedAccountUnsizedInit1": 6374, + "boxedAccountUnsizedInit1": 6661, "boxedAccountUnsized1": 1069, - "boxedAccountUnsizedInit2": 11211, + "boxedAccountUnsizedInit2": 11720, "boxedAccountUnsized2": 1679, - "boxedAccountUnsizedInit4": 20351, + "boxedAccountUnsizedInit4": 21372, "boxedAccountUnsized4": 2899, - "boxedAccountUnsizedInit8": 39118, + "boxedAccountUnsizedInit8": 41159, "boxedAccountUnsized8": 5517, "boxedInterfaceAccountMint1": 2299, "boxedInterfaceAccountMint2": 4053, @@ -173,4 +177,4 @@ "uncheckedAccount8": 3855 } } -} +} \ No newline at end of file diff --git a/tests/cashiers-check/programs/cashiers-check/src/lib.rs b/tests/cashiers-check/programs/cashiers-check/src/lib.rs index eb06e2cdcc..25fd217377 100644 --- a/tests/cashiers-check/programs/cashiers-check/src/lib.rs +++ b/tests/cashiers-check/programs/cashiers-check/src/lib.rs @@ -22,9 +22,9 @@ pub mod cashiers_check { ) -> Result<()> { // Transfer funds to the check. let cpi_accounts = Transfer { - from: ctx.accounts.from.to_account_info(), - to: ctx.accounts.vault.to_account_info(), - authority: ctx.accounts.owner.to_account_info(), + from: ctx.accounts.from.to_account_info().into(), + to: ctx.accounts.vault.to_account_info().into(), + authority: ctx.accounts.owner.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); @@ -50,9 +50,9 @@ pub mod cashiers_check { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.vault.to_account_info(), - to: ctx.accounts.to.to_account_info(), - authority: ctx.accounts.check_signer.to_account_info(), + from: ctx.accounts.vault.to_account_info().into(), + to: ctx.accounts.to.to_account_info().into(), + authority: ctx.accounts.check_signer.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -70,9 +70,9 @@ pub mod cashiers_check { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.vault.to_account_info(), - to: ctx.accounts.from.to_account_info(), - authority: ctx.accounts.check_signer.to_account_info(), + from: ctx.accounts.vault.to_account_info().into(), + to: ctx.accounts.from.to_account_info().into(), + authority: ctx.accounts.check_signer.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); diff --git a/tests/escrow/programs/escrow/src/lib.rs b/tests/escrow/programs/escrow/src/lib.rs index 8afed08665..ad769089c9 100644 --- a/tests/escrow/programs/escrow/src/lib.rs +++ b/tests/escrow/programs/escrow/src/lib.rs @@ -193,8 +193,11 @@ impl<'info> From<&mut InitializeEscrow<'info>> { fn from(accounts: &mut InitializeEscrow<'info>) -> Self { let cpi_accounts = SetAuthority { - account_or_mint: accounts.initializer_deposit_token_account.to_account_info(), - current_authority: accounts.initializer.to_account_info(), + account_or_mint: accounts + .initializer_deposit_token_account + .to_account_info() + .into(), + current_authority: accounts.initializer.to_account_info().into(), }; let cpi_program = accounts.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -204,8 +207,8 @@ impl<'info> From<&mut InitializeEscrow<'info>> impl<'info> CancelEscrow<'info> { fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: self.pda_deposit_token_account.to_account_info(), - current_authority: self.pda_account.to_account_info(), + account_or_mint: self.pda_deposit_token_account.to_account_info().into(), + current_authority: self.pda_account.to_account_info().into(), }; let cpi_program = self.token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -215,8 +218,8 @@ impl<'info> CancelEscrow<'info> { impl<'info> Exchange<'info> { fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> { let cpi_accounts = SetAuthority { - account_or_mint: self.pda_deposit_token_account.to_account_info(), - current_authority: self.pda_account.to_account_info(), + account_or_mint: self.pda_deposit_token_account.to_account_info().into(), + current_authority: self.pda_account.to_account_info().into(), }; let cpi_program = self.receive_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -228,10 +231,10 @@ impl<'info> Exchange<'info> { &self, ) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> { let cpi_accounts = TransferChecked { - from: self.pda_deposit_token_account.to_account_info(), - mint: self.receive_mint.to_account_info(), - to: self.taker_receive_token_account.to_account_info(), - authority: self.pda_account.to_account_info(), + from: self.pda_deposit_token_account.to_account_info().into(), + mint: self.receive_mint.to_account_info().into(), + to: self.taker_receive_token_account.to_account_info().into(), + authority: self.pda_account.to_account_info().into(), }; let cpi_program = self.receive_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) @@ -243,10 +246,13 @@ impl<'info> Exchange<'info> { &self, ) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> { let cpi_accounts = TransferChecked { - from: self.taker_deposit_token_account.to_account_info(), - mint: self.deposit_mint.to_account_info(), - to: self.initializer_receive_token_account.to_account_info(), - authority: self.taker.to_account_info(), + from: self.taker_deposit_token_account.to_account_info().into(), + mint: self.deposit_mint.to_account_info().into(), + to: self + .initializer_receive_token_account + .to_account_info() + .into(), + authority: self.taker.to_account_info().into(), }; let cpi_program = self.deposit_token_program.to_account_info(); CpiContext::new(cpi_program, cpi_accounts) diff --git a/tests/ido-pool/programs/ido-pool/src/lib.rs b/tests/ido-pool/programs/ido-pool/src/lib.rs index 0e72a49a2f..f1fad12d5f 100644 --- a/tests/ido-pool/programs/ido-pool/src/lib.rs +++ b/tests/ido-pool/programs/ido-pool/src/lib.rs @@ -51,9 +51,13 @@ pub mod ido_pool { // Transfer Watermelon from ido_authority to pool account. let cpi_accounts = Transfer { - from: ctx.accounts.ido_authority_watermelon.to_account_info(), - to: ctx.accounts.pool_watermelon.to_account_info(), - authority: ctx.accounts.ido_authority.to_account_info(), + from: ctx + .accounts + .ido_authority_watermelon + .to_account_info() + .into(), + to: ctx.accounts.pool_watermelon.to_account_info().into(), + authority: ctx.accounts.ido_authority.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); @@ -81,9 +85,9 @@ pub mod ido_pool { // Transfer user's USDC to pool USDC account. let cpi_accounts = Transfer { - from: ctx.accounts.user_usdc.to_account_info(), - to: ctx.accounts.pool_usdc.to_account_info(), - authority: ctx.accounts.user_authority.to_account_info(), + from: ctx.accounts.user_usdc.to_account_info().into(), + to: ctx.accounts.pool_usdc.to_account_info().into(), + authority: ctx.accounts.user_authority.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); @@ -97,9 +101,9 @@ pub mod ido_pool { ]; let signer = &[&seeds[..]]; let cpi_accounts = MintTo { - mint: ctx.accounts.redeemable_mint.to_account_info(), - to: ctx.accounts.user_redeemable.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + mint: ctx.accounts.redeemable_mint.to_account_info().into(), + to: ctx.accounts.user_redeemable.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -134,9 +138,9 @@ pub mod ido_pool { // Burn the user's redeemable tokens. let cpi_accounts = Burn { - mint: ctx.accounts.redeemable_mint.to_account_info(), - from: ctx.accounts.user_redeemable.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + mint: ctx.accounts.redeemable_mint.to_account_info().into(), + from: ctx.accounts.user_redeemable.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -144,9 +148,9 @@ pub mod ido_pool { // Transfer USDC from pool account to the user's escrow account. let cpi_accounts = Transfer { - from: ctx.accounts.pool_usdc.to_account_info(), - to: ctx.accounts.escrow_usdc.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.pool_usdc.to_account_info().into(), + to: ctx.accounts.escrow_usdc.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -182,9 +186,9 @@ pub mod ido_pool { // Burn the user's redeemable tokens. let cpi_accounts = Burn { - mint: ctx.accounts.redeemable_mint.to_account_info(), - from: ctx.accounts.user_redeemable.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + mint: ctx.accounts.redeemable_mint.to_account_info().into(), + from: ctx.accounts.user_redeemable.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -192,9 +196,9 @@ pub mod ido_pool { // Transfer Watermelon from pool account to user. let cpi_accounts = Transfer { - from: ctx.accounts.pool_watermelon.to_account_info(), - to: ctx.accounts.user_watermelon.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.pool_watermelon.to_account_info().into(), + to: ctx.accounts.user_watermelon.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -204,9 +208,9 @@ pub mod ido_pool { ctx.accounts.user_redeemable.reload()?; if ctx.accounts.user_redeemable.amount == 0 { let cpi_accounts = CloseAccount { - account: ctx.accounts.user_redeemable.to_account_info(), - destination: ctx.accounts.user_authority.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + account: ctx.accounts.user_redeemable.to_account_info().into(), + destination: ctx.accounts.user_authority.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -227,9 +231,9 @@ pub mod ido_pool { ]; let signer = &[&seeds[..]]; let cpi_accounts = Transfer { - from: ctx.accounts.pool_usdc.to_account_info(), - to: ctx.accounts.ido_authority_usdc.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.pool_usdc.to_account_info().into(), + to: ctx.accounts.ido_authority_usdc.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -255,9 +259,9 @@ pub mod ido_pool { // Transfer USDC from user's escrow account to user's USDC account. let cpi_accounts = Transfer { - from: ctx.accounts.escrow_usdc.to_account_info(), - to: ctx.accounts.user_usdc.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + from: ctx.accounts.escrow_usdc.to_account_info().into(), + to: ctx.accounts.user_usdc.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); @@ -267,9 +271,9 @@ pub mod ido_pool { ctx.accounts.escrow_usdc.reload()?; if ctx.accounts.escrow_usdc.amount == 0 { let cpi_accounts = CloseAccount { - account: ctx.accounts.escrow_usdc.to_account_info(), - destination: ctx.accounts.user_authority.to_account_info(), - authority: ctx.accounts.ido_account.to_account_info(), + account: ctx.accounts.escrow_usdc.to_account_info().into(), + destination: ctx.accounts.user_authority.to_account_info().into(), + authority: ctx.accounts.ido_account.to_account_info().into(), }; let cpi_program = ctx.accounts.token_program.to_account_info(); let cpi_ctx = CpiContext::new_with_signer(cpi_program, cpi_accounts, signer); diff --git a/tests/swap/programs/swap/src/lib.rs b/tests/swap/programs/swap/src/lib.rs index b9b16899c4..4ec8380b81 100644 --- a/tests/swap/programs/swap/src/lib.rs +++ b/tests/swap/programs/swap/src/lib.rs @@ -206,11 +206,11 @@ impl<'info> From<&Swap<'info>> for OrderbookClient<'info> { fn from(accounts: &Swap<'info>) -> OrderbookClient<'info> { OrderbookClient { market: accounts.market.clone(), - authority: accounts.authority.to_account_info(), - pc_wallet: accounts.pc_wallet.to_account_info(), - dex_program: accounts.dex_program.to_account_info(), - token_program: accounts.token_program.to_account_info(), - rent: accounts.rent.to_account_info(), + authority: accounts.authority.to_account_info().into(), + pc_wallet: accounts.pc_wallet.to_account_info().into(), + dex_program: accounts.dex_program.to_account_info().into(), + token_program: accounts.token_program.to_account_info().into(), + rent: accounts.rent.to_account_info().into(), } } } @@ -239,21 +239,21 @@ impl<'info> SwapTransitive<'info> { fn orderbook_from(&self) -> OrderbookClient<'info> { OrderbookClient { market: self.from.clone(), - authority: self.authority.to_account_info(), - pc_wallet: self.pc_wallet.to_account_info(), - dex_program: self.dex_program.to_account_info(), - token_program: self.token_program.to_account_info(), - rent: self.rent.to_account_info(), + authority: self.authority.to_account_info().into(), + pc_wallet: self.pc_wallet.to_account_info().into(), + dex_program: self.dex_program.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), + rent: self.rent.to_account_info().into(), } } fn orderbook_to(&self) -> OrderbookClient<'info> { OrderbookClient { market: self.to.clone(), - authority: self.authority.to_account_info(), - pc_wallet: self.pc_wallet.to_account_info(), - dex_program: self.dex_program.to_account_info(), - token_program: self.token_program.to_account_info(), - rent: self.rent.to_account_info(), + authority: self.authority.to_account_info().into(), + pc_wallet: self.pc_wallet.to_account_info().into(), + dex_program: self.dex_program.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), + rent: self.rent.to_account_info().into(), } } } @@ -334,18 +334,22 @@ impl<'info> OrderbookClient<'info> { let limit = 65535; let dex_accs = dex::NewOrderV3 { - market: self.market.market.to_account_info(), - open_orders: self.market.open_orders.to_account_info(), - request_queue: self.market.request_queue.to_account_info(), - event_queue: self.market.event_queue.to_account_info(), - market_bids: self.market.bids.to_account_info(), - market_asks: self.market.asks.to_account_info(), - order_payer_token_account: self.market.order_payer_token_account.to_account_info(), - open_orders_authority: self.authority.to_account_info(), - coin_vault: self.market.coin_vault.to_account_info(), - pc_vault: self.market.pc_vault.to_account_info(), - token_program: self.token_program.to_account_info(), - rent: self.rent.to_account_info(), + market: self.market.market.to_account_info().into(), + open_orders: self.market.open_orders.to_account_info().into(), + request_queue: self.market.request_queue.to_account_info().into(), + event_queue: self.market.event_queue.to_account_info().into(), + market_bids: self.market.bids.to_account_info().into(), + market_asks: self.market.asks.to_account_info().into(), + order_payer_token_account: self + .market + .order_payer_token_account + .to_account_info() + .into(), + open_orders_authority: self.authority.to_account_info().into(), + coin_vault: self.market.coin_vault.to_account_info().into(), + pc_vault: self.market.pc_vault.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), + rent: self.rent.to_account_info().into(), }; let mut ctx = CpiContext::new(self.dex_program.to_account_info(), dex_accs); if let Some(referral) = referral { @@ -366,15 +370,15 @@ impl<'info> OrderbookClient<'info> { fn settle(&self, referral: Option>) -> Result<()> { let settle_accs = dex::SettleFunds { - market: self.market.market.to_account_info(), - open_orders: self.market.open_orders.to_account_info(), - open_orders_authority: self.authority.to_account_info(), - coin_vault: self.market.coin_vault.to_account_info(), - pc_vault: self.market.pc_vault.to_account_info(), - coin_wallet: self.market.coin_wallet.to_account_info(), - pc_wallet: self.pc_wallet.to_account_info(), - vault_signer: self.market.vault_signer.to_account_info(), - token_program: self.token_program.to_account_info(), + market: self.market.market.to_account_info().into(), + open_orders: self.market.open_orders.to_account_info().into(), + open_orders_authority: self.authority.to_account_info().into(), + coin_vault: self.market.coin_vault.to_account_info().into(), + pc_vault: self.market.pc_vault.to_account_info().into(), + coin_wallet: self.market.coin_wallet.to_account_info().into(), + pc_wallet: self.pc_wallet.to_account_info().into(), + vault_signer: self.market.vault_signer.to_account_info().into(), + token_program: self.token_program.to_account_info().into(), }; let mut ctx = CpiContext::new(self.dex_program.to_account_info(), settle_accs); if let Some(referral) = referral { diff --git a/tests/yarn.lock b/tests/yarn.lock index f0a8cc1209..437dd856ee 100644 --- a/tests/yarn.lock +++ b/tests/yarn.lock @@ -16,28 +16,7 @@ dependencies: regenerator-runtime "^0.13.4" -"@coral-xyz/anchor@=0.27.0": - version "0.26.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.26.0.tgz#c8e4f7177e93441afd030f22d777d54d0194d7d1" - integrity sha512-PxRl+wu5YyptWiR9F2MBHOLLibm87Z4IMUBPreX+DYBtPM+xggvcPi0KAN7+kIL4IrIhXI8ma5V0MCXxSN1pHg== - dependencies: - "@coral-xyz/borsh" "^0.26.0" - "@solana/web3.js" "^1.68.0" - base64-js "^1.5.1" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^6.3.0" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - js-sha256 "^0.9.0" - pako "^2.0.3" - snake-case "^3.0.4" - superstruct "^0.15.4" - toml "^3.0.0" - -"@coral-xyz/anchor@file:../ts/packages/anchor": +"@coral-xyz/anchor@=0.27.0", "@coral-xyz/anchor@file:../ts/packages/anchor": version "0.27.0" dependencies: "@coral-xyz/borsh" "^0.27.0" @@ -56,10 +35,10 @@ superstruct "^0.15.4" toml "^3.0.0" -"@coral-xyz/borsh@^0.26.0", "@coral-xyz/borsh@^0.27.0": - version "0.26.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.26.0.tgz#d054f64536d824634969e74138f9f7c52bbbc0d5" - integrity sha512-uCZ0xus0CszQPHYfWAqKS5swS1UxvePu83oOF+TWpUkedsNlg6p2p4azxZNSSqwXb9uXMFgxhuMBX9r3Xoi0vQ== +"@coral-xyz/borsh@^0.27.0": + version "0.27.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.27.0.tgz#700c647ea5262b1488957ac7fb4e8acf72c72b63" + integrity sha512-tJKzhLukghTWPLy+n8K8iJKgBq1yLT/AxaNd10yJrX8mI56ao5+OFAKAqW/h0i79KCvb4BK0VGO5ECmmolFz9A== dependencies: bn.js "^5.1.2" buffer-layout "^1.2.0" diff --git a/tests/zero-copy/programs/zero-cpi/src/lib.rs b/tests/zero-copy/programs/zero-cpi/src/lib.rs index 3b25775b5c..f3b5e5355a 100644 --- a/tests/zero-copy/programs/zero-cpi/src/lib.rs +++ b/tests/zero-copy/programs/zero-cpi/src/lib.rs @@ -11,9 +11,9 @@ pub mod zero_cpi { pub fn check_cpi(ctx: Context, data: u64) -> Result<()> { let cpi_program = ctx.accounts.zero_copy_program.to_account_info(); let cpi_accounts = UpdateBar { - authority: ctx.accounts.authority.to_account_info(), - bar: ctx.accounts.bar.to_account_info(), - foo: ctx.accounts.foo.to_account_info(), + authority: ctx.accounts.authority.to_account_info().into(), + bar: ctx.accounts.bar.to_account_info().into(), + foo: ctx.accounts.foo.to_account_info().into(), }; let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts); zero_copy::cpi::update_bar(cpi_ctx, data)?;