Skip to content

Commit

Permalink
chore: Remove mock proof commitment escrow
Browse files Browse the repository at this point in the history
Simplifies deployment of L1 contracts all across the board.
  • Loading branch information
spalladino committed Oct 3, 2024
1 parent 241cfa2 commit 7b9f4e9
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 146 deletions.
10 changes: 3 additions & 7 deletions l1-contracts/src/core/ProofCommitmentEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract ProofCommitmentEscrow is IProofCommitmentEscrow {
Timestamp executableAt;
}

address public ROLLUP;
address public immutable ROLLUP;
uint256 public constant WITHDRAW_DELAY =
Constants.ETHEREUM_SLOT_DURATION * Constants.AZTEC_EPOCH_DURATION * 3;
mapping(address => uint256) public deposits;
Expand All @@ -30,13 +30,9 @@ contract ProofCommitmentEscrow is IProofCommitmentEscrow {
_;
}

constructor(IERC20 _token) {
token = _token;
}

function initialize(address _rollup) external {
require(ROLLUP == address(0));
constructor(IERC20 _token, address _rollup) {
ROLLUP = _rollup;
token = _token;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {SafeCast} from "@oz/utils/math/SafeCast.sol";
import {Inbox} from "@aztec/core/messagebridge/Inbox.sol";
import {Leonidas} from "@aztec/core/Leonidas.sol";
import {MockVerifier} from "@aztec/mock/MockVerifier.sol";
import {MockProofCommitmentEscrow} from "@aztec/mock/MockProofCommitmentEscrow.sol";
import {ProofCommitmentEscrow} from "@aztec/core/ProofCommitmentEscrow.sol";
import {Outbox} from "@aztec/core/messagebridge/Outbox.sol";

import {Timestamp, Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol";
Expand Down Expand Up @@ -83,14 +83,13 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {

constructor(
IFeeJuicePortal _fpcJuicePortal,
IProofCommitmentEscrow _proofCommitmentEscrow, // We should create a new instance instead of accepting one, once we remove the Mock version
bytes32 _vkTreeRoot,
address _ares,
address[] memory _validators
) Leonidas(_ares) {
epochProofVerifier = new MockVerifier();
FEE_JUICE_PORTAL = _fpcJuicePortal;
PROOF_COMMITMENT_ESCROW = _proofCommitmentEscrow;
PROOF_COMMITMENT_ESCROW = new ProofCommitmentEscrow(_fpcJuicePortal.underlying(), address(this));
INBOX = IInbox(address(new Inbox(address(this), Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT)));
OUTBOX = IOutbox(address(new Outbox(address(this))));
vkTreeRoot = _vkTreeRoot;
Expand Down
3 changes: 3 additions & 0 deletions l1-contracts/src/core/interfaces/IFeeJuicePortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.27;

import {IERC20} from "@oz/token/ERC20/IERC20.sol";

interface IFeeJuicePortal {
function initialize(address _registry, address _underlying, bytes32 _l2TokenAddress) external;
function distributeFees(address _to, uint256 _amount) external;
function depositToAztecPublic(bytes32 _to, uint256 _amount, bytes32 _secretHash)
external
returns (bytes32);
function underlying() external view returns (IERC20);
}
23 changes: 23 additions & 0 deletions l1-contracts/src/mock/MockFeeJuicePortal.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.27;

import {IERC20} from "@oz/token/ERC20/IERC20.sol";
import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol";
import {TestERC20} from "@aztec/mock/TestERC20.sol";

contract MockFeeJuicePortal is IFeeJuicePortal {
IERC20 public underlying;

constructor() {
underlying = new TestERC20();
}

function initialize(address, address, bytes32) external override {}

function distributeFees(address, uint256) external override {}

function depositToAztecPublic(bytes32, uint256, bytes32) external pure override returns (bytes32) {
return bytes32(0);
}
}
42 changes: 0 additions & 42 deletions l1-contracts/src/mock/MockProofCommitmentEscrow.sol

This file was deleted.

8 changes: 4 additions & 4 deletions l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {Leonidas} from "@aztec/core/Leonidas.sol";
import {NaiveMerkle} from "./merkle/Naive.sol";
import {MerkleTestUtil} from "./merkle/TestUtil.sol";
import {TestERC20} from "@aztec/mock/TestERC20.sol";
import {MockProofCommitmentEscrow} from "@aztec/mock/MockProofCommitmentEscrow.sol";

import {TxsDecoderHelper} from "./decoders/helpers/TxsDecoderHelper.sol";
import {IERC20Errors} from "@oz/interfaces/draft-IERC6093.sol";
Expand Down Expand Up @@ -73,11 +72,10 @@ contract RollupTest is DecoderBase {
feeJuicePortal.initialize(
address(registry), address(testERC20), bytes32(Constants.FEE_JUICE_ADDRESS)
);
proofCommitmentEscrow = new MockProofCommitmentEscrow();
rollup =
new Rollup(feeJuicePortal, proofCommitmentEscrow, bytes32(0), address(this), new address[](0));
rollup = new Rollup(feeJuicePortal, bytes32(0), address(this), new address[](0));
inbox = Inbox(address(rollup.INBOX()));
outbox = Outbox(address(rollup.OUTBOX()));
proofCommitmentEscrow = IProofCommitmentEscrow(address(rollup.PROOF_COMMITMENT_ESCROW()));

registry.upgrade(address(rollup));

Expand All @@ -98,6 +96,8 @@ contract RollupTest is DecoderBase {

testERC20.mint(signer, bond * 10);
vm.prank(signer);
testERC20.approve(address(proofCommitmentEscrow), bond * 10);
vm.prank(signer);
proofCommitmentEscrow.deposit(bond * 10);

_;
Expand Down
9 changes: 2 additions & 7 deletions l1-contracts/test/portals/TokenPortal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {TokenPortal} from "./TokenPortal.sol";
import {TestERC20} from "@aztec/mock/TestERC20.sol";

import {NaiveMerkle} from "../merkle/Naive.sol";
import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol";

contract TokenPortalTest is Test {
using Hash for DataStructures.L1ToL2Msg;
Expand Down Expand Up @@ -61,13 +62,7 @@ contract TokenPortalTest is Test {
function setUp() public {
registry = new Registry(address(this));
testERC20 = new TestERC20();
rollup = new Rollup(
IFeeJuicePortal(address(0)),
IProofCommitmentEscrow(address(0)),
bytes32(0),
address(this),
new address[](0)
);
rollup = new Rollup(new MockFeeJuicePortal(), bytes32(0), address(this), new address[](0));
inbox = rollup.INBOX();
outbox = rollup.OUTBOX();

Expand Down
10 changes: 3 additions & 7 deletions l1-contracts/test/portals/UniswapPortal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEsc
import {TokenPortal} from "./TokenPortal.sol";
import {UniswapPortal} from "./UniswapPortal.sol";

import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol";

contract UniswapPortalTest is Test {
using Hash for DataStructures.L2ToL1Msg;

Expand Down Expand Up @@ -53,13 +55,7 @@ contract UniswapPortalTest is Test {
vm.selectFork(forkId);

registry = new Registry(address(this));
rollup = new Rollup(
IFeeJuicePortal(address(0)),
IProofCommitmentEscrow(address(0)),
bytes32(0),
address(this),
new address[](0)
);
rollup = new Rollup(new MockFeeJuicePortal(), bytes32(0), address(this), new address[](0));
registry.upgrade(address(rollup));

daiTokenPortal = new TokenPortal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ contract TestProofCommitmentEscrow is Test {

function setUp() public {
TOKEN = new TestERC20();
ESCROW = new ProofCommitmentEscrow(TOKEN);
ESCROW.initialize(address(this));
ESCROW = new ProofCommitmentEscrow(TOKEN, address(this));
}

function testDeposit() public setupWithApproval(address(42), 100) {
Expand Down
9 changes: 2 additions & 7 deletions l1-contracts/test/sparta/Sparta.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {TxsDecoderHelper} from "../decoders/helpers/TxsDecoderHelper.sol";
import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol";
import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol";
import {MessageHashUtils} from "@oz/utils/cryptography/MessageHashUtils.sol";
import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol";

import {Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol";

Expand Down Expand Up @@ -75,13 +76,7 @@ contract SpartaTest is DecoderBase {
}

testERC20 = new TestERC20();
rollup = new Rollup(
IFeeJuicePortal(address(0)),
IProofCommitmentEscrow(address(0)),
bytes32(0),
address(this),
initialValidators
);
rollup = new Rollup(new MockFeeJuicePortal(), bytes32(0), address(this), initialValidators);
inbox = Inbox(address(rollup.INBOX()));
outbox = Outbox(address(rollup.OUTBOX()));

Expand Down
6 changes: 0 additions & 6 deletions yarn-project/aztec/src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import {
FeeJuicePortalBytecode,
InboxAbi,
InboxBytecode,
MockProofCommitmentEscrowAbi,
MockProofCommitmentEscrowBytecode,
OutboxAbi,
OutboxBytecode,
RegistryAbi,
Expand Down Expand Up @@ -117,10 +115,6 @@ export async function deployContractsToL1(
contractAbi: FeeJuicePortalAbi,
contractBytecode: FeeJuicePortalBytecode,
},
proofCommitmentEscrow: {
contractAbi: MockProofCommitmentEscrowAbi,
contractBytecode: MockProofCommitmentEscrowBytecode,
},
};

const chain = aztecNodeConfig.l1RpcUrl
Expand Down
6 changes: 0 additions & 6 deletions yarn-project/cli/src/utils/aztec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export async function deployAztecContracts(
RegistryBytecode,
RollupAbi,
RollupBytecode,
MockProofCommitmentEscrowAbi,
MockProofCommitmentEscrowBytecode,
FeeJuicePortalAbi,
FeeJuicePortalBytecode,
TestERC20Abi,
Expand Down Expand Up @@ -108,10 +106,6 @@ export async function deployAztecContracts(
contractAbi: FeeJuicePortalAbi,
contractBytecode: FeeJuicePortalBytecode,
},
proofCommitmentEscrow: {
contractAbi: MockProofCommitmentEscrowAbi,
contractBytecode: MockProofCommitmentEscrowBytecode,
},
};
const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types');

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class FullProverTest {
`full_prover_integration/${testName}`,
dataPath,
{ startProverNode: true },
{ assumeProvenThrough: undefined, useRealProofCommitmentEscrow: true },
{ assumeProvenThrough: undefined },
);
}

Expand Down
12 changes: 1 addition & 11 deletions yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import {
FeeJuicePortalBytecode,
InboxAbi,
InboxBytecode,
MockProofCommitmentEscrowAbi,
MockProofCommitmentEscrowBytecode,
OutboxAbi,
OutboxBytecode,
ProofCommitmentEscrowAbi,
ProofCommitmentEscrowBytecode,
RegistryAbi,
RegistryBytecode,
RollupAbi,
Expand All @@ -30,7 +26,7 @@ export const setupL1Contracts = async (
l1RpcUrl: string,
account: HDAccount | PrivateKeyAccount,
logger: DebugLogger,
args: Pick<DeployL1ContractsArgs, 'assumeProvenThrough' | 'initialValidators' | 'useRealProofCommitmentEscrow'>,
args: Pick<DeployL1ContractsArgs, 'assumeProvenThrough' | 'initialValidators'>,
) => {
const l1Artifacts: L1ContractArtifactsForDeployment = {
registry: {
Expand All @@ -57,12 +53,6 @@ export const setupL1Contracts = async (
contractAbi: FeeJuicePortalAbi,
contractBytecode: FeeJuicePortalBytecode,
},
proofCommitmentEscrow: {
contractAbi: args.useRealProofCommitmentEscrow ? ProofCommitmentEscrowAbi : MockProofCommitmentEscrowAbi,
contractBytecode: args.useRealProofCommitmentEscrow
? ProofCommitmentEscrowBytecode
: MockProofCommitmentEscrowBytecode,
},
};

const l1Data = await deployL1Contracts(l1RpcUrl, account, foundry, logger, l1Artifacts, {
Expand Down
11 changes: 0 additions & 11 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ import {
FeeJuicePortalBytecode,
InboxAbi,
InboxBytecode,
MockProofCommitmentEscrowAbi,
MockProofCommitmentEscrowBytecode,
OutboxAbi,
OutboxBytecode,
ProofCommitmentEscrowAbi,
ProofCommitmentEscrowBytecode,
RegistryAbi,
RegistryBytecode,
RollupAbi,
Expand Down Expand Up @@ -121,7 +117,6 @@ export const setupL1Contracts = async (
salt?: number;
initialValidators?: EthAddress[];
assumeProvenThrough?: number;
useRealProofCommitmentEscrow?: boolean;
} = {
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
},
Expand Down Expand Up @@ -152,12 +147,6 @@ export const setupL1Contracts = async (
contractAbi: FeeJuicePortalAbi,
contractBytecode: FeeJuicePortalBytecode,
},
proofCommitmentEscrow: {
contractAbi: args.useRealProofCommitmentEscrow ? ProofCommitmentEscrowAbi : MockProofCommitmentEscrowAbi,
contractBytecode: args.useRealProofCommitmentEscrow
? ProofCommitmentEscrowBytecode
: MockProofCommitmentEscrowBytecode,
},
};

const l1Data = await deployL1Contracts(l1RpcUrl, account, chain, logger, l1Artifacts, {
Expand Down
Loading

0 comments on commit 7b9f4e9

Please sign in to comment.