From 52fbe55d52837667273b109d8e1e887854449d90 Mon Sep 17 00:00:00 2001 From: "Jean Marchand (Exotic Markets)" Date: Tue, 26 Dec 2023 22:21:42 +0100 Subject: [PATCH] spl: Remove shared memory program (#2747) --- CHANGELOG.md | 1 + spl/Cargo.toml | 2 +- spl/src/lib.rs | 3 --- spl/src/shmem.rs | 50 ------------------------------------------------ 4 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 spl/src/shmem.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index addae99c9a..3ca6ac57f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ The minor version will be incremented upon a breaking change and the patch versi - ts: Remove `anchor-deprecated-state` feature ([#2717](https://github.com/coral-xyz/anchor/pull/2717)). - lang: Remove `CLOSED_ACCOUNT_DISCRIMINATOR` ([#2726](https://github.com/coral-xyz/anchor/pull/2726)). - lang: Make bumps of optional accounts `Option` rather than `u8` ([#2730](https://github.com/coral-xyz/anchor/pull/2730)). +- spl: Remove `shared-memory` program ([#2747](https://github.com/coral-xyz/anchor/pull/2747)). ## [0.29.0] - 2023-10-16 diff --git a/spl/Cargo.toml b/spl/Cargo.toml index 42b3294b4a..d61deef5be 100644 --- a/spl/Cargo.toml +++ b/spl/Cargo.toml @@ -17,7 +17,6 @@ idl-build = ["anchor-lang/idl-build"] memo = ["spl-memo"] metadata = ["mpl-token-metadata"] mint = [] -shmem = [] stake = ["borsh"] token = ["spl-token"] token_2022 = ["spl-token-2022"] @@ -32,3 +31,4 @@ spl-associated-token-account = { version = "2.2", features = ["no-entrypoint"], spl-memo = { version = "4", features = ["no-entrypoint"], optional = true } spl-token = { version = "4", features = ["no-entrypoint"], optional = true } spl-token-2022 = { version = "0.9", features = ["no-entrypoint"], optional = true } + diff --git a/spl/src/lib.rs b/spl/src/lib.rs index 1a485948d4..6ec5129ff4 100644 --- a/spl/src/lib.rs +++ b/spl/src/lib.rs @@ -19,9 +19,6 @@ pub mod dex; #[cfg(feature = "governance")] pub mod governance; -#[cfg(feature = "shmem")] -pub mod shmem; - #[cfg(feature = "stake")] pub mod stake; diff --git a/spl/src/shmem.rs b/spl/src/shmem.rs deleted file mode 100644 index 81a9f15869..0000000000 --- a/spl/src/shmem.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! CPI API for interacting with the SPL shared memory -//! [program](https://github.com/solana-labs/solana-program-library/tree/master/shared-memory). - -use anchor_lang::{context::CpiContext, Accounts}; -use solana_program::account_info::AccountInfo; -use solana_program::declare_id; -use solana_program::entrypoint::ProgramResult; -use solana_program::instruction::{AccountMeta, Instruction}; -use solana_program::program; -use solana_program::pubkey::Pubkey; - -// TODO: update this once the final shared memory program gets released. -// shmem4EWT2sPdVGvTZCzXXRAURL9G5vpPxNwSeKhHUL. -declare_id!("DynWy94wrWp5RimU49creYMQ5py3Up8BBNS4VA73VCpi"); - -/// `ret` writes the given `data` field to the shared memory account -/// acting as a return value that can be used across CPI. -/// The caleee should use this to write data into the shared memory account. -/// The caler should use the account directly to pull out and interpret the -/// bytes. Shared memory serialization is not specified and is up to the -/// caller and callee. -pub fn ret<'a, 'b, 'c, 'info>( - ctx: CpiContext<'a, 'b, 'c, 'info, Ret<'info>>, - data: Vec, -) -> ProgramResult { - let instruction = Instruction { - program_id: *ctx.program.key, - accounts: vec![AccountMeta::new(*ctx.accounts.buffer.key, false)], - data, - }; - let mut accounts = vec![ctx.accounts.buffer]; - accounts.push(ctx.program.clone()); - program::invoke(&instruction, &accounts) -} - -#[derive(Accounts)] -pub struct Ret<'info> { - #[account(mut)] - pub buffer: AccountInfo<'info>, -} - -// A set of accounts that can be used with shared memory. -#[derive(Accounts)] -pub struct Shmem<'info> { - // Shared memory account to write the return value into. - #[account(mut, constraint = shmem.owner == shmem_program.key)] - pub shmem: AccountInfo<'info>, - #[account(constraint = shmem_program.key == &ID)] - pub shmem_program: AccountInfo<'info>, -}