Go to file
optke3 f3edf9c971
[sui 9/x] - hot potato fix for price updates (#805)
* state getters and setters, change Move.toml dependency to sui/integration_v2

* finish state.move

* add new line to pyth

* use deployer cap pattern for state module

* sui pyth

* update price feeds, dynamic object fields, Sui object PriceInfoObject

* register price info object with pyth state after creation

* sui governance

* some newlines

* error codes

* update and comment

* unit tests for pyth.move, add UpgradeCap to Pyth State (will be used for contract upgrades)

* updates

* test_get_update_fee test passes

* fix test_get_update_fee and test_update_price_feeds_corrupt_vaa

* test_update_price_feeds_invalid_data_source

* test_create_and_update_price_feeds

* test_create_and_update_price_feeds_success and test_create_and_update_price_feeds_price_info_object_not_found_failure

* test_update_cache

* update

* test_update_cache_old_update

* update_price_feeds_if_fresh

* comment

* contract upgrades start

* contract upgradeability

* update clock stuff

* edits

* use clone of sui/integration_v2 for stability

* make contract_upgrade::execute a public(friend) fun, remove clock arg

* E_INCORRECT_IDENTIFIER_LENGTH

* comment and edit

* add a single comment

* upgradeability fixes, other fixes

* update, migrate, state, pyth, setup, version_control

* upgradeability, governance, LatestOnly

* - state init_version, init_package_info
- governance and contract ugpradeability stuff

* make several functions public(friend), and friend the right modules in data_source.move

* add comment

* fix bug in from_u8, so that value <= TRANSFER_FEE

* rename error message to E_MUST_USE_CONTRACT_UPGRADE_MODULE_TO_DO_UPGRADES

* set_last_executed_governance_sequence

* set pyth governance_module to 0000000000000000000000000000000000000000000000000000000000000001

* update README

* Update README.md

* Update README.md

* delete comments

* Update README.md

* Update README.md

* change Wormhole dependency to branch sui/mainnet, which has the latest update that includes VAA sequence number in DecreeReceipt

do proper checking of sequence number when executing governance instructions, allow set_governance_data_source to update the sequence number to some initial_sequence.

* state::set_last_executed_governance_sequence

* rename error

* add newline to setup.move

* delete space

* Update README.md

* mark test module as well as some imports #[test_only] so sui move build works

* scripts for Pyth contract testing and deployment
remove required_version.move, as it is no longer being used for access control
make init_and_share_state a public(friend) function

* add build to Makefile

* init pyth ts script

* sui deploy and testing scripts

* contract fixes, set_fee_recipient governance action, emit price update event only if fresh price update

* init_pyth.ts, registry.ts, create_price_feed.ts

* create price feeds

* deploy script and Move.toml

* some contract updates to compile with WH branch sui/mainnet
deployment script updates

* update README

* update readme

* rename TS scripts, edit readme

* add rev for wormhole dependency, edit README

* edit create_price_feed script

* - add price_info::get function for getting PriceInfoObject ID from PriceIdentifier
- add test for price_info::get

* contract updates

* script edits

* contract upgrade in version_control.move and fix pyth_create_price_feed.ts

* add get_price_info_object_id function to pyth::state

* tests and build pass

* update scripts

* Pyth mainnet deploy, create all price feeds script

* clean up script imports

* add mainnet addresses to readme

* correct Pyth Mainnet addresses

* create price feeds on mainnet

* use git dependency in Move.toml

* edits

* delete required contracts

* get price info object ids

* get price info object IDs

* add json file containing price feed id to price info object id

* comment

* clean up scripts folder and imports

* more script clean up (comments)

* script updates

* hot potato stuff

* create_price_infos_hot_potato and update_single_price_feed

* don't create hot potato in batch price attestation

* latest only checks in Pyth.move

* delete tab

* edit

* run pre-commit hooks

* update price feeds script

* update_single_price_feed_logic, give hot potato contents type T copy and drop ability

* delete custom price attestation test

* get update multiple price feeds POC to work

* formatting via pre-commit

* update Move.toml so can run "sui move test", delete some error codes that were unused

* update update_price_feeds demo to auto-retrieve price info object ids

* update readme

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* don't print map, get prices after update

* script comments

* Update update_price_feeds.ts

* Update update_price_feeds.ts

* Update README.md

* script for token transfers

* testnet "mainnet simulation" deployment (with 19 mainnet guardians), and testnet deployment (with single testnet guardian)

* mainnet deploy

* update Move.toml

* Update README.md

* Update README.md

* edit readme

* Update README.md

* Update README.md

* Update README.md

* add PRICE_INFO_OBJECT map ID to README

* common questions

* edit comment

* update readme

* fix link

* add comments for update_single_price_feed

* edits

* Update README.md

* Update README.md

* Update README.md

* pre-commit run --all-files
2023-06-20 00:04:01 -04:00
.github/workflows fix docker build (#898) 2023-06-16 10:39:26 -07:00
governance fix docker build (#898) 2023-06-16 10:39:26 -07:00
hermes [hermes] Add health probe (#899) 2023-06-19 19:25:29 +02:00
price_pusher [price_pusher] Injective: cache sequence number (#874) 2023-06-13 02:00:30 +05:30
price_service [price-service] Update readiness probe (#893) 2023-06-16 12:38:25 +02:00
pythnet [hermes] Switch to message structs in pythnet_sdk (#897) 2023-06-19 18:21:39 +02:00
scripts [eth] Add benchmark tests (#368) 2022-11-02 10:59:39 +01:00
target_chains [sui 9/x] - hot potato fix for price updates (#805) 2023-06-20 00:04:01 -04:00
third_party/pyth Expose pythnet message buffer idls (#865) 2023-06-09 14:10:28 +02:00
tilt_devnet [price-service] Improve vaa validation (#814) 2023-05-17 20:20:17 +02:00
tilt_modules Add pre-commit globally (#393) 2022-11-24 14:14:29 +01:00
wormhole_attester Choose unique VAA for query time if it exists (#853) 2023-06-01 07:32:10 -07:00
.dockerignore Update .dockerignore (#722) 2023-03-27 16:44:08 +02:00
.gitignore [sui 8/x] - finalize contracts, deploy scripts, address audit feedback (#783) 2023-06-19 23:05:33 -04:00
.pre-commit-config.yaml [ci] Fix pre-commit (#857) 2023-06-06 13:15:32 +02:00
LICENSE Remove unused components/projects (#481) 2023-01-12 13:52:43 +01:00
README.md Fix JS workflow (#727) 2023-03-29 09:36:25 -07:00
SECURITY.md Update SECURITY.md (#800) 2023-05-04 10:39:02 +01:00
Tiltfile [wormhole-attester] Increase accuracy and improve logging (#653) 2023-03-03 13:34:39 +01:00
lerna.json [refactor] Add global lerna (#546) 2023-01-31 17:09:31 +01:00
package-lock.json [sui 9/x] - hot potato fix for price updates (#805) 2023-06-20 00:04:01 -04:00
package.json [sui 9/x] - hot potato fix for price updates (#805) 2023-06-20 00:04:01 -04:00
rustfmt.toml Update rustfmt (#864) 2023-06-08 15:07:15 +02:00
tsconfig.base.json Expose pythnet message buffer idls (#865) 2023-06-09 14:10:28 +02:00

README.md

Pyth Crosschain

This repository acts as a monorepo for the various components that make up Pyth Crosschain.

Within this monorepo you will find the following subprojects:

Wormhole Attester

wormhole_attester

The main Pyth implementation currently exists as an on-chain contract on Pythnet, a separate instance of the Solana blockchain. In order to expose these prices cross-chain, the Wormhole Attester contract acts as a sender for Pyth prices. At regular intervals the Pyth contract will observe the current Pyth price for selected products, and produce an attestation which is then relayed over Wormhole to be consumed by the various receiver contracts.

Target Chains

target_chains

This directory contains on-chain contracts and SDKs for all of the various blockchain runtimes that Pyth supports. Each subdirectory corresponds to a blockchain runtime. Inside each subdirectory, there are subfolders for contracts, SDKs, and examples.

Price Service

price_service

The Price Service is an off-chain service which constantly observes the Wormhole network watching for price attestations emitted from the Pyth contract. It exposes all observed attestations via a public API over HTTPS/WSS which can be consumed by client-side applications that wish to use Pyth pricing data.

The client subdirectory provides an SDK for interacting with the price service. However, most users will interact with the price service via a chain-specific SDK

For a guide on utilising this service in your project, see the chain-specific SDK and examples for your blockchain runtime in the target_chains directory.

Development

Releases

The repository has a CI workflow that will release javascript packages whose version number has changed. To perform a release, follow these steps:

  1. Update the version number in the package.json file for the package(s) you wish to release. Please follow Semantic Versioning for package versions.
  2. Submit a PR with the changes and merge them in to main.
  3. Create a new release in github with a tag of the form pyth-js-v<number>. You can simply increment the version number each time -- it doesn't affect any of the published information.
  4. When this release is published, it will automatically trigger a CI workflow to publish the updated packages to NPM.

If you have a javascript package that shouldn't be published, simply add "private": "true" to the package.json file and it will be excluded from the publishing workflow. If you are creating a new public javascript package, you should add the following config option to package.json:

  "publishConfig": {
    "access": "public"
  },

pre-commit hooks

pre-commit is a tool that checks and fixes simple issues (formatting, ...) before each commit. You can install it by following their website. In order to enable checks for this repo run pre-commit install from command-line in the root of this repo.

The checks are also performed in the CI to ensure the code follows consistent formatting.

Tilt CI

Integration tests run in Tilt (via the tilt ci command). The Tilt CI workflow requires approval from a member of the Pyth team. If you are a member, click on "Details" next to the "Workflow / ci-pyth-crosschain" check in a pull request, and then on the "Resume" button on the workflow page.

Typescript Monorepo

All of the typescript / javascript packages in this repository are part of a lerna monorepo. This setup allows each package to reference the current version of the others. You can install dependencies using npm ci from the repository root. You can build all of the packages using npx lerna run build and test with npx lerna run test.

Lerna has some common failure modes that you may encounter:

  1. npm ci fails with a typescript compilation error about a missing package. This error likely means that the failing package has a prepare entry compiling the typescript in its package.json. Fix this error by moving that logic to the prepublishOnly entry.
  2. The software builds locally but fails in CI, or vice-versa. This error likely means that some local build caches need to be cleaned. The build error may not indicate that this is a caching issue, e.g., it may appear that the packages are being built in the wrong order. Delete node_modules/, lib/ and tsconfig.tsbuildinfo from each package's subdirectory. then try again.

Audit / Feature Status

This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Or plainly spoken - this is a very complex piece of software which targets a bleeding-edge, experimental smart contract runtime. Mistakes happen, and no matter how hard you try and whether you pay someone to audit it, it may eat your tokens, set your printer on fire or startle your cat. Cryptocurrencies are a high-risk investment, no matter how fancy.