Skip to content

Commit 827d7fd

Browse files
authored
Debug feature (#256)
* Feature debug * Cleanup * CI
1 parent 140716f commit 827d7fd

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

program/rust/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ solana-program = "=1.10.29"
1313
bytemuck = "1.11.0"
1414
thiserror = "1.0"
1515

16+
[features]
17+
debug = []
18+
1619
[lib]
1720
crate-type = ["cdylib", "lib"]

program/rust/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
mod c_oracle_header;
88
mod deserialize;
99
mod error;
10-
mod log;
1110
mod processor;
1211
mod rust_oracle;
1312
mod time_machine_types;
@@ -16,13 +15,18 @@ mod utils;
1615
#[cfg(test)]
1716
mod tests;
1817

18+
#[cfg(feature = "debug")]
19+
mod log;
20+
1921
use crate::c_oracle_header::SUCCESSFULLY_UPDATED_AGGREGATE;
2022
use crate::error::OracleError;
2123

24+
#[cfg(feature = "debug")]
2225
use crate::log::{
2326
post_log,
2427
pre_log,
2528
};
29+
2630
use processor::process_instruction;
2731

2832
use solana_program::entrypoint::deserialize;
@@ -51,6 +55,7 @@ use solana_program::{
5155
pub extern "C" fn entrypoint(input: *mut u8) -> u64 {
5256
let (program_id, accounts, instruction_data) = unsafe { deserialize(input) };
5357

58+
#[cfg(feature = "debug")]
5459
if let Err(error) = pre_log(&accounts, instruction_data) {
5560
return error.into();
5661
}
@@ -60,6 +65,7 @@ pub extern "C" fn entrypoint(input: *mut u8) -> u64 {
6065
Ok(success_status) => success_status,
6166
};
6267

68+
#[cfg(feature = "debug")]
6369
if let Err(error) = post_log(c_ret_val, &accounts) {
6470
return error.into();
6571
}

program/rust/src/log.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ pub fn pre_log(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResu
9898
Ok(())
9999
}
100100

101-
102101
pub fn post_log(c_ret_val: u64, accounts: &[AccountInfo]) -> ProgramResult {
103102
if c_ret_val == SUCCESSFULLY_UPDATED_AGGREGATE {
104103
// We trust that the C oracle has properly checked account 1, we can only get here through

0 commit comments

Comments
 (0)