From 8bed666c9f4888c26305747ea660c7d74d63c4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Thu, 28 Nov 2024 12:20:40 +0000 Subject: [PATCH] Bumps solana_rbpf to v0.9.0 --- Cargo.lock | 5 +- Cargo.toml | 2 +- program-runtime/src/invoke_context.rs | 6 +- programs/bpf_loader/src/lib.rs | 14 +- programs/bpf_loader/src/syscalls/cpi.rs | 24 ++-- programs/bpf_loader/src/syscalls/mem_ops.rs | 134 +++++++++--------- programs/bpf_loader/src/syscalls/mod.rs | 124 +++++++++------- ...lx-r10-sbfv1.so => sbpfv0_verifier_err.so} | Bin .../test_elfs/out/sbpfv3_return_err.so | Bin 0 -> 13816 bytes .../test_elfs/out/sbpfv3_return_ok.so | Bin 0 -> 14840 bytes programs/loader-v4/src/lib.rs | 55 +++---- programs/sbf/Cargo.lock | 5 +- programs/sbf/Cargo.toml | 2 +- runtime/src/bank/tests.rs | 8 +- sdk/feature-set/src/lib.rs | 23 ++- svm/examples/Cargo.lock | 5 +- .../json-rpc/server/src/svm_bridge.rs | 7 +- svm/tests/mock_bank.rs | 7 +- 18 files changed, 224 insertions(+), 197 deletions(-) rename programs/bpf_loader/test_elfs/out/{callx-r10-sbfv1.so => sbpfv0_verifier_err.so} (100%) create mode 100644 programs/bpf_loader/test_elfs/out/sbpfv3_return_err.so create mode 100644 programs/bpf_loader/test_elfs/out/sbpfv3_return_ok.so diff --git a/Cargo.lock b/Cargo.lock index ecc65cdbe1faf7..b3d9acecdad45f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9922,9 +9922,8 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1941b5ef0c3ce8f2ac5dd984d0fb1a97423c4ff2a02eec81e3913f02e2ac2b" +version = "0.8.2" +source = "git+https://github.com/solana-labs/rbpf.git#4ad935be45e5663be23b30cfc750b1ae1ad03c44" dependencies = [ "byteorder", "combine 3.8.1", diff --git a/Cargo.toml b/Cargo.toml index 21684e6126f9d1..5748e145e6dc6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -604,7 +604,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" diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index db6486a6194dd6..e5e9d55f568546 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -536,7 +536,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, @@ -555,13 +555,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, diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index 7dbc8cdb3e1ec9..e07ec7ccda55f5 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -328,9 +328,9 @@ macro_rules! mock_create_vm { let loader = solana_type_overrides::sync::Arc::new(BuiltinProgram::new_mock()); let function_registry = solana_rbpf::program::FunctionRegistry::default(); let executable = solana_rbpf::elf::Executable::::from_text_bytes( - &[0x95, 0, 0, 0, 0, 0, 0, 0], + &[0x9D, 0, 0, 0, 0, 0, 0, 0], loader, - SBPFVersion::V2, + SBPFVersion::V3, function_registry, ) .unwrap(); @@ -1696,7 +1696,7 @@ mod tests { let loader_id = bpf_loader::id(); let program_id = Pubkey::new_unique(); let program_account = - load_program_account_from_elf(&loader_id, "test_elfs/out/noop_aligned.so"); + load_program_account_from_elf(&loader_id, "test_elfs/out/sbpfv3_return_ok.so"); let parameter_id = Pubkey::new_unique(); let parameter_account = AccountSharedData::new(1, 0, &loader_id); let parameter_meta = AccountMeta { @@ -2184,10 +2184,10 @@ mod tests { #[test] fn test_bpf_loader_upgradeable_upgrade() { - let mut file = File::open("test_elfs/out/noop_aligned.so").expect("file open failed"); + let mut file = File::open("test_elfs/out/sbpfv3_return_ok.so").expect("file open failed"); let mut elf_orig = Vec::new(); file.read_to_end(&mut elf_orig).unwrap(); - let mut file = File::open("test_elfs/out/noop_unaligned.so").expect("file open failed"); + let mut file = File::open("test_elfs/out/sbpfv3_return_err.so").expect("file open failed"); let mut elf_new = Vec::new(); file.read_to_end(&mut elf_new).unwrap(); assert_ne!(elf_orig.len(), elf_new.len()); @@ -3783,7 +3783,7 @@ mod tests { let program_id = Pubkey::new_unique(); // Create program account - let mut file = File::open("test_elfs/out/noop_aligned.so").expect("file open failed"); + let mut file = File::open("test_elfs/out/sbpfv3_return_ok.so").expect("file open failed"); let mut elf = Vec::new(); file.read_to_end(&mut elf).unwrap(); @@ -3833,7 +3833,7 @@ mod tests { invoke_context: &mut InvokeContext, program_id: Pubkey, ) -> Result<(), InstructionError> { - let mut file = File::open("test_elfs/out/noop_unaligned.so").expect("file open failed"); + let mut file = File::open("test_elfs/out/sbpfv3_return_ok.so").expect("file open failed"); let mut elf = Vec::new(); file.read_to_end(&mut elf).unwrap(); deploy_program!( diff --git a/programs/bpf_loader/src/syscalls/cpi.rs b/programs/bpf_loader/src/syscalls/cpi.rs index bb0179da75d14c..4497468415f09b 100644 --- a/programs/bpf_loader/src/syscalls/cpi.rs +++ b/programs/bpf_loader/src/syscalls/cpi.rs @@ -1710,7 +1710,7 @@ mod tests { aligned_memory_mapping: false, ..Config::default() }; - let memory_mapping = MemoryMapping::new(vec![region], &config, &SBPFVersion::V2).unwrap(); + let memory_mapping = MemoryMapping::new(vec![region], &config, SBPFVersion::V3).unwrap(); let ins = SyscallInvokeSignedRust::translate_instruction( vm_addr, @@ -1746,7 +1746,7 @@ mod tests { aligned_memory_mapping: false, ..Config::default() }; - let memory_mapping = MemoryMapping::new(vec![region], &config, &SBPFVersion::V2).unwrap(); + let memory_mapping = MemoryMapping::new(vec![region], &config, SBPFVersion::V3).unwrap(); let signers = SyscallInvokeSignedRust::translate_signers( &program_id, @@ -1782,7 +1782,7 @@ mod tests { aligned_memory_mapping: false, ..Config::default() }; - let memory_mapping = MemoryMapping::new(vec![region], &config, &SBPFVersion::V2).unwrap(); + let memory_mapping = MemoryMapping::new(vec![region], &config, SBPFVersion::V3).unwrap(); let account_info = translate_type::(&memory_mapping, vm_addr, false).unwrap(); @@ -1832,7 +1832,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -1890,7 +1890,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2018,7 +2018,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2193,7 +2193,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2263,7 +2263,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2319,7 +2319,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2392,7 +2392,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2480,7 +2480,7 @@ mod tests { let memory_mapping = MemoryMapping::new( mock_caller_account.regions.split_off(0), &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2558,7 +2558,7 @@ mod tests { aligned_memory_mapping: false, ..Config::default() }; - let memory_mapping = MemoryMapping::new(vec![region], &config, &SBPFVersion::V2).unwrap(); + let memory_mapping = MemoryMapping::new(vec![region], &config, SBPFVersion::V3).unwrap(); mock_invoke_context!( invoke_context, diff --git a/programs/bpf_loader/src/syscalls/mem_ops.rs b/programs/bpf_loader/src/syscalls/mem_ops.rs index e6db37ccaa29bf..878fbbf7955cd3 100644 --- a/programs/bpf_loader/src/syscalls/mem_ops.rs +++ b/programs/bpf_loader/src/syscalls/mem_ops.rs @@ -573,7 +573,7 @@ mod tests { use { super::*, assert_matches::assert_matches, - solana_rbpf::{ebpf::MM_PROGRAM_START, program::SBPFVersion}, + solana_rbpf::{ebpf::MM_RODATA_START, program::SBPFVersion}, test_case::test_case, }; @@ -591,7 +591,7 @@ mod tests { aligned_memory_mapping: false, ..Config::default() }; - let memory_mapping = MemoryMapping::new(vec![], &config, &SBPFVersion::V2).unwrap(); + let memory_mapping = MemoryMapping::new(vec![], &config, SBPFVersion::V3).unwrap(); let mut src_chunk_iter = MemoryChunkIterator::new(&memory_mapping, &[], AccessType::Load, 0, 1).unwrap(); @@ -605,7 +605,7 @@ mod tests { aligned_memory_mapping: false, ..Config::default() }; - let memory_mapping = MemoryMapping::new(vec![], &config, &SBPFVersion::V2).unwrap(); + let memory_mapping = MemoryMapping::new(vec![], &config, SBPFVersion::V3).unwrap(); let mut src_chunk_iter = MemoryChunkIterator::new(&memory_mapping, &[], AccessType::Load, u64::MAX, 1).unwrap(); @@ -620,9 +620,9 @@ mod tests { }; let mem1 = vec![0xFF; 42]; let memory_mapping = MemoryMapping::new( - vec![MemoryRegion::new_readonly(&mem1, MM_PROGRAM_START)], + vec![MemoryRegion::new_readonly(&mem1, MM_RODATA_START)], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -631,34 +631,34 @@ mod tests { &memory_mapping, &[], AccessType::Load, - MM_PROGRAM_START - 1, + MM_RODATA_START - 1, 42, ) .unwrap(); assert_matches!( src_chunk_iter.next().unwrap().unwrap_err().downcast_ref().unwrap(), - EbpfError::AccessViolation(AccessType::Load, addr, 42, "unknown") if *addr == MM_PROGRAM_START - 1 + EbpfError::AccessViolation(AccessType::Load, addr, 42, "unknown") if *addr == MM_RODATA_START - 1 ); // check oob at the upper bound. Since the memory mapping isn't empty, // this always happens on the second next(). let mut src_chunk_iter = - MemoryChunkIterator::new(&memory_mapping, &[], AccessType::Load, MM_PROGRAM_START, 43) + MemoryChunkIterator::new(&memory_mapping, &[], AccessType::Load, MM_RODATA_START, 43) .unwrap(); assert!(src_chunk_iter.next().unwrap().is_ok()); assert_matches!( src_chunk_iter.next().unwrap().unwrap_err().downcast_ref().unwrap(), - EbpfError::AccessViolation(AccessType::Load, addr, 43, "program") if *addr == MM_PROGRAM_START + EbpfError::AccessViolation(AccessType::Load, addr, 43, "program") if *addr == MM_RODATA_START ); // check oob at the upper bound on the first next_back() let mut src_chunk_iter = - MemoryChunkIterator::new(&memory_mapping, &[], AccessType::Load, MM_PROGRAM_START, 43) + MemoryChunkIterator::new(&memory_mapping, &[], AccessType::Load, MM_RODATA_START, 43) .unwrap() .rev(); assert_matches!( src_chunk_iter.next().unwrap().unwrap_err().downcast_ref().unwrap(), - EbpfError::AccessViolation(AccessType::Load, addr, 43, "program") if *addr == MM_PROGRAM_START + EbpfError::AccessViolation(AccessType::Load, addr, 43, "program") if *addr == MM_RODATA_START ); // check oob at the upper bound on the 2nd next_back() @@ -666,7 +666,7 @@ mod tests { &memory_mapping, &[], AccessType::Load, - MM_PROGRAM_START - 1, + MM_RODATA_START - 1, 43, ) .unwrap() @@ -674,7 +674,7 @@ mod tests { assert!(src_chunk_iter.next().unwrap().is_ok()); assert_matches!( src_chunk_iter.next().unwrap().unwrap_err().downcast_ref().unwrap(), - EbpfError::AccessViolation(AccessType::Load, addr, 43, "unknown") if *addr == MM_PROGRAM_START - 1 + EbpfError::AccessViolation(AccessType::Load, addr, 43, "unknown") if *addr == MM_RODATA_START - 1 ); } @@ -686,9 +686,9 @@ mod tests { }; let mem1 = vec![0xFF; 42]; let memory_mapping = MemoryMapping::new( - vec![MemoryRegion::new_readonly(&mem1, MM_PROGRAM_START)], + vec![MemoryRegion::new_readonly(&mem1, MM_RODATA_START)], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -697,7 +697,7 @@ mod tests { &memory_mapping, &[], AccessType::Load, - MM_PROGRAM_START - 1, + MM_RODATA_START - 1, 1, ) .unwrap(); @@ -708,18 +708,18 @@ mod tests { &memory_mapping, &[], AccessType::Load, - MM_PROGRAM_START + 42, + MM_RODATA_START + 42, 1, ) .unwrap(); assert!(src_chunk_iter.next().unwrap().is_err()); for (vm_addr, len) in [ - (MM_PROGRAM_START, 0), - (MM_PROGRAM_START + 42, 0), - (MM_PROGRAM_START, 1), - (MM_PROGRAM_START, 42), - (MM_PROGRAM_START + 41, 1), + (MM_RODATA_START, 0), + (MM_RODATA_START + 42, 0), + (MM_RODATA_START, 1), + (MM_RODATA_START, 42), + (MM_RODATA_START + 41, 1), ] { for rev in [true, false] { let iter = @@ -749,22 +749,22 @@ mod tests { let mem2 = vec![0x22; 4]; let memory_mapping = MemoryMapping::new( vec![ - MemoryRegion::new_readonly(&mem1, MM_PROGRAM_START), - MemoryRegion::new_readonly(&mem2, MM_PROGRAM_START + 8), + MemoryRegion::new_readonly(&mem1, MM_RODATA_START), + MemoryRegion::new_readonly(&mem2, MM_RODATA_START + 8), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); for (vm_addr, len, mut expected) in [ - (MM_PROGRAM_START, 8, vec![(MM_PROGRAM_START, 8)]), + (MM_RODATA_START, 8, vec![(MM_RODATA_START, 8)]), ( - MM_PROGRAM_START + 7, + MM_RODATA_START + 7, 2, - vec![(MM_PROGRAM_START + 7, 1), (MM_PROGRAM_START + 8, 1)], + vec![(MM_RODATA_START + 7, 1), (MM_RODATA_START + 8, 1)], ), - (MM_PROGRAM_START + 8, 4, vec![(MM_PROGRAM_START + 8, 4)]), + (MM_RODATA_START + 8, 4, vec![(MM_RODATA_START + 8, 4)]), ] { for rev in [false, true] { let iter = @@ -792,11 +792,11 @@ mod tests { let mem2 = vec![0x22; 4]; let memory_mapping = MemoryMapping::new( vec![ - MemoryRegion::new_readonly(&mem1, MM_PROGRAM_START), - MemoryRegion::new_readonly(&mem2, MM_PROGRAM_START + 8), + MemoryRegion::new_readonly(&mem1, MM_RODATA_START), + MemoryRegion::new_readonly(&mem2, MM_RODATA_START + 8), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -804,32 +804,32 @@ mod tests { assert_matches!( iter_memory_pair_chunks( AccessType::Load, - MM_PROGRAM_START, + MM_RODATA_START, AccessType::Load, - MM_PROGRAM_START + 8, + MM_RODATA_START + 8, 8, &[], &memory_mapping, false, |_src, _dst, _len| Ok::<_, Error>(0), ).unwrap_err().downcast_ref().unwrap(), - EbpfError::AccessViolation(AccessType::Load, addr, 8, "program") if *addr == MM_PROGRAM_START + 8 + EbpfError::AccessViolation(AccessType::Load, addr, 8, "program") if *addr == MM_RODATA_START + 8 ); // src is shorter than dst assert_matches!( iter_memory_pair_chunks( AccessType::Load, - MM_PROGRAM_START + 10, + MM_RODATA_START + 10, AccessType::Load, - MM_PROGRAM_START + 2, + MM_RODATA_START + 2, 3, &[], &memory_mapping, false, |_src, _dst, _len| Ok::<_, Error>(0), ).unwrap_err().downcast_ref().unwrap(), - EbpfError::AccessViolation(AccessType::Load, addr, 3, "program") if *addr == MM_PROGRAM_START + 10 + EbpfError::AccessViolation(AccessType::Load, addr, 3, "program") if *addr == MM_RODATA_START + 10 ); } @@ -844,17 +844,17 @@ mod tests { let mem2 = vec![0x22; 4]; let memory_mapping = MemoryMapping::new( vec![ - MemoryRegion::new_readonly(&mem1, MM_PROGRAM_START), - MemoryRegion::new_readonly(&mem2, MM_PROGRAM_START + 8), + MemoryRegion::new_readonly(&mem1, MM_RODATA_START), + MemoryRegion::new_readonly(&mem2, MM_RODATA_START + 8), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); memmove_non_contiguous( - MM_PROGRAM_START, - MM_PROGRAM_START + 8, + MM_RODATA_START, + MM_RODATA_START + 8, 4, &[], &memory_mapping, @@ -903,8 +903,8 @@ mod tests { // do our memmove memmove_non_contiguous( - MM_PROGRAM_START + dst_offset as u64, - MM_PROGRAM_START + src_offset as u64, + MM_RODATA_START + dst_offset as u64, + MM_RODATA_START + src_offset as u64, len as u64, &[], &memory_mapping, @@ -929,16 +929,16 @@ mod tests { let mem2 = vec![0x22; 4]; let memory_mapping = MemoryMapping::new( vec![ - MemoryRegion::new_writable(&mut mem1, MM_PROGRAM_START), - MemoryRegion::new_readonly(&mem2, MM_PROGRAM_START + 8), + MemoryRegion::new_writable(&mut mem1, MM_RODATA_START), + MemoryRegion::new_readonly(&mem2, MM_RODATA_START + 8), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); assert_eq!( - memset_non_contiguous(MM_PROGRAM_START, 0x33, 9, &[], &memory_mapping).unwrap(), + memset_non_contiguous(MM_RODATA_START, 0x33, 9, &[], &memory_mapping).unwrap(), 0 ); } @@ -955,18 +955,18 @@ mod tests { let mut mem4 = vec![0x44; 4]; let memory_mapping = MemoryMapping::new( vec![ - MemoryRegion::new_readonly(&mem1, MM_PROGRAM_START), - MemoryRegion::new_writable(&mut mem2, MM_PROGRAM_START + 1), - MemoryRegion::new_writable(&mut mem3, MM_PROGRAM_START + 3), - MemoryRegion::new_writable(&mut mem4, MM_PROGRAM_START + 6), + MemoryRegion::new_readonly(&mem1, MM_RODATA_START), + MemoryRegion::new_writable(&mut mem2, MM_RODATA_START + 1), + MemoryRegion::new_writable(&mut mem3, MM_RODATA_START + 3), + MemoryRegion::new_writable(&mut mem4, MM_RODATA_START + 6), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); assert_eq!( - memset_non_contiguous(MM_PROGRAM_START + 1, 0x55, 7, &[], &memory_mapping).unwrap(), + memset_non_contiguous(MM_RODATA_START + 1, 0x55, 7, &[], &memory_mapping).unwrap(), 0 ); assert_eq!(&mem1, &[0x11]); @@ -986,20 +986,20 @@ mod tests { let mem3 = b"foobarbad".to_vec(); let memory_mapping = MemoryMapping::new( vec![ - MemoryRegion::new_readonly(&mem1, MM_PROGRAM_START), - MemoryRegion::new_readonly(&mem2, MM_PROGRAM_START + 3), - MemoryRegion::new_readonly(&mem3, MM_PROGRAM_START + 9), + MemoryRegion::new_readonly(&mem1, MM_RODATA_START), + MemoryRegion::new_readonly(&mem2, MM_RODATA_START + 3), + MemoryRegion::new_readonly(&mem3, MM_RODATA_START + 9), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); // non contiguous src assert_eq!( memcmp_non_contiguous( - MM_PROGRAM_START, - MM_PROGRAM_START + 9, + MM_RODATA_START, + MM_RODATA_START + 9, 9, &[], &memory_mapping @@ -1011,8 +1011,8 @@ mod tests { // non contiguous dst assert_eq!( memcmp_non_contiguous( - MM_PROGRAM_START + 10, - MM_PROGRAM_START + 1, + MM_RODATA_START + 10, + MM_RODATA_START + 1, 8, &[], &memory_mapping @@ -1024,8 +1024,8 @@ mod tests { // diff assert_eq!( memcmp_non_contiguous( - MM_PROGRAM_START + 1, - MM_PROGRAM_START + 11, + MM_RODATA_START + 1, + MM_RODATA_START + 11, 5, &[], &memory_mapping @@ -1050,12 +1050,12 @@ mod tests { ); regs.push(MemoryRegion::new_writable( &mut mem[i], - MM_PROGRAM_START + offset as u64, + MM_RODATA_START + offset as u64, )); offset += *region_len; } - let memory_mapping = MemoryMapping::new(regs, config, &SBPFVersion::V2).unwrap(); + let memory_mapping = MemoryMapping::new(regs, config, SBPFVersion::V3).unwrap(); (mem, memory_mapping) } diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index 3438c819c74bbe..29928a6094c6b7 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -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, @@ -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::{ @@ -244,12 +245,15 @@ macro_rules! register_feature_gated_function { pub fn morph_into_deployment_environment_v1( from: Arc>, ) -> Result, Error> { - let mut config = *from.get_config(); + let mut config = from.get_config().clone(); config.reject_broken_elfs = true; + // TODO: Uncomment once the SBPF toolchain can produce v3 programs + // config.enabled_sbpf_versions = + // *config.enabled_sbpf_versions.end()..=*config.enabled_sbpf_versions.end(); let mut result = FunctionRegistry::>::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)?; @@ -284,6 +288,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, @@ -297,11 +318,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. @@ -504,10 +521,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. @@ -2191,7 +2205,7 @@ mod tests { let memory_mapping = MemoryMapping::new( vec![MemoryRegion::new_readonly(&data, START)], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2232,7 +2246,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 +2262,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::(&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::(&memory_mapping, 0x100000000, true).is_err()); } @@ -2270,7 +2284,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 +2297,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 +2322,7 @@ mod tests { 0x100000000, )], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); let translated_data = @@ -2328,7 +2342,7 @@ mod tests { 0x100000000, )], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); let translated_data = @@ -2346,7 +2360,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 +2384,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 +2399,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 +2440,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 +2507,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 +2531,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 +2714,7 @@ mod tests { MemoryRegion::new_readonly(bytes2.as_bytes(), bytes_to_hash[1].vm_addr), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2798,7 +2812,7 @@ mod tests { MemoryRegion::new_readonly(&invalid_bytes, invalid_bytes_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2871,7 +2885,7 @@ mod tests { MemoryRegion::new_readonly(&invalid_bytes, invalid_bytes_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -2958,7 +2972,7 @@ mod tests { MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3113,7 +3127,7 @@ mod tests { MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3283,7 +3297,7 @@ mod tests { MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3376,7 +3390,7 @@ mod tests { MemoryRegion::new_writable(bytes_of_slice_mut(&mut result_point), result_point_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3561,7 +3575,7 @@ mod tests { MemoryRegion::new_readonly(&Clock::id().to_bytes(), clock_id_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3627,7 +3641,7 @@ mod tests { ), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3689,7 +3703,7 @@ mod tests { got_fees_va, )], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3728,7 +3742,7 @@ mod tests { MemoryRegion::new_readonly(&Rent::id().to_bytes(), rent_id_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3788,7 +3802,7 @@ mod tests { MemoryRegion::new_readonly(&EpochRewards::id().to_bytes(), rewards_id_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3853,7 +3867,7 @@ mod tests { MemoryRegion::new_readonly(&LastRestartSlot::id().to_bytes(), restart_id_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3938,7 +3952,7 @@ mod tests { MemoryRegion::new_readonly(&StakeHistory::id().to_bytes(), history_id_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -3997,7 +4011,7 @@ mod tests { MemoryRegion::new_readonly(&SlotHashes::id().to_bytes(), hashes_id_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -4043,7 +4057,7 @@ mod tests { MemoryRegion::new_readonly(&got_clock_buf_ro, got_clock_buf_ro_va), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -4232,7 +4246,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 +4310,7 @@ mod tests { MemoryRegion::new_writable(&mut id_buffer, PROGRAM_ID_VA), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -4396,7 +4410,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::( @@ -4702,7 +4716,7 @@ mod tests { MemoryRegion::new_writable(&mut data_out, VADDR_OUT), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -4744,7 +4758,7 @@ mod tests { MemoryRegion::new_writable(&mut data_out, VADDR_OUT), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -4799,7 +4813,7 @@ mod tests { let null_pointer_var = std::ptr::null::() 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 +4877,7 @@ mod tests { MemoryRegion::new_readonly(&[2; 31], vote_address_var), ], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -4893,7 +4907,7 @@ mod tests { vote_address_var, )], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); @@ -4925,7 +4939,7 @@ mod tests { vote_address_var, )], &config, - &SBPFVersion::V2, + SBPFVersion::V3, ) .unwrap(); diff --git a/programs/bpf_loader/test_elfs/out/callx-r10-sbfv1.so b/programs/bpf_loader/test_elfs/out/sbpfv0_verifier_err.so similarity index 100% rename from programs/bpf_loader/test_elfs/out/callx-r10-sbfv1.so rename to programs/bpf_loader/test_elfs/out/sbpfv0_verifier_err.so diff --git a/programs/bpf_loader/test_elfs/out/sbpfv3_return_err.so b/programs/bpf_loader/test_elfs/out/sbpfv3_return_err.so new file mode 100644 index 0000000000000000000000000000000000000000..fac0efc9da6945c07733812ba238f7d7e31c659e GIT binary patch literal 13816 zcmeHOziSjx5T0COqNY$Ih*-!LVj;Th?cVL}6++HaK1JS9p=$}$tV2G zlYN8n^7ArHK^0I1Q~^~$6;K6K0aZX1Pz6*0RX`QkR|VejpYHF7WWM76zpuH<3-o{D z|5fq#wYUzZ3aA3AfGVI0r~;~hDxeCe0;+&2pbDr02cp1*1F51#Q~^~$6;K6K0aZX1 zPz6*0RX`O`1yli5;D1zr_5#e99RYTB4o~tT$HnLE0s!4d3)Nsy^jDLjyOPCe)(`St zui99N>Twn}tA3t%k)K4(He~BXe{-X^x?TXB<#Ekf0JKlAFEGP~!+4TW>i*c??oo)h zG1xu+oJ0HUr`bNuc!*K<;~! z1>gsIZ{k)BbC=^EF%Fd}*g~M^BA41CUZdXAGmblm)I=|Ei|lCuZoiktMGWrJVBijl zIC*SMd~+M%rkm@7%{7Zf-(bA9nt+SZB3?pV!8dI!i}2f1RArQr!l!)V%Xu65o-u5i(MBA^8eTNE%zq1Q;%{;N zx9C%o_apV?u`c61scjOu^QzYPz&`!H&=|s(`L{79wK>(mSLQz`2hrX+|JxWF#lP-b J;+H-6zW|t0$z=cl literal 0 HcmV?d00001 diff --git a/programs/bpf_loader/test_elfs/out/sbpfv3_return_ok.so b/programs/bpf_loader/test_elfs/out/sbpfv3_return_ok.so new file mode 100644 index 0000000000000000000000000000000000000000..e3cd32871d39ce9c7bcc2841c9e3fe13a0a9a807 GIT binary patch literal 14840 zcmeHO&ubG=5PnH(qxN8}AmTyxARa`Q&2F;U9E8RijaaKvQS=fv`=bfcrX(xai}vEd z|3Q!5Jrun9$LLK#Pl6um%zHC&O#@YIL2w@IelzoC=Dqj5*+AgEXU(On#X>=Gn^GmM zS!7rs3_K%D0W7FM&A@wB9Z?vmqvyzR3H8&3Gm=oiagD=x?E!Y^f!s}qvMtJ4ocA%jdu|@riqxrI(;;^6n5kJyo zUxPirUJ4Ts2801&Ko}4PgaKhd7!U@80bxKG5C-;@fo=NJ{S^?!m-N5)6^-&7^zZP0 zb(?gy@9QKanJ^#>2m``^Fdz&F1HynXAPfit!hkR!3>+u}=MOZyBo_vR0bxKG5C((+ zVL%uV2801&Ko}4Pgn@sV0Xz#ZuTKP+Sz0vN3uI^g6xmh#;d0p6n80wzJbm z6CGnPXZ*L=uR4=+HN%)x4}705+^NtUcKV@t`kDpwy!)`Zrr@SXbAnwH`W3^`c6td7wz}x zz6|wo-LPv31dPw$c|l!S`1)CAM%%3)BcJ@;7tA%fSHm9|CD6G!8Q^L3g(n}cWrv*h zh(8N%_-*Fruj`uP@%zMv{NUKUey(Hu9m4TA9{n-CMe+PSgITxn`B%V-xq1FuAY=R% z#lHa^8}AQ~KWEJ95+ILFCJj#6Xz$2~zb}}B<9Yr~u<_XBs^K%m-_ILC9-sd$uuY1; V=9<7yd&G}*iz*BV1OE{NKL8nG%0U1C literal 0 HcmV?d00001 diff --git a/programs/loader-v4/src/lib.rs b/programs/loader-v4/src/lib.rs index 78033323e2a1e7..ba96010ed698f3 100644 --- a/programs/loader-v4/src/lib.rs +++ b/programs/loader-v4/src/lib.rs @@ -572,7 +572,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Deployed, - "noop_unaligned", + "sbpfv3_return_err", ), ), ( @@ -584,7 +584,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Finalized, - "noop_unaligned", + "sbpfv3_return_err", ), ), ( @@ -670,7 +670,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_unaligned", + "sbpfv3_return_err", ), ), ( @@ -682,7 +682,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Deployed, - "noop_unaligned", + "sbpfv3_return_err", ), ), ( @@ -767,7 +767,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_unaligned", + "sbpfv3_return_err", ), ), ( @@ -780,14 +780,14 @@ mod tests { ), ( Pubkey::new_unique(), - AccountSharedData::new(40000000, 0, &loader_v4::id()), + AccountSharedData::new(0, 0, &loader_v4::id()), ), ( Pubkey::new_unique(), load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_aligned", + "sbpfv3_return_ok", ), ), ( @@ -795,7 +795,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Deployed, - "noop_unaligned", + "sbpfv3_return_err", ), ), ( @@ -807,6 +807,9 @@ mod tests { create_account_shared_data_for_test(&rent::Rent::default()), ), ]; + let smaller_program_lamports = transaction_accounts[0].1.lamports(); + let larger_program_lamports = transaction_accounts[4].1.lamports(); + assert_ne!(smaller_program_lamports, larger_program_lamports); // No change let accounts = process_instruction( @@ -829,10 +832,11 @@ mod tests { transaction_accounts[0].1.data().len(), ); assert_eq!(accounts[2].lamports(), transaction_accounts[2].1.lamports()); - let lamports = transaction_accounts[4].1.lamports(); - transaction_accounts[0].1.set_lamports(lamports); // Initialize program account + transaction_accounts[3] + .1 + .set_lamports(smaller_program_lamports); let accounts = process_instruction( vec![], &bincode::serialize(&LoaderV4Instruction::Truncate { @@ -854,6 +858,9 @@ mod tests { ); // Increase program account size + transaction_accounts[0] + .1 + .set_lamports(larger_program_lamports); let accounts = process_instruction( vec![], &bincode::serialize(&LoaderV4Instruction::Truncate { @@ -1024,7 +1031,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_aligned", + "sbpfv3_return_ok", ), ), ( @@ -1036,7 +1043,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_unaligned", + "sbpfv3_return_err", ), ), ( @@ -1048,7 +1055,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "callx-r10-sbfv1", + "sbpfv0_verifier_err", ), ), (clock::id(), clock(1000)), @@ -1172,7 +1179,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Deployed, - "noop_aligned", + "sbpfv3_return_err", ), ), ( @@ -1188,7 +1195,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_aligned", + "sbpfv3_return_err", ), ), (clock::id(), clock(1000)), @@ -1252,7 +1259,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Deployed, - "noop_aligned", + "sbpfv3_return_err", ), ), ( @@ -1260,7 +1267,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_aligned", + "sbpfv3_return_err", ), ), ( @@ -1347,7 +1354,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Deployed, - "noop_aligned", + "sbpfv3_return_err", ), ), ( @@ -1355,7 +1362,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_aligned", + "sbpfv3_return_err", ), ), ( @@ -1363,7 +1370,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Finalized, - "noop_aligned", + "sbpfv3_return_err", ), ), ( @@ -1371,7 +1378,7 @@ mod tests { load_program_account_from_elf( Pubkey::new_unique(), LoaderV4Status::Retracted, - "noop_aligned", + "sbpfv3_return_err", ), ), ( @@ -1487,7 +1494,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Finalized, - "noop_aligned", + "sbpfv3_return_ok", ), ), ( @@ -1503,7 +1510,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Retracted, - "noop_aligned", + "sbpfv3_return_ok", ), ), ( @@ -1511,7 +1518,7 @@ mod tests { load_program_account_from_elf( authority_address, LoaderV4Status::Finalized, - "callx-r10-sbfv1", + "sbpfv0_verifier_err", ), ), ]; diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index ab6585e21f4c92..1312eca3a256c2 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -8291,9 +8291,8 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1941b5ef0c3ce8f2ac5dd984d0fb1a97423c4ff2a02eec81e3913f02e2ac2b" +version = "0.8.2" +source = "git+https://github.com/solana-labs/rbpf.git#4ad935be45e5663be23b30cfc750b1ae1ad03c44" dependencies = [ "byteorder 1.5.0", "combine 3.8.1", diff --git a/programs/sbf/Cargo.toml b/programs/sbf/Cargo.toml index 4e0a84483dd427..80c548ddc70f81 100644 --- a/programs/sbf/Cargo.toml +++ b/programs/sbf/Cargo.toml @@ -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] diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 5f1f751865ebb6..038935177c12dc 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -12019,10 +12019,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 @@ -12056,7 +12056,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), ); @@ -12131,7 +12131,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 diff --git a/sdk/feature-set/src/lib.rs b/sdk/feature-set/src/lib.rs index 04fe40e5190bc3..9f56ac419dffff 100644 --- a/sdk/feature-set/src/lib.rs +++ b/sdk/feature-set/src/lib.rs @@ -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"); } @@ -1106,8 +1118,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"), diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 9a72be80f1c225..f07b1487d3650b 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -7629,9 +7629,8 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1941b5ef0c3ce8f2ac5dd984d0fb1a97423c4ff2a02eec81e3913f02e2ac2b" +version = "0.8.2" +source = "git+https://github.com/solana-labs/rbpf.git#4ad935be45e5663be23b30cfc750b1ae1ad03c44" dependencies = [ "byteorder", "combine 3.8.1", diff --git a/svm/examples/json-rpc/server/src/svm_bridge.rs b/svm/examples/json-rpc/server/src/svm_bridge.rs index c136af791c08f0..87233c2d36e559 100644 --- a/svm/examples/json-rpc/server/src/svm_bridge.rs +++ b/svm/examples/json-rpc/server/src/svm_bridge.rs @@ -13,7 +13,7 @@ use { ProgramRuntimeEnvironments, }, solana_rbpf::{ - program::{BuiltinFunction, BuiltinProgram, FunctionRegistry}, + program::{BuiltinFunction, BuiltinProgram, FunctionRegistry, SBPFVersion}, vm::Config, }, }, @@ -154,10 +154,7 @@ pub fn create_custom_environment<'a>() -> BuiltinProgram> { reject_broken_elfs: true, noop_instruction_rate: 256, sanitize_user_provided_values: true, - external_internal_function_hash_collision: false, - reject_callx_r10: false, - enable_sbpf_v1: true, - enable_sbpf_v2: false, + enabled_sbpf_versions: SBPFVersion::V0..=SBPFVersion::V3, optimize_rodata: false, aligned_memory_mapping: true, }; diff --git a/svm/tests/mock_bank.rs b/svm/tests/mock_bank.rs index 6cd692133d219b..03ff7e49058084 100644 --- a/svm/tests/mock_bank.rs +++ b/svm/tests/mock_bank.rs @@ -12,7 +12,7 @@ use { invoke_context::InvokeContext, loaded_programs::{BlockRelation, ForkGraph, ProgramCacheEntry}, solana_rbpf::{ - program::{BuiltinFunction, BuiltinProgram, FunctionRegistry}, + program::{BuiltinFunction, BuiltinProgram, FunctionRegistry, SBPFVersion}, vm::Config, }, }, @@ -302,10 +302,7 @@ pub fn create_custom_loader<'a>() -> BuiltinProgram> { reject_broken_elfs: true, noop_instruction_rate: 256, sanitize_user_provided_values: true, - external_internal_function_hash_collision: false, - reject_callx_r10: true, - enable_sbpf_v1: true, - enable_sbpf_v2: false, + enabled_sbpf_versions: SBPFVersion::V0..=SBPFVersion::V3, optimize_rodata: false, aligned_memory_mapping: true, };