Skip to content

Commit

Permalink
repro in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay committed Apr 20, 2020
1 parent 2882894 commit c3008af
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,8 @@ fn process_deploy(
trace!("Finalizing program account");
rpc_client
.send_and_confirm_transaction_with_spinner(&mut finalize_tx, &signers)
.map_err(|_| {
CliError::DynamicProgramError("Program finalize transaction failed".to_string())
.map_err(|e| {
CliError::DynamicProgramError(format!("Program finalize transaction failed: {}", e))
})?;

Ok(json!({
Expand Down
9 changes: 4 additions & 5 deletions programs/bpf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 29 additions & 1 deletion programs/bpf/benches/bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ extern crate test;

use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
use solana_rbpf::EbpfVm;
use solana_sdk::{
account::Account,
entrypoint_native::InvokeContext,
instruction::{CompiledInstruction, InstructionError},
message::Message,
pubkey::Pubkey,
};
use std::{cell::RefCell, rc::Rc};
use std::{env, fs::File, io::Read, mem, path::PathBuf};
use test::Bencher;

Expand Down Expand Up @@ -69,9 +77,11 @@ fn bench_program_alu(bencher: &mut Bencher) {
.write_u64::<LittleEndian>(ARMSTRONG_LIMIT)
.unwrap();
inner_iter.write_u64::<LittleEndian>(0).unwrap();
let mut invoke_context = MockInvokeContext::default();

let elf = load_elf().unwrap();
let (mut vm, _) = solana_bpf_loader_program::create_vm(&elf).unwrap();
let (mut vm, _) =
solana_bpf_loader_program::create_vm(&elf, &mut invoke_context).unwrap();

println!("Interpreted:");
assert_eq!(
Expand Down Expand Up @@ -122,3 +132,21 @@ fn bench_program_alu(bencher: &mut Bencher) {
// println!(" {:?} MIPS", mips);
// println!("{{ \"type\": \"bench\", \"name\": \"bench_program_alu_jit_to_native_mips\", \"median\": {:?}, \"deviation\": 0 }}", mips);
}

#[derive(Debug, Default)]
pub struct MockInvokeContext {}
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,
_signers: Option<&[Pubkey]>,
_accounts: &[Rc<RefCell<Account>>],
) -> Result<(), InstructionError> {
Ok(())
}
}
2 changes: 1 addition & 1 deletion programs/bpf_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
bincode = "1.2.1"
byteorder = "1.3.4"
libc = "0.2.69"
jemalloc-sys = { version = "0.3.2", features = ["disable_initial_exec_tls"] }
log = "0.4.8"
num-derive = { version = "0.3" }
num-traits = { version = "0.2" }
Expand Down
7 changes: 3 additions & 4 deletions programs/librapay/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions programs/librapay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ pub mod librapay_transaction;

extern crate solana_move_loader_program;

use solana_move_loader_program::{account_state::LibraAccountState, processor::MoveProcessor};
use solana_move_loader_program::account_state::LibraAccountState;
use solana_runtime::loader_utils::load_program;
use solana_sdk::{
account::KeyedAccount,
client::Client,
instruction::InstructionError,
message::Message,
pubkey::Pubkey,
signature::{Keypair, Signer},
Expand Down Expand Up @@ -80,11 +78,3 @@ pub fn upload_payment_script<T: Client>(from: &Keypair, client: &T) -> Pubkey {

upload_script(from, client, code)
}

pub fn process_instruction(
program_id: &Pubkey,
keyed_accounts: &mut [KeyedAccount],
data: &[u8],
) -> Result<(), InstructionError> {
MoveProcessor::process_instruction(program_id, keyed_accounts, data)
}
9 changes: 4 additions & 5 deletions programs/librapay/src/librapay_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ pub fn get_libra_balance<T: Client>(
mod tests {
use super::*;
use crate::{create_genesis, upload_mint_script, upload_payment_script};
use solana_move_loader_program::processor::MoveProcessor;
use solana_runtime::bank::Bank;
use solana_runtime::bank_client::BankClient;
use solana_sdk::genesis_config::create_genesis_config;
Expand All @@ -161,10 +160,10 @@ mod tests {
fn create_bank(lamports: u64) -> (Arc<Bank>, Keypair, Keypair, Pubkey, Pubkey) {
let (mut genesis_config, mint) = create_genesis_config(lamports);
genesis_config.rent.lamports_per_byte_year = 0;
let mut bank = Bank::new(&genesis_config);
bank.add_instruction_processor(
solana_sdk::move_loader::id(),
MoveProcessor::process_instruction,
let bank = Bank::new(&genesis_config);
bank.register_native_instruction_processor(
"solana_move_loader_program",
&solana_sdk::move_loader::id(),
);
let shared_bank = Arc::new(bank);
let bank_client = BankClient::new_shared(&shared_bank);
Expand Down
2 changes: 2 additions & 0 deletions programs/move_loader/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use serde_derive::{Deserialize, Serialize};
use solana_sdk::{
account::KeyedAccount,
account_utils::State,
entrypoint_native::InvokeContext,
instruction::InstructionError,
move_loader::id,
program_utils::DecodeError,
Expand Down Expand Up @@ -445,6 +446,7 @@ impl MoveProcessor {
_program_id: &Pubkey,
keyed_accounts: &[KeyedAccount],
instruction_data: &[u8],
_invoke_context: &mut dyn InvokeContext,
) -> Result<(), InstructionError> {
solana_logger::setup();

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/entrypoint_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ macro_rules! declare_loader(
program_id: &$crate::pubkey::Pubkey,
keyed_accounts: &[$crate::account::KeyedAccount],
instruction_data: &[u8],
invoke_context: &mut dyn InvokeContext,
invoke_context: &mut dyn $crate::entrypoint_native::InvokeContext,
) -> Result<(), $crate::instruction::InstructionError> {
$entrypoint(program_id, keyed_accounts, instruction_data, invoke_context)
}
Expand Down

0 comments on commit c3008af

Please sign in to comment.