Add return data implementation

This consists of:
 - syscalls
 - passing return data from invoked to invoker
 - printing to stable log
 - rust and C SDK changes

(cherry picked from commit 53b47b87b2)
This commit is contained in:
Sean Young
2021-09-01 10:14:01 +01:00
parent df929bda38
commit 927d3b5e0d
20 changed files with 620 additions and 36 deletions

View File

@@ -940,6 +940,11 @@ impl Executor for BpfExecutor {
let trace_string = String::from_utf8(trace_buffer).unwrap();
trace!("BPF Program Instruction Trace:\n{}", trace_string);
}
drop(vm);
let return_data = invoke_context.get_return_data();
if let Some((program_id, return_data)) = return_data {
stable_log::program_return_data(&logger, program_id, return_data);
}
match result {
Ok(status) => {
if status != SUCCESS {
@@ -1271,6 +1276,7 @@ mod tests {
accounts: vec![],
sysvars: vec![],
disabled_features: vec![].into_iter().collect(),
return_data: None,
};
assert_eq!(
Err(InstructionError::ProgramFailedToComplete),