Remove feature switch for secp256k1 program (#18467)
* Remove feature switch for secp256k1 program * fix tests
This commit is contained in:
parent
4e1333fbe6
commit
fd574dcb3b
@ -1058,7 +1058,6 @@ impl BankingStage {
|
|||||||
fn transactions_from_packets(
|
fn transactions_from_packets(
|
||||||
msgs: &Packets,
|
msgs: &Packets,
|
||||||
transaction_indexes: &[usize],
|
transaction_indexes: &[usize],
|
||||||
secp256k1_program_enabled: bool,
|
|
||||||
cost_tracker: &Arc<RwLock<CostTracker>>,
|
cost_tracker: &Arc<RwLock<CostTracker>>,
|
||||||
banking_stage_stats: &BankingStageStats,
|
banking_stage_stats: &BankingStageStats,
|
||||||
) -> (Vec<HashedTransaction<'static>>, Vec<usize>, Vec<usize>) {
|
) -> (Vec<HashedTransaction<'static>>, Vec<usize>, Vec<usize>) {
|
||||||
@ -1069,9 +1068,7 @@ impl BankingStage {
|
|||||||
.filter_map(|tx_index| {
|
.filter_map(|tx_index| {
|
||||||
let p = &msgs.packets[*tx_index];
|
let p = &msgs.packets[*tx_index];
|
||||||
let tx: Transaction = limited_deserialize(&p.data[0..p.meta.size]).ok()?;
|
let tx: Transaction = limited_deserialize(&p.data[0..p.meta.size]).ok()?;
|
||||||
if secp256k1_program_enabled {
|
tx.verify_precompiles().ok()?;
|
||||||
tx.verify_precompiles().ok()?;
|
|
||||||
}
|
|
||||||
Some((tx, *tx_index))
|
Some((tx, *tx_index))
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
@ -1179,7 +1176,6 @@ impl BankingStage {
|
|||||||
Self::transactions_from_packets(
|
Self::transactions_from_packets(
|
||||||
msgs,
|
msgs,
|
||||||
&packet_indexes,
|
&packet_indexes,
|
||||||
bank.secp256k1_program_enabled(),
|
|
||||||
cost_tracker,
|
cost_tracker,
|
||||||
banking_stage_stats,
|
banking_stage_stats,
|
||||||
);
|
);
|
||||||
@ -1284,7 +1280,6 @@ impl BankingStage {
|
|||||||
Self::transactions_from_packets(
|
Self::transactions_from_packets(
|
||||||
msgs,
|
msgs,
|
||||||
transaction_indexes,
|
transaction_indexes,
|
||||||
bank.secp256k1_program_enabled(),
|
|
||||||
cost_tracker,
|
cost_tracker,
|
||||||
banking_stage_stats,
|
banking_stage_stats,
|
||||||
);
|
);
|
||||||
|
@ -2385,13 +2385,13 @@ fn main() {
|
|||||||
let mut store_failed_count = 0;
|
let mut store_failed_count = 0;
|
||||||
if force_enabled_count >= 1 {
|
if force_enabled_count >= 1 {
|
||||||
if base_bank
|
if base_bank
|
||||||
.get_account(&feature_set::secp256k1_program_enabled::id())
|
.get_account(&feature_set::spl_token_v2_multisig_fix::id())
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
// steal some lamports from the pretty old feature not to affect
|
// steal some lamports from the pretty old feature not to affect
|
||||||
// capitalizaion, which doesn't affect inflation behavior!
|
// capitalizaion, which doesn't affect inflation behavior!
|
||||||
base_bank.store_account(
|
base_bank.store_account(
|
||||||
&feature_set::secp256k1_program_enabled::id(),
|
&feature_set::spl_token_v2_multisig_fix::id(),
|
||||||
&AccountSharedData::default(),
|
&AccountSharedData::default(),
|
||||||
);
|
);
|
||||||
force_enabled_count -= 1;
|
force_enabled_count -= 1;
|
||||||
|
@ -791,11 +791,8 @@ pub fn confirm_slot(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let check_start = Instant::now();
|
let check_start = Instant::now();
|
||||||
let check_result = entries.verify_and_hash_transactions(
|
let check_result = entries
|
||||||
skip_verification,
|
.verify_and_hash_transactions(skip_verification, bank.verify_tx_signatures_len_enabled());
|
||||||
bank.secp256k1_program_enabled(),
|
|
||||||
bank.verify_tx_signatures_len_enabled(),
|
|
||||||
);
|
|
||||||
if check_result.is_none() {
|
if check_result.is_none() {
|
||||||
warn!("Ledger proof of history failed at slot: {}", slot);
|
warn!("Ledger proof of history failed at slot: {}", slot);
|
||||||
return Err(BlockError::InvalidEntryHash.into());
|
return Err(BlockError::InvalidEntryHash.into());
|
||||||
|
@ -359,7 +359,6 @@ pub trait EntrySlice {
|
|||||||
fn verify_and_hash_transactions(
|
fn verify_and_hash_transactions(
|
||||||
&self,
|
&self,
|
||||||
skip_verification: bool,
|
skip_verification: bool,
|
||||||
secp256k1_program_enabled: bool,
|
|
||||||
verify_tx_signatures_len: bool,
|
verify_tx_signatures_len: bool,
|
||||||
) -> Option<Vec<EntryType<'_>>>;
|
) -> Option<Vec<EntryType<'_>>>;
|
||||||
}
|
}
|
||||||
@ -515,7 +514,6 @@ impl EntrySlice for [Entry] {
|
|||||||
fn verify_and_hash_transactions<'a>(
|
fn verify_and_hash_transactions<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
skip_verification: bool,
|
skip_verification: bool,
|
||||||
secp256k1_program_enabled: bool,
|
|
||||||
verify_tx_signatures_len: bool,
|
verify_tx_signatures_len: bool,
|
||||||
) -> Option<Vec<EntryType<'a>>> {
|
) -> Option<Vec<EntryType<'a>>> {
|
||||||
let verify_and_hash = |tx: &'a Transaction| -> Option<HashedTransaction<'a>> {
|
let verify_and_hash = |tx: &'a Transaction| -> Option<HashedTransaction<'a>> {
|
||||||
@ -524,10 +522,7 @@ impl EntrySlice for [Entry] {
|
|||||||
if size > PACKET_DATA_SIZE as u64 {
|
if size > PACKET_DATA_SIZE as u64 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if secp256k1_program_enabled {
|
tx.verify_precompiles().ok()?;
|
||||||
// Verify tx precompiles if secp256k1 program is enabled.
|
|
||||||
tx.verify_precompiles().ok()?;
|
|
||||||
}
|
|
||||||
if verify_tx_signatures_len && !tx.verify_signatures_len() {
|
if verify_tx_signatures_len && !tx.verify_signatures_len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -927,10 +922,10 @@ mod tests {
|
|||||||
let tx = make_transaction(TestCase::RemoveSignature);
|
let tx = make_transaction(TestCase::RemoveSignature);
|
||||||
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx])];
|
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx])];
|
||||||
assert!(entries[..]
|
assert!(entries[..]
|
||||||
.verify_and_hash_transactions(false, false, false)
|
.verify_and_hash_transactions(false, false)
|
||||||
.is_some());
|
.is_some());
|
||||||
assert!(entries[..]
|
assert!(entries[..]
|
||||||
.verify_and_hash_transactions(false, false, true)
|
.verify_and_hash_transactions(false, true)
|
||||||
.is_none());
|
.is_none());
|
||||||
}
|
}
|
||||||
// Too many signatures.
|
// Too many signatures.
|
||||||
@ -938,10 +933,10 @@ mod tests {
|
|||||||
let tx = make_transaction(TestCase::AddSignature);
|
let tx = make_transaction(TestCase::AddSignature);
|
||||||
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx])];
|
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx])];
|
||||||
assert!(entries[..]
|
assert!(entries[..]
|
||||||
.verify_and_hash_transactions(false, false, false)
|
.verify_and_hash_transactions(false, false)
|
||||||
.is_some());
|
.is_some());
|
||||||
assert!(entries[..]
|
assert!(entries[..]
|
||||||
.verify_and_hash_transactions(false, false, true)
|
.verify_and_hash_transactions(false, true)
|
||||||
.is_none());
|
.is_none());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -967,7 +962,7 @@ mod tests {
|
|||||||
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx.clone()])];
|
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx.clone()])];
|
||||||
assert!(bincode::serialized_size(&tx).unwrap() <= PACKET_DATA_SIZE as u64);
|
assert!(bincode::serialized_size(&tx).unwrap() <= PACKET_DATA_SIZE as u64);
|
||||||
assert!(entries[..]
|
assert!(entries[..]
|
||||||
.verify_and_hash_transactions(false, false, false)
|
.verify_and_hash_transactions(false, false)
|
||||||
.is_some());
|
.is_some());
|
||||||
}
|
}
|
||||||
// Big transaction.
|
// Big transaction.
|
||||||
@ -976,7 +971,7 @@ mod tests {
|
|||||||
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx.clone()])];
|
let entries = vec![next_entry(&recent_blockhash, 1, vec![tx.clone()])];
|
||||||
assert!(bincode::serialized_size(&tx).unwrap() > PACKET_DATA_SIZE as u64);
|
assert!(bincode::serialized_size(&tx).unwrap() > PACKET_DATA_SIZE as u64);
|
||||||
assert!(entries[..]
|
assert!(entries[..]
|
||||||
.verify_and_hash_transactions(false, false, false)
|
.verify_and_hash_transactions(false, false)
|
||||||
.is_none());
|
.is_none());
|
||||||
}
|
}
|
||||||
// Assert that verify fails as soon as serialized
|
// Assert that verify fails as soon as serialized
|
||||||
@ -987,7 +982,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
bincode::serialized_size(&tx).unwrap() <= PACKET_DATA_SIZE as u64,
|
bincode::serialized_size(&tx).unwrap() <= PACKET_DATA_SIZE as u64,
|
||||||
entries[..]
|
entries[..]
|
||||||
.verify_and_hash_transactions(false, false, false)
|
.verify_and_hash_transactions(false, false)
|
||||||
.is_some(),
|
.is_some(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ use solana_sdk::{
|
|||||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||||
clock::{BankId, Slot, INITIAL_RENT_EPOCH},
|
clock::{BankId, Slot, INITIAL_RENT_EPOCH},
|
||||||
feature_set::{self, FeatureSet},
|
feature_set::{self, FeatureSet},
|
||||||
fee_calculator::{FeeCalculator, FeeConfig},
|
fee_calculator::FeeCalculator,
|
||||||
genesis_config::ClusterType,
|
genesis_config::ClusterType,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
message::{Message, MessageProgramIdsCache},
|
message::{Message, MessageProgramIdsCache},
|
||||||
@ -420,10 +420,6 @@ impl Accounts {
|
|||||||
rent_collector: &RentCollector,
|
rent_collector: &RentCollector,
|
||||||
feature_set: &FeatureSet,
|
feature_set: &FeatureSet,
|
||||||
) -> Vec<TransactionLoadResult> {
|
) -> Vec<TransactionLoadResult> {
|
||||||
let fee_config = FeeConfig {
|
|
||||||
secp256k1_program_enabled: feature_set
|
|
||||||
.is_active(&feature_set::secp256k1_program_enabled::id()),
|
|
||||||
};
|
|
||||||
txs.zip(lock_results)
|
txs.zip(lock_results)
|
||||||
.map(|etx| match etx {
|
.map(|etx| match etx {
|
||||||
(tx, (Ok(()), nonce_rollback)) => {
|
(tx, (Ok(()), nonce_rollback)) => {
|
||||||
@ -436,7 +432,7 @@ impl Accounts {
|
|||||||
.cloned()
|
.cloned()
|
||||||
});
|
});
|
||||||
let fee = if let Some(fee_calculator) = fee_calculator {
|
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 {
|
} else {
|
||||||
return (Err(TransactionError::BlockhashNotFound), None);
|
return (Err(TransactionError::BlockhashNotFound), None);
|
||||||
};
|
};
|
||||||
|
@ -80,7 +80,7 @@ use solana_sdk::{
|
|||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
feature,
|
feature,
|
||||||
feature_set::{self, FeatureSet},
|
feature_set::{self, FeatureSet},
|
||||||
fee_calculator::{FeeCalculator, FeeConfig, FeeRateGovernor},
|
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||||
genesis_config::{ClusterType, GenesisConfig},
|
genesis_config::{ClusterType, GenesisConfig},
|
||||||
hard_forks::HardForks,
|
hard_forks::HardForks,
|
||||||
hash::{extend_and_hash, hashv, Hash},
|
hash::{extend_and_hash, hashv, Hash},
|
||||||
@ -3314,10 +3314,6 @@ impl Bank {
|
|||||||
let hash_queue = self.blockhash_queue.read().unwrap();
|
let hash_queue = self.blockhash_queue.read().unwrap();
|
||||||
let mut fees = 0;
|
let mut fees = 0;
|
||||||
|
|
||||||
let fee_config = FeeConfig {
|
|
||||||
secp256k1_program_enabled: self.secp256k1_program_enabled(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let results = txs
|
let results = txs
|
||||||
.zip(executed)
|
.zip(executed)
|
||||||
.map(|(tx, (res, nonce_rollback))| {
|
.map(|(tx, (res, nonce_rollback))| {
|
||||||
@ -3335,7 +3331,7 @@ impl Bank {
|
|||||||
});
|
});
|
||||||
let fee_calculator = fee_calculator.ok_or(TransactionError::BlockhashNotFound)?;
|
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();
|
let message = tx.message();
|
||||||
match *res {
|
match *res {
|
||||||
@ -5013,11 +5009,6 @@ impl Bank {
|
|||||||
self.rc.accounts.accounts_db.shrink_candidate_slots()
|
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 {
|
pub fn no_overflow_rent_distribution_enabled(&self) -> bool {
|
||||||
self.feature_set
|
self.feature_set
|
||||||
.is_active(&feature_set::no_overflow_rent_distribution::id())
|
.is_active(&feature_set::no_overflow_rent_distribution::id())
|
||||||
@ -5593,7 +5584,7 @@ pub(crate) mod tests {
|
|||||||
cluster_type: ClusterType::MainnetBeta,
|
cluster_type: ClusterType::MainnetBeta,
|
||||||
..GenesisConfig::default()
|
..GenesisConfig::default()
|
||||||
}));
|
}));
|
||||||
let sysvar_and_native_proram_delta0 = 10;
|
let sysvar_and_native_proram_delta0 = 11;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank0.capitalization(),
|
bank0.capitalization(),
|
||||||
42 * 42 + sysvar_and_native_proram_delta0
|
42 * 42 + sysvar_and_native_proram_delta0
|
||||||
@ -7275,10 +7266,10 @@ pub(crate) mod tests {
|
|||||||
// not being eagerly-collected for exact rewards calculation
|
// not being eagerly-collected for exact rewards calculation
|
||||||
bank0.restore_old_behavior_for_fragile_tests();
|
bank0.restore_old_behavior_for_fragile_tests();
|
||||||
|
|
||||||
let sysvar_and_native_proram_delta0 = 10;
|
let sysvar_and_native_program_delta0 = 11;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank0.capitalization(),
|
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());
|
assert!(bank0.rewards.read().unwrap().is_empty());
|
||||||
|
|
||||||
@ -7397,7 +7388,7 @@ pub(crate) mod tests {
|
|||||||
// not being eagerly-collected for exact rewards calculation
|
// not being eagerly-collected for exact rewards calculation
|
||||||
bank.restore_old_behavior_for_fragile_tests();
|
bank.restore_old_behavior_for_fragile_tests();
|
||||||
|
|
||||||
let sysvar_and_native_proram_delta = 10;
|
let sysvar_and_native_proram_delta = 11;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.capitalization(),
|
bank.capitalization(),
|
||||||
42 * 1_000_000_000 + sysvar_and_native_proram_delta
|
42 * 1_000_000_000 + sysvar_and_native_proram_delta
|
||||||
@ -10625,25 +10616,25 @@ pub(crate) mod tests {
|
|||||||
if bank.slot == 0 {
|
if bank.slot == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.hash().to_string(),
|
bank.hash().to_string(),
|
||||||
"Cn7Wmi7w1n9NbK7RGnTQ4LpbJ2LtoJoc1sufiTwb57Ya"
|
"BfvaoHkrQwrkQo7T1mW6jmJXveRy11rut8bva2H1Rt5H"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if bank.slot == 32 {
|
if bank.slot == 32 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.hash().to_string(),
|
bank.hash().to_string(),
|
||||||
"BXupB8XsZukMTnDbKshJ8qPCydWnc8BKtSj7YTJ6gAH"
|
"JBGPApnSMPKZaYiR16v46XSSGcKxy8kCbVtN1CG1XDxW"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if bank.slot == 64 {
|
if bank.slot == 64 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.hash().to_string(),
|
bank.hash().to_string(),
|
||||||
"EDkKefgSMSV1NhxnGnJP7R5AGZ2JZD6oxnoZtGuEGBCU"
|
"BDCt9cGPfxpgJXzp8Tq1nX1zSqpbs8xrkAFyRhmXKiuX"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if bank.slot == 128 {
|
if bank.slot == 128 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.hash().to_string(),
|
bank.hash().to_string(),
|
||||||
"AtWu4tubU9zGFChfHtQghQx3RVWtMQu6Rj49rQymFc4z"
|
"4zUpK4VUhKLaPUgeMMSeDR2w827goriRL5NndJxGDVmz"
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -10793,7 +10784,7 @@ pub(crate) mod tests {
|
|||||||
// No more slots should be shrunk
|
// No more slots should be shrunk
|
||||||
assert_eq!(bank2.shrink_candidate_slots(), 0);
|
assert_eq!(bank2.shrink_candidate_slots(), 0);
|
||||||
// alive_counts represents the count of alive accounts in the three slots 0,1,2
|
// 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]
|
#[test]
|
||||||
@ -10841,7 +10832,7 @@ pub(crate) mod tests {
|
|||||||
.map(|_| bank.process_stale_slot_with_budget(0, force_to_return_alive_account))
|
.map(|_| bank.process_stale_slot_with_budget(0, force_to_return_alive_account))
|
||||||
.sum();
|
.sum();
|
||||||
// consumed_budgets represents the count of alive accounts in the three slots 0,1,2
|
// 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]
|
#[test]
|
||||||
|
@ -3,7 +3,6 @@ use crate::{
|
|||||||
system_instruction_processor,
|
system_instruction_processor,
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
feature_set,
|
|
||||||
instruction::InstructionError,
|
instruction::InstructionError,
|
||||||
process_instruction::{stable_log, InvokeContext, ProcessInstructionWithContext},
|
process_instruction::{stable_log, InvokeContext, ProcessInstructionWithContext},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
@ -64,6 +63,11 @@ fn genesis_builtins() -> Vec<Builtin> {
|
|||||||
solana_config_program::id(),
|
solana_config_program::id(),
|
||||||
with_program_logging!(solana_config_program::config_processor::process_instruction),
|
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.
|
/// normal child Bank creation.
|
||||||
/// https://github.com/solana-labs/solana/blob/84b139cc94b5be7c9e0c18c2ad91743231b85a0d/runtime/src/bank.rs#L1723
|
/// https://github.com/solana-labs/solana/blob/84b139cc94b5be7c9e0c18c2ad91743231b85a0d/runtime/src/bank.rs#L1723
|
||||||
fn feature_builtins() -> Vec<(Builtin, Pubkey, ActivationType)> {
|
fn feature_builtins() -> Vec<(Builtin, Pubkey, ActivationType)> {
|
||||||
vec![(
|
vec![]
|
||||||
Builtin::new(
|
|
||||||
"secp256k1_program",
|
|
||||||
solana_sdk::secp256k1_program::id(),
|
|
||||||
solana_secp256k1_program::process_instruction,
|
|
||||||
),
|
|
||||||
feature_set::secp256k1_program_enabled::id(),
|
|
||||||
ActivationType::NewProgram,
|
|
||||||
)]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get() -> Builtins {
|
pub(crate) fn get() -> Builtins {
|
||||||
|
@ -273,7 +273,7 @@ mod tests {
|
|||||||
..GenesisConfig::default()
|
..GenesisConfig::default()
|
||||||
};
|
};
|
||||||
let mut bank = Arc::new(Bank::new(&genesis_config));
|
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!(
|
assert_eq!(
|
||||||
bank.capitalization(),
|
bank.capitalization(),
|
||||||
(num_genesis_accounts + num_non_circulating_accounts + num_stake_accounts) * balance
|
(num_genesis_accounts + num_non_circulating_accounts + num_stake_accounts) * balance
|
||||||
|
@ -20,18 +20,6 @@ impl Default for FeeCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FeeConfig {
|
|
||||||
pub secp256k1_program_enabled: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for FeeConfig {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
secp256k1_program_enabled: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FeeCalculator {
|
impl FeeCalculator {
|
||||||
pub fn new(lamports_per_signature: u64) -> Self {
|
pub fn new(lamports_per_signature: u64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -40,20 +28,14 @@ impl FeeCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn calculate_fee(&self, message: &Message) -> u64 {
|
pub fn calculate_fee(&self, message: &Message) -> u64 {
|
||||||
self.calculate_fee_with_config(message, &FeeConfig::default())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn calculate_fee_with_config(&self, message: &Message, fee_config: &FeeConfig) -> u64 {
|
|
||||||
let mut num_secp256k1_signatures: u64 = 0;
|
let mut num_secp256k1_signatures: u64 = 0;
|
||||||
if fee_config.secp256k1_program_enabled {
|
for instruction in &message.instructions {
|
||||||
for instruction in &message.instructions {
|
let program_index = instruction.program_id_index as usize;
|
||||||
let program_index = instruction.program_id_index as usize;
|
// Transaction may not be sanitized here
|
||||||
// Transaction may not be sanitized here
|
if program_index < message.account_keys.len() {
|
||||||
if program_index < message.account_keys.len() {
|
let id = message.account_keys[program_index];
|
||||||
let id = message.account_keys[program_index];
|
if secp256k1_program::check_id(&id) && !instruction.data.is_empty() {
|
||||||
if secp256k1_program::check_id(&id) && !instruction.data.is_empty() {
|
num_secp256k1_signatures += instruction.data[0] as u64;
|
||||||
num_secp256k1_signatures += instruction.data[0] as u64;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,15 +241,6 @@ mod tests {
|
|||||||
Some(&pubkey0),
|
Some(&pubkey0),
|
||||||
);
|
);
|
||||||
assert_eq!(FeeCalculator::new(1).calculate_fee(&message), 2);
|
assert_eq!(FeeCalculator::new(1).calculate_fee(&message), 2);
|
||||||
assert_eq!(
|
|
||||||
FeeCalculator::new(1).calculate_fee_with_config(
|
|
||||||
&message,
|
|
||||||
&FeeConfig {
|
|
||||||
secp256k1_program_enabled: false
|
|
||||||
}
|
|
||||||
),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
secp_instruction.data = vec![0];
|
secp_instruction.data = vec![0];
|
||||||
secp_instruction2.data = vec![10];
|
secp_instruction2.data = vec![10];
|
||||||
|
@ -10,10 +10,6 @@ pub mod instructions_sysvar_enabled {
|
|||||||
solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs");
|
solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod secp256k1_program_enabled {
|
|
||||||
solana_sdk::declare_id!("E3PHP7w8kB7np3CTQ1qQ2tW3KCtjRSXBQgW9vM2mWv2Y");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod consistent_recent_blockhashes_sysvar {
|
pub mod consistent_recent_blockhashes_sysvar {
|
||||||
solana_sdk::declare_id!("3h1BQWPDS5veRsq6mDBWruEpgPxRJkfwGexg5iiQ9mYg");
|
solana_sdk::declare_id!("3h1BQWPDS5veRsq6mDBWruEpgPxRJkfwGexg5iiQ9mYg");
|
||||||
}
|
}
|
||||||
@ -171,7 +167,6 @@ lazy_static! {
|
|||||||
/// Map of feature identifiers to user-visible description
|
/// Map of feature identifiers to user-visible description
|
||||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||||
(instructions_sysvar_enabled::id(), "instructions sysvar"),
|
(instructions_sysvar_enabled::id(), "instructions sysvar"),
|
||||||
(secp256k1_program_enabled::id(), "secp256k1 program"),
|
|
||||||
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
|
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
|
||||||
(deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"),
|
(deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"),
|
||||||
(pico_inflation::id(), "pico inflation"),
|
(pico_inflation::id(), "pico inflation"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user