Skip to content

Intercepting price updates #204

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 25 commits into from
Jul 26, 2022

Conversation

majabbour
Copy link
Contributor

@majabbour majabbour commented Jul 22, 2022

Our design involves rersizing price accounts, as well as intercepting calls to instructions that update_the price in order to do the SMA tracking.

In this PR:

  1. We intercept the add_price calls (but we do not change their behavior yet)
  2. We add a no-op update_account_version instruction that is meant to update the version number of a given account, and resize price accounts.

The purpose of this is to get feedback on the structure of the program.

It also addressed two other issues:

  1. added panic and heap definitions. (These are usually added in the entrpoint! macro is solana sdk, code won't compile without them once we start using anything that code panic like arrays, etc)
  2. Updated the error message in the size of time machine assert so that it prints the correct size for better developer experience

@majabbour
Copy link
Contributor Author

majabbour commented Jul 22, 2022

.

@majabbour majabbour requested a review from guibescos July 22, 2022 19:06
@majabbour majabbour force-pushed the intercepting-price-updates branch from fa92df1 to 548f1de Compare July 22, 2022 19:11
Copy link
Contributor

@guibescos guibescos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use rust error handling and better import style.

@majabbour majabbour changed the base branch from main to twap-tracker-production July 25, 2022 18:05
@majabbour majabbour force-pushed the intercepting-price-updates branch from 548f1de to d65be07 Compare July 25, 2022 19:39
@majabbour majabbour marked this pull request as ready for review July 25, 2022 21:03
@majabbour majabbour requested a review from guibescos July 25, 2022 21:33
match unsafe { c_entrypoint(input) } {
0 => Ok(0), // Success
SUCCESSFULLY_UPDATED_AGGREGATE => Ok(SUCCESSFULLY_UPDATED_AGGREGATE),
2 => Err(ProgramError::InvalidArgument), //2 is ERROR_INVALID_ARGUMENT in solana_sdk.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the version from the bindings instead of the magic number 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, unless I make bindings of solana_sdk

@majabbour majabbour merged commit b439053 into twap-tracker-production Jul 26, 2022
@majabbour majabbour deleted the intercepting-price-updates branch July 26, 2022 20:22
guibescos added a commit that referenced this pull request Jul 28, 2022
* Make c robust to price account size (#201)

* make pythd robust

* made the oracle accept new size

* left space for extra publishers

* Make c robust to price account size (#207)

* make pythd robust

* made the oracle accept new size

* left space for extra publishers

* Intercepting price updates (#204)

* changed c return value of update price to indicate aggregation (#190)

* changed c return value of update price to indicate aggregation

* forgot to add bindings

* removed the need for casting

* fixed update_no_fail

* removed unnecessary docker packages

* timeless coments

* a convinient way to derive traits

* changed importing style

* added register_traits method

* fixed formatting

* add a new insctruction and interecepted update price calls

* fixed formatting

* more helpful error message for incorrect c account size

* fixed merging errors

* addressed some warning

* updated comment

* merging formatting issues

* memory borrowing issues after rebasing

* updated import

* more import style changes

* removed panics

* bug introduced by merge

* moved dispatching to processor

* better formatting

* cleaner error handling

* error handling wrapper for c_entrypoint

* removed unwrap

* more comments

* removed unused imports + changed import style

Co-authored-by: majabbour <59592028+majabbour@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants