Remove feature switch for secp256k1 program (#18467)

* Remove feature switch for secp256k1 program

* fix tests
This commit is contained in:
Justin Starry
2021-07-09 10:08:03 -05:00
committed by GitHub
parent 4e1333fbe6
commit fd574dcb3b
10 changed files with 41 additions and 103 deletions

View File

@ -25,7 +25,7 @@ use solana_sdk::{
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::{BankId, Slot, INITIAL_RENT_EPOCH},
feature_set::{self, FeatureSet},
fee_calculator::{FeeCalculator, FeeConfig},
fee_calculator::FeeCalculator,
genesis_config::ClusterType,
hash::Hash,
message::{Message, MessageProgramIdsCache},
@ -420,10 +420,6 @@ impl Accounts {
rent_collector: &RentCollector,
feature_set: &FeatureSet,
) -> Vec<TransactionLoadResult> {
let fee_config = FeeConfig {
secp256k1_program_enabled: feature_set
.is_active(&feature_set::secp256k1_program_enabled::id()),
};
txs.zip(lock_results)
.map(|etx| match etx {
(tx, (Ok(()), nonce_rollback)) => {
@ -436,7 +432,7 @@ impl Accounts {
.cloned()
});
let fee = if let Some(fee_calculator) = fee_calculator {
fee_calculator.calculate_fee_with_config(tx.message(), &fee_config)
fee_calculator.calculate_fee(tx.message())
} else {
return (Err(TransactionError::BlockhashNotFound), None);
};

View File

@ -80,7 +80,7 @@ use solana_sdk::{
epoch_schedule::EpochSchedule,
feature,
feature_set::{self, FeatureSet},
fee_calculator::{FeeCalculator, FeeConfig, FeeRateGovernor},
fee_calculator::{FeeCalculator, FeeRateGovernor},
genesis_config::{ClusterType, GenesisConfig},
hard_forks::HardForks,
hash::{extend_and_hash, hashv, Hash},
@ -3314,10 +3314,6 @@ impl Bank {
let hash_queue = self.blockhash_queue.read().unwrap();
let mut fees = 0;
let fee_config = FeeConfig {
secp256k1_program_enabled: self.secp256k1_program_enabled(),
};
let results = txs
.zip(executed)
.map(|(tx, (res, nonce_rollback))| {
@ -3335,7 +3331,7 @@ impl Bank {
});
let fee_calculator = fee_calculator.ok_or(TransactionError::BlockhashNotFound)?;
let fee = fee_calculator.calculate_fee_with_config(tx.message(), &fee_config);
let fee = fee_calculator.calculate_fee(tx.message());
let message = tx.message();
match *res {
@ -5013,11 +5009,6 @@ impl Bank {
self.rc.accounts.accounts_db.shrink_candidate_slots()
}
pub fn secp256k1_program_enabled(&self) -> bool {
self.feature_set
.is_active(&feature_set::secp256k1_program_enabled::id())
}
pub fn no_overflow_rent_distribution_enabled(&self) -> bool {
self.feature_set
.is_active(&feature_set::no_overflow_rent_distribution::id())
@ -5593,7 +5584,7 @@ pub(crate) mod tests {
cluster_type: ClusterType::MainnetBeta,
..GenesisConfig::default()
}));
let sysvar_and_native_proram_delta0 = 10;
let sysvar_and_native_proram_delta0 = 11;
assert_eq!(
bank0.capitalization(),
42 * 42 + sysvar_and_native_proram_delta0
@ -7275,10 +7266,10 @@ pub(crate) mod tests {
// not being eagerly-collected for exact rewards calculation
bank0.restore_old_behavior_for_fragile_tests();
let sysvar_and_native_proram_delta0 = 10;
let sysvar_and_native_program_delta0 = 11;
assert_eq!(
bank0.capitalization(),
42 * 1_000_000_000 + sysvar_and_native_proram_delta0
42 * 1_000_000_000 + sysvar_and_native_program_delta0
);
assert!(bank0.rewards.read().unwrap().is_empty());
@ -7397,7 +7388,7 @@ pub(crate) mod tests {
// not being eagerly-collected for exact rewards calculation
bank.restore_old_behavior_for_fragile_tests();
let sysvar_and_native_proram_delta = 10;
let sysvar_and_native_proram_delta = 11;
assert_eq!(
bank.capitalization(),
42 * 1_000_000_000 + sysvar_and_native_proram_delta
@ -10625,25 +10616,25 @@ pub(crate) mod tests {
if bank.slot == 0 {
assert_eq!(
bank.hash().to_string(),
"Cn7Wmi7w1n9NbK7RGnTQ4LpbJ2LtoJoc1sufiTwb57Ya"
"BfvaoHkrQwrkQo7T1mW6jmJXveRy11rut8bva2H1Rt5H"
);
}
if bank.slot == 32 {
assert_eq!(
bank.hash().to_string(),
"BXupB8XsZukMTnDbKshJ8qPCydWnc8BKtSj7YTJ6gAH"
"JBGPApnSMPKZaYiR16v46XSSGcKxy8kCbVtN1CG1XDxW"
);
}
if bank.slot == 64 {
assert_eq!(
bank.hash().to_string(),
"EDkKefgSMSV1NhxnGnJP7R5AGZ2JZD6oxnoZtGuEGBCU"
"BDCt9cGPfxpgJXzp8Tq1nX1zSqpbs8xrkAFyRhmXKiuX"
);
}
if bank.slot == 128 {
assert_eq!(
bank.hash().to_string(),
"AtWu4tubU9zGFChfHtQghQx3RVWtMQu6Rj49rQymFc4z"
"4zUpK4VUhKLaPUgeMMSeDR2w827goriRL5NndJxGDVmz"
);
break;
}
@ -10793,7 +10784,7 @@ pub(crate) mod tests {
// No more slots should be shrunk
assert_eq!(bank2.shrink_candidate_slots(), 0);
// alive_counts represents the count of alive accounts in the three slots 0,1,2
assert_eq!(alive_counts, vec![9, 1, 7]);
assert_eq!(alive_counts, vec![10, 1, 7]);
}
#[test]
@ -10841,7 +10832,7 @@ pub(crate) mod tests {
.map(|_| bank.process_stale_slot_with_budget(0, force_to_return_alive_account))
.sum();
// consumed_budgets represents the count of alive accounts in the three slots 0,1,2
assert_eq!(consumed_budgets, 10);
assert_eq!(consumed_budgets, 11);
}
#[test]

View File

@ -3,7 +3,6 @@ use crate::{
system_instruction_processor,
};
use solana_sdk::{
feature_set,
instruction::InstructionError,
process_instruction::{stable_log, InvokeContext, ProcessInstructionWithContext},
pubkey::Pubkey,
@ -64,6 +63,11 @@ fn genesis_builtins() -> Vec<Builtin> {
solana_config_program::id(),
with_program_logging!(solana_config_program::config_processor::process_instruction),
),
Builtin::new(
"secp256k1_program",
solana_sdk::secp256k1_program::id(),
solana_secp256k1_program::process_instruction,
),
]
}
@ -82,15 +86,7 @@ pub enum ActivationType {
/// normal child Bank creation.
/// https://github.com/solana-labs/solana/blob/84b139cc94b5be7c9e0c18c2ad91743231b85a0d/runtime/src/bank.rs#L1723
fn feature_builtins() -> Vec<(Builtin, Pubkey, ActivationType)> {
vec![(
Builtin::new(
"secp256k1_program",
solana_sdk::secp256k1_program::id(),
solana_secp256k1_program::process_instruction,
),
feature_set::secp256k1_program_enabled::id(),
ActivationType::NewProgram,
)]
vec![]
}
pub(crate) fn get() -> Builtins {

View File

@ -273,7 +273,7 @@ mod tests {
..GenesisConfig::default()
};
let mut bank = Arc::new(Bank::new(&genesis_config));
let sysvar_and_native_program_delta = 10;
let sysvar_and_native_program_delta = 11;
assert_eq!(
bank.capitalization(),
(num_genesis_accounts + num_non_circulating_accounts + num_stake_accounts) * balance