Skip to content

Commit

Permalink
Bumps solana_rbpf to v0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Nov 28, 2024
1 parent dc57128 commit 2c0e201
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 38 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ solana-zk-keygen = { path = "zk-keygen", version = "=2.2.0" }
solana-zk-sdk = { path = "zk-sdk", version = "=2.2.0" }
solana-zk-token-proof-program = { path = "programs/zk-token-proof", version = "=2.2.0" }
solana-zk-token-sdk = { path = "zk-token-sdk", version = "=2.2.0" }
solana_rbpf = "=0.8.5"
solana_rbpf = { git = "https://github.com/solana-labs/rbpf.git" }
spl-associated-token-account = "=6.0.0"
spl-instruction-padding = "0.3"
spl-memo = "=6.0.0"
Expand Down
6 changes: 3 additions & 3 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl<'a> InvokeContext<'a> {
.ok_or(InstructionError::UnsupportedProgramId)?;
let function = match &entry.program {
ProgramCacheEntryType::Builtin(program) => program
.get_function_registry()
.get_function_registry(SBPFVersion::V0)
.lookup_by_key(ENTRYPOINT_KEY)
.map(|(_name, function)| function),
_ => None,
Expand All @@ -560,13 +560,13 @@ impl<'a> InvokeContext<'a> {
// For now, only built-ins are invoked from here, so the VM and its Config are irrelevant.
let mock_config = Config::default();
let empty_memory_mapping =
MemoryMapping::new(Vec::new(), &mock_config, &SBPFVersion::V1).unwrap();
MemoryMapping::new(Vec::new(), &mock_config, SBPFVersion::V1).unwrap();
let mut vm = EbpfVm::new(
self.program_cache_for_tx_batch
.environments
.program_runtime_v2
.clone(),
&SBPFVersion::V1,
SBPFVersion::V0,
// Removes lifetime tracking
unsafe { std::mem::transmute::<&mut InvokeContext, &mut InvokeContext>(self) },
empty_memory_mapping,
Expand Down
45 changes: 29 additions & 16 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ use {
solana_feature_set::{
self as feature_set, abort_on_invalid_curve, blake3_syscall_enabled,
bpf_account_data_direct_mapping, curve25519_syscall_enabled,
disable_deploy_of_alloc_free_syscall, disable_fees_sysvar, disable_sbpf_v1_execution,
disable_deploy_of_alloc_free_syscall, disable_fees_sysvar, disable_sbpf_v0_execution,
enable_alt_bn128_compression_syscall, enable_alt_bn128_syscall, enable_big_mod_exp_syscall,
enable_get_epoch_stake_syscall, enable_partitioned_epoch_reward, enable_poseidon_syscall,
get_sysvar_syscall_enabled, last_restart_slot_sysvar,
partitioned_epoch_rewards_superfeature, reenable_sbpf_v1_execution,
remaining_compute_units_syscall_enabled, FeatureSet,
enable_sbpf_v1_deployment_and_execution, enable_sbpf_v2_deployment_and_execution,
enable_sbpf_v3_deployment_and_execution, get_sysvar_syscall_enabled,
last_restart_slot_sysvar, partitioned_epoch_rewards_superfeature,
reenable_sbpf_v0_execution, remaining_compute_units_syscall_enabled, FeatureSet,
},
solana_log_collector::{ic_logger_msg, ic_msg},
solana_poseidon as poseidon,
Expand All @@ -35,7 +36,7 @@ use {
solana_rbpf::{
declare_builtin_function,
memory_region::{AccessType, MemoryMapping},
program::{BuiltinFunction, BuiltinProgram, FunctionRegistry},
program::{BuiltinFunction, BuiltinProgram, FunctionRegistry, SBPFVersion},
vm::Config,
},
solana_sdk::{
Expand Down Expand Up @@ -244,12 +245,14 @@ macro_rules! register_feature_gated_function {
pub fn morph_into_deployment_environment_v1(
from: Arc<BuiltinProgram<InvokeContext>>,
) -> Result<BuiltinProgram<InvokeContext>, Error> {
let mut config = *from.get_config();
let mut config = from.get_config().clone();
config.reject_broken_elfs = true;
config.enabled_sbpf_versions =
*config.enabled_sbpf_versions.end()..=*config.enabled_sbpf_versions.end();

let mut result = FunctionRegistry::<BuiltinFunction<InvokeContext>>::default();

for (key, (name, value)) in from.get_function_registry().iter() {
for (key, (name, value)) in from.get_function_registry(SBPFVersion::V0).iter() {
// Deployment of programs with sol_alloc_free is disabled. So do not register the syscall.
if name != *b"sol_alloc_free_" {
result.register_function(key, name, value)?;
Expand Down Expand Up @@ -284,6 +287,23 @@ pub fn create_program_runtime_environment_v1<'a>(
let get_sysvar_syscall_enabled = feature_set.is_active(&get_sysvar_syscall_enabled::id());
let enable_get_epoch_stake_syscall =
feature_set.is_active(&enable_get_epoch_stake_syscall::id());
let min_sbpf_version = if !feature_set.is_active(&disable_sbpf_v0_execution::id())
|| feature_set.is_active(&reenable_sbpf_v0_execution::id())
{
SBPFVersion::V0
} else {
SBPFVersion::V3
};
let max_sbpf_version = if feature_set.is_active(&enable_sbpf_v3_deployment_and_execution::id())
{
SBPFVersion::V3
} else if feature_set.is_active(&enable_sbpf_v2_deployment_and_execution::id()) {
SBPFVersion::V2
} else if feature_set.is_active(&enable_sbpf_v1_deployment_and_execution::id()) {
SBPFVersion::V1
} else {
SBPFVersion::V0
};

let config = Config {
max_call_depth: compute_budget.max_call_depth,
Expand All @@ -297,11 +317,7 @@ pub fn create_program_runtime_environment_v1<'a>(
reject_broken_elfs: reject_deployment_of_broken_elfs,
noop_instruction_rate: 256,
sanitize_user_provided_values: true,
external_internal_function_hash_collision: true,
reject_callx_r10: true,
enable_sbpf_v1: !feature_set.is_active(&disable_sbpf_v1_execution::id())
|| feature_set.is_active(&reenable_sbpf_v1_execution::id()),
enable_sbpf_v2: false,
enabled_sbpf_versions: min_sbpf_version..=max_sbpf_version,
optimize_rodata: false,
aligned_memory_mapping: !feature_set.is_active(&bpf_account_data_direct_mapping::id()),
// Warning, do not use `Config::default()` so that configuration here is explicit.
Expand Down Expand Up @@ -504,10 +520,7 @@ pub fn create_program_runtime_environment_v2<'a>(
reject_broken_elfs: true,
noop_instruction_rate: 256,
sanitize_user_provided_values: true,
external_internal_function_hash_collision: true,
reject_callx_r10: true,
enable_sbpf_v1: false,
enable_sbpf_v2: true,
enabled_sbpf_versions: SBPFVersion::Reserved..=SBPFVersion::Reserved,
optimize_rodata: true,
aligned_memory_mapping: true,
// Warning, do not use `Config::default()` so that configuration here is explicit.
Expand Down
5 changes: 2 additions & 3 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion programs/sbf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ solana-vote = { path = "../../vote", version = "=2.2.0" }
solana-vote-program = { path = "../../programs/vote", version = "=2.2.0" }
agave-validator = { path = "../../validator", version = "=2.2.0" }
solana-zk-sdk = { path = "../../zk-sdk", version = "=2.2.0" }
solana_rbpf = "=0.8.5"
solana_rbpf = { git = "https://github.com/solana-labs/rbpf.git" }
thiserror = "1.0"

[package]
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12016,10 +12016,10 @@ fn test_feature_activation_loaded_programs_cache_preparation_phase() {
let (mut genesis_config, mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL);
genesis_config
.accounts
.remove(&feature_set::disable_sbpf_v1_execution::id());
.remove(&feature_set::disable_sbpf_v0_execution::id());
genesis_config
.accounts
.remove(&feature_set::reenable_sbpf_v1_execution::id());
.remove(&feature_set::reenable_sbpf_v0_execution::id());
let (root_bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);

// Program Setup
Expand Down Expand Up @@ -12053,7 +12053,7 @@ fn test_feature_activation_loaded_programs_cache_preparation_phase() {
let feature_account_balance =
std::cmp::max(genesis_config.rent.minimum_balance(Feature::size_of()), 1);
bank.store_account(
&feature_set::disable_sbpf_v1_execution::id(),
&feature_set::disable_sbpf_v0_execution::id(),
&feature::create_account(&Feature { activated_at: None }, feature_account_balance),
);

Expand Down Expand Up @@ -12128,7 +12128,7 @@ fn test_feature_activation_loaded_programs_epoch_transition() {
.remove(&feature_set::disable_fees_sysvar::id());
genesis_config
.accounts
.remove(&feature_set::reenable_sbpf_v1_execution::id());
.remove(&feature_set::reenable_sbpf_v0_execution::id());
let (root_bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);

// Program Setup
Expand Down
23 changes: 19 additions & 4 deletions sdk/feature-set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,14 +860,26 @@ pub mod deprecate_legacy_vote_ixs {
solana_pubkey::declare_id!("depVvnQ2UysGrhwdiwU42tCadZL8GcBb1i2GYhMopQv");
}

pub mod disable_sbpf_v1_execution {
pub mod disable_sbpf_v0_execution {
solana_pubkey::declare_id!("TestFeature11111111111111111111111111111111");
}

pub mod reenable_sbpf_v1_execution {
pub mod reenable_sbpf_v0_execution {
solana_pubkey::declare_id!("TestFeature21111111111111111111111111111111");
}

pub mod enable_sbpf_v1_deployment_and_execution {
solana_pubkey::declare_id!("JE86WkYvTrzW8HgNmrHY7dFYpCmSptUpKupbo2AdQ9cG");
}

pub mod enable_sbpf_v2_deployment_and_execution {
solana_pubkey::declare_id!("F6UVKh1ujTEFK3en2SyAL3cdVnqko1FVEXWhmdLRu6WP");
}

pub mod enable_sbpf_v3_deployment_and_execution {
solana_pubkey::declare_id!("C8XZNs1bfzaiT3YDeXZJ7G5swQWQv7tVzDnCxtHvnSpw");
}

pub mod remove_accounts_executable_flag_checks {
solana_pubkey::declare_id!("FfgtauHUWKeXTzjXkua9Px4tNGBFHKZ9WaigM5VbbzFx");
}
Expand Down Expand Up @@ -1102,8 +1114,11 @@ lazy_static! {
(enable_turbine_extended_fanout_experiments::id(), "enable turbine extended fanout experiments #"),
(deprecate_legacy_vote_ixs::id(), "Deprecate legacy vote instructions"),
(partitioned_epoch_rewards_superfeature::id(), "replaces enable_partitioned_epoch_reward to enable partitioned rewards at epoch boundary SIMD-0118"),
(disable_sbpf_v1_execution::id(), "Disables execution of SBPFv1 programs"),
(reenable_sbpf_v1_execution::id(), "Re-enables execution of SBPFv1 programs"),
(disable_sbpf_v0_execution::id(), "Disables execution of SBPFv1 programs SIMD-0161"),
(reenable_sbpf_v0_execution::id(), "Re-enables execution of SBPFv1 programs"),
(enable_sbpf_v1_deployment_and_execution::id(), "Enables deployment and execution of SBPFv1 programs SIMD-0161"),
(enable_sbpf_v2_deployment_and_execution::id(), "Enables deployment and execution of SBPFv2 programs SIMD-0161"),
(enable_sbpf_v3_deployment_and_execution::id(), "Enables deployment and execution of SBPFv3 programs SIMD-0161"),
(remove_accounts_executable_flag_checks::id(), "Remove checks of accounts is_executable flag SIMD-0162"),
(lift_cpi_caller_restriction::id(), "Lift the restriction in CPI that the caller must have the callee as an instruction account #2202"),
(disable_account_loader_special_case::id(), "Disable account loader special case #3513"),
Expand Down
5 changes: 2 additions & 3 deletions svm/examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c0e201

Please sign in to comment.