Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OVM #147

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
9d3fc68
Will drop eventually. Connect to the ovm compatible v3-core contracts
elenadimitrova May 18, 2021
4747619
Ignore optimism folder from source control
elenadimitrova May 18, 2021
1545be4
Add hardhat-ovm package and config
elenadimitrova May 18, 2021
2fa4241
Add npm scripts for compiling and testing against the OVM
elenadimitrova May 18, 2021
8355ceb
Update to latest rebased with upstream changes core
elenadimitrova May 20, 2021
c9857f2
Add scripts for starting/stopping the optimism services (copy from core)
elenadimitrova May 20, 2021
42577c0
Remove obsoleted Address.isContract check
elenadimitrova May 21, 2021
d89b364
Add @eth-optimism/hardhat-ovm and hardhat-contract-sizer to hardhat c…
elenadimitrova May 21, 2021
f890a06
Update commit used for ovm-compatible uniswap v3 core contracts
mds1 May 20, 2021
071b71e
Add to gitignore the ovm cache and artifacts folders
elenadimitrova May 21, 2021
96ad50c
Add hardhat-contract-sizer package
elenadimitrova May 21, 2021
730db29
Update PeripheryPayments.refundETH to use WETH instead of ETH
elenadimitrova May 21, 2021
ef0f6ce
Add hardhat-dependency-compiler plugin and use it to help link libraries
mds1 May 21, 2021
f4e786a
Lower optimisation runs
elenadimitrova May 23, 2021
390ddbf
Patch @openzeppelin Address library for compliance with OVM
elenadimitrova May 23, 2021
0fd3c46
Use WETH only for value transfer
elenadimitrova May 24, 2021
e2553c3
Extract NonfungiblePositionManager.collect function into a library
elenadimitrova May 24, 2021
c24bbc8
Extract NonfungiblePositionManager.decreaseLiquidity function into a …
elenadimitrova May 24, 2021
a3d3dce
Extract NonfungiblePositionManager.increaseLiquidity function into a …
elenadimitrova May 24, 2021
46e61d7
Extract LiquidityManagement.addLiquidity function into a library
elenadimitrova May 24, 2021
1f70e13
Merge NonfungibleTokenPositionDescriptor with NonfungiblePositionLibr…
elenadimitrova May 24, 2021
3445fb1
Do not recompose PoolKey struct. Saves 57 bytes in NonfungiblePositio…
elenadimitrova May 24, 2021
f13fce2
Do not recompose PoolKey struct in mint function. Saves 102 bytes in …
elenadimitrova May 24, 2021
6cf78e1
Remove mistakenly added empty file
elenadimitrova May 24, 2021
8a4f929
Do not instantiate PoolKey struct in memory, reference storage instea…
elenadimitrova May 24, 2021
15cbdc2
Optimise NonfungiblePositionLibrary.collect function. NonfungiblePosi…
elenadimitrova May 24, 2021
72c0000
Remove parameterisation of WETH address and make that constant
elenadimitrova May 24, 2021
c3b9090
Cleanup usage of the NonfungiblePositionLibrary
elenadimitrova May 24, 2021
c6090a7
Optimise NonfungiblePositionLibrary.decreaseLiquidity function.
elenadimitrova May 24, 2021
5f6ef33
UniswapV3Pool and UniswapV3Factory are now only deployed once per tes…
mds1 May 24, 2021
35a94d1
Fix ABI imports
mds1 May 24, 2021
f5b905d
Fix WETH test which broke from changes in commit de5a8d0
mds1 May 24, 2021
de6295b
Fix deployment of MockTimeNonfungiblePositionManager
mds1 May 24, 2021
9cd17e8
Add typechain-ovm folder to .gitignore
mds1 May 24, 2021
17604e8
fix import
mds1 May 24, 2021
e2e2743
Update hardhat config with same adjustments made to Uniswap V3 Core
mds1 May 24, 2021
6663adc
Fix deployment of NonfungiblePositionManager
mds1 May 24, 2021
c1d96ba
Hardcode response to estimateGas to get more info on failures
mds1 May 24, 2021
b6b57c7
Fix: when testing on OVM, use pre-deployed WETH instead of deploying it
mds1 May 25, 2021
859f5cd
Make NonfungiblePositionManager.poolIdToPoolKey mapping public
elenadimitrova May 25, 2021
b9a4dd1
Refactor NonfungibleTokenPositionDescriptor tests into NonfungibleTok…
elenadimitrova May 25, 2021
7df8eed
Update @uniswap/v3-core to latest OVM-compatible commit
mds1 May 26, 2021
dc10389
Reduce optimizer's number of runs
mds1 May 26, 2021
7759e41
Update POOL_INIT_CODE_HASH - required due to update of v3-core contracts
mds1 May 26, 2021
7435715
Optimise increaseLiquidity function in NonfungiblePositionManager
elenadimitrova May 26, 2021
573c7a1
Move all events from INonfungiblePositionManager to NonfungiblePositi…
elenadimitrova May 26, 2021
1e284f3
Switch isAuthorizedForToken from modifier to a private function
elenadimitrova May 26, 2021
9b6d455
Extract logic for updating a position after minting
elenadimitrova May 26, 2021
3a99025
Update script to pull regenesis/0.4.0 branch
elenadimitrova May 26, 2021
1b06417
Restoring ETH opcodes: remove openzeppelin patch (undo 390ddbfeb7cc2e…
mds1 May 27, 2021
6e19b64
Restoring ETH opcodes: Restore how PeripheryPayments handles ETH (und…
mds1 May 27, 2021
1545010
Restoring ETH opcodes: Undo test changes used to accomodate hardcoded…
mds1 May 27, 2021
1a6ecb0
Restoring ETH opcodes: Add WETH back as an input parameter (undo 72c0…
mds1 May 27, 2021
406f41e
Switch l2geth and ovm solc version to WIP versions supporting ETH opc…
mds1 May 27, 2021
3462ac9
Add WETH address constructor arg to MockTimeNonfungiblePositionManager
mds1 May 27, 2021
a315345
Fix token ordering in V3 migrator test (token input order must be sor…
mds1 May 27, 2021
26519a2
Restore isContract check so EVM tests pass (undo 42577c079324348be75a…
mds1 May 27, 2021
8aa098d
Fix test that expected a revert but is no longer expected to revert
mds1 May 27, 2021
f712db6
Remove estimateGas override - estimateGas now provides useful error m…
mds1 May 28, 2021
56e691a
Add original WETH9 contract (sourced from https://etherscan.io/addres…
mds1 May 28, 2021
dde5cb8
Modify WETH9 to support 0.7.6 and deploy it from compiled contract
mds1 May 28, 2021
bde2512
Fix nonce too low error by awaiting each deploy instead of Promise.all()
mds1 May 28, 2021
ad9eb7a
Fix unsafe opcode from IncreaseLiquidity event
mds1 May 29, 2021
ff19473
Fix various nonce too low errors by awaiting each call instead of Pro…
mds1 Jun 1, 2021
80e2a7e
Add a 'Setup' test to ensure we always get the same bytecode hash
mds1 Jun 2, 2021
8c25c1e
Update optimism repo and branch used
mds1 Jun 3, 2021
907a65d
Remove unnecessary isContract check (undo 26519a2)
mds1 Jun 3, 2021
9d5e6b3
Update fixtures to only deploy WETH once to ensure safe address
mds1 Jun 3, 2021
43a1d68
Skip EOA tests since OVM has no EOAs
mds1 Jun 7, 2021
a5fa0b7
Fix nonce too low error by awaiting each call instead of Promise.all()
mds1 Jun 8, 2021
6af84f2
Fix for 'fully populated ticks' test reverting by using too much gas
mds1 Jun 8, 2021
3d75488
Add instructions about how to run tests
mds1 Jun 9, 2021
68e27f6
Update to latest v3-core commit
mds1 Jun 9, 2021
d709dab
Update branch used for optimism docker containers
mds1 Jun 10, 2021
277aa1a
Fix WETH9 to use a call instead of msg.sender.transfer()
mds1 Jun 10, 2021
c403e63
Update run-optimism script to use the regenesis/0.4.0 branch
mds1 Jun 11, 2021
242d984
Rename NonfungibleTokenPositionLibrary test file back to NonfungibleT…
mds1 Jun 11, 2021
7501b87
Update expected revert string for permit test with invalid v value
mds1 Jun 11, 2021
4a51d92
Merge branch 'upstream-main' into feature/l2-ovm-compatible-contracts
mds1 Jun 11, 2021
21c5545
Merge commit fix: Add WETH9 getter to TestNonfungiblePositionLibrary
mds1 Jun 11, 2021
ef62f95
Merge commit fix: Remove Promise.all and link library in Oracle test
mds1 Jun 11, 2021
d583959
Merge commit fix: Remove Promise.all, only run gas estimate assertion…
mds1 Jun 11, 2021
ee47567
Patch waffle's deployMockContract to support mock OVM contracts
mds1 Jun 12, 2021
78c0c13
Only run EOA permit tests on the OVM since they require EIP-1271
mds1 Jun 12, 2021
15af024
Update multicall test to use two transactions to avoid exceeding OVM …
mds1 Jun 12, 2021
a1f8bbb
Update README
mds1 Jun 14, 2021
46d33ec
Update OVM solc version (same build, cleaner syntax)
mds1 Jun 14, 2021
3828a79
Automatically update POOL_INIT_CODE_HASH when running tests
mds1 Jun 14, 2021
830749a
Add CI job for OVM unit tests
mds1 Jun 14, 2021
46fdd14
Update @uniswap/v3-core dependency to point to Uniswap repo
mds1 Jun 15, 2021
e9dec92
Run prettier
mds1 Jun 15, 2021
596b5b7
deploy WETH in EVM, use 0x420..06 in OVM
K-Ho Jun 16, 2021
5da89d6
Configure test reliant on hardcoded WETH address to only run on OVM
mds1 Jun 16, 2021
9d235a3
Run prettier
mds1 Jun 16, 2021
22ed22f
Skip V3 migrator tests on OVM
mds1 Jun 16, 2021
a5336ca
Don't fail if there is no backup file created by sed (for CI)
mds1 Jun 16, 2021
a21d704
Update EVM snapshots for CI (OVM CI tests update snapshots)
mds1 Jun 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,36 @@ jobs:

- name: Run unit tests
run: yarn test

ovm-unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x

- id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-

- name: Install dependencies
run: yarn install --frozen-lockfile

# This is required separately from yarn test because it generates the typechain definitions
- name: Compile
run: yarn compile:ovm

- name: Bring Optimism Up
run: yarn optimism-up

- name: Run unit tests
run: UPDATE_SNAPSHOT=1 yarn test:ovm
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ artifacts/
cache/
crytic-export/
node_modules/
typechain/
typechain/
typechain-ovm/
optimism

artifacts-ovm/
cache-ovm/
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ This repository contains the periphery smart contracts for the Uniswap V3 Protoc
For the lower level core contracts, see the [uniswap-v3-core](https://github.com/Uniswap/uniswap-v3-core)
repository.

## Testing

Because these contracts and tests are modified for OVM support, there are some changes that mean we can no longer simply run `yarn test` and `yarn test:ovm` and expect all tests to pass for both the EVM and OVM. There are a few reasons for this:

1. EVM vs. OVM contracts will use different amounts of gas, so the gas tests will fail
2. `PoolAddress.sol` has a hardcoded bytecode hash, but this hash will be different for EVM vs. OVM bytecode
3. In Uniswap V3 Core and Periphery contracts some logic was pulled out into library contracts to reduce contract size. The original EVM contracts had deterministic bytecode, so a bytecode hash can be easily hardcoded in `PoolAddress.sol`, but this is no longer true. The contracts now require linking libraries, and therefore the bytecode and bytecode hash is dependent on the library addresses, which are dependent on the deployer account and nonce

Therefore, we must follow the steps below to run EVM tests in this repo:

1. Run `UPDATE_SNAPSHOT=1 yarn test` which will ensure gas costs snapshots are updated (i.e. tests will not fail for gas cost reasons)

And to run OVM tests:

1. Run `yarn postinstall` to apply a patch that adds OVM mock contract support to Waffle
2. Run `UPDATE_SNAPSHOT=1 yarn test:ovm` which will ensure gas costs snapshots are updated (i.e. tests will not fail for gas cost reasons)
3. On subsequent test runs, run `yarn optimism-down && yarn optimism-up && UPDATE_SNAPSHOT=1 yarn test:ovm`. This is required so the deployer account nonce is reset to zero, which is necessary to get the above bytecode hash when deploying contracts

Both test commands (`yarn test` and `yarn test:ovm`) will automatically update the `POOL_INIT_CODE_HASH` in `PoolAddress.sol` as needed for testing.

## Bug bounty

This repository is subject to the Uniswap V3 bug bounty program,
Expand Down