Proposal: log binary data for Solidity

Rename "Program return data: " to "Program return: " since "data" is
redundant.

(cherry picked from commit b89177c8de)

Conflicts:
	programs/bpf_loader/src/syscalls.rs
	sdk/bpf/c/inc/sol/log.h
	sdk/program/Cargo.toml
	sdk/src/feature_set.rs
	sdk/src/process_instruction.rs
This commit is contained in:
Sean Young
2021-09-17 09:14:49 +01:00
parent 400a88786a
commit ebe77a0985
17 changed files with 429 additions and 8 deletions

View File

@@ -235,6 +235,10 @@ pub mod return_data_syscall_enabled {
solana_sdk::declare_id!("BJVXq6NdLC7jCDGjfqJv7M1XHD4Y13VrpDqRF2U7UBcC");
}
pub mod sol_log_data_syscall_enabled {
solana_sdk::declare_id!("HYPs7jyJ3KwQFdDpuSzMtVKf1MLJDaZRv3CSWvfUqdFo");
}
lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@@ -293,7 +297,8 @@ lazy_static! {
(tx_wide_compute_cap::id(), "Transaction wide compute cap"),
(gate_large_block::id(), "validator checks block cost against max limit in realtime, reject if exceeds."),
(remove_native_loader::id(), "Remove support for the native loader"),
(return_data_syscall_enabled::id(), "enable sol_{set,get}_return_data syscall")
(return_data_syscall_enabled::id(), "enable sol_{set,get}_return_data syscall"),
(sol_log_data_syscall_enabled::id(), "enable sol_log_data syscall"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()

View File

@@ -1,3 +1,4 @@
use itertools::Itertools;
use solana_sdk::{
account::AccountSharedData,
instruction::{CompiledInstruction, Instruction, InstructionError},
@@ -269,20 +270,37 @@ pub mod stable_log {
ic_logger_msg!(logger, "Program log: {}", message);
}
/// Emit a program data.
///
/// The general form is:
///
/// ```notrust
/// "Program data: <binary-data-in-base64>*"
/// ```
///
/// That is, any program-generated output is guaranteed to be prefixed by "Program data: "
pub fn program_data(logger: &Rc<RefCell<dyn Logger>>, data: &[&[u8]]) {
ic_logger_msg!(
logger,
"Program data: {}",
data.iter().map(base64::encode).join(" ")
);
}
/// Log return data as from the program itself. This line will not be present if no return
/// data was set, or if the return data was set to zero length.
///
/// The general form is:
///
/// ```notrust
/// "Program return data: <program-id> <program-generated-data-in-base64>"
/// "Program return: <program-id> <program-generated-data-in-base64>"
/// ```
///
/// That is, any program-generated output is guaranteed to be prefixed by "Program return data: "
pub fn program_return_data(logger: &Rc<RefCell<dyn Logger>>, program_id: &Pubkey, data: &[u8]) {
/// That is, any program-generated output is guaranteed to be prefixed by "Program return: "
pub fn program_return(logger: &Rc<RefCell<dyn Logger>>, program_id: &Pubkey, data: &[u8]) {
ic_logger_msg!(
logger,
"Program return data: {} {}",
"Program return: {} {}",
program_id,
base64::encode(data)
);