Skip to content

Commit f31a788

Browse files
authored
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 f0bb36c. Co-authored-by: Guillermo Bescos <guibescos>
1 parent 542755f commit f31a788

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+130
-71
lines changed

.github/workflows/check-fomatting.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Check Formatting
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: nightly
18+
components: rustfmt
19+
- uses: pre-commit/action@v2.0.3

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.2.0
4+
hooks:
5+
- id: trailing-whitespace
6+
files : program/
7+
- id: end-of-file-fixer
8+
files : program/
9+
- id: check-added-large-files
10+
- repo: local
11+
hooks:
12+
- id: cargo-fmt-nightly
13+
name: Cargo Fmt Nightly
14+
language: "rust"
15+
entry: cargo +nightly fmt
16+
pass_filenames: false

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[workspace]
2+
members = [
3+
"program/rust"
4+
]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@ root@pyth-dev# usermod -u 1002 -g 1004 -s /bin/bash pyth
107107
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.
108108

109109
To get best experience from C++ IntelliSense, open entire `/home/pyth` in VS Code to include `solana` directory in home for lookup directories.
110+
111+
### pre-commit hooks
112+
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.
113+
114+
The checks are also performed in the CI to ensure the code follows consistent formatting. Formatting is only currently enforced in the `program/` directory.
115+
You might also need to install the nightly toolchain to run the formatting by running `rustup toolchain install nightly`.

program/c/src/oracle/model/clean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/bin/sh
22
rm -rfv bin
3-

program/c/src/oracle/model/price_model.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ price_model_core( uint64_t cnt,
1717
optimized mergesort (merge with an unrolled insertion sorting
1818
network small n base cases). The best case is ~0.5 n lg n compares
1919
and the average and worst cases are ~n lg n compares.
20-
20+
2121
While not completely data oblivious, this has quite low variance in
2222
operation count practically and this is _better_ than quicksort's
2323
average case and quicksort's worst case is a computational
2424
denial-of-service and timing attack vulnerable O(n^2). Unlike
2525
quicksort, this is also stable (but this stability does not
2626
currently matter ... it might be a factor in future models).
27-
27+
2828
A data oblivious sorting network approach might be viable here with
2929
and would have a completely deterministic operations count. It
3030
currently isn't used as the best known practical approaches for
@@ -101,7 +101,7 @@ price_model_core( uint64_t cnt,
101101

102102
*_p50 = avg_2_int64( vl, vr );
103103
}
104-
104+
105105
/* Extract the p75 (this is the mirror image of the p25 case) */
106106

107107
uint64_t p75_idx = cnt - ((uint64_t)1) - p25_idx;
@@ -110,4 +110,3 @@ price_model_core( uint64_t cnt,
110110

111111
return sort_quote;
112112
}
113-

program/c/src/oracle/model/run_tests

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ $CC test_price_model.c price_model.c -o bin/test_price_model || exit 1
1515
bin/test_price_model || exit 1
1616

1717
echo all tests passed
18-

program/c/src/oracle/model/test_price_model.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,3 @@ main( int argc,
6666
printf( "pass\n" );
6767
return 0;
6868
}
69-

program/c/src/oracle/oracle.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,4 +563,3 @@ extern uint64_t c_entrypoint(const uint8_t *input)
563563
}
564564
return dispatch( prm, ka );
565565
}
566-

program/c/src/oracle/oracle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern "C" {
1313
// defines to u32 (even with ULL suffix)
1414
const uint64_t SUCCESSFULLY_UPDATED_AGGREGATE = 1000ULL;
1515

16-
// The size of the "time machine" account defined in the
16+
// The size of the "time machine" account defined in the
1717
// Rust portion of the codebase.
1818
const uint64_t TIME_MACHINE_STRUCT_SIZE = 1864ULL;
1919

0 commit comments

Comments
 (0)