* Cleanup nits (#16211)
(cherry picked from commit f84e88f0a2
)
# Conflicts:
# programs/bpf/Cargo.lock
# programs/bpf/rust/sysvar/Cargo.toml
* resolve conflicts
Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
2
programs/bpf/Cargo.lock
generated
2
programs/bpf/Cargo.lock
generated
@ -2863,7 +2863,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-bpf-rust-sysval"
|
||||
name = "solana-bpf-rust-sysvar"
|
||||
version = "1.6.3"
|
||||
dependencies = [
|
||||
"solana-program 1.6.3",
|
||||
|
@ -73,7 +73,7 @@ members = [
|
||||
"rust/sha256",
|
||||
"rust/spoof1",
|
||||
"rust/spoof1_system",
|
||||
"rust/sysval",
|
||||
"rust/sysvar",
|
||||
"rust/upgradeable",
|
||||
"rust/upgraded",
|
||||
]
|
||||
|
@ -88,7 +88,7 @@ fn main() {
|
||||
"sha256",
|
||||
"spoof1",
|
||||
"spoof1_system",
|
||||
"sysval",
|
||||
"sysvar",
|
||||
"upgradeable",
|
||||
"upgraded",
|
||||
];
|
||||
|
@ -1,12 +1,12 @@
|
||||
[package]
|
||||
name = "solana-bpf-rust-sysval"
|
||||
name = "solana-bpf-rust-sysvar"
|
||||
version = "1.6.3"
|
||||
description = "Solana BPF test program written in Rust"
|
||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
documentation = "https://docs.rs/solana-bpf-rust-sysval"
|
||||
documentation = "https://docs.rs/solana-bpf-rust-sysvar"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
@ -1,4 +1,4 @@
|
||||
//! @brief Example Rust-based BPF program that tests sysval use
|
||||
//! @brief Example Rust-based BPF program that tests sysvar use
|
||||
|
||||
extern crate solana_program;
|
||||
use solana_program::{
|
@ -438,7 +438,7 @@ fn test_program_bpf_sanity() {
|
||||
("solana_bpf_rust_ristretto", true),
|
||||
("solana_bpf_rust_sanity", true),
|
||||
("solana_bpf_rust_sha256", true),
|
||||
("solana_bpf_rust_sysval", true),
|
||||
("solana_bpf_rust_sysvar", true),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -108,13 +108,6 @@ pub fn register_syscalls(
|
||||
|
||||
syscall_registry.register_syscall_by_name(b"sol_log_pubkey", SyscallLogPubkey::call)?;
|
||||
|
||||
syscall_registry.register_syscall_by_name(b"sol_sha256", SyscallSha256::call)?;
|
||||
|
||||
if invoke_context.is_feature_active(&ristretto_mul_syscall_enabled::id()) {
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_ristretto_mul", SyscallRistrettoMul::call)?;
|
||||
}
|
||||
|
||||
syscall_registry.register_syscall_by_name(
|
||||
b"sol_create_program_address",
|
||||
SyscallCreateProgramAddress::call,
|
||||
@ -123,6 +116,14 @@ pub fn register_syscalls(
|
||||
b"sol_try_find_program_address",
|
||||
SyscallTryFindProgramAddress::call,
|
||||
)?;
|
||||
|
||||
syscall_registry.register_syscall_by_name(b"sol_sha256", SyscallSha256::call)?;
|
||||
|
||||
if invoke_context.is_feature_active(&ristretto_mul_syscall_enabled::id()) {
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_ristretto_mul", SyscallRistrettoMul::call)?;
|
||||
}
|
||||
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_invoke_signed_c", SyscallInvokeSignedC::call)?;
|
||||
syscall_registry
|
||||
@ -200,6 +201,24 @@ pub fn bind_syscall_context_objects<'a>(
|
||||
None,
|
||||
)?;
|
||||
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallCreateProgramAddress {
|
||||
cost: bpf_compute_budget.create_program_address_units,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
}),
|
||||
None,
|
||||
)?;
|
||||
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallTryFindProgramAddress {
|
||||
cost: bpf_compute_budget.create_program_address_units,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
}),
|
||||
None,
|
||||
)?;
|
||||
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallSha256 {
|
||||
sha256_base_cost: bpf_compute_budget.sha256_base_cost,
|
||||
@ -221,24 +240,6 @@ pub fn bind_syscall_context_objects<'a>(
|
||||
}),
|
||||
);
|
||||
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallCreateProgramAddress {
|
||||
cost: bpf_compute_budget.create_program_address_units,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
}),
|
||||
None,
|
||||
)?;
|
||||
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallTryFindProgramAddress {
|
||||
cost: bpf_compute_budget.create_program_address_units,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
}),
|
||||
None,
|
||||
)?;
|
||||
|
||||
// Cross-program invocation syscalls
|
||||
|
||||
let invoke_context = Rc::new(RefCell::new(invoke_context));
|
||||
|
@ -175,30 +175,39 @@ pub enum InstructionError {
|
||||
#[error("Cross-program invocation with unauthorized signer or writable account")]
|
||||
PrivilegeEscalation,
|
||||
|
||||
/// Failed to create program execution environment
|
||||
#[error("Failed to create program execution environment")]
|
||||
ProgramEnvironmentSetupFailure,
|
||||
|
||||
/// Program failed to complete
|
||||
#[error("Program failed to complete")]
|
||||
ProgramFailedToComplete,
|
||||
|
||||
/// Program failed to compile
|
||||
#[error("Program failed to compile")]
|
||||
ProgramFailedToCompile,
|
||||
|
||||
/// Account is immutable
|
||||
#[error("Account is immutable")]
|
||||
Immutable,
|
||||
|
||||
/// Incorrect authority provided
|
||||
#[error("Incorrect authority provided")]
|
||||
IncorrectAuthority,
|
||||
|
||||
/// Failed to serialize or deserialize account data
|
||||
#[error("Failed to serialize or deserialize account data: {0}")]
|
||||
BorshIoError(String),
|
||||
|
||||
/// An account does not have enough lamports to be rent-exempt
|
||||
#[error("An account does not have enough lamports to be rent-exempt")]
|
||||
AccountNotRentExempt,
|
||||
|
||||
/// Invalid account owner
|
||||
#[error("Invalid account owner")]
|
||||
InvalidAccountOwner,
|
||||
|
||||
/// Program arithmetic overflowed
|
||||
#[error("Program arithmetic overflowed")]
|
||||
ArithmeticOverflow,
|
||||
}
|
||||
|
Reference in New Issue
Block a user