Update shared-memory to latest solana-program/solana-sdk
This commit is contained in:
parent
6fde6e0cda
commit
8ad2512de6
|
@ -170,7 +170,7 @@ jobs:
|
|||
toolchain: 1.47.0 # MSRV
|
||||
override: true
|
||||
profile: minimal
|
||||
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||
|
@ -206,8 +206,6 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
path:
|
||||
- shared-memory/client
|
||||
- token/perf-monitor
|
||||
- themis/client_ristretto
|
||||
|
||||
steps:
|
||||
|
@ -360,4 +358,4 @@ jobs:
|
|||
npm run localnet:update
|
||||
npm run localnet:up
|
||||
- run: npm run start
|
||||
- run: npm run localnet:down
|
||||
- run: npm run localnet:down
|
||||
|
|
|
@ -11,7 +11,6 @@ fi
|
|||
|
||||
workspace_crates=(
|
||||
Cargo.toml
|
||||
shared-memory/client/Cargo.toml
|
||||
themis/client_ristretto/Cargo.toml
|
||||
token/perf-monitor/Cargo.toml
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,16 +0,0 @@
|
|||
[package]
|
||||
name = "spl_shared_memory_client"
|
||||
version = "0.0.1"
|
||||
description = "SPL Shared-memory client"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana-program-library"
|
||||
license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dev-dependencies]
|
||||
rand = { version = "0.7.0"}
|
||||
spl-shared-memory = { path = "../program" }
|
||||
solana-bpf-loader-program = "1.4.3"
|
||||
solana_rbpf = "=0.1.32"
|
||||
solana-runtime = "1.4.3"
|
||||
solana-sdk = "1.4.3"
|
|
@ -1,10 +0,0 @@
|
|||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:warning=(not a warning) Building BPF shared-memory program");
|
||||
Command::new("cargo")
|
||||
.arg("build-bpf")
|
||||
.status()
|
||||
.expect("Failed to build BPF shared-memory program")
|
||||
.success();
|
||||
}
|
|
@ -11,5 +11,10 @@ edition = "2018"
|
|||
arrayref = "0.3.6"
|
||||
solana-program = "1.4.3"
|
||||
|
||||
[dev-dependencies]
|
||||
solana-bpf-loader-program = "1.5.0"
|
||||
solana-sdk = "1.5.0"
|
||||
solana_rbpf = "=0.1.32"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("XARGO").is_err() {
|
||||
println!("cargo:warning=(not a warning) Building BPF shared-memory program");
|
||||
Command::new("cargo")
|
||||
.arg("build-bpf")
|
||||
.status()
|
||||
.expect("Failed to build BPF shared-memory program")
|
||||
.success();
|
||||
}
|
||||
}
|
|
@ -39,7 +39,9 @@ fn fast_copy(mut src: &[u8], mut dst: &mut [u8]) {
|
|||
/// Deserializes only the particular input parameters that the shared memory
|
||||
/// program uses. For more information about the format of the serialized input
|
||||
/// parameters see `solana_sdk::entrypoint::deserialize`
|
||||
unsafe fn deserialize_input_parametes<'a>(input: *mut u8) -> Result<(&'a mut [u8], &'a [u8]), u64> {
|
||||
unsafe fn deserialize_input_parameters<'a>(
|
||||
input: *mut u8,
|
||||
) -> Result<(&'a mut [u8], &'a [u8]), u64> {
|
||||
// Only one account expected
|
||||
let num_accounts = read(input as *const u64);
|
||||
if num_accounts == 0 {
|
||||
|
@ -90,7 +92,7 @@ unsafe fn deserialize_input_parametes<'a>(input: *mut u8) -> Result<(&'a mut [u8
|
|||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn entrypoint(input: *mut u8) -> u64 {
|
||||
match deserialize_input_parametes(input) {
|
||||
match deserialize_input_parameters(input) {
|
||||
Ok((account_data, instruction_data)) => {
|
||||
if instruction_data.len() < 8 {
|
||||
return ProgramError::AccountDataTooSmall.into();
|
||||
|
|
|
@ -2,29 +2,23 @@ use solana_bpf_loader_program::{
|
|||
create_vm,
|
||||
serialization::{deserialize_parameters, serialize_parameters},
|
||||
};
|
||||
use solana_rbpf::vm::{EbpfVm, InstructionMeter};
|
||||
use solana_runtime::process_instruction::{
|
||||
ComputeBudget, ComputeMeter, Executor, InvokeContext, Logger, ProcessInstruction,
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::{Account, KeyedAccount},
|
||||
bpf_loader,
|
||||
entrypoint::SUCCESS,
|
||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||
message::Message,
|
||||
program_error::ProgramError,
|
||||
use solana_program::{
|
||||
bpf_loader, entrypoint::SUCCESS, instruction::InstructionError, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
use solana_rbpf::vm::EbpfVm;
|
||||
use solana_sdk::{
|
||||
account::Account, keyed_account::KeyedAccount, process_instruction::MockInvokeContext,
|
||||
};
|
||||
use spl_shared_memory::entrypoint;
|
||||
|
||||
use std::{cell::RefCell, fs::File, io::Read, path::PathBuf, rc::Rc, sync::Arc};
|
||||
use std::{fs::File, io::Read, path::PathBuf};
|
||||
|
||||
fn load_program(name: &str) -> Vec<u8> {
|
||||
let mut path = PathBuf::new();
|
||||
path.push("../../target/bpfel-unknown-unknown/release");
|
||||
path.push(name);
|
||||
path.set_extension("so");
|
||||
let mut file = File::open(path).unwrap();
|
||||
let mut file = File::open(&path)
|
||||
.unwrap_or_else(|err| panic!("Unable to open {}: {}", path.display(), err));
|
||||
|
||||
let mut program = Vec::new();
|
||||
file.read_to_end(&mut program).unwrap();
|
||||
|
@ -189,79 +183,3 @@ fn test_share_data() {
|
|||
u64::from(ProgramError::AccountDataTooSmall)
|
||||
);
|
||||
}
|
||||
|
||||
// Mock InvokeContext
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct MockInvokeContext {
|
||||
pub key: Pubkey,
|
||||
pub logger: MockLogger,
|
||||
pub compute_budget: ComputeBudget,
|
||||
pub compute_meter: MockComputeMeter,
|
||||
}
|
||||
impl InvokeContext for MockInvokeContext {
|
||||
fn push(&mut self, _key: &Pubkey) -> Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
fn pop(&mut self) {}
|
||||
fn verify_and_update(
|
||||
&mut self,
|
||||
_message: &Message,
|
||||
_instruction: &CompiledInstruction,
|
||||
_accounts: &[Rc<RefCell<Account>>],
|
||||
) -> Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
fn get_caller(&self) -> Result<&Pubkey, InstructionError> {
|
||||
Ok(&self.key)
|
||||
}
|
||||
fn get_programs(&self) -> &[(Pubkey, ProcessInstruction)] {
|
||||
&[]
|
||||
}
|
||||
fn get_logger(&self) -> Rc<RefCell<dyn Logger>> {
|
||||
Rc::new(RefCell::new(self.logger.clone()))
|
||||
}
|
||||
fn get_compute_budget(&self) -> &ComputeBudget {
|
||||
&self.compute_budget
|
||||
}
|
||||
fn get_compute_meter(&self) -> Rc<RefCell<dyn ComputeMeter>> {
|
||||
Rc::new(RefCell::new(self.compute_meter.clone()))
|
||||
}
|
||||
fn add_executor(&mut self, _pubkey: &Pubkey, _executor: Arc<dyn Executor>) {}
|
||||
fn get_executor(&mut self, _pubkey: &Pubkey) -> Option<Arc<dyn Executor>> {
|
||||
None
|
||||
}
|
||||
fn record_instruction(&self, _instruction: &Instruction) {}
|
||||
fn is_feature_active(&self, _feature_id: &Pubkey) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
struct MockComputeMeter {}
|
||||
impl ComputeMeter for MockComputeMeter {
|
||||
fn consume(&mut self, _amount: u64) -> Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
fn get_remaining(&self) -> u64 {
|
||||
u64::MAX
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Default, Clone)]
|
||||
struct MockLogger {}
|
||||
impl Logger for MockLogger {
|
||||
fn log_enabled(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn log(&mut self, message: &str) {
|
||||
println!("{}", message);
|
||||
}
|
||||
}
|
||||
|
||||
struct TestInstructionMeter {}
|
||||
impl InstructionMeter for TestInstructionMeter {
|
||||
fn consume(&mut self, _amount: u64) {}
|
||||
fn get_remaining(&self) -> u64 {
|
||||
u64::MAX
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue