Add resize_price_account support; create .dockerignore #41
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.
Motivation
This is the main changeset responsible for price account resizing in program-admin. Account resizing is realized as a new CLI subcommand (
resize-price-accounts-v2
). The new command performs account discovery similar tosync
, finds accounts with insufficient data size and expands them using the relevant on-chain instruction. The reason for a separate subcommand (and not expandingsync
) is that resizing will likely be performed only once per oracle deployment, as with current program-admin code, new price accounts are already allocated to use expanded PriceAccountV2 size.In order to perform tests in
integration
, a way to allocate v1-sized price accounts was necessary. To support that, thesync
subcommand got an option to allocate new price accounts using v1 size (--allocate-price-v2
, uses v1 size when set tofalse
). This way, whenresize_price_account
is called on chain, a true resize is performed. The resize would be skipped otherwise, as the on-chain instruction exits early if there's enough space already.Additionally, a
.dockerignore
file is created from.gitignore
to prevent Python runtime artifacts and locally-stored secrets from being copied into Docker storage.Summary of changes
cli.py
- Add new subcommand, add choice between v1 and v2 account size forsync
price account allocation__init__.py
- Add logic for finding, filtering and expanding v1 price accounts;instructions.py
- Implementresize_price_account
on-chain instructionutil.py
- Differentiate between V1 and V2 account sizes in constantsparsing.py
- Makeparse_price
aware of the extra price components for v2 prices, ensure that trailingPriceCumulative
data is not misinterpreted as a price componentpyproject.toml
- Bump package version tov0.1.2
.dockerignore
- copied from.gitignore
Testing
integration
environment, correctly identifying v1 accounts and v2 ones. The resize transactions succeed and do not break other services in the Tilt environment (agent continues to publish).Review highlights
parsing.py
- I decided against parsing the trailing data after expanded price component array, because the data is not relevant to administrative tasks on price accounts. It is indicated in the code comments.