Port BPFLoader2 activation to FeatureSet and rework built-in program activation

This commit is contained in:
Michael Vines
2020-09-24 12:23:09 -07:00
parent 6071d0d206
commit 31696a1d72
26 changed files with 251 additions and 703 deletions

44
core/src/builtins.rs Normal file
View File

@ -0,0 +1,44 @@
use solana_runtime::{
bank::{Builtin, Builtins, Entrypoint},
feature_set,
};
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
/// Builtin programs that are always available
fn genesis_builtins(cluster_type: ClusterType) -> Vec<Builtin> {
let builtins = if cluster_type != ClusterType::MainnetBeta {
vec![
solana_bpf_loader_deprecated_program!(),
solana_bpf_loader_program!(),
]
} else {
// Remove this `else` block and the `cluster_type` argument to this function once
// `feature_set::bpf_loader2_program::id()` is active on Mainnet Beta
vec![solana_bpf_loader_deprecated_program!()]
};
builtins
.into_iter()
.map(|b| Builtin::new(&b.0, b.1, Entrypoint::Loader(b.2)))
.collect()
}
/// Builtin programs activated dynamically by feature
fn feature_builtins() -> Vec<(Builtin, Pubkey)> {
let builtins = vec![(
solana_bpf_loader_program!(),
feature_set::bpf_loader2_program::id(),
)];
builtins
.into_iter()
.map(|(b, p)| (Builtin::new(&b.0, b.1, Entrypoint::Loader(b.2)), p))
.collect()
}
pub(crate) fn get(cluster_type: ClusterType) -> Builtins {
Builtins {
genesis_builtins: genesis_builtins(cluster_type),
feature_builtins: feature_builtins(),
}
}

View File

@ -6,11 +6,15 @@
//! command-line tools to spin up validators and a Rust library
//!
#[macro_use]
extern crate solana_bpf_loader_program;
pub mod accounts_background_service;
pub mod accounts_hash_verifier;
pub mod banking_stage;
pub mod bigtable_upload_service;
pub mod broadcast_stage;
mod builtins;
pub mod cache_block_time_service;
pub mod cluster_info_vote_listener;
pub mod commitment_service;

View File

@ -69,6 +69,7 @@ impl TestValidator {
&Pubkey::new_rand(),
42,
bootstrap_validator_lamports,
solana_sdk::genesis_config::ClusterType::Development,
);
genesis_config.rent.lamports_per_byte_year = 1;
genesis_config.rent.exemption_threshold = 1.0;

View File

@ -2,6 +2,7 @@
use crate::{
broadcast_stage::BroadcastStageType,
builtins,
cache_block_time_service::{CacheBlockTimeSender, CacheBlockTimeService},
cluster_info::{ClusterInfo, Node},
cluster_info_vote_listener::VoteTracker,
@ -791,6 +792,7 @@ fn new_banks_from_ledger(
new_hard_forks: config.new_hard_forks.clone(),
frozen_accounts: config.frozen_accounts.clone(),
debug_keys: config.debug_keys.clone(),
additional_builtins: Some(builtins::get(genesis_config.cluster_type)),
..blockstore_processor::ProcessOptions::default()
};