diff --git a/program/rust/src/lib.rs b/program/rust/src/lib.rs index 79e8d9558..2ddf766b0 100644 --- a/program/rust/src/lib.rs +++ b/program/rust/src/lib.rs @@ -40,7 +40,7 @@ pub extern "C" fn c_entrypoint(input: *mut u8) -> u64 { pub extern "C" fn entrypoint(input: *mut u8) -> u64 { let (_program_id, accounts, instruction_data) = unsafe { deserialize(input) }; - match pre_log(instruction_data) { + match pre_log(&accounts,instruction_data) { Err(error) => return error.into(), _ => {} } diff --git a/program/rust/src/log.rs b/program/rust/src/log.rs index 71495af3f..9176e3722 100644 --- a/program/rust/src/log.rs +++ b/program/rust/src/log.rs @@ -6,7 +6,7 @@ use solana_program::entrypoint::ProgramResult; use solana_program::msg; use std::mem::size_of; -pub fn pre_log(instruction_data: &[u8]) -> ProgramResult { +pub fn pre_log(accounts : &[AccountInfo], instruction_data: &[u8]) -> ProgramResult { msg!("Pyth oracle contract"); let instruction_header: cmd_hdr = cmd_hdr::try_from_slice(&instruction_data[..8])?; @@ -15,64 +15,64 @@ pub fn pre_log(instruction_data: &[u8]) -> ProgramResult { .try_into() .map_err(|_| OracleError::Generic)?; match instruction_id { - command_t_e_cmd_upd_price => { + command_t_e_cmd_upd_price | command_t_e_cmd_agg_price=> { let instruction: cmd_upd_price = cmd_upd_price::try_from_slice(instruction_data)?; msg!( - "Update price: price={:}, conf={:}, status={:}", + "UpdatePrice: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}", + accounts.get(0) + .ok_or(OracleError::Generic)?.key, + accounts.get(1) + .ok_or(OracleError::Generic)?.key, instruction.price_, instruction.conf_, - instruction.status_ + instruction.status_, + instruction.pub_slot_ ); } - command_t_e_cmd_agg_price => { + command_t_e_cmd_upd_price_no_fail_on_error=> { let instruction: cmd_upd_price = cmd_upd_price::try_from_slice(instruction_data)?; msg!( - "Update price: price={:}, conf={:}, status={:}", + "UpdatePriceNoFailOnError: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}", + accounts.get(0) + .ok_or(OracleError::Generic)?.key, + accounts.get(1) + .ok_or(OracleError::Generic)?.key, instruction.price_, instruction.conf_, - instruction.status_ + instruction.status_, + instruction.pub_slot_ ); } - command_t_e_cmd_upd_price_no_fail_on_error => { - let instruction: cmd_upd_price = cmd_upd_price::try_from_slice(instruction_data)?; - msg!( - "Update price no fail on error: price={:}, conf={:}, status={:}", - instruction.price_, - instruction.conf_, - instruction.status_ - ); - } - command_t_e_cmd_add_mapping => { - msg!("Add mapping"); + msg!("AddMapping"); } command_t_e_cmd_add_price => { - msg!("Add price"); + msg!("AddPrice"); } command_t_e_cmd_add_product => { - msg!("Add product") + msg!("AddProduct") } command_t_e_cmd_add_publisher => { - msg!("Add publisher") + msg!("AddPublisher") } command_t_e_cmd_del_publisher => { - msg!("Delete publisher") + msg!("DeletePublisher") } command_t_e_cmd_init_price => { - msg!("Initialize price") + msg!("InitializePrice") } command_t_e_cmd_init_mapping => { - msg!("Initialize mapping account"); + msg!("InitializeMapping"); } command_t_e_cmd_set_min_pub => { - msg!("Set minimum number of publishers"); + msg!("SetMinimumPublishers"); } command_t_e_cmd_upd_product => { - msg!("Update product"); + msg!("UpdateProduct"); } _ => { - msg!("Unrecognized instruction"); + msg!("UnrecognizedInstruction"); return Err(OracleError::Generic.into()); } } @@ -92,10 +92,13 @@ pub fn post_log(c_ret_val: u64, accounts: &[AccountInfo]) -> ProgramResult { .try_borrow_data()?[start..(start + size_of::())], )?; msg!( - "Aggregate updated : price={:}, conf={:}, status={:}", + "UpdateAggregate : price_account={:}, price={:}, conf={:}, status={:}, slot={:}", + accounts.get(1) + .ok_or(OracleError::Generic)?.key, aggregate_price_info.price_, aggregate_price_info.conf_, - aggregate_price_info.status_ + aggregate_price_info.status_, + aggregate_price_info.pub_slot_ ); } Ok(())