pyth-crosschain/ethereum/test/pyth.js

1264 lines
49 KiB
JavaScript
Raw Normal View History

const jsonfile = require("jsonfile");
const elliptic = require("elliptic");
const BigNumber = require("bignumber.js");
const governance = require("@pythnetwork/xc-governance-sdk");
const PythStructs = artifacts.require("PythStructs");
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
const { deployProxy, upgradeProxy } = require("@openzeppelin/truffle-upgrades");
const { expectRevert, expectEvent, time } = require("@openzeppelin/test-helpers");
const { assert, expect } = require("chai");
const { deployProxyImpl } = require("@openzeppelin/truffle-upgrades/dist/utils");
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Use "WormholeReceiver" if you are testing with Wormhole Receiver
const Wormhole = artifacts.require("Wormhole");
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
const PythUpgradable = artifacts.require("PythUpgradable");
const MockPythUpgrade = artifacts.require("MockPythUpgrade");
const testSigner1PK =
"cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0";
const testSigner2PK =
"892330666a850761e7370376430bb8c2aa1494072d3bfeaed0c4fa3d5a9135fe";
contract("Pyth", function () {
const testSigner1 = web3.eth.accounts.privateKeyToAccount(testSigner1PK);
const testSigner2 = web3.eth.accounts.privateKeyToAccount(testSigner2PK);
const testGovernanceChainId = "1";
const testGovernanceEmitter =
"0x0000000000000000000000000000000000000000000000000000000000001234";
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
const testPyth2WormholeChainId = "1";
const testPyth2WormholeEmitter =
"0x71f8dcb863d176e2c420ad6610cf687359612b6fb392e0642b0ca6b1f186aa3b";
const notOwnerError =
"Ownable: caller is not the owner -- Reason given: Ownable: caller is not the owner.";
const insufficientFeeError =
"insufficient paid fee amount";
// Place all atomic operations that are done within migrations here.
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
beforeEach(async function () {
this.pythProxy = await deployProxy(PythUpgradable, [
(await Wormhole.deployed()).address,
testPyth2WormholeChainId,
testPyth2WormholeEmitter,
]);
await this.pythProxy.addDataSource(
testPyth2WormholeChainId,
testPyth2WormholeEmitter
);
// Setting the validity time to 60 seconds
await this.pythProxy.updateValidTimePeriodSeconds(60);
// Setting the governance data source to 0x1 (solana) and some random emitter address
await this.pythProxy.updateGovernanceDataSource(testGovernanceChainId, testGovernanceEmitter, 0);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
});
it("should be initialized with the correct signers and values", async function () {
await this.pythProxy.isValidDataSource(testPyth2WormholeChainId, testPyth2WormholeEmitter);
});
it("should allow upgrades from the owner", async function () {
// Check that the owner is the default account Truffle
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// has configured for the network. upgradeProxy will send
// transactions from the default account.
const accounts = await web3.eth.getAccounts();
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
const defaultAccount = accounts[0];
const owner = await this.pythProxy.owner();
assert.equal(owner, defaultAccount);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Try and upgrade the proxy
const newImplementation = await upgradeProxy(
this.pythProxy.address,
MockPythUpgrade
);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Check that the new upgrade is successful
assert.equal(await newImplementation.isUpgradeActive(), true);
assert.equal(this.pythProxy.address, newImplementation.address);
});
it("should allow ownership transfer", async function () {
// Check that the owner is the default account Truffle
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Check that another account can't transfer the ownership
await expectRevert(
this.pythProxy.transferOwnership(accounts[1], {
from: accounts[1],
}),
notOwnerError
);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Transfer the ownership to another account
await this.pythProxy.transferOwnership(accounts[2], {
from: defaultAccount,
});
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
assert.equal(await this.pythProxy.owner(), accounts[2]);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Check that the original account can't transfer the ownership back to itself
await expectRevert(
this.pythProxy.transferOwnership(defaultAccount, {
from: defaultAccount,
}),
notOwnerError
);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Check that the new owner can transfer the ownership back to the original account
await this.pythProxy.transferOwnership(defaultAccount, {
from: accounts[2],
});
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
assert.equal(await this.pythProxy.owner(), defaultAccount);
});
it("should not allow upgrades from the another account", async function () {
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// This test is slightly convoluted as, due to a limitation of Truffle,
// we cannot specify which account upgradeProxy send transactions from:
// it will always use the default account.
//
// Therefore, we transfer the ownership to another account first,
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// and then attempt an upgrade using the default account.
// Check that the owner is the default account Truffle
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Transfer the ownership to another account
const newOwnerAccount = accounts[1];
await this.pythProxy.transferOwnership(newOwnerAccount, {
from: defaultAccount,
});
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
assert.equal(await this.pythProxy.owner(), newOwnerAccount);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
// Try and upgrade using the default account, which will fail
// because we are no longer the owner.
await expectRevert(
upgradeProxy(this.pythProxy.address, MockPythUpgrade),
notOwnerError
);
});
it("should allow updating singleUpdateFeeInWei by owner", async function () {
// Check that the owner is the default account Truffle
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
// Check initial fee is zero
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 0);
// Set fee
await this.pythProxy.updateSingleUpdateFeeInWei(10);
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 10);
});
it("should not allow updating singleUpdateFeeInWei by another account", async function () {
// Check that the owner is the default account Truffle
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
// Check initial valid time period is zero
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 0);
// Checks setting valid time period using another account reverts.
await expectRevert(
this.pythProxy.updateSingleUpdateFeeInWei(10, {from: accounts[1]}),
notOwnerError,
);
});
it("should allow updating validTimePeriodSeconds by owner", async function () {
// Check that the owner is the default account Truffle
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
// Check valid time period is 60 (set in beforeEach)
assert.equal(await this.pythProxy.validTimePeriodSeconds(), 60);
// Set valid time period
await this.pythProxy.updateValidTimePeriodSeconds(30);
assert.equal(await this.pythProxy.validTimePeriodSeconds(), 30);
});
it("should not allow updating validTimePeriodSeconds by another account", async function () {
// Check that the owner is the default account Truffle
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
// Check valid time period is 60 (set in beforeEach)
assert.equal(await this.pythProxy.validTimePeriodSeconds(), 60);
// Checks setting validity time using another account reverts.
await expectRevert(
this.pythProxy.updateValidTimePeriodSeconds(30, {from: accounts[1]}),
notOwnerError,
);
});
// NOTE(2022-05-02): Raw hex payload obtained from format serialization unit tests in `p2w-sdk/rust`
// Latest known addition: wire format v3
//
// Tests rely on a p2w-sdk mock price/prod ID generation rule:
// nthProdByte(n) = n % 256, starting with n=1
// nthPriceByte(n) = 255 - (n % 256), starting with n=1
//
// Examples:
// 1st prod = "0x010101[...]"
// 1st price = "0xFEFEFE[...]"
// 2nd prod = "0x020202[...]"
// 2nd price = "0xFDFDFD[...]"
// 3rd prod = "0x030303[...]"
// 3rd price = "0xFCFCFC[...]"
const RAW_BATCH_ATTESTATION_TIME_REGEX = /DEADBEEFFADEDEED/g;
const RAW_BATCH_PUBLISH_TIME_REGEX = /00000000DADEBEEF/g;
const RAW_BATCH_PRICE_REGEX = /0000002BAD2FEED7/g;
const RAW_BATCH_PREV_PRICE_REGEX = /0000DEADFACEBEEF/g;
const RAW_BATCH_PREV_PUBLISH_TIME_REGEX = /00000000DEADBABE/g;
const RAW_BATCH_EMA_PRICE_REGEX = /FFFFFFFFFFFFFFD6/g;
const RAW_PRICE_ATTESTATION_SIZE = 149;
const RAW_BATCH_ATTESTATION_COUNT = 10;
const RAW_BATCH =
"0x" +
"5032574800030000000102000A00950101010101010101010101010101010101010101010101010101010101010101FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0202020202020202020202020202020202020202020202020202020202020202FDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0303030303030303030303030303030303030303030303030303030303030303FCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFC0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0404040404040404040404040404040404040404040404040404040404040404FBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBFB0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0505050505050505050505050505050505050505050505050505050505050505FAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFAFA0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0606060606060606060606060606060606060606060606060606060606060606F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F9F90000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0707070707070707070707070707070707070707070707070707070707070707F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F80000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0808080808080808080808080808080808080808080808080808080808080808F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F70000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0909090909090909090909090909090909090909090909090909090909090909F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F6F60000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0AF5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F50000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A010001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF";
const RAW_UNKNOWN_BATCH_ATTESTATION_COUNT = 3;
const RAW_UNKNOWN_BATCH =
"0x" +
"5032574800030000000102000300950101010101010101010101010101010101010101010101010101010101010101FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A000001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0202020202020202020202020202020202020202020202020202020202020202FDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFD0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A000001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF0303030303030303030303030303030303030303030303030303030303030303FCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFCFC0000002BAD2FEED70000000000000065FFFFFFFDFFFFFFFFFFFFFFD6000000000000002A000001E14C0004E6D0DEADBEEFFADEDEED00000000DADEBEEF00000000DEADBABE0000DEADFACEBEEF000000BADBADBEEF";
// Takes an unsigned 64-bit integer, converts it to hex with 0-padding
function u64ToHex(timestamp) {
// u64 -> 8 bytes -> 16 hex bytes
return timestamp.toString(16).padStart(16, "0");
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
}
function generateRawBatchAttestation(
publishTime,
attestationTime,
priceVal
) {
const pubTs = u64ToHex(publishTime);
const attTs = u64ToHex(attestationTime);
const price = u64ToHex(priceVal);
const replaced = RAW_BATCH.replace(RAW_BATCH_PUBLISH_TIME_REGEX, pubTs)
.replace(RAW_BATCH_ATTESTATION_TIME_REGEX, attTs)
.replace(RAW_BATCH_PRICE_REGEX, price);
return replaced;
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
}
function generateRawUnknownBatchAttestation(
publishTime,
attestationTime,
priceVal,
emaPriceVal,
prevPublishTime,
prevPriceVal,
) {
const pubTs = u64ToHex(publishTime);
const attTs = u64ToHex(attestationTime);
const price = u64ToHex(priceVal);
const emaPrice = u64ToHex(emaPriceVal);
const prevPubTs = u64ToHex(prevPublishTime);
const prevPrice = u64ToHex(prevPriceVal);
const replaced = RAW_UNKNOWN_BATCH.replace(RAW_BATCH_PUBLISH_TIME_REGEX, pubTs)
.replace(RAW_BATCH_ATTESTATION_TIME_REGEX, attTs)
.replace(RAW_BATCH_PRICE_REGEX, price)
.replace(RAW_BATCH_EMA_PRICE_REGEX, emaPrice)
.replace(RAW_BATCH_PREV_PUBLISH_TIME_REGEX, prevPubTs)
.replace(RAW_BATCH_PREV_PRICE_REGEX, prevPrice);
return replaced;
}
it("should parse batch price attestation correctly", async function () {
const magic = 0x50325748;
const versionMajor = 3;
const versionMinor = 0;
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
let attestationTime = 1647273460; // re-used for publishTime
let publishTime = 1647273465; // re-used for publishTime
let priceVal = 1337;
let rawBatch = generateRawBatchAttestation(
publishTime,
attestationTime,
priceVal
);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
let parsed = await this.pythProxy.parseBatchPriceAttestation(rawBatch);
// Check the header
assert.equal(parsed.header.magic, magic);
assert.equal(parsed.header.versionMajor, versionMajor);
assert.equal(parsed.header.versionMinor, versionMinor);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
assert.equal(parsed.header.payloadId, 2);
assert.equal(parsed.nAttestations, RAW_BATCH_ATTESTATION_COUNT);
assert.equal(parsed.attestationSize, RAW_PRICE_ATTESTATION_SIZE);
assert.equal(parsed.attestations.length, parsed.nAttestations);
for (var i = 0; i < parsed.attestations.length; ++i) {
const prodId =
"0x" + (i + 1).toString(16).padStart(2, "0").repeat(32);
const priceByte = 255 - ((i + 1) % 256);
const priceId =
"0x" + priceByte.toString(16).padStart(2, "0").repeat(32);
assert.equal(parsed.attestations[i].productId, prodId);
assert.equal(parsed.attestations[i].priceId, priceId);
assert.equal(parsed.attestations[i].price, priceVal);
assert.equal(parsed.attestations[i].conf, 101);
assert.equal(parsed.attestations[i].expo, -3);
assert.equal(parsed.attestations[i].emaPrice, -42);
assert.equal(parsed.attestations[i].emaConf, 42);
assert.equal(parsed.attestations[i].status, 1);
assert.equal(parsed.attestations[i].numPublishers, 123212);
assert.equal(parsed.attestations[i].maxNumPublishers, 321232);
assert.equal(
parsed.attestations[i].attestationTime,
attestationTime
);
assert.equal(parsed.attestations[i].publishTime, publishTime);
assert.equal(parsed.attestations[i].prevPublishTime, 0xdeadbabe);
assert.equal(parsed.attestations[i].prevPrice, 0xdeadfacebeef);
assert.equal(parsed.attestations[i].prevConf, 0xbadbadbeef);
console.debug(
`attestation ${i + 1}/${parsed.attestations.length} parsed OK`
);
}
});
async function updatePriceFeeds(contract, batches, valueInWei, chainId, emitter) {
let updateData = [];
for (let data of batches) {
const vm = await signAndEncodeVM(
1,
1,
chainId || testPyth2WormholeChainId,
emitter || testPyth2WormholeEmitter,
0,
data,
[testSigner1PK],
0,
0
);
updateData.push("0x" + vm);
}
return await contract.updatePriceFeeds(updateData, {value: valueInWei});
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
}
it("should attest price updates over wormhole", async function () {
let ts = 1647273460;
let rawBatch = generateRawBatchAttestation(ts - 5, ts, 1337);
await updatePriceFeeds(this.pythProxy, [rawBatch]);
});
it("should attest price updates empty", async function () {
const receipt = await updatePriceFeeds(this.pythProxy, []);
expectEvent.notEmitted(receipt, 'PriceFeedUpdate');
expectEvent.notEmitted(receipt, 'BatchPriceFeedUpdate');
expectEvent(receipt, 'UpdatePriceFeeds', {
batchCount: '0',
});
});
it("should attest price updates with multiple batches of correct order", async function () {
let ts = 1647273460;
let rawBatch1 = generateRawBatchAttestation(ts - 5, ts, 1337);
let rawBatch2 = generateRawBatchAttestation(ts + 5, ts + 10, 1338);
const receipt = await updatePriceFeeds(this.pythProxy, [rawBatch1, rawBatch2]);
expectEvent(receipt, 'PriceFeedUpdate', {
fresh: true,
});
expectEvent(receipt, 'BatchPriceFeedUpdate', {
batchSize: '10',
freshPricesInBatch: '10',
});
expectEvent(receipt, 'UpdatePriceFeeds', {
batchCount: '2',
});
});
it("should attest price updates with multiple batches of wrong order", async function () {
let ts = 1647273460;
let rawBatch1 = generateRawBatchAttestation(ts - 5, ts, 1337);
let rawBatch2 = generateRawBatchAttestation(ts + 5, ts + 10, 1338);
const receipt = await updatePriceFeeds(this.pythProxy, [rawBatch2, rawBatch1]);
expectEvent(receipt, 'PriceFeedUpdate', {
fresh: true,
});
expectEvent(receipt, 'PriceFeedUpdate', {
fresh: false,
});
expectEvent(receipt, 'BatchPriceFeedUpdate', {
batchSize: '10',
freshPricesInBatch: '10',
});
expectEvent(receipt, 'BatchPriceFeedUpdate', {
batchSize: '10',
freshPricesInBatch: '0',
});
expectEvent(receipt, 'UpdatePriceFeeds', {
batchCount: '2',
});
});
it("should not attest price updates with when required fee is not given", async function () {
// Check that the owner is the default account Truffle
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
// Check initial fee is zero
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 0);
// Set fee
await this.pythProxy.updateSingleUpdateFeeInWei(10);
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 10);
let ts = 1647273460;
let rawBatch1 = generateRawBatchAttestation(ts - 5, ts, 1337);
let rawBatch2 = generateRawBatchAttestation(ts + 5, ts + 10, 1338);
// Getting the fee from the contract
let feeInWei = await this.pythProxy.getUpdateFee(2);
assert.equal(feeInWei, 20);
// When a smaller fee is payed it reverts
await expectRevert(
updatePriceFeeds(this.pythProxy, [rawBatch1, rawBatch2], feeInWei - 1),
insufficientFeeError
);
});
it("should attest price updates with when required fee is given", async function () {
// Check that the owner is the default account Truffle
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
// Check initial fee is zero
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 0);
// Set fee
await this.pythProxy.updateSingleUpdateFeeInWei(10);
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 10);
let ts = 1647273460;
let rawBatch1 = generateRawBatchAttestation(ts - 5, ts, 1337);
let rawBatch2 = generateRawBatchAttestation(ts + 5, ts + 10, 1338);
// Getting the fee from the contract
let feeInWei = await this.pythProxy.getUpdateFee(2);
assert.equal(feeInWei, 20);
const receipt = await updatePriceFeeds(this.pythProxy, [rawBatch1, rawBatch2], feeInWei);
expectEvent(receipt, 'UpdatePriceFeeds', {
fee: feeInWei
});
const pythBalance = await web3.eth.getBalance(this.pythProxy.address);
assert.equal(pythBalance, feeInWei);
});
it("should attest price updates with required fee even if more fee is given", async function () {
// Check that the owner is the default account Truffle
// has configured for the network.
const accounts = await web3.eth.getAccounts();
const defaultAccount = accounts[0];
assert.equal(await this.pythProxy.owner(), defaultAccount);
// Check initial fee is zero
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 0);
// Set fee
await this.pythProxy.updateSingleUpdateFeeInWei(10);
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), 10);
let ts = 1647273460;
let rawBatch1 = generateRawBatchAttestation(ts - 5, ts, 1337);
let rawBatch2 = generateRawBatchAttestation(ts + 5, ts + 10, 1338);
// Getting the fee from the contract
let feeInWei = await this.pythProxy.getUpdateFee(2);
assert.equal(feeInWei, 20);
const receipt = await updatePriceFeeds(this.pythProxy, [rawBatch1, rawBatch2], feeInWei + 10);
expectEvent(receipt, 'UpdatePriceFeeds', {
fee: feeInWei
});
const pythBalance = await web3.eth.getBalance(this.pythProxy.address);
assert.equal(pythBalance, feeInWei);
});
it("should cache price updates", async function () {
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
let currentTimestamp = (await web3.eth.getBlock("latest")).timestamp;
let priceVal = 521;
let rawBatch = generateRawBatchAttestation(
currentTimestamp - 5,
currentTimestamp,
priceVal
);
let receipt = await updatePriceFeeds(this.pythProxy, [rawBatch]);
expectEvent(receipt, 'PriceFeedUpdate', {
fresh: true,
});
expectEvent(receipt, 'BatchPriceFeedUpdate', {
batchSize: '10',
freshPricesInBatch: '10',
});
expectEvent(receipt, 'UpdatePriceFeeds', {
batchCount: '1',
});
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
let first_prod_id = "0x" + "01".repeat(32);
let first_price_id = "0x" + "fe".repeat(32);
let second_prod_id = "0x" + "02".repeat(32);
let second_price_id = "0x" + "fd".repeat(32);
// Confirm that previously non-existent feeds are created
let first = await this.pythProxy.queryPriceFeed(first_price_id);
console.debug(`first is ${JSON.stringify(first)}`);
assert.equal(first.price.price, priceVal);
let second = await this.pythProxy.queryPriceFeed(second_price_id);
assert.equal(second.price.price, priceVal);
// Confirm the price is bumped after a new attestation updates each record
let nextTimestamp = currentTimestamp + 1;
let rawBatch2 = generateRawBatchAttestation(
nextTimestamp - 5,
nextTimestamp,
priceVal + 5
);
receipt = await updatePriceFeeds(this.pythProxy, [rawBatch2]);
expectEvent(receipt, 'PriceFeedUpdate', {
fresh: true,
});
expectEvent(receipt, 'BatchPriceFeedUpdate', {
batchSize: '10',
freshPricesInBatch: '10',
});
expectEvent(receipt, 'UpdatePriceFeeds', {
batchCount: '1',
});
first = await this.pythProxy.queryPriceFeed(first_price_id);
assert.equal(first.price.price, priceVal + 5);
second = await this.pythProxy.queryPriceFeed(second_price_id);
assert.equal(second.price.price, priceVal + 5);
// Confirm that only strictly larger timestamps trigger updates
let rawBatch3 = generateRawBatchAttestation(
nextTimestamp - 5,
nextTimestamp,
priceVal + 10
);
receipt = await updatePriceFeeds(this.pythProxy, [rawBatch3]);
expectEvent(receipt, 'PriceFeedUpdate', {
fresh: false,
});
expectEvent(receipt, 'BatchPriceFeedUpdate', {
batchSize: '10',
freshPricesInBatch: '0',
});
expectEvent(receipt, 'UpdatePriceFeeds', {
batchCount: '1',
});
first = await this.pythProxy.queryPriceFeed(first_price_id);
assert.equal(first.price.price, priceVal + 5);
assert.notEqual(first.price.price, priceVal + 10);
second = await this.pythProxy.queryPriceFeed(second_price_id);
assert.equal(second.price.price, priceVal + 5);
assert.notEqual(second.price.price, priceVal + 10);
});
it("should fail transaction if a price is not found", async function () {
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
await expectRevert(
this.pythProxy.queryPriceFeed(
"0xdeadfeeddeadfeeddeadfeeddeadfeeddeadfeeddeadfeeddeadfeeddeadfeed"
),
"no price feed found for the given price id"
);
});
it("should revert on getting stale current prices", async function () {
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
let smallestTimestamp = 1;
let rawBatch = generateRawBatchAttestation(
smallestTimestamp,
smallestTimestamp + 5,
1337
);
await updatePriceFeeds(this.pythProxy, [rawBatch]);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
for (var i = 1; i <= RAW_BATCH_ATTESTATION_COUNT; i++) {
const price_id =
"0x" +
(255 - (i % 256)).toString(16).padStart(2, "0").repeat(32);
expectRevert(
this.pythProxy.getPrice(price_id),
"no price available which is recent enough"
);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
}
});
it("should revert on getting current prices too far into the future as they are considered unknown", async function () {
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
let largestTimestamp = 4294967295;
let rawBatch = generateRawBatchAttestation(
largestTimestamp - 5,
largestTimestamp,
1337
);
await updatePriceFeeds(this.pythProxy, [rawBatch]);
Merge Dev.v2 into main (#181) * Move js sdk on p2w-sdk to js folder Also modifies other dependencies to correct path * Reversed removal of wasm build for nodejs * Add newline to a file * pyth2wormhole: Fix attestation validation bug commit-id:567942d7 * Add p2w sdk It uses Pyth clients structs and cleans some of definitions for Pyth2Wormhole structures. * Add emitter type and add wasm function for it - It requires solitaire and it requires nightly rust - No logic is applied, code is from p2w solana contract. (Eventually will be removed from there) * Add new line * Move WASM gen docker to root It is because wasm is going to be used for p2w-sdk too. * Fix unchanged cache mount paths * Move terra relayer into the repo * Update readme * p2w-client: Add lib target, make helpers into lib functions there commit-id:3aeb9ee6 * pyth2wormhole-client: Implement retries commit-id:462677a2 * Make p2w-sdk js use p2w-sdk rust wasm bindings (#65) * Make p2w-sdk js use p2w-sdk rust wasm bindings (instead of solana contract bindings) - Removes `wasm.rs` in solana contract too. * p2w attester contract use p2w-sdk (#68) * Make solana pyth2wormhole contract to use the sdk * Use threadpool to set up price symbols (#69) * Add solana feature flag for p2w sdk (#71) * Pyth bridge terra contract support batch attestation + use p2w sdk (#72) * Make terra contract to use pyth2wormhole-sdk and support batch attestation * Update packages + code format * Move terra dockerfile out to support third-party dependency * pyth2wormhole-client: Add polling-based concurrent tx confirmation commit-id:5d16d035 * chore: p2w spy guarding improve Dockerfile * fix: p2w_autoattest don't die after initialization also minimal formatting * add P2W_EXIT_ON_ERROR * set P2W_EXIT_ON_ERROR default to True * Remove bool test * hopefully this time. * add tilt p2w-attest P2W_EXIT_ON_ERROR * convert P2W_EXIT_ON_ERROR to "true" * Fix pyth test publisher (#76) * Fix test pyth publisher to actually publish price - Uses newer pyth images and removes existing hacks for old versions. It essentially makes dockers cleaner. - Also improve some adds in dockers to cache more efficiently * Support Batch Price attestation for terra relay (#75) * Support Batch Price attestation for terra relay * Abehjati/update p2w sdk to pyth sdk (#83) * Make p2w-sdk use pyth-sdk * Correct test values to reflect .env.test * update p2w sdk to use ema instead of twa (#84) * Rename twa to ema in terra relay (#85) * Bring PythStructs.PriceAttestation struct in line with new API * Add ability to parse batch price attestations * Pyth terra remove wormhole governance (#87) * Pyth in terra: remove wormhole governance * [WIP] p2w-relay-iface: Add NPM package with relayer interface PoC commit-id:efcb9b34 * Define Pyth SDK Price struct * Define internal PythStructs.PriceInfo struct * Cache price updates in standardised PriceInfo format * Cache price updates from batch attestations * p2w-relay-iface -> p2w-relay-terra/src/relay/iface.ts commit-id:ed9846e3 * p2w relay interface: remove config from Relay iface commit-id:0359d886 * Remove now unnused parsePriceAttestation function * Pyth terra bridge: add contract deployment script (#88) * Add pyth deployment script - Also updates build.sh to build pyth completely - Add a readme for deployment guide * Add test for partial update behaviour * update p2w sdk to new pyth (#91) * p2w-sdk/rust use pyth sdk solana v2 * Dockerfile.client: solana 1.8.1 -> 1.9.4 commit-id:643299d3 * p2w-terra-relay: ignore lib and node, own project dir in docker commit-id:b084bc40 * p2w-terra-relay: iface.ts review nits, naive impl for Terra commit-id:0ecbfdd6 * Terra contract public api (#79) * Use pyth-sdk in terra contract * Update terra contract according to agreed API - Also adds v2 suffix to price_info key because this migration is breaking. * p2w-terra-relay: apply review nits commit-id:aec39c85 * p2w-terra-relay: make worker.ts generic w.r.t. Relay interface commit-id:5937a08c * terra.ts: add missing return statement commit-id:ba0365e6 * Update worket to handle timeout in callback correctly (#97) * Remove wormhole-based governance * Remove now unused legacy governance state and variables * Remove Pyth Implementation implementation * p2w-terra-relay: run formatter commit-id:df311e23 * p2w-terra-relay: apply review nits commit-id:5034b061 * Run formatter to trigger CI commit-id:7c643d79 * p2w-terra-relay: EVM boilerplate commit-id:8ad73ded * Remove old PythProxy inheritance hierarchy * Remove now unnused initialized implementations map * Remove old mock bridge implementation * Remove dependency to wormhole sdk as path and cleanup wrong eth copies (#104) * Dockerfile.pyth_relay: Fix lockfile issue in ethereum This commit fixes a lockfile issue resulting from newer NPM in our container. Specifically, our Dockerfile is pinned, relaxes Ethereum's lockfile (npm ci -> npm install) and hardens our lockfile (npm install -> npm ci) commit-id:3381c8ec * p2w-terra-relay: Admit loss against mkdir -p commit-id:3abdb58d * Remove unused components from wormhole (#108) * Remove unused components from wormhole Removes the following: - explorer - e2e - bridge_ui - algorand stuff (teal dockerfile and third_party/algorand) - ci_tests (testing directory) which are for JS/Bridge UI * Remove unused terra contracts (#109) - Note: Terra contract addresses are changed by this PR due to deterministic ordering. - Removed unused nft and token bridge, and migration contracts in Terra - Modified documentation to remove info regarding removed contracts.(docs/devnet.md) * Remove unused solana contracts and their wasm creations (#110) Removes token bridge, nft bridge, migration. Also removes them from deployments and docs. * Add fee estimate for terra relay (#112) * Removes directores which are not related to p2w (#111) Removes - audits - dashboards (dashboard is removed from Tilt) - event_database (all of it's dependencies are removed from Tilt and it's not for p2w) - lp_ui: a project (pressumably liquidity pool) not related to p2w - sdk: wormhole sdk, p2w depends on it's npm package and there is no dependency to rust one - spydk: it's not anywhere in p2w - staging/algorand: these are for alrogrand which is not used in p2w - whitepapers: these are for wormhole * Add and update openzeppelin packages * Add initializer to Pyth contract * Add upgradable PythProxy contract * Update tests to work with new proxy setup * Update migrate script to work with new proxy setup * Add tests for new proxy setup * Inline PythStorage.Provider struct * Make Pyth.verifyPythVM function internal * Fix struct field names * Rename Price to PriceFeed to be consistent with SDK * Replace PythGetters.latestPriceInfo with Pyth.queryPriceFeed in public API * p2w-terra-relay: Add a query() EVM call and Tilt boilerplate commit-id:f97d0c16 * Clarify test comments * Add health probe (#107) * Rename PythProxy to PythUpgradable * p2w-evm-relay: Backport the proxy address change from debug session commit-id:55b63ed5 * p2w-terra-relay -> p2w-relay, split EVM relay into new service commit-id:36d0db6e * Tiltfile: typo commit-id:3bbba986 * p2w-evm-relay.yaml: typo commit-id:35c87c79 * p2w-evm-relay.yaml: typo 2: electric boogaloo commit-id:40892265 * Add build folder to dockerignore * Rename attestPriceBatch to updatePriceBatchFromVm * Update comment on time check * Trigger Build * Tiltfile: Fix port forwards for p2w-evm-relay commit-id:6e5e9c14 * p2w-relay: PythImplementation -> PythUpgradable commit-id:bfea7eb5 * Remove unused Pyth Chain ID metadata * Add the query() call commit-id:02966ce5 * p2w-terra-relay: Fix evm.ts after contract rename commit-id:87381bec * Make truffle migrations directory configurable * p2w-evm-relay: Fix wrong EVM contract ID, add a check for it This commit takes care of an outdated pyth2wormhole EVM contract address and implements a contract/non-contract check using web3.eth.getCode() (empty for non-contracts). This problem cost us several hours of debugging and resulted from an EVM gotcha - a contract call to a non-contract address will simply ignore the call payload and make a plain transfer. Additionally, ETH accounts don't have a notion of initialization - used and unused addresses are equally valid tx recipients. Resulting from both properties, any unused address could potentially yield wrongly successful calls, wasting funds and debug time over p2w-relay. Thus the heuristic to protect us from this is to see if the address' code storage is populated. commit-id:b655a720 * p2w-relay: Also implement the contract check in EVM relay() commit-id:e28709e5 * evm.ts: Fix wording in changed/unchanged logs commit-id:13c81625 * Make terra relayer more resillient (#120) - Increase retry attempts (4 to 6) and retry_delay (250ms to 1s) to be more resillient - This is because when account sequence mismatch happens it might take some time be fixed - Removed estimate fee because it's being done in wallet.createAndSignTx (less requests) - Improved logging on when error happens * Update dockerfile to chown less files (#121) * Update dockerfile to chown sooner * p2w-relay: review nits * p2w-evm-relay: make feed verification queries configurable * p2w-relay: cache wormhole import * p2w-relay: formatter, remove getcode() from relay(), add comments commit-id:1a65c52c * p2w-relay: typos and leftovers commit-id:9b523b25 * Change websocket to json socket to support bsc testnet + improves env vars (#139) * Change websocket to json socket to support bsc testnet + imporving env vars * Add unit test to Pyth Terra Contract (#123) * Add unit test to the terra contract - Refactors the code into multiple functions to make unit testing easier - Adds build and test of terra contract to CI according to #73 * p2w-relay: harden exception handling, yell about uncaught stuff commit-id:24e14835 * p2w-relay: Correct outdated comment commit-id:d0b57d33 * p2w-evm-relay: s/async (e)/(e)/ commit-id:11b3a474 * Modify proto docker and tiltfile to stop creating unnecessary files (#144) * Remove sdk/spydk from wasm and remove buf gen web yaml (#145) * Remove wormhole contract from wasm generation (#160) * pyth2wormhole: Add num_publishers to libraries and contracts commit-id:f7263eed * pyth2wormhole: add max_num_publishers to cross-chain metadata commit-id:7550fa50 * Move p2w relayer parsing to p2w sdk js (#162) * Move Price Attestation parsing logic to the sdk * pyth2wormhole: Add contract testing boilerplate for attest() commit-id:51949fbe * Create p2w-api base (from p2w-relay) (#142) * Create p2w-api base (from p2w-relay) * Refactor project structure * Rename p2w to pyth price service (#166) * Abehjati/price-service-add-rest-layer (#167) * Add rest api for latest vaa Co-authored-by: Stan Drozd <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Eran Davidovich <[email protected]> Co-authored-by: Tom Pointon <[email protected]> Co-authored-by: Stan Drozd <[email protected]>
2022-04-11 09:15:20 -07:00
for (var i = 1; i <= RAW_BATCH_ATTESTATION_COUNT; i++) {
const price_id =
"0x" +
(255 - (i % 256)).toString(16).padStart(2, "0").repeat(32);
expectRevert(
this.pythProxy.getPrice(price_id),
"no price available which is recent enough"
);
}
});
it("changing validity time works", async function() {
const latestTime = await time.latest();
let rawBatch = generateRawBatchAttestation(
latestTime,
latestTime,
1337
);
await updatePriceFeeds(this.pythProxy, [rawBatch]);
// Setting the validity time to 30 seconds
await this.pythProxy.updateValidTimePeriodSeconds(30);
// Then prices should be available
for (var i = 1; i <= RAW_BATCH_ATTESTATION_COUNT; i++) {
const price_id =
"0x" +
(255 - (i % 256)).toString(16).padStart(2, "0").repeat(32);
// Expect getPrice to work (not revert)
await this.pythProxy.getPrice(price_id);
}
// One minute passes
await time.increase(time.duration.minutes(1));
// The prices should become unavailable now.
for (var i = 1; i <= RAW_BATCH_ATTESTATION_COUNT; i++) {
const price_id =
"0x" +
(255 - (i % 256)).toString(16).padStart(2, "0").repeat(32);
expectRevert(
this.pythProxy.getPrice(price_id),
"no price available which is recent enough"
);
}
// Setting the validity time to 120 seconds
await this.pythProxy.updateValidTimePeriodSeconds(120);
// Then prices should be available because the valid period is now 120 seconds
for (var i = 1; i <= RAW_BATCH_ATTESTATION_COUNT; i++) {
const price_id =
"0x" +
(255 - (i % 256)).toString(16).padStart(2, "0").repeat(32);
let priceFeedResult = await this.pythProxy.queryPriceFeed(price_id);
// Expect getPrice to work (not revert)
await this.pythProxy.getPrice(price_id);
}
});
it("should use prev price and timestamp on unknown attestation status", async function () {
const latestTime = await time.latest();
let rawBatch = generateRawUnknownBatchAttestation(
latestTime,
latestTime,
1337, // price
1500, // ema price
latestTime - 10,
1000, // prev price
);
const receipt = await updatePriceFeeds(this.pythProxy, [rawBatch]);
expectEvent(receipt, 'PriceFeedUpdate', {
price: "1000",
});
// Then prices should be available because the valid period is now 120 seconds
for (var i = 1; i <= RAW_UNKNOWN_BATCH_ATTESTATION_COUNT; i++) {
const price_id =
"0x" +
(255 - (i % 256)).toString(16).padStart(2, "0").repeat(32);
const price = await this.pythProxy.getPrice(price_id);
assert.equal(price.price, "1000");
assert.equal(price.publishTime, (latestTime - 10).toString());
const emaPrice = await this.pythProxy.getEmaPrice(price_id);
assert.equal(emaPrice.price, "1500");
assert.equal(emaPrice.publishTime, (latestTime - 10).toString());
}
});
it("should accept a VM after adding its data source", async function () {
let newChainId = "42424";
let newEmitter = testPyth2WormholeEmitter.replace("a", "f");
await this.pythProxy.addDataSource(newChainId, newEmitter);
let currentTimestamp = (await web3.eth.getBlock("latest")).timestamp;
let rawBatch = generateRawBatchAttestation(
currentTimestamp - 5,
currentTimestamp,
1337
);
let vm = await signAndEncodeVM(
1,
1,
newChainId,
newEmitter,
0,
rawBatch,
[testSigner1PK],
0,
0
);
await this.pythProxy.updatePriceFeeds(["0x" + vm]);
});
it("should reject a VM after removing its data source", async function () {
// Add 2 new data sources to produce a non-trivial data source state.
let newChainId = "42424";
let newEmitter = testPyth2WormholeEmitter.replace("a", "f");
await this.pythProxy.addDataSource(newChainId, newEmitter);
let newChainId2 = "42425";
let newEmitter2 = testPyth2WormholeEmitter.replace("a", "e");
await this.pythProxy.addDataSource(newChainId2, newEmitter2);
// Remove the first one added
await this.pythProxy.removeDataSource(newChainId, newEmitter);
// Sign a batch with the removed data source
let currentTimestamp = (await web3.eth.getBlock("latest")).timestamp;
let rawBatch = generateRawBatchAttestation(
currentTimestamp - 5,
currentTimestamp,
1337
);
let vm = await signAndEncodeVM(
1,
1,
newChainId,
newEmitter,
0,
rawBatch,
[testSigner1PK],
0,
0
);
await expectRevert(
this.pythProxy.updatePriceFeeds(["0x" + vm]),
"invalid data source chain/emitter ID"
);
});
// Governance
// Logics that apply to all governance messages
it("Make sure invalid magic and module won't work", async function () {
// First 4 bytes of data are magic and the second byte after that is module
const data = new governance.SetValidPeriodInstruction(governance.CHAINS.ethereum, BigInt(10)).serialize();
const wrongMagic = Buffer.from(data);
wrongMagic[1] = 0;
const vaaWrongMagic = await createVAAFromUint8Array(wrongMagic,
testGovernanceChainId,
testGovernanceEmitter,
1
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaWrongMagic),
"invalid magic for GovernanceInstruction"
);
const wrongModule = Buffer.from(data);
wrongModule[4] = 0;
const vaaWrongModule = await createVAAFromUint8Array(wrongModule,
testGovernanceChainId,
testGovernanceEmitter,
1
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaWrongModule),
"invalid module for GovernanceInstruction"
);
const outOfBoundModule = Buffer.from(data);
outOfBoundModule[4] = 20;
const vaaOutOfBoundModule = await createVAAFromUint8Array(outOfBoundModule,
testGovernanceChainId,
testGovernanceEmitter,
1
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaOutOfBoundModule),
"Panic: Enum value out of bounds.",
);
});
it("Make sure governance with wrong sender won't work", async function () {
const data = new governance.SetValidPeriodInstruction(governance.CHAINS.ethereum, BigInt(10)).serialize();
const vaaWrongEmitter = await createVAAFromUint8Array(data,
testGovernanceChainId,
"0x0000000000000000000000000000000000000000000000000000000000001111",
1
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaWrongEmitter),
"VAA is not coming from the governance data source"
);
const vaaWrongChain = await createVAAFromUint8Array(data,
governance.CHAINS.karura,
testGovernanceEmitter,
1
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaWrongChain),
"VAA is not coming from the governance data source"
);
});
it("Make sure governance with only target chain id and 0 work", async function () {
const wrongChainData = new governance.SetValidPeriodInstruction(governance.CHAINS.solana, BigInt(10)).serialize();
const wrongChainVaa = await createVAAFromUint8Array(wrongChainData,
testGovernanceChainId,
testGovernanceEmitter,
1
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(wrongChainVaa),
"invalid target chain for this governance instruction"
);
const dataForAllChains = new governance.SetValidPeriodInstruction(governance.CHAINS.unset, BigInt(10)).serialize();
const vaaForAllChains = await createVAAFromUint8Array(dataForAllChains,
testGovernanceChainId,
testGovernanceEmitter,
1
);
await this.pythProxy.executeGovernanceInstruction(vaaForAllChains);
const dataForEth = new governance.SetValidPeriodInstruction(governance.CHAINS.ethereum, BigInt(10)).serialize();
const vaaForEth = await createVAAFromUint8Array(dataForEth,
testGovernanceChainId,
testGovernanceEmitter,
2,
);
await this.pythProxy.executeGovernanceInstruction(vaaForEth);
});
it("Make sure that governance messages are executed in order and cannot be reused", async function () {
const data = new governance.SetValidPeriodInstruction(governance.CHAINS.ethereum, BigInt(10)).serialize();
const vaaSeq1 = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
1
);
await this.pythProxy.executeGovernanceInstruction(vaaSeq1),
// Replaying shouldn't work
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaSeq1),
"VAA is older than the last executed governance VAA",
)
const vaaSeq2 = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
2
);
await this.pythProxy.executeGovernanceInstruction(vaaSeq2),
// Replaying shouldn't work
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaSeq1),
"VAA is older than the last executed governance VAA",
)
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaaSeq2),
"VAA is older than the last executed governance VAA",
)
});
// Per governance type logic
it("Upgrading the contract with chain id 0 is invalid", async function () {
const newImplementation = await PythUpgradable.new();
const data = new governance.EthereumUpgradeContractInstruction(
governance.CHAINS.unset, // 0
new governance.HexString20Bytes(newImplementation.address),
).serialize();
const vaa = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
1
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(vaa),
"upgrade with chain id 0 is not possible"
);
});
it("Upgrading the contract should work", async function () {
const newImplementation = await PythUpgradable.new();
const data = new governance.EthereumUpgradeContractInstruction(
governance.CHAINS.ethereum,
new governance.HexString20Bytes(newImplementation.address),
).serialize();
const vaa = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
1
);
const receipt = await this.pythProxy.executeGovernanceInstruction(vaa);
// Couldn't get the oldImplementation address.
expectEvent(receipt, 'ContractUpgraded', {
newImplementation: newImplementation.address,
});
expectEvent(receipt, 'Upgraded', {
implementation: newImplementation.address
});
});
it("Setting governance data source should work", async function () {
const data = new governance.SetGovernanceDataSourceInstruction(
governance.CHAINS.ethereum,
new governance.DataSource(
governance.CHAINS.acala,
new governance.HexString32Bytes(
"0x0000000000000000000000000000000000000000000000000000000000001111",
)
),
BigInt(10)
).serialize();
const vaa = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
1
);
const oldGovernanceDataSource = await this.pythProxy.governanceDataSource();
const receipt = await this.pythProxy.executeGovernanceInstruction(vaa);
expectEvent(receipt, 'GovernanceDataSourceSet', {
oldDataSource: oldGovernanceDataSource,
newDataSource: await this.pythProxy.governanceDataSource(),
});
const newVaaFromOldGovernanceSource = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
2
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(newVaaFromOldGovernanceSource),
"VAA is not coming from the governance data source"
);
const newVaaFromNewGovernanceOldSequence = await createVAAFromUint8Array(data,
governance.CHAINS.acala,
"0x0000000000000000000000000000000000000000000000000000000000001111",
2
);
await expectRevert(
this.pythProxy.executeGovernanceInstruction(newVaaFromNewGovernanceOldSequence),
"VAA is older than the last executed governance VAA"
);
const newVaaFromNewGovernanceGood = await createVAAFromUint8Array(data,
governance.CHAINS.acala,
"0x0000000000000000000000000000000000000000000000000000000000001111",
20
);
await this.pythProxy.executeGovernanceInstruction(newVaaFromNewGovernanceGood);
});
it("Setting data sources should work", async function () {
const data = new governance.SetDataSourcesInstruction(
governance.CHAINS.ethereum,
[new governance.DataSource(
governance.CHAINS.acala,
new governance.HexString32Bytes(
"0x0000000000000000000000000000000000000000000000000000000000001111",
)
)],
).serialize();
const vaa = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
1
);
const oldDataSources = await this.pythProxy.validDataSources();
const receipt = await this.pythProxy.executeGovernanceInstruction(vaa);
expectEvent(receipt, 'DataSourcesSet', {
oldDataSources: oldDataSources,
newDataSources: await this.pythProxy.validDataSources(),
});
assert.isTrue(await this.pythProxy.isValidDataSource(governance.CHAINS.acala,
"0x0000000000000000000000000000000000000000000000000000000000001111"));
assert.isFalse(await this.pythProxy.isValidDataSource(testPyth2WormholeChainId,
testPyth2WormholeEmitter));
let rawBatch = generateRawBatchAttestation(
100,
100,
1337
);
await expectRevert(
updatePriceFeeds(this.pythProxy, [rawBatch]),
"invalid data source chain/emitter ID"
);
await updatePriceFeeds(this.pythProxy, [rawBatch], 0, governance.CHAINS.acala,
"0x0000000000000000000000000000000000000000000000000000000000001111");
});
it("Setting fee should work", async function () {
const data = new governance.SetFeeInstruction(
governance.CHAINS.ethereum,
BigInt(5), BigInt(3) // 5*10**3 = 5000
).serialize();
const vaa = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
1
);
const oldFee = await this.pythProxy.singleUpdateFeeInWei();
const receipt = await this.pythProxy.executeGovernanceInstruction(vaa);
expectEvent(receipt, 'FeeSet', {
oldFee: oldFee,
newFee: await this.pythProxy.singleUpdateFeeInWei(),
});
assert.equal(await this.pythProxy.singleUpdateFeeInWei(), "5000");
let rawBatch = generateRawBatchAttestation(
100,
100,
1337
);
await expectRevert(
updatePriceFeeds(this.pythProxy, [rawBatch], 0),
insufficientFeeError
);
const receiptUpdateFeeds = await updatePriceFeeds(this.pythProxy, [rawBatch], 5000);
expectEvent(receiptUpdateFeeds, 'UpdatePriceFeeds', {
fee: "5000"
});
});
it("Setting valid period should work", async function () {
const data = new governance.SetValidPeriodInstruction(
governance.CHAINS.ethereum,
BigInt(0),
).serialize();
const vaa = await createVAAFromUint8Array(data,
testGovernanceChainId,
testGovernanceEmitter,
1
);
const oldValidPeriod = await this.pythProxy.validTimePeriodSeconds();
const receipt = await this.pythProxy.executeGovernanceInstruction(vaa);
expectEvent(receipt, 'ValidPeriodSet', {
oldValidPeriod: oldValidPeriod,
newValidPeriod: await this.pythProxy.validTimePeriodSeconds(),
});
assert.equal(await this.pythProxy.validTimePeriodSeconds(), "0");
// The behaviour of valid time period is extensively tested before,
// and adding it here will cause more complexity (and is not so short).
});
// Renounce ownership works
it("Renouncing ownership should work", async function () {
await this.pythProxy.updateValidTimePeriodSeconds(100);
await this.pythProxy.renounceOwnership();
await expectRevert(
this.pythProxy.updateValidTimePeriodSeconds(60),
"Ownable: caller is not the owner",
)
});
// Version
it("Make sure version is the npm package version", async function () {
const contractVersion = await this.pythProxy.version();
const { version } = require('../package.json');
expect(contractVersion).equal(version);
});
});
const signAndEncodeVM = async function (
timestamp,
nonce,
emitterChainId,
emitterAddress,
sequence,
data,
signers,
guardianSetIndex,
consistencyLevel
) {
const body = [
web3.eth.abi
.encodeParameter("uint32", timestamp)
.substring(2 + (64 - 8)),
web3.eth.abi.encodeParameter("uint32", nonce).substring(2 + (64 - 8)),
web3.eth.abi
.encodeParameter("uint16", emitterChainId)
.substring(2 + (64 - 4)),
web3.eth.abi.encodeParameter("bytes32", emitterAddress).substring(2),
web3.eth.abi
.encodeParameter("uint64", sequence)
.substring(2 + (64 - 16)),
web3.eth.abi
.encodeParameter("uint8", consistencyLevel)
.substring(2 + (64 - 2)),
data.substr(2),
];
const hash = web3.utils.soliditySha3(
web3.utils.soliditySha3("0x" + body.join(""))
);
let signatures = "";
for (let i in signers) {
const ec = new elliptic.ec("secp256k1");
const key = ec.keyFromPrivate(signers[i]);
const signature = key.sign(hash.substr(2), { canonical: true });
const packSig = [
web3.eth.abi.encodeParameter("uint8", i).substring(2 + (64 - 2)),
zeroPadBytes(signature.r.toString(16), 32),
zeroPadBytes(signature.s.toString(16), 32),
web3.eth.abi
.encodeParameter("uint8", signature.recoveryParam)
.substr(2 + (64 - 2)),
];
signatures += packSig.join("");
}
const vm = [
web3.eth.abi.encodeParameter("uint8", 1).substring(2 + (64 - 2)),
web3.eth.abi
.encodeParameter("uint32", guardianSetIndex)
.substring(2 + (64 - 8)),
web3.eth.abi
.encodeParameter("uint8", signers.length)
.substring(2 + (64 - 2)),
signatures,
body.join(""),
].join("");
return vm;
};
function zeroPadBytes(value, length) {
while (value.length < 2 * length) {
value = "0" + value;
}
return value;
[WIP] Pr/drozdziak1/p2w batching/5e704f8b (#877) * ethereum: p2w contract -> p2w emitter, fill in essential envs Change-Id: I6fa9364a96738d2cc02ec829a31fedba0586d8e8 commit-id:0a56f1f8 * Add p2w-relay, a p2w-sdk integration test commit-id:6bfab639 * p2w-sdk: Expand README Change-Id: I17cb547d6aaddc240588923561c26d11a787df2e commit-id:6ebd6a22 * p2w-sdk: don't build ETH contracts, only the types Change-Id: I7cbd18328227700635d7688aa24a9671e8919fcd commit-id:adf079f7 * p2w: configurability and sane envs commit-id:f10fd90e * Solitaire: Implement Option<T> support in structs commit-id:31aa12d6 * bridge/governance.rs: Stop pestering about EMITTER_ADDRESS commit-id:d5bd7234 * p2w-attest: price batching This commit introduces support for multiple Pyth product/price pairs per call. The initial maximum batch size is 5 and is enforced using a `P2W_MAX_BATCH_SIZE` constant. solana/pyth2wormhole/program: * On-chain batching logic * Batch message parsing logic solana/pyth2wormhole/client: * Off-chain batching logic - divides any number of symbols into largest possible batches * Use a multi-symbol config file instead of CLI arguments third_party/pyth/p2w-sdk: * Expose batch parsing logic third_party/pyth/p2w-relay: * Comment out target chain calls until ETH contract supports batching * Test the batch parsing function third_party/pyth/p2w_autoattest.py: * Generate and use the symbol config file with pyth2wormhole-client third_party/pyth/pyth_publisher.py: * Add a configurable number of mock Pyth symbols * Adjust HTTP endpoint for multiple symbols commit-id:73787a61 * p2w-attest: mention attestation size in batch This commit ensures that no matter the attestation format, a batch will never contain attestations of different sizes. This guarantee enables forward compatibility by adding new constant-size fields at the end of a batch at all times. An older implementation will simply not consume the remaining newer values while respecting the stated batch member alignment. commit-id:210da230 * pyth2wormhole-client: use fresh blockhashes, harden batch errors This commit makes sure we don't have to deal with expired transactions due to stale blockhashes. The problem existed with larger symbol configs as well as on Solana mainnet. Additionally, the attestation logic now treats transaction errors as non-critical - a failure for a batch does not prevent attestation attempts for batches farther in the queue commit-id:5e704f8b
2022-02-23 10:12:16 -08:00
}
async function createVAAFromUint8Array(
dataBuffer,
emitterChainId,
emitterAddress,
sequence,
) {
const dataHex = "0x" + dataBuffer.toString("hex");
return "0x" + await signAndEncodeVM(
0,
0,
emitterChainId.toString(),
emitterAddress,
sequence,
dataHex,
[testSigner1PK],
0,
0
);
}