Fix ed25519 builtin program handling (#23182)

* Fix ed25519 builtin program handling

* Fix tests

* Add integration tests for processing transactions with ed25519 ixs

* Fix another test

* fix formatting
This commit is contained in:
Justin Starry
2022-02-17 02:48:55 +08:00
committed by GitHub
parent de30699fa5
commit 813725dfec
9 changed files with 177 additions and 13 deletions

View File

@ -25,6 +25,7 @@ use {
account_info::AccountInfo,
clock::Slot,
entrypoint::{ProgramResult, SUCCESS},
feature_set::FEATURE_NAMES,
fee_calculator::{FeeCalculator, FeeRateGovernor},
genesis_config::{ClusterType, GenesisConfig},
hash::Hash,
@ -57,7 +58,10 @@ use {
tokio::task::JoinHandle,
};
// Export types so test clients can limit their solana crate dependencies
pub use {solana_banks_client::BanksClient, solana_program_runtime::invoke_context::InvokeContext};
pub use {
solana_banks_client::{BanksClient, BanksClientError},
solana_program_runtime::invoke_context::InvokeContext,
};
pub mod programs;
@ -456,6 +460,7 @@ pub struct ProgramTest {
compute_max_units: Option<u64>,
prefer_bpf: bool,
use_bpf_jit: bool,
deactivate_feature_set: HashSet<Pubkey>,
}
impl Default for ProgramTest {
@ -486,6 +491,7 @@ impl Default for ProgramTest {
compute_max_units: None,
prefer_bpf,
use_bpf_jit: false,
deactivate_feature_set: HashSet::default(),
}
}
}
@ -715,6 +721,13 @@ impl ProgramTest {
.push(Builtin::new(program_name, program_id, process_instruction));
}
/// Deactivate a runtime feature.
///
/// Note that all features are activated by default.
pub fn deactivate_feature(&mut self, feature_id: Pubkey) {
self.deactivate_feature_set.insert(feature_id);
}
fn setup_bank(
&self,
) -> (
@ -754,6 +767,25 @@ impl ProgramTest {
ClusterType::Development,
vec![],
);
// Remove features tagged to deactivate
for deactivate_feature_pk in &self.deactivate_feature_set {
if FEATURE_NAMES.contains_key(deactivate_feature_pk) {
match genesis_config.accounts.remove(deactivate_feature_pk) {
Some(_) => debug!("Feature for {:?} deactivated", deactivate_feature_pk),
None => warn!(
"Feature {:?} set for deactivation not found in genesis_config account list, ignored.",
deactivate_feature_pk
),
}
} else {
warn!(
"Feature {:?} set for deactivation is not a known Feature public key",
deactivate_feature_pk
);
}
}
let target_tick_duration = Duration::from_micros(100);
genesis_config.poh_config = PohConfig::new_sleep(target_tick_duration);
debug!("Payer address: {}", mint_keypair.pubkey());