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

Commit e8177d5

Browse files
committed
Revert runtime changes
1 parent 3945ca2 commit e8177d5

File tree

8 files changed

+29
-43
lines changed

8 files changed

+29
-43
lines changed

Cargo.lock

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

program-runtime/src/invoke_context.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ use {
2020
cap_accounts_data_len, enable_early_verification_of_account_modifications, FeatureSet,
2121
},
2222
hash::Hash,
23-
instruction::{AccountMeta, InstructionError},
23+
instruction::{AccountMeta, Instruction, InstructionError},
2424
native_loader,
2525
pubkey::Pubkey,
2626
rent::Rent,
2727
saturating_add_assign,
28-
stable_layout::stable_instruction::StableInstruction,
2928
transaction_context::{InstructionAccount, TransactionAccount, TransactionContext},
3029
},
3130
std::{
@@ -564,7 +563,7 @@ impl<'a> InvokeContext<'a> {
564563
/// Entrypoint for a cross-program invocation from a builtin program
565564
pub fn native_invoke(
566565
&mut self,
567-
instruction: StableInstruction,
566+
instruction: Instruction,
568567
signers: &[Pubkey],
569568
) -> Result<(), InstructionError> {
570569
let (instruction_accounts, program_indices) =
@@ -584,7 +583,7 @@ impl<'a> InvokeContext<'a> {
584583
#[allow(clippy::type_complexity)]
585584
pub fn prepare_instruction(
586585
&mut self,
587-
instruction: &StableInstruction,
586+
instruction: &Instruction,
588587
signers: &[Pubkey],
589588
) -> Result<(Vec<InstructionAccount>, Vec<usize>), InstructionError> {
590589
// Finds the index of each account in the instruction by its pubkey.
@@ -1112,7 +1111,7 @@ mod tests {
11121111
super::*,
11131112
crate::compute_budget,
11141113
serde::{Deserialize, Serialize},
1115-
solana_sdk::{account::WritableAccount, instruction::Instruction},
1114+
solana_sdk::account::WritableAccount,
11161115
};
11171116

11181117
#[derive(Debug, Serialize, Deserialize)]
@@ -1232,7 +1231,7 @@ mod tests {
12321231
assert_eq!(result, Err(InstructionError::UnbalancedInstruction));
12331232
result?;
12341233
invoke_context
1235-
.native_invoke(inner_instruction.into(), &[])
1234+
.native_invoke(inner_instruction, &[])
12361235
.and(invoke_context.pop())?;
12371236
}
12381237
MockInstruction::UnbalancedPop => instruction_context
@@ -1385,7 +1384,7 @@ mod tests {
13851384
let inner_instruction =
13861385
Instruction::new_with_bincode(callee_program_id, &case.0, metas.clone());
13871386
let result = invoke_context
1388-
.native_invoke(inner_instruction.into(), &[])
1387+
.native_invoke(inner_instruction, &[])
13891388
.and(invoke_context.pop());
13901389
assert_eq!(result, case.1);
13911390
}
@@ -1405,7 +1404,6 @@ mod tests {
14051404
},
14061405
metas.clone(),
14071406
);
1408-
let inner_instruction = StableInstruction::from(inner_instruction);
14091407
let (inner_instruction_accounts, program_indices) = invoke_context
14101408
.prepare_instruction(&inner_instruction, &[])
14111409
.unwrap();

program-test/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use {
3737
pubkey::Pubkey,
3838
rent::Rent,
3939
signature::{Keypair, Signer},
40-
stable_layout::stable_instruction::StableInstruction,
4140
sysvar::{Sysvar, SysvarId},
4241
},
4342
solana_vote_program::vote_state::{VoteState, VoteStateVersions},
@@ -227,7 +226,6 @@ impl solana_sdk::program_stubs::SyscallStubs for SyscallStubs {
227226
account_infos: &[AccountInfo],
228227
signers_seeds: &[&[&[u8]]],
229228
) -> ProgramResult {
230-
let instruction = StableInstruction::from(instruction.clone());
231229
let invoke_context = get_invoke_context();
232230
let log_collector = invoke_context.get_log_collector();
233231
let transaction_context = &invoke_context.transaction_context;
@@ -250,7 +248,7 @@ impl solana_sdk::program_stubs::SyscallStubs for SyscallStubs {
250248
.collect::<Vec<_>>();
251249

252250
let (instruction_accounts, program_indices) = invoke_context
253-
.prepare_instruction(&instruction, &signers)
251+
.prepare_instruction(instruction, &signers)
254252
.unwrap();
255253

256254
// Copy caller's account_info modifications into invoke_context accounts

programs/address-lookup-table/src/processor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,18 @@ impl Processor {
125125

126126
if required_lamports > 0 {
127127
invoke_context.native_invoke(
128-
system_instruction::transfer(&payer_key, &table_key, required_lamports).into(),
128+
system_instruction::transfer(&payer_key, &table_key, required_lamports),
129129
&[payer_key],
130130
)?;
131131
}
132132

133133
invoke_context.native_invoke(
134-
system_instruction::allocate(&table_key, table_account_data_len as u64).into(),
134+
system_instruction::allocate(&table_key, table_account_data_len as u64),
135135
&[table_key],
136136
)?;
137137

138138
invoke_context.native_invoke(
139-
system_instruction::assign(&table_key, &crate::id()).into(),
139+
system_instruction::assign(&table_key, &crate::id()),
140140
&[table_key],
141141
)?;
142142

@@ -313,7 +313,7 @@ impl Processor {
313313
drop(payer_account);
314314

315315
invoke_context.native_invoke(
316-
system_instruction::transfer(&payer_key, &table_key, required_lamports).into(),
316+
system_instruction::transfer(&payer_key, &table_key, required_lamports),
317317
&[payer_key],
318318
)?;
319319
}

programs/bpf_loader/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ solana_rbpf = "=0.2.31"
2323
thiserror = "1.0"
2424

2525
[dev-dependencies]
26-
memoffset = "0.6"
2726
rand = "0.7.3"
2827
solana-runtime = { path = "../../runtime", version = "=1.14.24" }
2928

programs/bpf_loader/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ fn process_loader_upgradeable_instruction(
652652
.iter()
653653
.map(|seeds| Pubkey::create_program_address(*seeds, caller_program_id))
654654
.collect::<Result<Vec<Pubkey>, solana_sdk::pubkey::PubkeyError>>()?;
655-
invoke_context.native_invoke(instruction.into(), signers.as_slice())?;
655+
invoke_context.native_invoke(instruction, signers.as_slice())?;
656656

657657
// Load and verify the program bits
658658
let executor = create_executor(
@@ -1146,8 +1146,7 @@ fn process_loader_upgradeable_instruction(
11461146
)?;
11471147

11481148
invoke_context.native_invoke(
1149-
system_instruction::transfer(&payer_key, &programdata_key, required_payment)
1150-
.into(),
1149+
system_instruction::transfer(&payer_key, &programdata_key, required_payment),
11511150
&[],
11521151
)?;
11531152
}

programs/bpf_loader/src/syscalls/cpi.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use {
22
super::*,
33
crate::declare_syscall,
4-
solana_sdk::{
5-
stable_layout::stable_instruction::StableInstruction,
6-
syscalls::{
7-
MAX_CPI_ACCOUNT_INFOS, MAX_CPI_INSTRUCTION_ACCOUNTS, MAX_CPI_INSTRUCTION_DATA_LEN,
8-
},
4+
solana_sdk::syscalls::{
5+
MAX_CPI_ACCOUNT_INFOS, MAX_CPI_INSTRUCTION_ACCOUNTS, MAX_CPI_INSTRUCTION_DATA_LEN,
96
},
107
};
118

@@ -30,7 +27,7 @@ trait SyscallInvokeSigned<'a, 'b> {
3027
addr: u64,
3128
memory_mapping: &mut MemoryMapping,
3229
invoke_context: &mut InvokeContext,
33-
) -> Result<StableInstruction, EbpfError<BpfError>>;
30+
) -> Result<Instruction, EbpfError<BpfError>>;
3431
fn translate_accounts<'c>(
3532
&'c self,
3633
instruction_accounts: &[InstructionAccount],
@@ -87,8 +84,8 @@ impl<'a, 'b> SyscallInvokeSigned<'a, 'b> for SyscallInvokeSignedRust<'a, 'b> {
8784
addr: u64,
8885
memory_mapping: &mut MemoryMapping,
8986
invoke_context: &mut InvokeContext,
90-
) -> Result<StableInstruction, EbpfError<BpfError>> {
91-
let ix = translate_type::<StableInstruction>(
87+
) -> Result<Instruction, EbpfError<BpfError>> {
88+
let ix = translate_type::<Instruction>(
9289
memory_mapping,
9390
addr,
9491
invoke_context.get_check_aligned(),
@@ -124,11 +121,10 @@ impl<'a, 'b> SyscallInvokeSigned<'a, 'b> for SyscallInvokeSignedRust<'a, 'b> {
124121
invoke_context.get_check_size(),
125122
)?
126123
.to_vec();
127-
128-
Ok(StableInstruction {
129-
accounts: accounts.into(),
130-
data: data.into(),
124+
Ok(Instruction {
131125
program_id: ix.program_id,
126+
accounts,
127+
data,
132128
})
133129
}
134130

@@ -398,7 +394,7 @@ impl<'a, 'b> SyscallInvokeSigned<'a, 'b> for SyscallInvokeSignedC<'a, 'b> {
398394
addr: u64,
399395
memory_mapping: &mut MemoryMapping,
400396
invoke_context: &mut InvokeContext,
401-
) -> Result<StableInstruction, EbpfError<BpfError>> {
397+
) -> Result<Instruction, EbpfError<BpfError>> {
402398
let ix_c = translate_type::<SolInstruction>(
403399
memory_mapping,
404400
addr,
@@ -458,10 +454,10 @@ impl<'a, 'b> SyscallInvokeSigned<'a, 'b> for SyscallInvokeSignedC<'a, 'b> {
458454
})
459455
.collect::<Result<Vec<AccountMeta>, EbpfError<BpfError>>>()?;
460456

461-
Ok(StableInstruction {
462-
accounts: accounts.into(),
463-
data: data.into(),
457+
Ok(Instruction {
464458
program_id: *program_id,
459+
accounts,
460+
data,
465461
})
466462
}
467463

programs/bpf_loader/src/syscalls/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use {
4141
},
4242
hash::{Hasher, HASH_BYTES},
4343
instruction::{
44-
AccountMeta, InstructionError, ProcessedSiblingInstruction,
44+
AccountMeta, Instruction, InstructionError, ProcessedSiblingInstruction,
4545
TRANSACTION_LEVEL_STACK_HEIGHT,
4646
},
4747
keccak, native_loader,
@@ -2073,9 +2073,7 @@ mod tests {
20732073
bpf_loader,
20742074
fee_calculator::FeeCalculator,
20752075
hash::hashv,
2076-
instruction::Instruction,
20772076
program::check_type_assumptions,
2078-
stable_layout::stable_instruction::StableInstruction,
20792077
sysvar::{clock::Clock, epoch_schedule::EpochSchedule, rent::Rent},
20802078
transaction_context::TransactionContext,
20812079
},
@@ -2193,12 +2191,11 @@ mod tests {
21932191
&"foobar",
21942192
vec![AccountMeta::new(solana_sdk::pubkey::new_rand(), false)],
21952193
);
2196-
let instruction = StableInstruction::from(instruction);
21972194
let addr = &instruction as *const _ as u64;
21982195
let mut memory_region = MemoryRegion {
21992196
host_addr: addr,
22002197
vm_addr: 0x100000000,
2201-
len: std::mem::size_of::<StableInstruction>() as u64,
2198+
len: std::mem::size_of::<Instruction>() as u64,
22022199
vm_gap_shift: 63,
22032200
is_writable: false,
22042201
};
@@ -2208,13 +2205,13 @@ mod tests {
22082205
)
22092206
.unwrap();
22102207
let translated_instruction =
2211-
translate_type::<StableInstruction>(&memory_mapping, 0x100000000, true).unwrap();
2208+
translate_type::<Instruction>(&memory_mapping, 0x100000000, true).unwrap();
22122209
assert_eq!(instruction, *translated_instruction);
22132210
memory_region.len = 1;
22142211
memory_mapping
22152212
.replace_region::<BpfError>(1, memory_region)
22162213
.unwrap();
2217-
assert!(translate_type::<StableInstruction>(&memory_mapping, 0x100000000, true).is_err());
2214+
assert!(translate_type::<Instruction>(&memory_mapping, 0x100000000, true).is_err());
22182215
}
22192216

22202217
#[test]

0 commit comments

Comments
 (0)