Remove unactivated ristretto syscall (#16727)
This commit is contained in:
parent
639650ed2c
commit
be4df39a4c
|
@ -4039,7 +4039,6 @@ version = "1.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"curve25519-dalek 3.0.0",
|
|
||||||
"log 0.4.11",
|
"log 0.4.11",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
|
|
@ -2714,7 +2714,6 @@ version = "1.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"byteorder 1.3.4",
|
"byteorder 1.3.4",
|
||||||
"curve25519-dalek 3.0.0",
|
|
||||||
"log",
|
"log",
|
||||||
"num-derive 0.3.0",
|
"num-derive 0.3.0",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
@ -2947,15 +2946,6 @@ dependencies = [
|
||||||
"solana-program 1.7.0",
|
"solana-program 1.7.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "solana-bpf-rust-ristretto"
|
|
||||||
version = "1.7.0"
|
|
||||||
dependencies = [
|
|
||||||
"curve25519-dalek 3.0.0",
|
|
||||||
"getrandom 0.1.14",
|
|
||||||
"solana-program 1.7.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "solana-bpf-rust-ro-modify"
|
name = "solana-bpf-rust-ro-modify"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
|
|
|
@ -68,7 +68,6 @@ members = [
|
||||||
"rust/param_passing",
|
"rust/param_passing",
|
||||||
"rust/param_passing_dep",
|
"rust/param_passing_dep",
|
||||||
"rust/rand",
|
"rust/rand",
|
||||||
"rust/ristretto",
|
|
||||||
"rust/ro_modify",
|
"rust/ro_modify",
|
||||||
"rust/sanity",
|
"rust/sanity",
|
||||||
"rust/sha256",
|
"rust/sha256",
|
||||||
|
|
|
@ -82,7 +82,6 @@ fn main() {
|
||||||
"panic",
|
"panic",
|
||||||
"param_passing",
|
"param_passing",
|
||||||
"rand",
|
"rand",
|
||||||
"ristretto",
|
|
||||||
"ro_modify",
|
"ro_modify",
|
||||||
"sanity",
|
"sanity",
|
||||||
"sha256",
|
"sha256",
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "solana-bpf-rust-ristretto"
|
|
||||||
version = "1.7.0"
|
|
||||||
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-ristretto"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
curve25519-dalek = "3"
|
|
||||||
getrandom = { version = "0.1.14", features = ["dummy"] }
|
|
||||||
solana-program = { path = "../../../../sdk/program", version = "=1.7.0" }
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
|
|
@ -1,46 +0,0 @@
|
||||||
//! @brief Example Rust-based BPF program that performs a ristretto multiply
|
|
||||||
|
|
||||||
pub mod ristretto;
|
|
||||||
|
|
||||||
use crate::ristretto::ristretto_mul;
|
|
||||||
use curve25519_dalek::{constants::RISTRETTO_BASEPOINT_POINT, scalar::Scalar};
|
|
||||||
use solana_program::{
|
|
||||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn test_ristretto_mul() -> ProgramResult {
|
|
||||||
let point = RISTRETTO_BASEPOINT_POINT;
|
|
||||||
let scalar = Scalar::zero();
|
|
||||||
let result = ristretto_mul(&point, &scalar)?;
|
|
||||||
assert_ne!(point, result);
|
|
||||||
|
|
||||||
let point = RISTRETTO_BASEPOINT_POINT;
|
|
||||||
let scalar = Scalar::one();
|
|
||||||
let result = ristretto_mul(&point, &scalar)?;
|
|
||||||
assert_eq!(point, result);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
entrypoint!(process_instruction);
|
|
||||||
fn process_instruction(
|
|
||||||
_program_id: &Pubkey,
|
|
||||||
_accounts: &[AccountInfo],
|
|
||||||
_instruction_data: &[u8],
|
|
||||||
) -> ProgramResult {
|
|
||||||
msg!("Ristretto multiply");
|
|
||||||
|
|
||||||
test_ristretto_mul()?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_ristretto() {
|
|
||||||
test_ristretto_mul().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
|
|
||||||
use solana_program::program_error::ProgramError;
|
|
||||||
|
|
||||||
/// Multiply a ristretto point with a scalar
|
|
||||||
///
|
|
||||||
/// @param point - Ristretto point
|
|
||||||
/// @param scalar - Scalar to mulitply against
|
|
||||||
/// @return - result of the multiplication
|
|
||||||
#[inline]
|
|
||||||
pub fn ristretto_mul(
|
|
||||||
point: &RistrettoPoint,
|
|
||||||
scalar: &Scalar,
|
|
||||||
) -> Result<RistrettoPoint, ProgramError> {
|
|
||||||
// Perform the calculation inline, calling this from within a program is
|
|
||||||
// not supported
|
|
||||||
#[cfg(not(target_arch = "bpf"))]
|
|
||||||
{
|
|
||||||
Ok(point * scalar)
|
|
||||||
}
|
|
||||||
// Call via a system call to perform the calculation
|
|
||||||
#[cfg(target_arch = "bpf")]
|
|
||||||
{
|
|
||||||
extern "C" {
|
|
||||||
fn sol_ristretto_mul(
|
|
||||||
point_addr: *const u8,
|
|
||||||
scalar_addr: *const u8,
|
|
||||||
result_addr: *mut u8,
|
|
||||||
) -> u64;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut result = RistrettoPoint::default();
|
|
||||||
let status = unsafe {
|
|
||||||
sol_ristretto_mul(
|
|
||||||
point as *const _ as *const u8,
|
|
||||||
scalar as *const _ as *const u8,
|
|
||||||
&mut result as *const _ as *mut u8,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
match status {
|
|
||||||
solana_program::entrypoint::SUCCESS => Ok(result),
|
|
||||||
_ => Err(status.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,7 +30,6 @@ use solana_sdk::{
|
||||||
client::SyncClient,
|
client::SyncClient,
|
||||||
clock::MAX_PROCESSING_AGE,
|
clock::MAX_PROCESSING_AGE,
|
||||||
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||||
feature_set::ristretto_mul_syscall_enabled,
|
|
||||||
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
||||||
keyed_account::KeyedAccount,
|
keyed_account::KeyedAccount,
|
||||||
message::Message,
|
message::Message,
|
||||||
|
@ -443,7 +442,6 @@ fn test_program_bpf_sanity() {
|
||||||
("solana_bpf_rust_panic", false),
|
("solana_bpf_rust_panic", false),
|
||||||
("solana_bpf_rust_param_passing", true),
|
("solana_bpf_rust_param_passing", true),
|
||||||
("solana_bpf_rust_rand", true),
|
("solana_bpf_rust_rand", 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),
|
||||||
]);
|
]);
|
||||||
|
@ -1258,7 +1256,6 @@ fn assert_instruction_count() {
|
||||||
("solana_bpf_rust_noop", 472),
|
("solana_bpf_rust_noop", 472),
|
||||||
("solana_bpf_rust_param_passing", 46),
|
("solana_bpf_rust_param_passing", 46),
|
||||||
("solana_bpf_rust_rand", 475),
|
("solana_bpf_rust_rand", 475),
|
||||||
("solana_bpf_rust_ristretto", 19220),
|
|
||||||
("solana_bpf_rust_sanity", 869),
|
("solana_bpf_rust_sanity", 869),
|
||||||
("solana_bpf_rust_sha256", 10830),
|
("solana_bpf_rust_sha256", 10830),
|
||||||
]);
|
]);
|
||||||
|
@ -2319,44 +2316,6 @@ fn test_program_upgradeable_locks() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bpf_rust")]
|
|
||||||
#[test]
|
|
||||||
fn test_program_bpf_syscall_feature_activation() {
|
|
||||||
solana_logger::setup();
|
|
||||||
|
|
||||||
let GenesisConfigInfo {
|
|
||||||
genesis_config,
|
|
||||||
mint_keypair,
|
|
||||||
..
|
|
||||||
} = create_genesis_config(50);
|
|
||||||
let mut bank = Bank::new(&genesis_config);
|
|
||||||
bank.deactivate_feature(&ristretto_mul_syscall_enabled::id());
|
|
||||||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
|
||||||
bank.add_builtin(&name, id, entrypoint);
|
|
||||||
let bank = Arc::new(bank);
|
|
||||||
let bank_client = BankClient::new_shared(&bank);
|
|
||||||
|
|
||||||
let program_id = load_bpf_program(
|
|
||||||
&bank_client,
|
|
||||||
&bpf_loader::id(),
|
|
||||||
&mint_keypair,
|
|
||||||
"solana_bpf_rust_noop",
|
|
||||||
);
|
|
||||||
let instruction = Instruction::new_with_bytes(program_id, &[0], vec![]);
|
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
|
||||||
assert!(result.is_ok());
|
|
||||||
|
|
||||||
let mut bank = Bank::new_from_parent(&bank, &Pubkey::default(), 1);
|
|
||||||
bank.activate_feature(&ristretto_mul_syscall_enabled::id());
|
|
||||||
|
|
||||||
let bank = Arc::new(bank);
|
|
||||||
let bank_client = BankClient::new_shared(&bank);
|
|
||||||
let instruction = Instruction::new_with_bytes(program_id, &[1], vec![]);
|
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
|
||||||
println!("result: {:?}", result);
|
|
||||||
assert!(result.is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "bpf_rust")]
|
#[cfg(feature = "bpf_rust")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_program_bpf_finalize() {
|
fn test_program_bpf_finalize() {
|
||||||
|
|
|
@ -12,7 +12,6 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
byteorder = "1.3.4"
|
byteorder = "1.3.4"
|
||||||
curve25519-dalek = "3"
|
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
num-derive = "0.3"
|
num-derive = "0.3"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{alloc, BpfError};
|
use crate::{alloc, BpfError};
|
||||||
use alloc::Alloc;
|
use alloc::Alloc;
|
||||||
use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
|
|
||||||
use solana_rbpf::{
|
use solana_rbpf::{
|
||||||
aligned_memory::AlignedMemory,
|
aligned_memory::AlignedMemory,
|
||||||
ebpf::MM_HEAP_START,
|
ebpf::MM_HEAP_START,
|
||||||
|
@ -21,8 +20,7 @@ use solana_sdk::{
|
||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
feature_set::{
|
feature_set::{
|
||||||
cpi_data_cost, cpi_share_ro_and_exec_accounts, demote_sysvar_write_locks,
|
cpi_data_cost, cpi_share_ro_and_exec_accounts, demote_sysvar_write_locks,
|
||||||
enforce_aligned_host_addrs, ristretto_mul_syscall_enabled,
|
enforce_aligned_host_addrs, set_upgrade_authority_via_cpi_enabled, sysvar_via_syscall,
|
||||||
set_upgrade_authority_via_cpi_enabled, sysvar_via_syscall,
|
|
||||||
},
|
},
|
||||||
hash::{Hasher, HASH_BYTES},
|
hash::{Hasher, HASH_BYTES},
|
||||||
ic_msg,
|
ic_msg,
|
||||||
|
@ -128,11 +126,6 @@ pub fn register_syscalls(
|
||||||
|
|
||||||
syscall_registry.register_syscall_by_name(b"sol_sha256", SyscallSha256::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)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if invoke_context.is_feature_active(&sysvar_via_syscall::id()) {
|
if invoke_context.is_feature_active(&sysvar_via_syscall::id()) {
|
||||||
syscall_registry
|
syscall_registry
|
||||||
.register_syscall_by_name(b"sol_get_clock_sysvar", SyscallGetClockSysvar::call)?;
|
.register_syscall_by_name(b"sol_get_clock_sysvar", SyscallGetClockSysvar::call)?;
|
||||||
|
@ -258,17 +251,6 @@ pub fn bind_syscall_context_objects<'a>(
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
bind_feature_gated_syscall_context_object!(
|
|
||||||
vm,
|
|
||||||
invoke_context.is_feature_active(&ristretto_mul_syscall_enabled::id()),
|
|
||||||
Box::new(SyscallRistrettoMul {
|
|
||||||
cost: 0,
|
|
||||||
compute_meter: invoke_context.get_compute_meter(),
|
|
||||||
loader_id,
|
|
||||||
enforce_aligned_host_addrs,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
let is_sysvar_via_syscall_active = invoke_context.is_feature_active(&sysvar_via_syscall::id());
|
let is_sysvar_via_syscall_active = invoke_context.is_feature_active(&sysvar_via_syscall::id());
|
||||||
|
|
||||||
let invoke_context = Rc::new(RefCell::new(invoke_context));
|
let invoke_context = Rc::new(RefCell::new(invoke_context));
|
||||||
|
@ -951,59 +933,6 @@ impl<'a> SyscallObject<BpfError> for SyscallSha256<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ristretto point multiply
|
|
||||||
pub struct SyscallRistrettoMul<'a> {
|
|
||||||
cost: u64,
|
|
||||||
compute_meter: Rc<RefCell<dyn ComputeMeter>>,
|
|
||||||
loader_id: &'a Pubkey,
|
|
||||||
enforce_aligned_host_addrs: bool,
|
|
||||||
}
|
|
||||||
impl<'a> SyscallObject<BpfError> for SyscallRistrettoMul<'a> {
|
|
||||||
fn call(
|
|
||||||
&mut self,
|
|
||||||
point_addr: u64,
|
|
||||||
scalar_addr: u64,
|
|
||||||
result_addr: u64,
|
|
||||||
_arg4: u64,
|
|
||||||
_arg5: u64,
|
|
||||||
memory_mapping: &MemoryMapping,
|
|
||||||
result: &mut Result<u64, EbpfError<BpfError>>,
|
|
||||||
) {
|
|
||||||
question_mark!(self.compute_meter.consume(self.cost), result);
|
|
||||||
|
|
||||||
let point = question_mark!(
|
|
||||||
translate_type::<RistrettoPoint>(
|
|
||||||
memory_mapping,
|
|
||||||
point_addr,
|
|
||||||
self.loader_id,
|
|
||||||
self.enforce_aligned_host_addrs,
|
|
||||||
),
|
|
||||||
result
|
|
||||||
);
|
|
||||||
let scalar = question_mark!(
|
|
||||||
translate_type::<Scalar>(
|
|
||||||
memory_mapping,
|
|
||||||
scalar_addr,
|
|
||||||
self.loader_id,
|
|
||||||
self.enforce_aligned_host_addrs,
|
|
||||||
),
|
|
||||||
result
|
|
||||||
);
|
|
||||||
let output = question_mark!(
|
|
||||||
translate_type_mut::<RistrettoPoint>(
|
|
||||||
memory_mapping,
|
|
||||||
result_addr,
|
|
||||||
self.loader_id,
|
|
||||||
self.enforce_aligned_host_addrs,
|
|
||||||
),
|
|
||||||
result
|
|
||||||
);
|
|
||||||
*output = point * scalar;
|
|
||||||
|
|
||||||
*result = Ok(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_sysvar<T: std::fmt::Debug + Sysvar + SysvarId>(
|
fn get_sysvar<T: std::fmt::Debug + Sysvar + SysvarId>(
|
||||||
id: &Pubkey,
|
id: &Pubkey,
|
||||||
var_addr: u64,
|
var_addr: u64,
|
||||||
|
|
|
@ -51,10 +51,6 @@ pub mod no_overflow_rent_distribution {
|
||||||
solana_sdk::declare_id!("4kpdyrcj5jS47CZb2oJGfVxjYbsMm2Kx97gFyZrxxwXz");
|
solana_sdk::declare_id!("4kpdyrcj5jS47CZb2oJGfVxjYbsMm2Kx97gFyZrxxwXz");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod ristretto_mul_syscall_enabled {
|
|
||||||
solana_sdk::declare_id!("HRe7A6aoxgjKzdjbBv6HTy7tJ4YWqE6tVmYCGho6S9Aq");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod pull_request_ping_pong_check {
|
pub mod pull_request_ping_pong_check {
|
||||||
solana_sdk::declare_id!("5RzEHTnf6D7JPZCvwEzjM19kzBsyjSU3HoMfXaQmVgnZ");
|
solana_sdk::declare_id!("5RzEHTnf6D7JPZCvwEzjM19kzBsyjSU3HoMfXaQmVgnZ");
|
||||||
}
|
}
|
||||||
|
@ -153,7 +149,6 @@ lazy_static! {
|
||||||
(full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"),
|
(full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"),
|
||||||
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
||||||
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
||||||
(ristretto_mul_syscall_enabled::id(), "ristretto multiply syscall"),
|
|
||||||
(pull_request_ping_pong_check::id(), "ping-pong packet check #12794"),
|
(pull_request_ping_pong_check::id(), "ping-pong packet check #12794"),
|
||||||
(stake_program_v2::id(), "solana_stake_program v2"),
|
(stake_program_v2::id(), "solana_stake_program v2"),
|
||||||
(rewrite_stake::id(), "rewrite stake"),
|
(rewrite_stake::id(), "rewrite stake"),
|
||||||
|
|
Loading…
Reference in New Issue