Jayant Krishnamurthy c45664c951 [evm] Polygon ZKEVM deployment (#711) 2 жил өмнө
..
contracts bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
deploy bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
forge-test bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
lib bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
migrations bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
networks c45664c951 [evm] Polygon ZKEVM deployment (#711) 2 жил өмнө
scripts 085f08055a [eth] Add zksync mainnet (#682) 2 жил өмнө
test bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.dockerignore bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.cluster.mainnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.cluster.testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.arbitrum bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.arbitrum_testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.aurora bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.aurora_testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.avalanche bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.base_goerli 70c006176b Add base goerli config (#668) 2 жил өмнө
.env.prod.bnb bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.bnb_testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.celo bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.celo_alfajores_testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.chiado 1771a8a98a [eth] Add new testnets (#669) 2 жил өмнө
.env.prod.cronos bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.cronos_testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.development bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.ethereum bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.evmos de0096efd4 [eth] add evmos mainnet (#686) 2 жил өмнө
.env.prod.evmos_testnet 533181cc80 [eth] add evmos testnet (#683) 2 жил өмнө
.env.prod.fantom bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.fantom_testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.fuji bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.goerli bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.kcc bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.kcc_testnet bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.mumbai bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.neon_devnet 156fb23f24 [evm] deploy neon devnet (#693) 2 жил өмнө
.env.prod.optimism bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.optimism_goerli bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.polygon bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.polygon_zkevm_testnet c45664c951 [evm] Polygon ZKEVM deployment (#711) 2 жил өмнө
.env.prod.shimmer_testnet 1771a8a98a [eth] Add new testnets (#669) 2 жил өмнө
.env.prod.zksync bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.prod.zksync_goerli bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.template bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.env.test bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
.gitignore 085f08055a [eth] Add zksync mainnet (#682) 2 жил өмнө
Deploying.md c45664c951 [evm] Polygon ZKEVM deployment (#711) 2 жил өмнө
README.md 533181cc80 [eth] add evmos testnet (#683) 2 жил өмнө
VERIFY.md d06c10502d [evm] Verifying shimmer_testnet and neon_devnet with hardhat (#703) 2 жил өмнө
deploy.sh bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
foundry.toml bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
hardhat.config.ts d06c10502d [evm] Verifying shimmer_testnet and neon_devnet with hardhat (#703) 2 жил өмнө
mine.js bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
package.json e995a2b89e Add CI workflow to publish javascript packages (#707) 2 жил өмнө
remappings.txt bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 жил өмнө
truffle-config.js c45664c951 [evm] Polygon ZKEVM deployment (#711) 2 жил өмнө

README.md

Pyth Ethereum Contract

This directory contains The Pyth contract on Ethereum and utilities to deploy it in EVM chains.

Installation

Run the following command on the repo root to install required dependencies for the contract:

npm ci
npx lerna run build --scope="@pythnetwork/pyth-evm-contract" --include-dependencies

Deployment

Please refer to Deploying.md for more information.

Foundry

Foundry can be installed by the official installer, or by running our helper script which will automatically pull the correct installation script individually for Foundry and the Solidity compiler for your current OS. This may work better if you are running into networking/firewall issues using Foundry's Solidity installer. To use helper script, run the command below from this directory:

pyth-crosschain/target_chains/ethereum/contracts $ bash ../../../scripts/install-foundry.sh

You need to install npm dependencies as described in Installation. Also, you need to run the following command in the contracts directory to install forge dependencies:

npm run install-forge-deps

After installing the dependencies. Run forge build to build the contracts and forge test to test the contracts using tests in forge-test directory.

Gas Benchmark

You can use foundry to run benchmark tests written in forge-test/GasBenchmark.t.sol. To run the tests with gas report you can run forge test --gas-report --match-contract GasBenchmark. However, as there are multiple benchmarks, this might not be useful. You can run a specific benchmark test by passing the test name using --match-test. A full command to run testBenchmarkUpdatePriceFeedsFresh benchmark test is like this:

forge test --gas-report --match-contract GasBenchmark --match-test testBenchmarkUpdatePriceFeedsFresh

A gas report should have a couple of tables like this:

╭───────────────────────────────────────────────────────────────────────────────────────────┬─────────────────┬────────┬────────┬─────────┬─────────╮
│ node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy contract ┆                 ┆        ┆        ┆         ┆         │
╞═══════════════════════════════════════════════════════════════════════════════════════════╪═════════════════╪════════╪════════╪═════════╪═════════╡
│ Deployment Cost                                                                           ┆ Deployment Size ┆        ┆        ┆         ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 164236                                                                                    ┆ 2050            ┆        ┆        ┆         ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name                                                                             ┆ min             ┆ avg    ┆ median ┆ max     ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ .............                                                                             ┆ .....           ┆ .....  ┆ .....  ┆ .....   ┆ ..      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ updatePriceFeeds                                                                          ┆ 383169          ┆ 724277 ┆ 187385 ┆ 1065385 ┆ 2       │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ .............                                                                             ┆ .....           ┆ .....  ┆ .....  ┆ .....   ┆ ...     │
╰───────────────────────────────────────────────────────────────────────────────────────────┴─────────────────┴────────┴────────┴─────────┴─────────╯

For most of the methods, the minimum gas usage is an indication of our desired gas usage. Because the calls that store something in the storage for the first time in setUp use significantly more gas. For example, in the above table, there are two calls to updatePriceFeeds. The first call has happend in the setUp method and costed over a million gas and is not intended for our Benchmark. So our desired value is the minimum value which is around 380k gas.

If you like to optimize the contract and measure the gas optimization you can get gas snapshots using forge snapshot and evaluate your optimization with it. For more information, please refer to Gas Snapshots documentation. Once you optimized the code, please share the snapshot difference (generated using forge snapshot --diff <old-snapshot>) in the PR too. This snapshot gas value also includes an initial transaction cost as well as reading from the contract storage itself. You can get the most accurate result by looking at the gas report or the gas shown in the call trace with -vvvv argument to forge test.