From f31a788ef9ae373b2f01ad1d2005e88b87aec3a6 Mon Sep 17 00:00:00 2001 From: guibescos <59208140+guibescos@users.noreply.github.com> Date: Fri, 29 Jul 2022 12:37:00 -0500 Subject: [PATCH] Format (#215) * Format * CI * Fixed * Add comment to README * Format config * Fix build * Log time and ema (#212) * Log time and ema * Fix ema deserialize * Revert format * Add expo * Fix comments * Unused import * Revert "Log time and ema (#212)" (#216) This reverts commit f0bb36cbc58df46a17a733fd5422419965829183. Co-authored-by: Guillermo Bescos --- .github/workflows/check-fomatting.yml | 19 ++++++++++++++++ .pre-commit-config.yaml | 16 ++++++++++++++ Cargo.toml | 4 ++++ README.md | 6 +++++ program/c/src/oracle/model/clean | 1 - program/c/src/oracle/model/price_model.c | 7 +++--- program/c/src/oracle/model/run_tests | 1 - program/c/src/oracle/model/test_price_model.c | 1 - program/c/src/oracle/oracle.c | 1 - program/c/src/oracle/oracle.h | 2 +- program/c/src/oracle/pd.h | 1 - program/c/src/oracle/sort/clean | 1 - program/c/src/oracle/sort/run_tests | 1 - .../c/src/oracle/sort/sort_stable_base_gen.c | 1 - program/c/src/oracle/sort/test_sort_stable.c | 7 +++--- program/c/src/oracle/sort/tmpl/sort_stable.c | 5 ++--- program/c/src/oracle/upd_aggregate.h | 1 - program/c/src/oracle/util/avg.h | 7 +++--- program/c/src/oracle/util/clean | 1 - program/c/src/oracle/util/hash.h | 1 - program/c/src/oracle/util/prng.h | 10 ++++----- program/c/src/oracle/util/run_tests | 1 - program/c/src/oracle/util/sar.h | 1 - program/c/src/oracle/util/test_align.c | 3 +-- program/c/src/oracle/util/test_avg.c | 7 +++--- program/c/src/oracle/util/test_hash.c | 1 - program/c/src/oracle/util/test_prng.c | 1 - program/c/src/oracle/util/test_prng_battery.c | 1 - program/c/src/oracle/util/test_round.c | 1 - program/c/src/oracle/util/test_sar.c | 3 +-- program/c/src/oracle/util/util.h | 1 - program/rust/.gitignore | 1 + program/rust/build.rs | 2 +- program/rust/build_utils.rs | 3 ++- program/rust/src/c_oracle_header.rs | 5 ++++- program/rust/src/error.rs | 4 ++-- program/rust/src/lib.rs | 16 +++++++++++--- program/rust/src/price_t_offsets.h | 2 +- program/rust/src/processor.rs | 18 +++++++++++---- program/rust/src/rust_oracle.rs | 4 ++-- rustfmt.toml | 22 +++++++++++++++++++ scripts/build-bpf.sh | 10 +-------- 42 files changed, 130 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/check-fomatting.yml create mode 100644 .pre-commit-config.yaml create mode 100644 Cargo.toml create mode 100644 program/rust/.gitignore create mode 100644 rustfmt.toml diff --git a/.github/workflows/check-fomatting.yml b/.github/workflows/check-fomatting.yml new file mode 100644 index 000000000..7ae5af5aa --- /dev/null +++ b/.github/workflows/check-fomatting.yml @@ -0,0 +1,19 @@ +name: Check Formatting + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + components: rustfmt + - uses: pre-commit/action@v2.0.3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..88f24ce08 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + files : program/ + - id: end-of-file-fixer + files : program/ + - id: check-added-large-files +- repo: local + hooks: + - id: cargo-fmt-nightly + name: Cargo Fmt Nightly + language: "rust" + entry: cargo +nightly fmt + pass_filenames: false diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..6bb097555 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,4 @@ +[workspace] +members = [ + "program/rust" +] diff --git a/README.md b/README.md index 2e5d28897..0295ec09e 100644 --- a/README.md +++ b/README.md @@ -107,3 +107,9 @@ root@pyth-dev# usermod -u 1002 -g 1004 -s /bin/bash pyth Finally, in docker extension inside VS Code click right and choose "Attach VS Code". If you're using a remote host in VS Code make sure to let this connection be open. To get best experience from C++ IntelliSense, open entire `/home/pyth` in VS Code to include `solana` directory in home for lookup directories. + +### pre-commit hooks +pre-commit is a tool that checks and fixes simple issues (formatting, ...) before each commit. You can install it by following [their website](https://pre-commit.com/). In order to enable checks for this repo run `pre-commit install` from command-line in the root of this repo. + +The checks are also performed in the CI to ensure the code follows consistent formatting. Formatting is only currently enforced in the `program/` directory. +You might also need to install the nightly toolchain to run the formatting by running `rustup toolchain install nightly`. diff --git a/program/c/src/oracle/model/clean b/program/c/src/oracle/model/clean index 860ef1641..2ca7bfcfd 100755 --- a/program/c/src/oracle/model/clean +++ b/program/c/src/oracle/model/clean @@ -1,3 +1,2 @@ #!/bin/sh rm -rfv bin - diff --git a/program/c/src/oracle/model/price_model.c b/program/c/src/oracle/model/price_model.c index 303d52e0a..846ee898d 100644 --- a/program/c/src/oracle/model/price_model.c +++ b/program/c/src/oracle/model/price_model.c @@ -17,14 +17,14 @@ price_model_core( uint64_t cnt, optimized mergesort (merge with an unrolled insertion sorting network small n base cases). The best case is ~0.5 n lg n compares and the average and worst cases are ~n lg n compares. - + While not completely data oblivious, this has quite low variance in operation count practically and this is _better_ than quicksort's average case and quicksort's worst case is a computational denial-of-service and timing attack vulnerable O(n^2). Unlike quicksort, this is also stable (but this stability does not currently matter ... it might be a factor in future models). - + A data oblivious sorting network approach might be viable here with and would have a completely deterministic operations count. It currently isn't used as the best known practical approaches for @@ -101,7 +101,7 @@ price_model_core( uint64_t cnt, *_p50 = avg_2_int64( vl, vr ); } - + /* Extract the p75 (this is the mirror image of the p25 case) */ uint64_t p75_idx = cnt - ((uint64_t)1) - p25_idx; @@ -110,4 +110,3 @@ price_model_core( uint64_t cnt, return sort_quote; } - diff --git a/program/c/src/oracle/model/run_tests b/program/c/src/oracle/model/run_tests index 11c8f8731..ab5c8a1ce 100755 --- a/program/c/src/oracle/model/run_tests +++ b/program/c/src/oracle/model/run_tests @@ -15,4 +15,3 @@ $CC test_price_model.c price_model.c -o bin/test_price_model || exit 1 bin/test_price_model || exit 1 echo all tests passed - diff --git a/program/c/src/oracle/model/test_price_model.c b/program/c/src/oracle/model/test_price_model.c index 321ff1746..06038d8e6 100644 --- a/program/c/src/oracle/model/test_price_model.c +++ b/program/c/src/oracle/model/test_price_model.c @@ -66,4 +66,3 @@ main( int argc, printf( "pass\n" ); return 0; } - diff --git a/program/c/src/oracle/oracle.c b/program/c/src/oracle/oracle.c index b7ab6e55e..e555d7d62 100644 --- a/program/c/src/oracle/oracle.c +++ b/program/c/src/oracle/oracle.c @@ -563,4 +563,3 @@ extern uint64_t c_entrypoint(const uint8_t *input) } return dispatch( prm, ka ); } - diff --git a/program/c/src/oracle/oracle.h b/program/c/src/oracle/oracle.h index fc9ea6dac..a85e0632c 100644 --- a/program/c/src/oracle/oracle.h +++ b/program/c/src/oracle/oracle.h @@ -13,7 +13,7 @@ extern "C" { // defines to u32 (even with ULL suffix) const uint64_t SUCCESSFULLY_UPDATED_AGGREGATE = 1000ULL; -// The size of the "time machine" account defined in the +// The size of the "time machine" account defined in the // Rust portion of the codebase. const uint64_t TIME_MACHINE_STRUCT_SIZE = 1864ULL; diff --git a/program/c/src/oracle/pd.h b/program/c/src/oracle/pd.h index 413e4ccdb..d8b282fae 100644 --- a/program/c/src/oracle/pd.h +++ b/program/c/src/oracle/pd.h @@ -188,4 +188,3 @@ static inline void pd_sqrt( pd_t *r, pd_t *val, const int64_t *f ) #ifdef __cplusplus } #endif - diff --git a/program/c/src/oracle/sort/clean b/program/c/src/oracle/sort/clean index 860ef1641..2ca7bfcfd 100755 --- a/program/c/src/oracle/sort/clean +++ b/program/c/src/oracle/sort/clean @@ -1,3 +1,2 @@ #!/bin/sh rm -rfv bin - diff --git a/program/c/src/oracle/sort/run_tests b/program/c/src/oracle/sort/run_tests index 0eb277605..310a2e4ae 100755 --- a/program/c/src/oracle/sort/run_tests +++ b/program/c/src/oracle/sort/run_tests @@ -15,4 +15,3 @@ $CC test_sort_stable.c -o bin/test_sort_stable || exit 1 bin/test_sort_stable || exit 1 echo all tests passed - diff --git a/program/c/src/oracle/sort/sort_stable_base_gen.c b/program/c/src/oracle/sort/sort_stable_base_gen.c index 598f85a4d..046abf8b8 100644 --- a/program/c/src/oracle/sort/sort_stable_base_gen.c +++ b/program/c/src/oracle/sort/sort_stable_base_gen.c @@ -92,4 +92,3 @@ main( int argc, sort_gen( n ); return 0; } - diff --git a/program/c/src/oracle/sort/test_sort_stable.c b/program/c/src/oracle/sort/test_sort_stable.c index 86d72b59f..dc620a0d8 100644 --- a/program/c/src/oracle/sort/test_sort_stable.c +++ b/program/c/src/oracle/sort/test_sort_stable.c @@ -49,11 +49,11 @@ main( int argc, prng_t _prng[1]; prng_t * prng = prng_join( prng_new( _prng, (uint32_t)0, (uint64_t)0 ) ); - int ctr = 0; + int ctr = 0; for( int iter=0; iter<10000000; iter++ ) { if( !ctr ) { printf( "Randomized: Completed %i iterations\n", iter ); ctr = 100000; } ctr--; - + int n = (int)(prng_uint32( prng ) % (uint32_t)(N+1)); /* In [0,N], approx uniform IID */ for( int i=0; i64-bit integer hash functions (i.e. full avalanche) with the property hash_uint64(0)==0 and hash_uint64(i) for i in [0,2^64) yields a permutation of [0,2^64) @@ -88,7 +88,7 @@ prng_private_contract( uint64_t seq ) { state of a _prng and returns ownership of the underlying memory region to the caller. There should be no joins in the system on the prng. Returns a pointer to the underlying memory region. - + FIXME: CONSIDER FLATTENING ALIGN? */ static inline uint64_t prng_footprint( void ) { return (uint64_t)sizeof ( prng_t ); } @@ -143,7 +143,7 @@ prng_idx_set( prng_t * prng, possible values of of a signed int uniform IID can be obtained by casting the output of the unsigned generator of the same, assuming typical twos complement arithmetic platform.) - + The theory for this that hash_uint64(i) for i in [0,2^64) specifies a random looking permutation of the integers in [0,2^64). Returning the low order bits of this random permutation then yields a high @@ -207,7 +207,7 @@ static inline int64_t prng_int64( prng_t * prng ) { return (int64_t)( prng_uint6 goes from [i/N,(i+1)/N) where i is in [0,N). For single (double) precision, "float" ("double"), the largest N for which the range of each interval is _exactly_ representable is N = 2^24 (2^53). - + Given then a uniform IID uint32_t random input, the prng_uint32_to_float_c0 converter output is as though an continuous IID uniform random in [0,1) was generated and then rounded down to @@ -246,7 +246,7 @@ static inline int64_t prng_int64( prng_t * prng ) { return (int64_t)( prng_uint6 Note that it is possible to make converters that will handle exactly rounding toward all possible floating point representations in [0,1] but this are significantly more expensive. - + Assumes IEEE-754 style float and doubles. FIXME: ADD UNIT TEST COVERAGE */ diff --git a/program/c/src/oracle/util/run_tests b/program/c/src/oracle/util/run_tests index 38b754b23..00ae9dbba 100755 --- a/program/c/src/oracle/util/run_tests +++ b/program/c/src/oracle/util/run_tests @@ -52,4 +52,3 @@ bin/test_avg || exit 1 #bin/test_prng_battery 4 0 0 || exit 1 # BigCrush: Takes >~3 hours (seq 0, idx 0) echo all tests passed - diff --git a/program/c/src/oracle/util/sar.h b/program/c/src/oracle/util/sar.h index 9b0722560..34322e423 100644 --- a/program/c/src/oracle/util/sar.h +++ b/program/c/src/oracle/util/sar.h @@ -71,4 +71,3 @@ sar_int64( int64_t x, #endif #endif /* _pyth_oracle_util_sar_h_ */ - diff --git a/program/c/src/oracle/util/test_align.c b/program/c/src/oracle/util/test_align.c index eaa55767b..f958c89f2 100644 --- a/program/c/src/oracle/util/test_align.c +++ b/program/c/src/oracle/util/test_align.c @@ -17,7 +17,7 @@ main( int argc, prng_t _prng[1]; prng_t * prng = prng_join( prng_new( _prng, (uint32_t)0, (uint64_t)0 ) ); - int ctr = 0; + int ctr = 0; for( int i=0; i<1000000000; i++ ) { if( !ctr ) { printf( "Completed %i iterations\n", i ); ctr = 10000000; } ctr--; @@ -74,4 +74,3 @@ main( int argc, return 0; } - diff --git a/program/c/src/oracle/util/test_avg.c b/program/c/src/oracle/util/test_avg.c index 21f042449..98f4f2502 100644 --- a/program/c/src/oracle/util/test_avg.c +++ b/program/c/src/oracle/util/test_avg.c @@ -10,12 +10,12 @@ main( int argc, prng_t * prng = prng_join( prng_new( _prng, (uint32_t)0, (uint64_t)0 ) ); int ctr; - - ctr = 0; + + ctr = 0; for( int i=0; i<1000000000; i++ ) { if( !ctr ) { printf( "reg: Completed %i iterations\n", i ); ctr = 10000000; } ctr--; - + # define TEST(w) do { \ uint##w##_t x = prng_uint##w( prng ); \ uint##w##_t y = prng_uint##w( prng ); \ @@ -140,4 +140,3 @@ main( int argc, return 0; } - diff --git a/program/c/src/oracle/util/test_hash.c b/program/c/src/oracle/util/test_hash.c index e4dcc6cf0..ce39b1e80 100644 --- a/program/c/src/oracle/util/test_hash.c +++ b/program/c/src/oracle/util/test_hash.c @@ -56,4 +56,3 @@ main( int argc, printf( "pass\n" ); return 0; } - diff --git a/program/c/src/oracle/util/test_prng.c b/program/c/src/oracle/util/test_prng.c index 20f65e360..d5a9ccafa 100644 --- a/program/c/src/oracle/util/test_prng.c +++ b/program/c/src/oracle/util/test_prng.c @@ -174,4 +174,3 @@ main( int argc, printf( "pass\n" ); return 0; } - diff --git a/program/c/src/oracle/util/test_prng_battery.c b/program/c/src/oracle/util/test_prng_battery.c index 41ffb9ee2..8a198ca8d 100644 --- a/program/c/src/oracle/util/test_prng_battery.c +++ b/program/c/src/oracle/util/test_prng_battery.c @@ -89,4 +89,3 @@ main( int argc, return 0; } - diff --git a/program/c/src/oracle/util/test_round.c b/program/c/src/oracle/util/test_round.c index aff69822f..c9326d832 100644 --- a/program/c/src/oracle/util/test_round.c +++ b/program/c/src/oracle/util/test_round.c @@ -28,4 +28,3 @@ main( int argc, return 0; } - diff --git a/program/c/src/oracle/util/test_sar.c b/program/c/src/oracle/util/test_sar.c index f0b1ac5ef..88366fb2c 100644 --- a/program/c/src/oracle/util/test_sar.c +++ b/program/c/src/oracle/util/test_sar.c @@ -12,7 +12,7 @@ main( int argc, /* FIXME: EXPLICT COVERAGE OF EDGE CASES (PROBABLY STATICALLY FULLY SAMPLED ALREADY THOUGH FOR 8 AND 16 BIT TYPES) */ - int ctr = 0; + int ctr = 0; for( int i=0; i<1000000000; i++ ) { if( !ctr ) { printf( "Completed %i iterations\n", i ); ctr = 10000000; } ctr--; @@ -46,4 +46,3 @@ main( int argc, return 0; } - diff --git a/program/c/src/oracle/util/util.h b/program/c/src/oracle/util/util.h index c6a179cc6..c9aaa36e8 100644 --- a/program/c/src/oracle/util/util.h +++ b/program/c/src/oracle/util/util.h @@ -8,4 +8,3 @@ #include "prng.h" /* includes stdalign.h and hash.h */ #endif /* _pyth_oracle_util_util_h_ */ - diff --git a/program/rust/.gitignore b/program/rust/.gitignore new file mode 100644 index 000000000..55300bdb3 --- /dev/null +++ b/program/rust/.gitignore @@ -0,0 +1 @@ +bindings.rs diff --git a/program/rust/build.rs b/program/rust/build.rs index ae5b99c18..4b8c39def 100644 --- a/program/rust/build.rs +++ b/program/rust/build.rs @@ -2,7 +2,7 @@ mod build_utils; use bindgen::Builder; fn main() { - println!("cargo:rustc-link-search=../c/target"); + println!("cargo:rustc-link-search=./program/c/target"); let borsh_derives = ["BorshSerialize".to_string(), "BorshDeserialize".to_string()]; diff --git a/program/rust/build_utils.rs b/program/rust/build_utils.rs index a081373c1..6c3cfcd85 100644 --- a/program/rust/build_utils.rs +++ b/program/rust/build_utils.rs @@ -24,7 +24,8 @@ impl<'a> DeriveAdderParserCallback<'a> { } //this is required to implement the callback trait -impl UnwindSafe for DeriveAdderParserCallback<'_> {} +impl UnwindSafe for DeriveAdderParserCallback<'_> { +} impl ParseCallbacks for DeriveAdderParserCallback<'_> { fn add_derives(&self, _name: &str) -> Vec { diff --git a/program/rust/src/c_oracle_header.rs b/program/rust/src/c_oracle_header.rs index 5432e3e7b..5f2f8399f 100644 --- a/program/rust/src/c_oracle_header.rs +++ b/program/rust/src/c_oracle_header.rs @@ -5,7 +5,10 @@ #![allow(unused_variables)] #![allow(dead_code)] //All the custom trait imports should go here -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::{ + BorshDeserialize, + BorshSerialize, +}; //bindings.rs is generated by build.rs to include //things defined in bindings.h include!("../bindings.rs"); diff --git a/program/rust/src/error.rs b/program/rust/src/error.rs index ba859b7dd..514fd8676 100644 --- a/program/rust/src/error.rs +++ b/program/rust/src/error.rs @@ -10,13 +10,13 @@ pub type OracleResult = Result; pub enum OracleError { /// Generic catch all error #[error("Generic")] - Generic = 600, + Generic = 600, /// integer casting error #[error("IntegerCastingError")] IntegerCastingError = 601, /// c_entrypoint returned an unexpected value #[error("UnknownCError")] - UnknownCError = 602, + UnknownCError = 602, } impl From for ProgramError { diff --git a/program/rust/src/lib.rs b/program/rust/src/lib.rs index 1f664eeb2..ad9aca120 100644 --- a/program/rust/src/lib.rs +++ b/program/rust/src/lib.rs @@ -6,11 +6,21 @@ mod rust_oracle; mod time_machine_types; use crate::c_oracle_header::SUCCESSFULLY_UPDATED_AGGREGATE; -use crate::error::{OracleError, OracleResult}; -use crate::log::{post_log, pre_log}; +use crate::error::{ + OracleError, + OracleResult, +}; +use crate::log::{ + post_log, + pre_log, +}; use processor::process_instruction; +use solana_program::entrypoint::deserialize; use solana_program::program_error::ProgramError; -use solana_program::{custom_heap_default, custom_panic_default, entrypoint::deserialize}; +use solana_program::{ + custom_heap_default, + custom_panic_default, +}; //Below is a high lever description of the rust/c setup. diff --git a/program/rust/src/price_t_offsets.h b/program/rust/src/price_t_offsets.h index 64df8d2f6..072be70cf 100644 --- a/program/rust/src/price_t_offsets.h +++ b/program/rust/src/price_t_offsets.h @@ -11,4 +11,4 @@ const size_t PRICE_T_AGGREGATE_PRICE_OFFSET = offsetof(struct pc_price, agg_) + const size_t PRICE_T_AGGREGATE_STATUS_OFFSET = offsetof(struct pc_price, agg_) + offsetof(struct pc_price_info, status_); const size_t PRICE_T_PREV_TIMESTAMP_OFFSET = offsetof(struct pc_price, prev_timestamp_); const size_t PRICE_T_PREV_CONF_OFFSET = offsetof(struct pc_price, prev_conf_); -const size_t PRICE_T_PREV_AGGREGATE_OFFSET = offsetof(struct pc_price, prev_price_); \ No newline at end of file +const size_t PRICE_T_PREV_AGGREGATE_OFFSET = offsetof(struct pc_price, prev_price_); diff --git a/program/rust/src/processor.rs b/program/rust/src/processor.rs index d13e3f82d..6397674c3 100644 --- a/program/rust/src/processor.rs +++ b/program/rust/src/processor.rs @@ -1,10 +1,20 @@ use crate::c_entrypoint_wrapper; use crate::c_oracle_header::{ - cmd_hdr, command_t_e_cmd_agg_price, command_t_e_cmd_upd_account_version, - command_t_e_cmd_upd_price, command_t_e_cmd_upd_price_no_fail_on_error, PC_VERSION, + cmd_hdr, + command_t_e_cmd_agg_price, + command_t_e_cmd_upd_account_version, + command_t_e_cmd_upd_price, + command_t_e_cmd_upd_price_no_fail_on_error, + PC_VERSION, +}; +use crate::error::{ + OracleError, + OracleResult, +}; +use crate::rust_oracle::{ + update_price, + update_version, }; -use crate::error::{OracleError, OracleResult}; -use crate::rust_oracle::{update_price, update_version}; use ::std::mem::size_of; use borsh::BorshDeserialize; use solana_program::pubkey::Pubkey; diff --git a/program/rust/src/rust_oracle.rs b/program/rust/src/rust_oracle.rs index 3ba916332..a17970e9f 100644 --- a/program/rust/src/rust_oracle.rs +++ b/program/rust/src/rust_oracle.rs @@ -10,8 +10,8 @@ pub fn update_price( instruction_data: &[u8], input: *mut u8, ) -> OracleResult { - //For now, we did not change the behavior of this. this is just to show the proposed structure of the - //program + //For now, we did not change the behavior of this. this is just to show the proposed structure + // of the program c_entrypoint_wrapper(input) } /// has version number/ account type dependant logic to make sure the given account is compatible diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..89ad8b9a5 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,22 @@ +# Merge similar crates together to avoid multiple use statements. +imports_granularity = "Module" + +# Consistency in formatting makes tool based searching/editing better. +empty_item_single_line = false + +# Easier editing when arbitrary mixed use statements do not collapse. +imports_layout = "Vertical" + +# Default rustfmt formatting of match arms with branches is awful. +match_arm_leading_pipes = "Preserve" + +# Align Fields +enum_discrim_align_threshold = 80 +struct_field_align_threshold = 80 + +# Allow up to two blank lines for grouping. +blank_lines_upper_bound = 2 + +# Wrap comments +comment_width = 120 +wrap_comments = true \ No newline at end of file diff --git a/scripts/build-bpf.sh b/scripts/build-bpf.sh index 8880ce140..2ed8be054 100755 --- a/scripts/build-bpf.sh +++ b/scripts/build-bpf.sh @@ -15,11 +15,6 @@ PYTH_DIR=$( cd "${1:-.}" && pwd) C_DIR="$( find $PYTH_DIR | grep makefile)" C_DIR=$(dirname $C_DIR) -#finds Cargo.toml in pyth-client -#ASSUMES THAT there is only one Cargo.toml there -RUST_DIR="$( find $PYTH_DIR | grep Cargo.toml )" -RUST_DIR=$(dirname $RUST_DIR) - if ! which cargo 2> /dev/null then # shellcheck disable=SC1090 @@ -39,16 +34,13 @@ rm ./target/*-keypair.json #build Rust and link it with C -cd "${RUST_DIR}" +cd "${PYTH_DIR}" cargo clean cargo test cargo clean cargo build-bpf sha256sum ./target/**/*.so -rm ./target/**/*-keypair.json -rm -r $PYTH_DIR/target || true -mv ./target $PYTH_DIR/target