|
|
@@ -21,21 +21,22 @@ 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,
|
|
|
solana_program_memory::is_nonoverlapping,
|
|
|
solana_program_runtime::{invoke_context::InvokeContext, stable_log},
|
|
|
- solana_rbpf::{
|
|
|
+ solana_sbpf::{
|
|
|
declare_builtin_function,
|
|
|
memory_region::{AccessType, MemoryMapping},
|
|
|
- program::{BuiltinFunction, BuiltinProgram, FunctionRegistry},
|
|
|
+ program::{BuiltinProgram, FunctionRegistry, SBPFVersion},
|
|
|
vm::Config,
|
|
|
},
|
|
|
solana_sdk::{
|
|
|
@@ -232,11 +233,11 @@ fn consume_compute_meter(invoke_context: &InvokeContext, amount: u64) -> Result<
|
|
|
}
|
|
|
|
|
|
macro_rules! register_feature_gated_function {
|
|
|
- ($result:expr, $is_feature_active:expr, $name:expr, $call:expr $(,)?) => {
|
|
|
+ ($result:expr, $is_feature_active:expr, $name:expr, $key:expr, $call:expr $(,)?) => {
|
|
|
if $is_feature_active {
|
|
|
- $result.register_function_hashed($name, $call)
|
|
|
+ $result.register_function($name, $key, $call)
|
|
|
} else {
|
|
|
- Ok(0)
|
|
|
+ Ok(())
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
@@ -244,19 +245,23 @@ 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;
|
|
|
+ // Once the tests are being build using a toolchain which supports the newer SBPF versions,
|
|
|
+ // the deployment of older versions will be disabled:
|
|
|
+ // config.enabled_sbpf_versions =
|
|
|
+ // *config.enabled_sbpf_versions.end()..=*config.enabled_sbpf_versions.end();
|
|
|
|
|
|
- let mut result = FunctionRegistry::<BuiltinFunction<InvokeContext>>::default();
|
|
|
+ let mut result = BuiltinProgram::new_loader_with_dense_registration(config);
|
|
|
|
|
|
- for (key, (name, value)) in from.get_function_registry().iter() {
|
|
|
+ for (key, (name, value)) in from.get_function_registry(SBPFVersion::V3).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)?;
|
|
|
+ result.register_function(unsafe { std::str::from_utf8_unchecked(name) }, key, value)?;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Ok(BuiltinProgram::new_loader(config, result))
|
|
|
+ Ok(result)
|
|
|
}
|
|
|
|
|
|
pub fn create_program_runtime_environment_v1<'a>(
|
|
|
@@ -284,6 +289,24 @@ 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
|
|
|
+ };
|
|
|
+ debug_assert!(min_sbpf_version <= max_sbpf_version);
|
|
|
|
|
|
let config = Config {
|
|
|
max_call_depth: compute_budget.max_call_depth,
|
|
|
@@ -297,53 +320,52 @@ 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.
|
|
|
};
|
|
|
- let mut result = FunctionRegistry::<BuiltinFunction<InvokeContext>>::default();
|
|
|
+ let mut result = BuiltinProgram::new_loader_with_dense_registration(config);
|
|
|
|
|
|
// Abort
|
|
|
- result.register_function_hashed(*b"abort", SyscallAbort::vm)?;
|
|
|
+ result.register_function("abort", 1, SyscallAbort::vm)?;
|
|
|
|
|
|
// Panic
|
|
|
- result.register_function_hashed(*b"sol_panic_", SyscallPanic::vm)?;
|
|
|
+ result.register_function("sol_panic_", 2, SyscallPanic::vm)?;
|
|
|
|
|
|
// Logging
|
|
|
- result.register_function_hashed(*b"sol_log_", SyscallLog::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_log_64_", SyscallLogU64::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_log_compute_units_", SyscallLogBpfComputeUnits::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_log_pubkey", SyscallLogPubkey::vm)?;
|
|
|
+ result.register_function("sol_log_", 7, SyscallLog::vm)?;
|
|
|
+ result.register_function("sol_log_64_", 8, SyscallLogU64::vm)?;
|
|
|
+ result.register_function("sol_log_pubkey", 9, SyscallLogPubkey::vm)?;
|
|
|
+ result.register_function("sol_log_compute_units_", 10, SyscallLogBpfComputeUnits::vm)?;
|
|
|
|
|
|
// Program defined addresses (PDA)
|
|
|
- result.register_function_hashed(
|
|
|
- *b"sol_create_program_address",
|
|
|
+ result.register_function(
|
|
|
+ "sol_create_program_address",
|
|
|
+ 32,
|
|
|
SyscallCreateProgramAddress::vm,
|
|
|
)?;
|
|
|
- result.register_function_hashed(
|
|
|
- *b"sol_try_find_program_address",
|
|
|
+ result.register_function(
|
|
|
+ "sol_try_find_program_address",
|
|
|
+ 33,
|
|
|
SyscallTryFindProgramAddress::vm,
|
|
|
)?;
|
|
|
|
|
|
// Sha256
|
|
|
- result.register_function_hashed(*b"sol_sha256", SyscallHash::vm::<Sha256Hasher>)?;
|
|
|
+ result.register_function("sol_sha256", 17, SyscallHash::vm::<Sha256Hasher>)?;
|
|
|
|
|
|
// Keccak256
|
|
|
- result.register_function_hashed(*b"sol_keccak256", SyscallHash::vm::<Keccak256Hasher>)?;
|
|
|
+ result.register_function("sol_keccak256", 18, SyscallHash::vm::<Keccak256Hasher>)?;
|
|
|
|
|
|
// Secp256k1 Recover
|
|
|
- result.register_function_hashed(*b"sol_secp256k1_recover", SyscallSecp256k1Recover::vm)?;
|
|
|
+ result.register_function("sol_secp256k1_recover", 19, SyscallSecp256k1Recover::vm)?;
|
|
|
|
|
|
// Blake3
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
blake3_syscall_enabled,
|
|
|
- *b"sol_blake3",
|
|
|
+ "sol_blake3",
|
|
|
+ 20,
|
|
|
SyscallHash::vm::<Blake3Hasher>,
|
|
|
)?;
|
|
|
|
|
|
@@ -351,78 +373,87 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
curve25519_syscall_enabled,
|
|
|
- *b"sol_curve_validate_point",
|
|
|
+ "sol_curve_validate_point",
|
|
|
+ 24,
|
|
|
SyscallCurvePointValidation::vm,
|
|
|
)?;
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
curve25519_syscall_enabled,
|
|
|
- *b"sol_curve_group_op",
|
|
|
+ "sol_curve_group_op",
|
|
|
+ 25,
|
|
|
SyscallCurveGroupOps::vm,
|
|
|
)?;
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
curve25519_syscall_enabled,
|
|
|
- *b"sol_curve_multiscalar_mul",
|
|
|
+ "sol_curve_multiscalar_mul",
|
|
|
+ 26,
|
|
|
SyscallCurveMultiscalarMultiplication::vm,
|
|
|
)?;
|
|
|
|
|
|
// Sysvars
|
|
|
- result.register_function_hashed(*b"sol_get_clock_sysvar", SyscallGetClockSysvar::vm)?;
|
|
|
- result.register_function_hashed(
|
|
|
- *b"sol_get_epoch_schedule_sysvar",
|
|
|
+ result.register_function("sol_get_clock_sysvar", 36, SyscallGetClockSysvar::vm)?;
|
|
|
+ result.register_function(
|
|
|
+ "sol_get_epoch_schedule_sysvar",
|
|
|
+ 37,
|
|
|
SyscallGetEpochScheduleSysvar::vm,
|
|
|
)?;
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
!disable_fees_sysvar,
|
|
|
- *b"sol_get_fees_sysvar",
|
|
|
+ "sol_get_fees_sysvar",
|
|
|
+ 40,
|
|
|
SyscallGetFeesSysvar::vm,
|
|
|
)?;
|
|
|
- result.register_function_hashed(*b"sol_get_rent_sysvar", SyscallGetRentSysvar::vm)?;
|
|
|
+ result.register_function("sol_get_rent_sysvar", 41, SyscallGetRentSysvar::vm)?;
|
|
|
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
last_restart_slot_syscall_enabled,
|
|
|
- *b"sol_get_last_restart_slot",
|
|
|
+ "sol_get_last_restart_slot",
|
|
|
+ 38,
|
|
|
SyscallGetLastRestartSlotSysvar::vm,
|
|
|
)?;
|
|
|
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
epoch_rewards_syscall_enabled,
|
|
|
- *b"sol_get_epoch_rewards_sysvar",
|
|
|
+ "sol_get_epoch_rewards_sysvar",
|
|
|
+ 39,
|
|
|
SyscallGetEpochRewardsSysvar::vm,
|
|
|
)?;
|
|
|
|
|
|
// Memory ops
|
|
|
- result.register_function_hashed(*b"sol_memcpy_", SyscallMemcpy::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_memmove_", SyscallMemmove::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_memcmp_", SyscallMemcmp::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_memset_", SyscallMemset::vm)?;
|
|
|
+ result.register_function("sol_memcpy_", 3, SyscallMemcpy::vm)?;
|
|
|
+ result.register_function("sol_memmove_", 4, SyscallMemmove::vm)?;
|
|
|
+ result.register_function("sol_memset_", 5, SyscallMemset::vm)?;
|
|
|
+ result.register_function("sol_memcmp_", 6, SyscallMemcmp::vm)?;
|
|
|
|
|
|
// Processed sibling instructions
|
|
|
- result.register_function_hashed(
|
|
|
- *b"sol_get_processed_sibling_instruction",
|
|
|
+ result.register_function(
|
|
|
+ "sol_get_processed_sibling_instruction",
|
|
|
+ 22,
|
|
|
SyscallGetProcessedSiblingInstruction::vm,
|
|
|
)?;
|
|
|
|
|
|
// Stack height
|
|
|
- result.register_function_hashed(*b"sol_get_stack_height", SyscallGetStackHeight::vm)?;
|
|
|
+ result.register_function("sol_get_stack_height", 23, SyscallGetStackHeight::vm)?;
|
|
|
|
|
|
// Return data
|
|
|
- result.register_function_hashed(*b"sol_set_return_data", SyscallSetReturnData::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_get_return_data", SyscallGetReturnData::vm)?;
|
|
|
+ result.register_function("sol_set_return_data", 14, SyscallSetReturnData::vm)?;
|
|
|
+ result.register_function("sol_get_return_data", 15, SyscallGetReturnData::vm)?;
|
|
|
|
|
|
// Cross-program invocation
|
|
|
- result.register_function_hashed(*b"sol_invoke_signed_c", SyscallInvokeSignedC::vm)?;
|
|
|
- result.register_function_hashed(*b"sol_invoke_signed_rust", SyscallInvokeSignedRust::vm)?;
|
|
|
+ result.register_function("sol_invoke_signed_c", 12, SyscallInvokeSignedC::vm)?;
|
|
|
+ result.register_function("sol_invoke_signed_rust", 13, SyscallInvokeSignedRust::vm)?;
|
|
|
|
|
|
// Memory allocator
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
!disable_deploy_of_alloc_free_syscall,
|
|
|
- *b"sol_alloc_free_",
|
|
|
+ "sol_alloc_free_",
|
|
|
+ 11,
|
|
|
SyscallAllocFree::vm,
|
|
|
)?;
|
|
|
|
|
|
@@ -430,7 +461,8 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
enable_alt_bn128_syscall,
|
|
|
- *b"sol_alt_bn128_group_op",
|
|
|
+ "sol_alt_bn128_group_op",
|
|
|
+ 28,
|
|
|
SyscallAltBn128::vm,
|
|
|
)?;
|
|
|
|
|
|
@@ -438,7 +470,8 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
enable_big_mod_exp_syscall,
|
|
|
- *b"sol_big_mod_exp",
|
|
|
+ "sol_big_mod_exp",
|
|
|
+ 30,
|
|
|
SyscallBigModExp::vm,
|
|
|
)?;
|
|
|
|
|
|
@@ -446,7 +479,8 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
enable_poseidon_syscall,
|
|
|
- *b"sol_poseidon",
|
|
|
+ "sol_poseidon",
|
|
|
+ 21,
|
|
|
SyscallPoseidon::vm,
|
|
|
)?;
|
|
|
|
|
|
@@ -454,7 +488,8 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
remaining_compute_units_syscall_enabled,
|
|
|
- *b"sol_remaining_compute_units",
|
|
|
+ "sol_remaining_compute_units",
|
|
|
+ 31,
|
|
|
SyscallRemainingComputeUnits::vm
|
|
|
)?;
|
|
|
|
|
|
@@ -462,7 +497,8 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
enable_alt_bn128_compression_syscall,
|
|
|
- *b"sol_alt_bn128_compression",
|
|
|
+ "sol_alt_bn128_compression",
|
|
|
+ 29,
|
|
|
SyscallAltBn128Compression::vm,
|
|
|
)?;
|
|
|
|
|
|
@@ -470,7 +506,8 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
get_sysvar_syscall_enabled,
|
|
|
- *b"sol_get_sysvar",
|
|
|
+ "sol_get_sysvar",
|
|
|
+ 34,
|
|
|
SyscallGetSysvar::vm,
|
|
|
)?;
|
|
|
|
|
|
@@ -478,14 +515,15 @@ pub fn create_program_runtime_environment_v1<'a>(
|
|
|
register_feature_gated_function!(
|
|
|
result,
|
|
|
enable_get_epoch_stake_syscall,
|
|
|
- *b"sol_get_epoch_stake",
|
|
|
+ "sol_get_epoch_stake",
|
|
|
+ 35,
|
|
|
SyscallGetEpochStake::vm,
|
|
|
)?;
|
|
|
|
|
|
// Log data
|
|
|
- result.register_function_hashed(*b"sol_log_data", SyscallLogData::vm)?;
|
|
|
+ result.register_function("sol_log_data", 16, SyscallLogData::vm)?;
|
|
|
|
|
|
- Ok(BuiltinProgram::new_loader(config, result))
|
|
|
+ Ok(result)
|
|
|
}
|
|
|
|
|
|
pub fn create_program_runtime_environment_v2<'a>(
|
|
|
@@ -504,10 +542,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.
|
|
|
@@ -1848,7 +1883,7 @@ declare_builtin_function!(
|
|
|
let budget = invoke_context.get_compute_budget();
|
|
|
consume_compute_meter(invoke_context, budget.syscall_base_cost)?;
|
|
|
|
|
|
- use solana_rbpf::vm::ContextObject;
|
|
|
+ use solana_sbpf::vm::ContextObject;
|
|
|
Ok(invoke_context.get_remaining())
|
|
|
}
|
|
|
);
|
|
|
@@ -2120,7 +2155,7 @@ mod tests {
|
|
|
assert_matches::assert_matches,
|
|
|
core::slice,
|
|
|
solana_program_runtime::{invoke_context::InvokeContext, with_mock_invoke_context},
|
|
|
- solana_rbpf::{
|
|
|
+ solana_sbpf::{
|
|
|
error::EbpfError, memory_region::MemoryRegion, program::SBPFVersion, vm::Config,
|
|
|
},
|
|
|
solana_sdk::{
|
|
|
@@ -2191,7 +2226,7 @@ mod tests {
|
|
|
let memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(&data, START)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -2232,7 +2267,7 @@ mod tests {
|
|
|
let memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(bytes_of(&pubkey), 0x100000000)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
let translated_pubkey =
|
|
|
@@ -2248,14 +2283,14 @@ mod tests {
|
|
|
let instruction = StableInstruction::from(instruction);
|
|
|
let memory_region = MemoryRegion::new_readonly(bytes_of(&instruction), 0x100000000);
|
|
|
let memory_mapping =
|
|
|
- MemoryMapping::new(vec![memory_region], &config, &SBPFVersion::V2).unwrap();
|
|
|
+ MemoryMapping::new(vec![memory_region], &config, SBPFVersion::V3).unwrap();
|
|
|
let translated_instruction =
|
|
|
translate_type::<StableInstruction>(&memory_mapping, 0x100000000, true).unwrap();
|
|
|
assert_eq!(instruction, *translated_instruction);
|
|
|
|
|
|
let memory_region = MemoryRegion::new_readonly(&bytes_of(&instruction)[..1], 0x100000000);
|
|
|
let memory_mapping =
|
|
|
- MemoryMapping::new(vec![memory_region], &config, &SBPFVersion::V2).unwrap();
|
|
|
+ MemoryMapping::new(vec![memory_region], &config, SBPFVersion::V3).unwrap();
|
|
|
assert!(translate_type::<Instruction>(&memory_mapping, 0x100000000, true).is_err());
|
|
|
}
|
|
|
|
|
|
@@ -2270,7 +2305,7 @@ mod tests {
|
|
|
let memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(&good_data, 0x100000000)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
let translated_data =
|
|
|
@@ -2283,7 +2318,7 @@ mod tests {
|
|
|
let memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(&data, 0x100000000)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
let translated_data =
|
|
|
@@ -2308,7 +2343,7 @@ mod tests {
|
|
|
0x100000000,
|
|
|
)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
let translated_data =
|
|
|
@@ -2328,7 +2363,7 @@ mod tests {
|
|
|
0x100000000,
|
|
|
)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
let translated_data =
|
|
|
@@ -2346,7 +2381,7 @@ mod tests {
|
|
|
let memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(string.as_bytes(), 0x100000000)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
assert_eq!(
|
|
|
@@ -2370,7 +2405,7 @@ mod tests {
|
|
|
fn test_syscall_abort() {
|
|
|
prepare_mockup!(invoke_context, program_id, bpf_loader::id());
|
|
|
let config = Config::default();
|
|
|
- let mut memory_mapping = MemoryMapping::new(vec![], &config, &SBPFVersion::V2).unwrap();
|
|
|
+ let mut memory_mapping = MemoryMapping::new(vec![], &config, SBPFVersion::V3).unwrap();
|
|
|
let result = SyscallAbort::rust(&mut invoke_context, 0, 0, 0, 0, 0, &mut memory_mapping);
|
|
|
result.unwrap();
|
|
|
}
|
|
|
@@ -2385,7 +2420,7 @@ mod tests {
|
|
|
let mut memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(string.as_bytes(), 0x100000000)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -2426,7 +2461,7 @@ mod tests {
|
|
|
let mut memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(string.as_bytes(), 0x100000000)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -2493,7 +2528,7 @@ mod tests {
|
|
|
|
|
|
invoke_context.mock_set_remaining(cost);
|
|
|
let config = Config::default();
|
|
|
- let mut memory_mapping = MemoryMapping::new(vec![], &config, &SBPFVersion::V2).unwrap();
|
|
|
+ let mut memory_mapping = MemoryMapping::new(vec![], &config, SBPFVersion::V3).unwrap();
|
|
|
let result = SyscallLogU64::rust(&mut invoke_context, 1, 2, 3, 4, 5, &mut memory_mapping);
|
|
|
result.unwrap();
|
|
|
|
|
|
@@ -2517,7 +2552,7 @@ mod tests {
|
|
|
let mut memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_readonly(bytes_of(&pubkey), 0x100000000)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -2700,7 +2735,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(bytes2.as_bytes(), bytes_to_hash[1].vm_addr),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -2798,7 +2833,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&invalid_bytes, invalid_bytes_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -2871,7 +2906,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&invalid_bytes, invalid_bytes_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -2958,7 +2993,7 @@ mod tests {
|
|
|
MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3113,7 +3148,7 @@ mod tests {
|
|
|
MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3283,7 +3318,7 @@ mod tests {
|
|
|
MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3376,7 +3411,7 @@ mod tests {
|
|
|
MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3561,7 +3596,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&Clock::id().to_bytes(), clock_id_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3627,7 +3662,7 @@ mod tests {
|
|
|
),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3689,7 +3724,7 @@ mod tests {
|
|
|
got_fees_va,
|
|
|
)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3728,7 +3763,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&Rent::id().to_bytes(), rent_id_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3788,7 +3823,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&EpochRewards::id().to_bytes(), rewards_id_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3853,7 +3888,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&LastRestartSlot::id().to_bytes(), restart_id_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3938,7 +3973,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&StakeHistory::id().to_bytes(), history_id_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -3997,7 +4032,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&SlotHashes::id().to_bytes(), hashes_id_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -4043,7 +4078,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&got_clock_buf_ro, got_clock_buf_ro_va),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -4232,7 +4267,7 @@ mod tests {
|
|
|
bytes_of_slice(&mock_slices),
|
|
|
SEEDS_VA,
|
|
|
));
|
|
|
- let mut memory_mapping = MemoryMapping::new(regions, &config, &SBPFVersion::V2).unwrap();
|
|
|
+ let mut memory_mapping = MemoryMapping::new(regions, &config, SBPFVersion::V3).unwrap();
|
|
|
|
|
|
let result = syscall(
|
|
|
invoke_context,
|
|
|
@@ -4296,7 +4331,7 @@ mod tests {
|
|
|
MemoryRegion::new_writable(&mut id_buffer, PROGRAM_ID_VA),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -4396,7 +4431,7 @@ mod tests {
|
|
|
let mut memory_mapping = MemoryMapping::new(
|
|
|
vec![MemoryRegion::new_writable(&mut memory, VM_BASE_ADDRESS)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
let processed_sibling_instruction = translate_type_mut::<ProcessedSiblingInstruction>(
|
|
|
@@ -4702,7 +4737,7 @@ mod tests {
|
|
|
MemoryRegion::new_writable(&mut data_out, VADDR_OUT),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -4744,7 +4779,7 @@ mod tests {
|
|
|
MemoryRegion::new_writable(&mut data_out, VADDR_OUT),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -4799,7 +4834,7 @@ mod tests {
|
|
|
|
|
|
let null_pointer_var = std::ptr::null::<Pubkey>() as u64;
|
|
|
|
|
|
- let mut memory_mapping = MemoryMapping::new(vec![], &config, &SBPFVersion::V2).unwrap();
|
|
|
+ let mut memory_mapping = MemoryMapping::new(vec![], &config, SBPFVersion::V3).unwrap();
|
|
|
|
|
|
let result = SyscallGetEpochStake::rust(
|
|
|
&mut invoke_context,
|
|
|
@@ -4863,7 +4898,7 @@ mod tests {
|
|
|
MemoryRegion::new_readonly(&[2; 31], vote_address_var),
|
|
|
],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -4893,7 +4928,7 @@ mod tests {
|
|
|
vote_address_var,
|
|
|
)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -4925,7 +4960,7 @@ mod tests {
|
|
|
vote_address_var,
|
|
|
)],
|
|
|
&config,
|
|
|
- &SBPFVersion::V2,
|
|
|
+ SBPFVersion::V3,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|