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

@@ -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!(),
}