Cleanup nits (#16211)
This commit is contained in:
2
programs/bpf/Cargo.lock
generated
2
programs/bpf/Cargo.lock
generated
@ -2863,7 +2863,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "solana-bpf-rust-sysval"
|
name = "solana-bpf-rust-sysvar"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"solana-program 1.7.0",
|
"solana-program 1.7.0",
|
||||||
|
@ -73,7 +73,7 @@ members = [
|
|||||||
"rust/sha256",
|
"rust/sha256",
|
||||||
"rust/spoof1",
|
"rust/spoof1",
|
||||||
"rust/spoof1_system",
|
"rust/spoof1_system",
|
||||||
"rust/sysval",
|
"rust/sysvar",
|
||||||
"rust/upgradeable",
|
"rust/upgradeable",
|
||||||
"rust/upgraded",
|
"rust/upgraded",
|
||||||
]
|
]
|
||||||
|
@ -88,7 +88,7 @@ fn main() {
|
|||||||
"sha256",
|
"sha256",
|
||||||
"spoof1",
|
"spoof1",
|
||||||
"spoof1_system",
|
"spoof1_system",
|
||||||
"sysval",
|
"sysvar",
|
||||||
"upgradeable",
|
"upgradeable",
|
||||||
"upgraded",
|
"upgraded",
|
||||||
];
|
];
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solana-bpf-rust-sysval"
|
name = "solana-bpf-rust-sysvar"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
description = "Solana BPF test program written in Rust"
|
description = "Solana BPF test program written in Rust"
|
||||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
||||||
repository = "https://github.com/solana-labs/solana"
|
repository = "https://github.com/solana-labs/solana"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
homepage = "https://solana.com/"
|
homepage = "https://solana.com/"
|
||||||
documentation = "https://docs.rs/solana-bpf-rust-sysval"
|
documentation = "https://docs.rs/solana-bpf-rust-sysvar"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[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;
|
extern crate solana_program;
|
||||||
use solana_program::{
|
use solana_program::{
|
@ -438,7 +438,7 @@ fn test_program_bpf_sanity() {
|
|||||||
("solana_bpf_rust_ristretto", true),
|
("solana_bpf_rust_ristretto", true),
|
||||||
("solana_bpf_rust_sanity", true),
|
("solana_bpf_rust_sanity", true),
|
||||||
("solana_bpf_rust_sha256", true),
|
("solana_bpf_rust_sha256", true),
|
||||||
("solana_bpf_rust_sysval", true),
|
("solana_bpf_rust_sysvar", true),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,13 +111,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_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(
|
syscall_registry.register_syscall_by_name(
|
||||||
b"sol_create_program_address",
|
b"sol_create_program_address",
|
||||||
SyscallCreateProgramAddress::call,
|
SyscallCreateProgramAddress::call,
|
||||||
@ -126,6 +119,14 @@ pub fn register_syscalls(
|
|||||||
b"sol_try_find_program_address",
|
b"sol_try_find_program_address",
|
||||||
SyscallTryFindProgramAddress::call,
|
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
|
syscall_registry
|
||||||
.register_syscall_by_name(b"sol_invoke_signed_c", SyscallInvokeSignedC::call)?;
|
.register_syscall_by_name(b"sol_invoke_signed_c", SyscallInvokeSignedC::call)?;
|
||||||
syscall_registry
|
syscall_registry
|
||||||
@ -203,6 +204,24 @@ pub fn bind_syscall_context_objects<'a>(
|
|||||||
None,
|
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(
|
vm.bind_syscall_context_object(
|
||||||
Box::new(SyscallSha256 {
|
Box::new(SyscallSha256 {
|
||||||
sha256_base_cost: bpf_compute_budget.sha256_base_cost,
|
sha256_base_cost: bpf_compute_budget.sha256_base_cost,
|
||||||
@ -224,24 +243,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
|
// Cross-program invocation syscalls
|
||||||
|
|
||||||
let invoke_context = Rc::new(RefCell::new(invoke_context));
|
let invoke_context = Rc::new(RefCell::new(invoke_context));
|
||||||
|
@ -176,30 +176,39 @@ pub enum InstructionError {
|
|||||||
#[error("Cross-program invocation with unauthorized signer or writable account")]
|
#[error("Cross-program invocation with unauthorized signer or writable account")]
|
||||||
PrivilegeEscalation,
|
PrivilegeEscalation,
|
||||||
|
|
||||||
|
/// Failed to create program execution environment
|
||||||
#[error("Failed to create program execution environment")]
|
#[error("Failed to create program execution environment")]
|
||||||
ProgramEnvironmentSetupFailure,
|
ProgramEnvironmentSetupFailure,
|
||||||
|
|
||||||
|
/// Program failed to complete
|
||||||
#[error("Program failed to complete")]
|
#[error("Program failed to complete")]
|
||||||
ProgramFailedToComplete,
|
ProgramFailedToComplete,
|
||||||
|
|
||||||
|
/// Program failed to compile
|
||||||
#[error("Program failed to compile")]
|
#[error("Program failed to compile")]
|
||||||
ProgramFailedToCompile,
|
ProgramFailedToCompile,
|
||||||
|
|
||||||
|
/// Account is immutable
|
||||||
#[error("Account is immutable")]
|
#[error("Account is immutable")]
|
||||||
Immutable,
|
Immutable,
|
||||||
|
|
||||||
|
/// Incorrect authority provided
|
||||||
#[error("Incorrect authority provided")]
|
#[error("Incorrect authority provided")]
|
||||||
IncorrectAuthority,
|
IncorrectAuthority,
|
||||||
|
|
||||||
|
/// Failed to serialize or deserialize account data
|
||||||
#[error("Failed to serialize or deserialize account data: {0}")]
|
#[error("Failed to serialize or deserialize account data: {0}")]
|
||||||
BorshIoError(String),
|
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")]
|
#[error("An account does not have enough lamports to be rent-exempt")]
|
||||||
AccountNotRentExempt,
|
AccountNotRentExempt,
|
||||||
|
|
||||||
|
/// Invalid account owner
|
||||||
#[error("Invalid account owner")]
|
#[error("Invalid account owner")]
|
||||||
InvalidAccountOwner,
|
InvalidAccountOwner,
|
||||||
|
|
||||||
|
/// Program arithmetic overflowed
|
||||||
#[error("Program arithmetic overflowed")]
|
#[error("Program arithmetic overflowed")]
|
||||||
ArithmeticOverflow,
|
ArithmeticOverflow,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user