Skip to content

Commit

Permalink
Rollup encoder as an external dependency (AztecProtocol#262)
Browse files Browse the repository at this point in the history
* refactor: WIP on using external encoder

* refactor: using new encoder version + big cleanup

* refactor: importing IRollupProcessor from rollup-encoder lib

* fix: commited dependency

* test: added assert that was removed by accident when rebasing

* chore: solhinignore cleanup
  • Loading branch information
benesjan authored Oct 31, 2022
1 parent ddf79e9 commit f8ef3f8
Show file tree
Hide file tree
Showing 66 changed files with 522 additions and 1,024 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/rollup-encoder"]
path = lib/rollup-encoder
url = https://github.com/AztecProtocol/rollup-encoder
4 changes: 1 addition & 3 deletions .solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ src/libraries/
src/test/bridges/element/MockDeploymentValidator.sol
# TODO: remove the following 2 lines once the bridge is deprecated
src/bridges/element/
src/test/bridges/element/aztecmocks
# TODO: remove the following line once linting rules are unified between internal and this repo
src/aztec/interfaces/IRollupProcessor.sol
src/test/bridges/element/aztecmocks
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ We decided to have 2 separate approaches of bridge testing:

We encourage you to first write all tests as unit tests to be able to leverage simple traces while you are debugging the bridge.
Once you make the bridge work in the unit tests environment convert the relevant tests to E2E.
Converting unit tests to E2E is straightforward because we made the `BridgeTestBase.sendDefiRollup(...)` function return the same values as `IDefiBridge.convert(...)`.
Converting unit tests to E2E is straightforward because we made the `ROLLUP_ENCODER.processRollupAndGetBridgeResult()` function return the same values as `IDefiBridge.convert(...)`.

In production, the rollup contract will supply `_totalInputValue` of both input assets and use the `_interactionNonce` as a globally unique ID.
For testing, you may provide this value.
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
src = 'src'
out = 'out'
libs = ['lib']
remappings = ['@openzeppelin/=node_modules/@openzeppelin/', 'forge-std/=lib/forge-std/src']
remappings = ['@openzeppelin/=node_modules/@openzeppelin/', 'forge-std/=lib/forge-std/src', 'rollup-encoder/=lib/rollup-encoder/src']
fuzz_runs = 256
gas_reports = ["*"]
eth-rpc-url = 'https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c'
Expand Down
1 change: 1 addition & 0 deletions lib/rollup-encoder
Submodule rollup-encoder added at 04407b
4 changes: 2 additions & 2 deletions src/aztec/DataProvider.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022 Aztec.
pragma solidity >=0.8.4;
import {AztecTypes} from "./libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IRollupProcessor} from "./interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {BridgeBase} from "../bridges/base/BridgeBase.sol";
import {ISubsidy} from "./interfaces/ISubsidy.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/aztec/interfaces/IDefiBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2022 Aztec
pragma solidity >=0.8.4;

import {AztecTypes} from "../libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";

interface IDefiBridge {
/**
Expand Down
116 changes: 0 additions & 116 deletions src/aztec/interfaces/IRollupProcessor.sol

This file was deleted.

18 changes: 0 additions & 18 deletions src/aztec/libraries/AztecTypes.sol

This file was deleted.

4 changes: 2 additions & 2 deletions src/bridges/angle/AngleSLPBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
pragma solidity >=0.8.4;

import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {BridgeBase} from "../base/BridgeBase.sol";
import {IStableMaster} from "../../interfaces/angle/IStableMaster.sol";
import {IPoolManager, IStrategy} from "../../interfaces/angle/IPoolManager.sol";
import {IWETH} from "../../interfaces/IWETH.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";

/**
* @title Angle Protocol bridge contract.
Expand Down
2 changes: 1 addition & 1 deletion src/bridges/base/BridgeBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.4;

import {IDefiBridge} from "../../aztec/interfaces/IDefiBridge.sol";
import {ISubsidy} from "../../aztec/interfaces/ISubsidy.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {ErrorLib} from "./ErrorLib.sol";

/**
Expand Down
5 changes: 2 additions & 3 deletions src/bridges/curve/CurveStEthBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ pragma solidity >=0.8.4;
import {ICurvePool} from "../../interfaces/curve/ICurvePool.sol";
import {ILido} from "../../interfaces/lido/ILido.sol";
import {IWstETH} from "../../interfaces/lido/IWstETH.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";

import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";

import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
Expand Down
5 changes: 2 additions & 3 deletions src/bridges/dca/BiDCABridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ pragma solidity >=0.8.4;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";

import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {IWETH} from "../../interfaces/IWETH.sol";

import {SafeCastLib} from "./SafeCastLib.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/bridges/donation/DonationBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";

/**
* @notice Bridge that allows users to collectively donate funds to an L1 address
Expand Down
4 changes: 2 additions & 2 deletions src/bridges/element/ElementBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {IPool} from "../../interfaces/element/IPool.sol";
import {ITranche} from "../../interfaces/element/ITranche.sol";
import {IDeploymentValidator} from "../../interfaces/element/IDeploymentValidator.sol";
import {IWrappedPosition} from "../../interfaces/element/IWrappedPosition.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {MinHeap} from "./MinHeap.sol";
import {FullMath} from "../../libraries/uniswapv3/FullMath.sol";

import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";

import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";

/**
* @title Element Bridge
Expand Down
4 changes: 2 additions & 2 deletions src/bridges/erc4626/ERC4626Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pragma solidity >=0.8.4;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {IWETH} from "../../interfaces/IWETH.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/bridges/example/ExampleBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity >=0.8.4;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {BridgeBase} from "../base/BridgeBase.sol";

Expand Down
5 changes: 2 additions & 3 deletions src/bridges/lido/LidoBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ICurvePool} from "../../interfaces/curve/ICurvePool.sol";
import {ILido} from "../../interfaces/lido/ILido.sol";
import {IWstETH} from "../../interfaces/lido/IWstETH.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";

import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";

import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract LidoBridge is BridgeBase {
Expand Down
2 changes: 1 addition & 1 deletion src/bridges/liquity/StabilityPoolBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.4;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {IWETH} from "../../interfaces/IWETH.sol";
import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/bridges/liquity/StakingBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.4;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {IWETH} from "../../interfaces/IWETH.sol";
import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/bridges/liquity/TroveBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {BridgeBase} from "../base/BridgeBase.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {IWETH} from "../../interfaces/IWETH.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/bridges/uniswap/UniswapBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pragma solidity >=0.8.4;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {ErrorLib} from "../base/ErrorLib.sol";
import {BridgeBase} from "../base/BridgeBase.sol";
import {ISwapRouter} from "../../interfaces/uniswapv3/ISwapRouter.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/bridges/yearn/YearnBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright 2022 Aztec
pragma solidity >=0.8.4;

import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {IYearnRegistry} from "../../interfaces/yearn/IYearnRegistry.sol";
import {IYearnVault} from "../../interfaces/yearn/IYearnVault.sol";
import {IWETH} from "../../interfaces/IWETH.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/deployment/AggregateDeployment.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

import {BaseDeployment} from "./base/BaseDeployment.s.sol";
import {IRollupProcessor} from "../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {DataProvider} from "../aztec/DataProvider.sol";

import {CurveDeployment} from "./curve/CurveDeployment.s.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/deployment/base/BaseDeployment.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2022 Aztec.
pragma solidity >=0.8.4;

import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";
import {Test} from "forge-std/Test.sol";
import {stdJson} from "forge-std/StdJson.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/deployment/dataprovider/DataProviderDeployment.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {BaseDeployment} from "../base/BaseDeployment.s.sol";
import {DataProvider} from "../../aztec/DataProvider.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";

contract DataProviderDeployment is BaseDeployment {
function deploy() public returns (address) {
Expand Down
2 changes: 1 addition & 1 deletion src/deployment/erc4626/ERC4626Lister.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {BaseDeployment} from "../base/BaseDeployment.s.sol";
import {ERC4626Bridge} from "../../bridges/erc4626/ERC4626Bridge.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
import {IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessor.sol";

contract ERC4626Lister is BaseDeployment {
function listVault(address _bridge, address _vault) public {
Expand Down
Loading

0 comments on commit f8ef3f8

Please sign in to comment.