Add return data implementation

This consists of:
 - syscalls
 - passing return data from invoked to invoker
 - printing to stable log
 - rust and C SDK changes
This commit is contained in:
Sean Young
2021-09-01 10:14:01 +01:00
parent 2dee098b91
commit 098585234d
23 changed files with 641 additions and 35 deletions

View File

@ -18,6 +18,7 @@ pub const VERIFY_PRIVILEGE_DEESCALATION_ESCALATION_SIGNER: u8 = 9;
pub const VERIFY_PRIVILEGE_DEESCALATION_ESCALATION_WRITABLE: u8 = 10;
pub const WRITE_ACCOUNT: u8 = 11;
pub const CREATE_AND_INIT: u8 = 12;
pub const SET_RETURN_DATA: u8 = 13;
pub fn create_instruction(
program_id: Pubkey,

View File

@ -8,7 +8,7 @@ use solana_program::{
bpf_loader, entrypoint,
entrypoint::{ProgramResult, MAX_PERMITTED_DATA_INCREASE},
msg,
program::{invoke, invoke_signed},
program::{get_return_data, invoke, invoke_signed, set_return_data},
program_error::ProgramError,
pubkey::Pubkey,
system_instruction,
@ -27,6 +27,8 @@ fn process_instruction(
return Ok(());
}
assert_eq!(get_return_data(), None);
match instruction_data[0] {
VERIFY_TRANSLATIONS => {
msg!("verify data translations");
@ -286,6 +288,11 @@ fn process_instruction(
}
}
}
SET_RETURN_DATA => {
msg!("Set return data");
set_return_data(b"Set by invoked");
}
_ => panic!(),
}