guibescos d06c10502d [evm] Verifying shimmer_testnet and neon_devnet with hardhat (#703) 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 fc0de28b86 [eth] Update zksync goerli after network reset (#697) 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.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 533181cc80 [eth] add evmos testnet (#683) 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 d06c10502d [evm] Verifying shimmer_testnet and neon_devnet with hardhat (#703) 2 年 前
remappings.txt bbe10ba553 [sdk] Move JS sdks into this repo (#611) 2 年 前
truffle-config.js 156fb23f24 [evm] deploy neon devnet (#693) 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.