From 3eb69be0ff23b15ccabe1baf1712355dcc28b4ab Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 29 Nov 2022 18:52:39 +0000 Subject: [PATCH 1/3] Solve some typos --- program/c/src/oracle/model/price_model.h | 4 ++-- program/c/src/oracle/sort/tmpl/sort_stable.c | 2 +- program/c/src/oracle/util/avg.h | 2 +- program/c/src/oracle/util/prng.h | 4 ++-- program/rust/src/lib.rs | 14 +++++--------- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/program/c/src/oracle/model/price_model.h b/program/c/src/oracle/model/price_model.h index 59cc9d8c0..c7d14d198 100644 --- a/program/c/src/oracle/model/price_model.h +++ b/program/c/src/oracle/model/price_model.h @@ -47,7 +47,7 @@ price_model_scratch_footprint( uint64_t cnt ) { /* Assumes price_model_cnt_valid large ... typically a multiple of 3 but this is not required, quote[i] for i in [0,cnt) are the quotes of interest on input, p25, p50, p75 point to where to write model outputs, scratch points to a - suitable footprint srcatch region). + suitable footprint scratch region). Returns a pointer to the quotes sorted in ascending order. As such, the min and max and any other rank statistic can be extracted easily @@ -68,7 +68,7 @@ price_model_scratch_footprint( uint64_t cnt ) { /* Assumes price_model_cnt_valid worst cases. This function uses no heap / dynamic memory allocation. It is thread safe provided it passed non-conflicting quote, output and scratch arrays. It has a bounded call depth ~lg cnt <= ~64 (this - could reducd to O(1) by using a non-recursive sort/select + could reduce to O(1) by using a non-recursive sort/select implementation under the hood if desired). */ int64_t * /* Returns pointer to sorted quotes (either quote or ALIGN_UP(scratch,int64_t)) */ diff --git a/program/c/src/oracle/sort/tmpl/sort_stable.c b/program/c/src/oracle/sort/tmpl/sort_stable.c index da5ec21b2..c618f4fa3 100644 --- a/program/c/src/oracle/sort/tmpl/sort_stable.c +++ b/program/c/src/oracle/sort/tmpl/sort_stable.c @@ -161,7 +161,7 @@ SORT_IMPL(stable_node)( SORT_KEY_T * x, SORT_IDX_T k = (SORT_IDX_T)0; /* Note that nl and nr are both at least one at this point so at least - one interation of the loop body is necessary. */ + one iteration of the loop body is necessary. */ for(;;) { /* Minimal C language operations */ if( SORT_BEFORE( yr[k], yl[j] ) ) { diff --git a/program/c/src/oracle/util/avg.h b/program/c/src/oracle/util/avg.h index 575bada49..2de6c6c3d 100644 --- a/program/c/src/oracle/util/avg.h +++ b/program/c/src/oracle/util/avg.h @@ -3,7 +3,7 @@ /* Portable robust integer averaging. (No intermediate overflow, no assumptions about platform type wides, no assumptions about integer - signed right shift, no signed integer division, no implict + signed right shift, no signed integer division, no implicit conversions, etc.) */ #include "sar.h" diff --git a/program/c/src/oracle/util/prng.h b/program/c/src/oracle/util/prng.h index ac6cc6bd8..dd7b1dabf 100644 --- a/program/c/src/oracle/util/prng.h +++ b/program/c/src/oracle/util/prng.h @@ -15,7 +15,7 @@ #include "hash.h" /* includes stdint.h */ /* prng_t should be treated as an opaque handle of a pseudo random - number generator. (It technically isn't here to faciliate inlining + number generator. (It technically isn't here to facilitate inlining of prng operations.) */ struct prng { @@ -65,7 +65,7 @@ prng_private_contract( uint64_t seq ) { prng_new takes ownership of the memory region pointed to by mem (which is assumed to be non-NULL with the appropriate footprint and - alingment) and formats it as a prng. The pseudo random number + alignment) and formats it as a prng. The pseudo random number generator stream will initialized to use sequence random sequence "seq" and will start at index "idx". Returns mem (which will be formatted for use). The caller will not be joined to the region on diff --git a/program/rust/src/lib.rs b/program/rust/src/lib.rs index 186ceeeda..05502ec85 100644 --- a/program/rust/src/lib.rs +++ b/program/rust/src/lib.rs @@ -23,19 +23,15 @@ use { solana_program::entrypoint, }; -// Below is a high lever description of the rust/c setup. +// Below is a high level description of the rust/c setup. -// As we migrate from C to Rust, our Rust code needs to be able to interact with C -// build-bpf.sh is set up to compile the C code into a two archive files +// As we migrate from C to Rust, our Rust code needs to be able to interact with C/ +// build-bpf.sh is set up to compile the C code into a two archive files/ // contained in `./program/c/target/` // - `libcpyth-bpf.a` contains the bpf version for production code // - `libcpyth-native.a` contains the systems architecture version for tests -// We also generate bindings for the types and constants in oracle.h (as well as other things -// included in bindings.h), these bindings can be accessed through c_oracle_header.rs -// Bindings allow us to access type definitions, function definitions and constants. In order to -// add traits to the bindings, we use the parser in build.rs. The traits must be defined/included -// at the the top of c_oracle_headers.rs. One of the most important traits we deal are the Borsh -// serialization traits. +// We also generate bindings for the constants in oracle.h (as well as other things +// included in bindings.h). entrypoint!(process_instruction); From cc1b8fa79aeb6cb23f4b8557c2ea9e804e4862da Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 29 Nov 2022 18:53:51 +0000 Subject: [PATCH 2/3] Fix comment --- program/rust/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/program/rust/src/lib.rs b/program/rust/src/lib.rs index 05502ec85..31b985c06 100644 --- a/program/rust/src/lib.rs +++ b/program/rust/src/lib.rs @@ -25,8 +25,8 @@ use { // Below is a high level description of the rust/c setup. -// As we migrate from C to Rust, our Rust code needs to be able to interact with C/ -// build-bpf.sh is set up to compile the C code into a two archive files/ +// As we migrate from C to Rust, our Rust code needs to be able to interact with C. +// build-bpf.sh is set up to compile the C code into a two archive files. // contained in `./program/c/target/` // - `libcpyth-bpf.a` contains the bpf version for production code // - `libcpyth-native.a` contains the systems architecture version for tests From 16635ade7fcdf1e7a41810ac5da3365d01dd1d4c Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 29 Nov 2022 18:54:31 +0000 Subject: [PATCH 3/3] Fix lib comments: --- program/rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/rust/src/lib.rs b/program/rust/src/lib.rs index 31b985c06..71fd912d8 100644 --- a/program/rust/src/lib.rs +++ b/program/rust/src/lib.rs @@ -26,7 +26,7 @@ use { // Below is a high level description of the rust/c setup. // As we migrate from C to Rust, our Rust code needs to be able to interact with C. -// build-bpf.sh is set up to compile the C code into a two archive files. +// build-bpf.sh is set up to compile the C code into a two archive files // contained in `./program/c/target/` // - `libcpyth-bpf.a` contains the bpf version for production code // - `libcpyth-native.a` contains the systems architecture version for tests