Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 9b3076f

Browse files
authored
instruction-padding: Remove solana-program dependency (#7436)
* instruction-padding: Remove solana-program dependency #### Problem The instruction-padding program still has an explicit dependency on solana-program, but it isn't needed. #### Summary of changes Use the component crates instead. Some of the syscall consts aren't available yet outside of solana-program, but it was easy to add a static assertion for those. * Add re-exports
1 parent 8f550c5 commit 9b3076f

File tree

6 files changed

+46
-19
lines changed

6 files changed

+46
-19
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

instruction-padding/program/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ test-sbf = []
1414

1515
[dependencies]
1616
num_enum = "0.7.3"
17-
solana-program = "2.1.0"
17+
solana-account-info = "2.1.0"
18+
solana-cpi = "2.1.0"
19+
solana-instruction = { version = "2.1.0", features = ["std"] }
20+
solana-program-entrypoint = "2.1.0"
21+
solana-program-error = "2.1.0"
22+
solana-pubkey = "2.1.0"
1823

1924
[dev-dependencies]
25+
solana-program = "2.1.0"
2026
solana-program-test = "2.1.0"
2127
solana-sdk = "2.1.0"
28+
static_assertions = "1.1.0"
2229

2330
[lib]
2431
crate-type = ["cdylib", "lib"]

instruction-padding/program/src/entrypoint.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
33
#![cfg(not(feature = "no-entrypoint"))]
44

5-
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
5+
use {
6+
solana_account_info::AccountInfo, solana_program_error::ProgramResult, solana_pubkey::Pubkey,
7+
};
68

7-
solana_program::entrypoint!(process_instruction);
9+
solana_program_entrypoint::entrypoint!(process_instruction);
810
fn process_instruction(
911
program_id: &Pubkey,
1012
accounts: &[AccountInfo],

instruction-padding/program/src/instruction.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22
33
use {
44
num_enum::{IntoPrimitive, TryFromPrimitive},
5-
solana_program::{
6-
instruction::{AccountMeta, Instruction},
7-
program_error::ProgramError,
8-
pubkey::Pubkey,
9-
syscalls::{MAX_CPI_ACCOUNT_INFOS, MAX_CPI_INSTRUCTION_DATA_LEN},
10-
},
5+
solana_instruction::{AccountMeta, Instruction},
6+
solana_program_error::ProgramError,
7+
solana_pubkey::Pubkey,
118
std::{convert::TryInto, mem::size_of},
129
};
1310

11+
const MAX_CPI_ACCOUNT_INFOS: usize = 128;
12+
const MAX_CPI_INSTRUCTION_DATA_LEN: u64 = 10 * 1024;
13+
14+
#[cfg(test)]
15+
static_assertions::const_assert_eq!(
16+
MAX_CPI_ACCOUNT_INFOS,
17+
solana_program::syscalls::MAX_CPI_ACCOUNT_INFOS
18+
);
19+
#[cfg(test)]
20+
static_assertions::const_assert_eq!(
21+
MAX_CPI_INSTRUCTION_DATA_LEN,
22+
solana_program::syscalls::MAX_CPI_INSTRUCTION_DATA_LEN
23+
);
24+
1425
/// Instructions supported by the padding program, which takes in additional
1526
/// account data or accounts and does nothing with them. It's meant for testing
1627
/// larger transactions with bench-tps.

instruction-padding/program/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@ mod entrypoint;
22
pub mod instruction;
33
pub mod processor;
44

5-
pub use solana_program;
6-
solana_program::declare_id!("iXpADd6AW1k5FaaXum5qHbSqyd7TtoN6AD7suVa83MF");
5+
pub use {
6+
solana_account_info, solana_cpi, solana_instruction, solana_program_entrypoint,
7+
solana_program_error, solana_pubkey,
8+
};
9+
solana_pubkey::declare_id!("iXpADd6AW1k5FaaXum5qHbSqyd7TtoN6AD7suVa83MF");

instruction-padding/program/src/processor.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
use {
22
crate::instruction::{PadInstruction, WrapData},
3-
solana_program::{
4-
account_info::AccountInfo,
5-
entrypoint::ProgramResult,
6-
instruction::{AccountMeta, Instruction},
7-
program::invoke,
8-
program_error::ProgramError,
9-
pubkey::Pubkey,
10-
},
3+
solana_account_info::AccountInfo,
4+
solana_cpi::invoke,
5+
solana_instruction::{AccountMeta, Instruction},
6+
solana_program_error::{ProgramError, ProgramResult},
7+
solana_pubkey::Pubkey,
118
std::convert::TryInto,
129
};
1310

0 commit comments

Comments
 (0)