Remove sysvar special cases for rent and assign

This commit is contained in:
Ryo Onodera
2021-05-18 00:30:48 +09:00
parent 8b87d86358
commit c2320fceab
7 changed files with 543 additions and 36 deletions

View File

@@ -163,6 +163,10 @@ pub mod neon_evm_compute_budget {
solana_sdk::declare_id!("GLrVvDPkQi5PMYUrsYWT9doZhSHr1BVZXqj5DbFps3rS");
}
pub mod rent_for_sysvars {
solana_sdk::declare_id!("BKCPBQQBZqggVnFso5nQ8rQ4RwwogYwjuUt9biBjxwNF");
}
lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@@ -203,6 +207,7 @@ lazy_static! {
(vote_stake_checked_instructions::id(), "vote/state program checked instructions #18345"),
(updated_verify_policy::id(), "Update verify policy"),
(neon_evm_compute_budget::id(), "bump neon_evm's compute budget"),
(rent_for_sysvars::id(), "collect rent from accounts owned by sysvars"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()

View File

@@ -5,7 +5,7 @@ use solana_sdk::{
pubkey::Pubkey,
sysvar::Sysvar,
};
use std::{cell::RefCell, fmt::Debug, rc::Rc, sync::Arc};
use std::{cell::RefCell, collections::HashSet, fmt::Debug, rc::Rc, sync::Arc};
/// Prototype of a native loader entry point
///
@@ -334,6 +334,7 @@ pub struct MockInvokeContext<'a> {
pub programs: Vec<(Pubkey, ProcessInstructionWithContext)>,
pub accounts: Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>,
pub sysvars: Vec<(Pubkey, Option<Rc<Vec<u8>>>)>,
pub disabled_features: HashSet<Pubkey>,
}
impl<'a> MockInvokeContext<'a> {
pub fn new(keyed_accounts: Vec<KeyedAccount<'a>>) -> Self {
@@ -348,6 +349,7 @@ impl<'a> MockInvokeContext<'a> {
programs: vec![],
accounts: vec![],
sysvars: vec![],
disabled_features: HashSet::default(),
};
invoke_context
.invoke_stack
@@ -441,8 +443,8 @@ impl<'a> InvokeContext for MockInvokeContext<'a> {
None
}
fn record_instruction(&self, _instruction: &Instruction) {}
fn is_feature_active(&self, _feature_id: &Pubkey) -> bool {
true
fn is_feature_active(&self, feature_id: &Pubkey) -> bool {
!self.disabled_features.contains(feature_id)
}
fn get_account(&self, pubkey: &Pubkey) -> Option<Rc<RefCell<AccountSharedData>>> {
for (key, account) in self.accounts.iter() {