Commit Graph

188 Commits

Author SHA1 Message Date
Ali Behjati 04d8a468ac
[eth] Improve docs and repo (#438)
* Remove .openzeppelin and its docs

This directory is no longer useful as we are not using truffle for
upgrades anymore.

* Update Deploying.md doc according to the feedbacks

* Add *mnemonic* to gitignore to avoid mistakes
2022-12-21 14:16:28 +01:00
Daniel Chew 2efd512d36
[eth] Deploy to arbitrum-testnet (#436)
* add arbitrum-testnet contract

* Fix format issues

Co-authored-by: Ali Behjati <bahjatia@gmail.com>
2022-12-20 19:02:59 +01:00
Ali Behjati 09f8af74ed
[eth] Complete syncPythState.js (#425) 2022-12-13 17:54:15 +01:00
Ali Behjati b1aea626e9
[eth] Add new networks and their configurations (#418)
* Add new networks RPCs

* Update governance sdk to support Wormhole receiver

* Fix receiver deployment script bugs

* Add new network configurations

* Add a comment about merging wh and receiver chains
2022-12-08 18:14:18 +01:00
Ali Behjati 4821b877e3
[eth] Improve and automate deployment process (#412)
* Bump contract version

* Some refactoring to add types with JSDoc

* Use better RPCs for some networks

* Remove unneeded migration files

* Add initial syncPythState script that does upgrade

* Update truffle-config for new gas values
2022-12-06 17:56:21 +01:00
Ali Behjati f8447f871e
[eth]: Improve optimization runs to 10000 (#406)
* Update a deprecated state var comment

* Improve optimization runs 10000
2022-11-30 15:56:44 +01:00
Ali Behjati 33f5b8a5bf
[eth] Remove ownership entirely in favor of governance (#405) 2022-11-30 12:13:46 +01:00
Ali Behjati c3461e5e1c
[eth] Use PythErrors everywhere (#404)
* Remove unnecessary check
* Use PythErrors everywhere
2022-11-29 18:30:45 +01:00
Ali Behjati b31f768d37
Update wormhole receiver contract (#398)
- Add chainId
- Remove receiver ownership
2022-11-29 13:39:39 +01:00
Ali Behjati 45ce07725f
Update contract initializer (#397)
* Update contract initializer
* Reduce optimizer runs to 1000
2022-11-29 12:11:49 +01:00
Ali Behjati d6e25d9209
Add pre-commit globally (#393)
* Add pre-commit globally

* Fix CI errors
2022-11-24 14:14:29 +01:00
Ali Behjati 275c7b8d1a
[eth] Add parsePriceFeedUpdates method (#392)
* Add the implementation with tests and benchmark

* Refactor the contract to reduce redundancy

* Reduce optimization runs as the contract was huge

It has 177 more gas usage on some benchmark tests
2022-11-23 17:16:28 +01:00
Ali Behjati 598b0dde1b
[eth] Gas improvement: Increase optimizer runs to 10000 (#390)
* [eth]: Gas improvement: Increase optimizer runs to 1_000_000
Increasing optimizer runs will optimize the gas usage of methods more and will increase the contract size, hence the deployment cost.

Snapshot difference:
```
testBenchmarkGetUpdateFee() (gas: -101 (-0.076%))
testBenchmarkUpdatePriceFeedsIfNecessaryNotFresh() (gas: -334 (-0.189%))
testBenchmarkUpdatePriceFeedsNotFresh() (gas: -1312 (-0.416%))
testBenchmarkUpdatePriceFeedsIfNecessaryFresh() (gas: -1626 (-0.430%))
testBenchmarkUpdatePriceFeedsFresh() (gas: -1576 (-0.441%))
testBenchmarkGetPrice() (gas: -259 (-0.969%))
```

p.s: I read one place that `runs` is an estimate of how many times the contract is expected to be called as opposed to number of optimization passes through the code!

* Change optimizer_runs to 10000
2022-11-18 15:42:19 +01:00
Ali Behjati bb06fdb831
[eth] Gas improvement: Optimize getPrice and getEmaPrice (#389)
* Optimize getPrice and getEmaPrice
2022-11-18 14:42:06 +01:00
Ali Behjati 9c5425d829
Optimize updatePriceFeedsIfNecessary (#388) 2022-11-17 20:41:02 +01:00
Ali Behjati 2597596022
[eth] Gas improvement: Optimize events (#387)
* Update pyth-sdk-solidity version

* Add parsePriceFeedUpdates as an empty method

To be implemented in the future

* Update events

* Fix tests

* Address Tom review comment

* Fix Pyth forge test
2022-11-17 17:44:21 +01:00
Ali Behjati ca7441fd68
[eth] Gas improvement: Use optimized version of BytesLib (#380)
* Copy BytesLib.sol to OptimizedBytesLib.sol

* Remove `require`s from OptimizedBytesLib

* Use OptimizedBytesLib

* revert to use BytesLib for governance

* Rename to UnsafeBytesLib + use it explicitly
2022-11-10 17:17:16 +00:00
Ali Behjati 9d5cc533ea
Change internal storage layout and order (#379) 2022-11-07 13:01:49 +01:00
Ali Behjati b0a2b13e22
[eth] Wrap parsing method with unchecked (#378)
* Move parsing method to unchecked

There is no overflow possible there

* Update another for loop to be unchecked
2022-11-04 17:48:20 +01:00
Ali Behjati 8db2af6ee5
Use latestPriceInfoPublishTime when possible (#377) 2022-11-04 17:16:14 +01:00
Ali Behjati b23258112d
Remove middle structs (#375)
* Remove middle structs

* Parse and process attestation in place

It helps a lot because we won't expand memory anymore

* Update comments

* Remove unusued PriceAttestation struct
2022-11-04 16:44:07 +01:00
Ali Behjati 61651a10f2
Modify PriceInfo struct for gas optimization (#373)
This PR removes unneeded PriceInfo fields and rearranges the struct in a way that it takes less storage.
2022-11-04 11:41:01 +01:00
Ali Behjati 1a9dfb6c0d
[eth]: Fix gas benchmark to generate useful gas snapshot (#372)
* [eth]: Fix incorrect gas usage problem

* Make gas report more accurate

* Update readme

* Address Jayant comment
2022-11-03 12:18:48 +01:00
Ali Behjati 0df243ba9e
[eth] Add benchmark tests (#368)
* Add remappings

This helps vs code solidity LSP work

* Remove unused wormhole contract

* Format foundry config file

* Fix install foundry script

* Add benchmark tests and its utils
2022-11-02 10:59:39 +01:00
Ali Behjati a9a1fb7b5a
Add deployment files of optimism goerli + fix bugs (#364) 2022-10-27 20:01:14 +02:00
Ali Behjati 1c17499d03
Add foundry base (#362)
* Add foundry base

* Address Reisen comments
2022-10-25 17:49:24 +02:00
Ali Behjati d9e94b284d
Refactor the governance code a bit (#359) 2022-10-21 17:04:19 +02:00
Ali Behjati bdc492f919
[eth] Some contract improvements (#356) 2022-10-19 19:47:09 +02:00
Ali Behjati 398b18743d
[eth] Make governance transfer less error-prone (#355) 2022-10-19 19:46:26 +02:00
Ali Behjati d3d10f2ce2
Add set fee to tests + add some sanity checks (#350)
* Add set fee to tests + add some sanity checks

* Add fee to evm relayer
2022-10-18 19:07:37 +02:00
Ali Behjati c47199d6cb
[eth] contract improvement (#348)
* Make Pyth.initialize private

* Make contract upgrade more resillient + add fail test

* Remove deployCommitHash

The deployCommitHash process is error-prone and it's alternatives
require changing many parts of the code.
And as it is not used anywhere. I believe it is not
worth the effort.

* Improve price not found log
2022-10-17 16:19:55 +02:00
Ali Behjati 62ef9d7d1f
Add set fee mainnet deployment info (#349) 2022-10-17 13:46:11 +02:00
Ali Behjati f7958e387f
[eth] Add set fee migration step + deployment process improvement (#346)
* Remove celo conf files as we are not there

* Remove some unused files

* Move common variables to cluster env
Also rename mainnet to ethereum

* Update migration scripts

* Remove ropsten, it's decommissioned

* Update template

* Create deployment script

* Add set fee migration step

* Comment out old upgrade process with good comments

* Address Tom comments

* Use a helper function for loading env
2022-10-13 19:09:52 -05:00
Ali Behjati 8760bfb739
Add deployment files (#320) 2022-09-30 10:38:05 +02:00
Ali Behjati d5b4f571f0
Set/Update governance emitter addresses (#307) 2022-09-28 09:22:50 +02:00
Ali Behjati 4cec02d4da
Upgrade bnb testnet and renounce ownership (#303) 2022-09-28 00:44:51 +02:00
Ali Behjati 9a285cf799
Abehjati/eth-update-interface (#301)
* Update contract interface to the latest sdk

* Add migration step

* Fix eth2 chainid change

* Address reviews
2022-09-23 19:19:02 +02:00
Ali Behjati 44111714f9
Add new contract memory layout (#293) 2022-09-21 15:00:44 +02:00
Ali Behjati 2ad991f4ab
Abehjati/add-eth-governance (#279)
Also add governance-sdk-js to generate messages (both in testing and in multisig)
2022-09-20 18:24:57 +02:00
Ali Behjati 05c631b022
Add mainnet networks (#274) 2022-09-10 08:35:07 +02:00
Ali Behjati dd3f5a57ee
Abehjati/fix-deployment-bugs (#272)
* Fix migration files

* Use another rpc endpoint for bnb

* Fix the bogus commit hash replacement instruction

* Use a more clear placeholder
2022-09-07 12:00:18 +02:00
Ali Behjati 65c273fa0a
Add pythnet migration files (#246)
* Add pythnet migration files

Also:
- Add related env vars for testnet networks. Mainnet ones to be added
when it's ready.
- Rename Pyth2Wormhole env vars to solana

* Add mainnet emitter

* Fix migration file numbers

* Address Jayant comments
2022-09-06 13:03:21 +02:00
Ali Behjati 56563599ac
Abehjati/update-target-chains (#260)
* Disable storage collision check on some migrations

Some changes after them have storage collision and this requires them to
disable it too

* Add new implementation memory layouts
2022-08-26 12:01:30 +02:00
Ali Behjati a17b27f3d1
Eth contract fix memory + new sdk + refactor (#257)
* Update sdk version

* Update the contract according to the sdk changes

- Change some memory modifiers to improve gas efficiency
- Implement getValidTimePeriod() and remove old staleness logic
- Update the tests

* Update latest migration descriptions

* Add version

* Update Deploying.md

* Add test to validate version of the contract

* Add deploy commit hash

* Rename the placeholder

* Fix placeholder
2022-08-24 19:33:49 +02:00
Ali Behjati 995c886804
Update solidity sdk version (#255)
* Update solidity sdk package.

* Add migration files
2022-08-23 09:48:24 +02:00
Ali Behjati f09c46b1cd
Make validTimePeriod configurable (#249)
* Make validTimePeriod configurable
2022-08-22 20:13:13 +02:00
Ali Behjati 22cdd5efb1
Abehjati/update-eth-contract-prev-price (#252)
* Set prev* to current* when price gets stale

* Add new solidity sdk

* Add migration files for this update

* rename diff to absDiff

Strangely, although you cannot use parent private method, you cannot
define a method with same name

* Add a comment to explain the prevPrice replacement
2022-08-19 13:42:19 +02:00
Ali Behjati 6fc11fc289
Upgrade testnet contracts (#248)
* Upgrade testnet contracts

And fixes some issues for it. Specially it uses
unsafeSkipStorage to skip OZ collision check
as they are very conservative and doesn't
cover our valid memory changes.
We should be very careful in memory
changes now that we cannot use
OZ collision check.

* Address Tom comments
2022-08-10 15:58:13 +02:00
Ali Behjati d5186f8d56
Update 4_pyth_add_events_and_update_fee.js (#244) 2022-07-29 15:57:10 +02:00
Ali Behjati 5320c58cf6
Implement the new IPyth events and methods (#241)
* Implement the new IPyth events and methods

* Check contracts gets the fees in tests

* Fix the fee variable position to avoid conflict

* Add migration files.

* Add events to migration names and docs

* Fix pyth contract address in tests

Very strangely after adding migration steps the old address
used in evm relay became wormhole implementation address
I looked at eth-0/tests container logs and saw the
address is entirely different (before and after the change)

* Fix previous migration bug.

* rename instance to proxy to be more clear

* Update Deploying.md
2022-07-28 14:56:13 +02:00