Remove clones in native programs
This commit is contained in:
parent
33f2d83506
commit
30b662df39
|
@ -148,18 +148,18 @@ fn entrypoint(
|
|||
solana_logger::setup();
|
||||
|
||||
if keyed_accounts[0].account.executable {
|
||||
let prog = keyed_accounts[0].account.userdata.clone();
|
||||
let (progs, params) = keyed_accounts.split_at_mut(1);
|
||||
let prog = &progs[0].account.userdata;
|
||||
info!("Call BPF program");
|
||||
//dump_program(keyed_accounts[0].key, &prog);
|
||||
let mut vm = match create_vm(&prog) {
|
||||
//dump_program(keyed_accounts[0].key, prog);
|
||||
let mut vm = match create_vm(prog) {
|
||||
Ok(vm) => vm,
|
||||
Err(e) => {
|
||||
warn!("create_vm failed: {}", e);
|
||||
return Err(ProgramError::GenericError);
|
||||
}
|
||||
};
|
||||
let mut v =
|
||||
serialize_parameters(program_id, &mut keyed_accounts[1..], &tx_data, tick_height);
|
||||
let mut v = serialize_parameters(program_id, params, &tx_data, tick_height);
|
||||
match vm.execute_program(v.as_mut_slice()) {
|
||||
Ok(status) => {
|
||||
if 0 == status {
|
||||
|
@ -171,7 +171,7 @@ fn entrypoint(
|
|||
return Err(ProgramError::GenericError);
|
||||
}
|
||||
}
|
||||
deserialize_parameters(&mut keyed_accounts[1..], &v);
|
||||
deserialize_parameters(params, &v);
|
||||
info!(
|
||||
"BPF program executed {} instructions",
|
||||
vm.get_last_instruction_count()
|
||||
|
|
|
@ -63,9 +63,10 @@ fn entrypoint(
|
|||
solana_logger::setup();
|
||||
|
||||
if keyed_accounts[0].account.executable {
|
||||
let code = keyed_accounts[0].account.userdata.clone();
|
||||
let code = str::from_utf8(&code).unwrap();
|
||||
match run_lua(&mut keyed_accounts[1..], &code, tx_data) {
|
||||
let (codes, params) = keyed_accounts.split_at_mut(1);
|
||||
let code = &codes[0].account.userdata;
|
||||
let code = str::from_utf8(code).unwrap();
|
||||
match run_lua(params, &code, tx_data) {
|
||||
Ok(()) => {
|
||||
trace!("Lua success");
|
||||
}
|
||||
|
|
|
@ -60,8 +60,9 @@ pub fn entrypoint(
|
|||
) -> Result<(), ProgramError> {
|
||||
if keyed_accounts[0].account.executable {
|
||||
// dispatch it
|
||||
let name = keyed_accounts[0].account.userdata.clone();
|
||||
let name = match str::from_utf8(&name) {
|
||||
let (names, params) = keyed_accounts.split_at_mut(1);
|
||||
let name = &names[0].account.userdata;
|
||||
let name = match str::from_utf8(name) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
warn!("Invalid UTF-8 sequence: {}", e);
|
||||
|
@ -85,12 +86,7 @@ pub fn entrypoint(
|
|||
return Err(ProgramError::GenericError);
|
||||
}
|
||||
};
|
||||
return entrypoint(
|
||||
program_id,
|
||||
&mut keyed_accounts[1..],
|
||||
ix_userdata,
|
||||
tick_height,
|
||||
);
|
||||
return entrypoint(program_id, params, ix_userdata, tick_height);
|
||||
},
|
||||
Err(e) => {
|
||||
warn!("Unable to load: {:?}", e);
|
||||
|
|
Loading…
Reference in New Issue