-
Notifications
You must be signed in to change notification settings - Fork 115
refactor: remove pythnet feature flag #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
86bf353
remove solana specific code
cctdaniel 9f27d4b
remove default feature
cctdaniel 3099d2d
fix ci
cctdaniel 19505ef
fix readme
cctdaniel 78078c2
refactor
cctdaniel a43a6a0
try fix
cctdaniel 5d04587
address comments
cctdaniel d649901
fix ci
cctdaniel 47115ab
remove PC_PYTHNET flag
cctdaniel efd6e52
refactor
cctdaniel 10dce76
address comments
cctdaniel e6cc181
address comments
cctdaniel ef8fc82
remove comment
cctdaniel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
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 | ||
name: Cargo Fmt | ||
language: "rust" | ||
entry: cargo +nightly-2023-03-01 fmt | ||
pass_filenames: false | ||
- id: cargo-clippy-solana | ||
name: Cargo Clippy Solana | ||
language: "rust" | ||
entry : cargo +nightly-2023-03-01 clippy --tests --features check -- -D warnings | ||
pass_filenames : false | ||
- id: cargo-clippy-pythnet | ||
name: Cargo Clippy Pythnet | ||
language: "rust" | ||
entry : cargo +nightly-2023-03-01 clippy --tests --features pythnet,check -- -D warnings | ||
pass_filenames : false | ||
- 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 | ||
name: Cargo Fmt | ||
language: "rust" | ||
entry: cargo +nightly-2023-03-01 fmt | ||
pass_filenames: false | ||
- id: cargo-clippy-pythnet | ||
name: Cargo Clippy Pythnet | ||
language: "rust" | ||
entry: cargo +nightly-2023-03-01 clippy --tests --features check -- -D warnings | ||
pass_filenames: false |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,16 +23,12 @@ extern "C" { | |
#define PC_MAP_TABLE_SIZE 640 | ||
|
||
// Total price component slots available | ||
#define PC_NUM_COMP_SOLANA 32 | ||
#define PC_NUM_COMP_PYTHNET 128 | ||
|
||
// PC_NUM_COMP - number of price components in use | ||
#ifdef PC_PYTHNET | ||
// Not whole PC_NUM_COMP_PYTHNET because of stack issues appearing in upd_aggregate() | ||
#define PC_NUM_COMP 64 | ||
#else | ||
#define PC_NUM_COMP PC_NUM_COMP_SOLANA | ||
#endif | ||
|
||
|
||
#define PC_PROD_ACC_SIZE 512 | ||
#define PC_EXP_DECAY -9 | ||
|
@@ -209,20 +205,47 @@ typedef struct pc_price | |
pc_price_comp_t comp_[PC_NUM_COMP];// component prices | ||
} pc_price_t; | ||
|
||
#ifdef PC_PYTHNET | ||
|
||
// Replace Solana component size's contribution with Pythnet's | ||
#define PC_EXPECTED_PRICE_T_SIZE_PYTHNET (3312 \ | ||
- PC_NUM_COMP_SOLANA * sizeof(pc_price_comp_t) \ | ||
/* | ||
The value 240 is derived from the fixed size of the pc_price_t struct excluding the size of the comp_ array. | ||
Here is the breakdown of the sizes (in bytes) for each field within the pc_price_t struct: | ||
|
||
- magic_ (uint32_t): 4 bytes | ||
- ver_ (uint32_t): 4 bytes | ||
- type_ (uint32_t): 4 bytes | ||
- size_ (uint32_t): 4 bytes | ||
- ptype_ (uint32_t): 4 bytes | ||
- expo_ (int32_t): 4 bytes | ||
- num_ (uint32_t): 4 bytes | ||
- num_qt_ (uint32_t): 4 bytes | ||
- last_slot_ (uint64_t): 8 bytes | ||
- valid_slot_ (uint64_t): 8 bytes | ||
- twap_ (pc_ema_t): 24 bytes (3 fields of int64_t each taking 8 bytes) | ||
- twac_ (pc_ema_t): 24 bytes (similar to twap_) | ||
- timestamp_ (int64_t): 8 bytes | ||
- min_pub_ (uint8_t): 1 byte | ||
- message_sent_ (int8_t): 1 byte | ||
- max_latency_ (uint8_t): 1 byte | ||
- drv3_ (int8_t): 1 byte | ||
- drv4_ (int32_t): 4 bytes | ||
- prod_ (pc_pub_key_t): 32 bytes (assuming pc_pub_key_t is a 32-byte array or struct) | ||
- next_ (pc_pub_key_t): 32 bytes (similar to prod_) | ||
- prev_slot_ (uint64_t): 8 bytes | ||
- prev_price_ (int64_t): 8 bytes | ||
- prev_conf_ (uint64_t): 8 bytes | ||
- prev_timestamp_ (int64_t): 8 bytes | ||
- agg_ (pc_price_info_t): 32 bytes | ||
|
||
Adding up all these sizes gives us a total of 240 bytes for the fixed part of the pc_price_t struct. | ||
The size of the comp_ array is variable and depends on PC_NUM_COMP, hence it is calculated separately and added to the base size of 240 bytes. | ||
*/ | ||
#define PC_EXPECTED_PRICE_T_SIZE_PYTHNET (240 \ | ||
+ PC_NUM_COMP * sizeof(pc_price_comp_t) \ | ||
) | ||
|
||
static_assert( sizeof( pc_price_t ) == PC_EXPECTED_PRICE_T_SIZE_PYTHNET, "" ); | ||
#undef PC_EXPECTED_PRICE_SIZE_PYTHNET | ||
#undef PC_EXPECTED_PRICE_T_SIZE_PYTHNET | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems like a typo before |
||
|
||
#else | ||
static_assert( sizeof( pc_price_t ) == 3312, "" ); | ||
#endif | ||
|
||
// This constant needs to be an upper bound of the price account size, it is used within pythd for ztsd. | ||
// It is set tighly to the current price account + 96 component prices + 48 bytes for cumulative sums | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.