bug: sysvar::Instructions
is not owned by Sysvar1111111111111111111111111111111111111
(#19242)
* Fix instructions sysvar owner * Update feature switch address Co-authored-by: Justin Starry <justin@solana.com>
This commit is contained in:
@ -10,6 +10,7 @@ use solana_program::{
|
|||||||
msg,
|
msg,
|
||||||
program_error::ProgramError,
|
program_error::ProgramError,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
|
system_program,
|
||||||
sysvar::{
|
sysvar::{
|
||||||
self, clock::Clock, epoch_schedule::EpochSchedule, instructions, rent::Rent,
|
self, clock::Clock, epoch_schedule::EpochSchedule, instructions, rent::Rent,
|
||||||
slot_hashes::SlotHashes, slot_history::SlotHistory, stake_history::StakeHistory, Sysvar,
|
slot_hashes::SlotHashes, slot_history::SlotHistory, stake_history::StakeHistory, Sysvar,
|
||||||
@ -46,6 +47,7 @@ pub fn process_instruction(
|
|||||||
// Instructions
|
// Instructions
|
||||||
msg!("Instructions identifier:");
|
msg!("Instructions identifier:");
|
||||||
sysvar::instructions::id().log();
|
sysvar::instructions::id().log();
|
||||||
|
assert_eq!(*accounts[4].owner, system_program::id());
|
||||||
let index = instructions::load_current_index(&accounts[4].try_borrow_data()?);
|
let index = instructions::load_current_index(&accounts[4].try_borrow_data()?);
|
||||||
assert_eq!(0, index);
|
assert_eq!(0, index);
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ use solana_sdk::{
|
|||||||
native_loader, nonce,
|
native_loader, nonce,
|
||||||
nonce::NONCED_TX_MARKER_IX_INDEX,
|
nonce::NONCED_TX_MARKER_IX_INDEX,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
|
system_program, sysvar,
|
||||||
transaction::{Result, SanitizedTransaction, TransactionError},
|
transaction::{Result, SanitizedTransaction, TransactionError},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
@ -197,12 +198,21 @@ impl Accounts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn construct_instructions_account(message: &SanitizedMessage) -> AccountSharedData {
|
fn construct_instructions_account(
|
||||||
|
message: &SanitizedMessage,
|
||||||
|
is_owned_by_sysvar: bool,
|
||||||
|
) -> AccountSharedData {
|
||||||
let mut data = message.serialize_instructions();
|
let mut data = message.serialize_instructions();
|
||||||
// add room for current instruction index.
|
// add room for current instruction index.
|
||||||
data.resize(data.len() + 2, 0);
|
data.resize(data.len() + 2, 0);
|
||||||
|
let owner = if is_owned_by_sysvar {
|
||||||
|
sysvar::id()
|
||||||
|
} else {
|
||||||
|
system_program::id()
|
||||||
|
};
|
||||||
AccountSharedData::from(Account {
|
AccountSharedData::from(Account {
|
||||||
data,
|
data,
|
||||||
|
owner,
|
||||||
..Account::default()
|
..Account::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -243,7 +253,11 @@ impl Accounts {
|
|||||||
if message.is_writable(i) {
|
if message.is_writable(i) {
|
||||||
return Err(TransactionError::InvalidAccountIndex);
|
return Err(TransactionError::InvalidAccountIndex);
|
||||||
}
|
}
|
||||||
Self::construct_instructions_account(message)
|
Self::construct_instructions_account(
|
||||||
|
message,
|
||||||
|
feature_set
|
||||||
|
.is_active(&feature_set::instructions_sysvar_owned_by_sysvar::id()),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
let (account, rent) = self
|
let (account, rent) = self
|
||||||
.accounts_db
|
.accounts_db
|
||||||
|
@ -30,6 +30,10 @@ pub mod instructions_sysvar_enabled {
|
|||||||
solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs");
|
solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod instructions_sysvar_owned_by_sysvar {
|
||||||
|
solana_sdk::declare_id!("H3kBSaKdeiUsyHmeHqjJYNc27jesXZ6zWj3zWkowQbkV");
|
||||||
|
}
|
||||||
|
|
||||||
pub mod deprecate_rewards_sysvar {
|
pub mod deprecate_rewards_sysvar {
|
||||||
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
|
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user