Skip to content

Commit

Permalink
chore: autumn cleaning (#8818)
Browse files Browse the repository at this point in the history
Doing some autumn cleaning as part of #8324. I would still like to
refactor a bunch of the tests, but will have to be separate.

@just-mitch altered on some of your data structures to clarify the diff
between a quote and a signed quote.
  • Loading branch information
LHerskind authored and Rumata888 committed Sep 27, 2024
1 parent 4fa7e0b commit 077c410
Show file tree
Hide file tree
Showing 42 changed files with 246 additions and 314 deletions.
3 changes: 2 additions & 1 deletion l1-contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ libs = ['lib']
solc = "0.8.23"

remappings = [
"@oz/=lib/openzeppelin-contracts/contracts/"
"@oz/=lib/openzeppelin-contracts/contracts/",
"@aztec/=src"
]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Expand Down
18 changes: 9 additions & 9 deletions l1-contracts/src/core/FeeJuicePortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
pragma solidity >=0.8.18;

import {IERC20} from "@oz/token/ERC20/IERC20.sol";
import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol";
import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol";
import {IRegistry} from "@aztec/core/interfaces/messagebridge/IRegistry.sol";

import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
import {DataStructures} from "@aztec/core/libraries/DataStructures.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";
import {Hash} from "@aztec/core/libraries/crypto/Hash.sol";
import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "@oz/access/Ownable.sol";

// Messaging
import {IRegistry} from "./interfaces/messagebridge/IRegistry.sol";
import {IInbox} from "./interfaces/messagebridge/IInbox.sol";
import {IFeeJuicePortal} from "./interfaces/IFeeJuicePortal.sol";
import {DataStructures} from "./libraries/DataStructures.sol";
import {Errors} from "./libraries/Errors.sol";
import {Constants} from "./libraries/ConstantsGen.sol";
import {Hash} from "./libraries/Hash.sol";
import {Ownable} from "@oz/access/Ownable.sol";

contract FeeJuicePortal is IFeeJuicePortal, Ownable {
using SafeERC20 for IERC20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.18;

import {DataStructures} from "../libraries/DataStructures.sol";
import {Errors} from "../libraries/Errors.sol";
import {EnumerableSet} from "@oz/utils/structs/EnumerableSet.sol";
import {Ownable} from "@oz/access/Ownable.sol";
import {SampleLib} from "./SampleLib.sol";
import {SignatureLib} from "../libraries/SignatureLib.sol";
import {Constants} from "../libraries/ConstantsGen.sol";
import {ILeonidas} from "@aztec/core/interfaces/ILeonidas.sol";

import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
import {DataStructures} from "@aztec/core/libraries/DataStructures.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";
import {SampleLib} from "@aztec/core/libraries/crypto/SampleLib.sol";
import {SignatureLib} from "@aztec/core/libraries/crypto/SignatureLib.sol";
import {MessageHashUtils} from "@oz/utils/cryptography/MessageHashUtils.sol";
import {EnumerableSet} from "@oz/utils/structs/EnumerableSet.sol";

import {ILeonidas} from "./ILeonidas.sol";
import {Ownable} from "@oz/access/Ownable.sol";

/**
* @title Leonidas
Expand Down
73 changes: 36 additions & 37 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

// Interfaces
import {IRollup, ITestRollup} from "./interfaces/IRollup.sol";
import {IProofCommitmentEscrow} from "./interfaces/IProofCommitmentEscrow.sol";
import {IInbox} from "./interfaces/messagebridge/IInbox.sol";
import {IOutbox} from "./interfaces/messagebridge/IOutbox.sol";
import {IRegistry} from "./interfaces/messagebridge/IRegistry.sol";
import {IVerifier} from "./interfaces/IVerifier.sol";
import {IFeeJuicePortal} from "./interfaces/IFeeJuicePortal.sol";

// Libraries
import {HeaderLib} from "./libraries/HeaderLib.sol";
import {Errors} from "./libraries/Errors.sol";
import {Constants} from "./libraries/ConstantsGen.sol";
import {MerkleLib} from "./libraries/MerkleLib.sol";
import {SignatureLib} from "./libraries/SignatureLib.sol";
import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol";
import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol";
import {IOutbox} from "@aztec/core/interfaces/messagebridge/IOutbox.sol";
import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol";
import {IRegistry} from "@aztec/core/interfaces/messagebridge/IRegistry.sol";
import {IRollup, ITestRollup} from "@aztec/core/interfaces/IRollup.sol";
import {IVerifier} from "@aztec/core/interfaces/IVerifier.sol";

import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
import {DataStructures} from "@aztec/core/libraries/DataStructures.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";
import {HeaderLib} from "@aztec/core/libraries/HeaderLib.sol";
import {TxsDecoder} from "@aztec/core/libraries/TxsDecoder.sol";
import {MerkleLib} from "@aztec/core/libraries/crypto/MerkleLib.sol";
import {SignatureLib} from "@aztec/core/libraries/crypto/SignatureLib.sol";
import {SafeCast} from "@oz/utils/math/SafeCast.sol";
import {DataStructures} from "./libraries/DataStructures.sol";
import {TxsDecoder} from "./libraries/decoders/TxsDecoder.sol";

// Contracts
import {MockVerifier} from "../mock/MockVerifier.sol";
import {MockProofCommitmentEscrow} from "../mock/MockProofCommitmentEscrow.sol";
import {Inbox} from "./messagebridge/Inbox.sol";
import {Outbox} from "./messagebridge/Outbox.sol";
import {Leonidas} from "./sequencer_selection/Leonidas.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 {Outbox} from "@aztec/core/messagebridge/Outbox.sol";

/**
* @title Rollup
Expand Down Expand Up @@ -89,8 +86,8 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
REGISTRY = _registry;
FEE_JUICE_PORTAL = _fpcJuicePortal;
PROOF_COMMITMENT_ESCROW = new MockProofCommitmentEscrow();
INBOX = new Inbox(address(this), Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT);
OUTBOX = new Outbox(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;
VERSION = 1;
L1_BLOCK_AT_GENESIS = block.number;
Expand Down Expand Up @@ -157,7 +154,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
vkTreeRoot = _vkTreeRoot;
}

function claimEpochProofRight(DataStructures.EpochProofQuote calldata _quote)
function claimEpochProofRight(DataStructures.SignedEpochProofQuote calldata _quote)
external
override(IRollup)
{
Expand All @@ -169,8 +166,8 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
revert Errors.Leonidas__InvalidProposer(currentProposer, msg.sender);
}

if (_quote.epochToProve != epochToProve) {
revert Errors.Rollup__NotClaimingCorrectEpoch(epochToProve, _quote.epochToProve);
if (_quote.quote.epochToProve != epochToProve) {
revert Errors.Rollup__NotClaimingCorrectEpoch(epochToProve, _quote.quote.epochToProve);
}

if (currentSlot % Constants.AZTEC_EPOCH_DURATION >= CLAIM_DURATION_IN_L2_SLOTS) {
Expand All @@ -185,30 +182,32 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
revert Errors.Rollup__ProofRightAlreadyClaimed();
}

if (_quote.bondAmount < PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST) {
if (_quote.quote.bondAmount < PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST) {
revert Errors.Rollup__InsufficientBondAmount(
PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST, _quote.bondAmount
PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST, _quote.quote.bondAmount
);
}

if (_quote.validUntilSlot < currentSlot) {
revert Errors.Rollup__QuoteExpired(currentSlot, _quote.validUntilSlot);
if (_quote.quote.validUntilSlot < currentSlot) {
revert Errors.Rollup__QuoteExpired(currentSlot, _quote.quote.validUntilSlot);
}

// We don't currently unstake,
// but we will as part of https://github.com/AztecProtocol/aztec-packages/issues/8652.
// Blocked on submitting epoch proofs to this contract.
PROOF_COMMITMENT_ESCROW.stakeBond(_quote.bondAmount, _quote.prover);
PROOF_COMMITMENT_ESCROW.stakeBond(_quote.quote.bondAmount, _quote.quote.prover);

proofClaim = DataStructures.EpochProofClaim({
epochToProve: epochToProve,
basisPointFee: _quote.basisPointFee,
bondAmount: _quote.bondAmount,
bondProvider: _quote.prover,
basisPointFee: _quote.quote.basisPointFee,
bondAmount: _quote.quote.bondAmount,
bondProvider: _quote.quote.prover,
proposerClaimant: msg.sender
});

emit ProofRightClaimed(epochToProve, _quote.prover, msg.sender, _quote.bondAmount, currentSlot);
emit ProofRightClaimed(
epochToProve, _quote.quote.prover, msg.sender, _quote.quote.bondAmount, currentSlot
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.18;

import {SignatureLib} from "../libraries/SignatureLib.sol";
import {SignatureLib} from "@aztec/core/libraries/crypto/SignatureLib.sol";

interface IProofCommitmentEscrow {
function deposit(uint256 _amount) external;
Expand Down
10 changes: 5 additions & 5 deletions l1-contracts/src/core/interfaces/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

import {IInbox} from "../interfaces/messagebridge/IInbox.sol";
import {IOutbox} from "../interfaces/messagebridge/IOutbox.sol";
import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol";
import {IOutbox} from "@aztec/core/interfaces/messagebridge/IOutbox.sol";

import {SignatureLib} from "../libraries/SignatureLib.sol";
import {DataStructures} from "../libraries/DataStructures.sol";
import {SignatureLib} from "@aztec/core/libraries/crypto/SignatureLib.sol";
import {DataStructures} from "@aztec/core/libraries/DataStructures.sol";

interface ITestRollup {
function setVerifier(address _verifier) external;
Expand All @@ -28,7 +28,7 @@ interface IRollup {

function prune() external;

function claimEpochProofRight(DataStructures.EpochProofQuote calldata _quote) external;
function claimEpochProofRight(DataStructures.SignedEpochProofQuote calldata _quote) external;

function propose(
bytes calldata _header,
Expand Down
24 changes: 0 additions & 24 deletions l1-contracts/src/core/interfaces/messagebridge/IFrontier.sol

This file was deleted.

44 changes: 37 additions & 7 deletions l1-contracts/src/core/libraries/DataStructures.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

import {SignatureLib} from "./SignatureLib.sol";
import {SignatureLib} from "@aztec/core/libraries/crypto/SignatureLib.sol";

/**
* @title Data Structures Library
Expand Down Expand Up @@ -77,25 +77,55 @@ library DataStructures {
}
// docs:end:registry_snapshot

/**
* @notice Struct for storing flags for block header validation
* @param ignoreDA - True will ignore DA check, otherwise checks
* @param ignoreSignature - True will ignore the signatures, otherwise checks
*/
struct ExecutionFlags {
bool ignoreDA;
bool ignoreSignatures;
}

/**
* @notice Struct encompassing an epoch proof quote
* @param epochToProve - The epoch number to prove
* @param validUntilSlot - The deadline of the quote, denoted in L2 slots
* @param bondAmount - The size of the bond
* @param prover - The address of the prover
* @param basisPointFee - The fee measured in basis points
*/
struct EpochProofQuote {
SignatureLib.Signature signature;
uint256 epochToProve;
uint256 validUntilSlot;
uint256 bondAmount;
address prover;
uint32 basisPointFee;
}

/**
* @notice A signed quote for the epoch proof
* @param quote - The Epoch Proof Quote
* @param signature - A signature on the quote
*/
struct SignedEpochProofQuote {
EpochProofQuote quote;
SignatureLib.Signature signature;
}

/**
* @notice Struct containing the Epoch Proof Claim
* @param epochToProve - the epoch that the bond provider is claiming to prove
* @param basisPointFee the fee that the bond provider will receive as a percentage of the block rewards
* @param bondAmount - the size of the bond
* @param bondProvider - the address that put up the bond
* @param proposerClaimant - the address of the proposer that submitted the claim
*/
struct EpochProofClaim {
uint256 epochToProve; // the epoch that the bond provider is claiming to prove
uint256 basisPointFee; // the fee that the bond provider will receive as a percentage of the block rewards
uint256 bondAmount; // the amount of escrowed funds that the bond provider will stake. Must be at least PROOF_COMMITMENT_BOND_AMOUNT
address bondProvider; // the address that has deposited funds in the escrow contract
address proposerClaimant; // the address of the proposer that submitted the claim
uint256 epochToProve;
uint256 basisPointFee;
uint256 bondAmount;
address bondProvider;
address proposerClaimant;
}
}
5 changes: 2 additions & 3 deletions l1-contracts/src/core/libraries/HeaderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

// Libraries
import {Errors} from "./Errors.sol";
import {Constants} from "./ConstantsGen.sol";
import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";

/**
* @title Header Library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

// Libraries
import {Errors} from "../Errors.sol";
import {Constants} from "../ConstantsGen.sol";
import {Hash} from "../Hash.sol";
import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";
import {Hash} from "@aztec/core/libraries/crypto/Hash.sol";

/**
* @title Txs Decoder Library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

import {Hash} from "../../libraries/Hash.sol";
import {Hash} from "@aztec/core/libraries/crypto/Hash.sol";

/**
* @title FrontierLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Copyright 2023 Aztec Labs.
pragma solidity >=0.8.18;

// Libraries
import {Constants} from "./ConstantsGen.sol";
import {DataStructures} from "./DataStructures.sol";
import {DataStructures} from "@aztec/core/libraries/DataStructures.sol";

/**
* @title Hash library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.18;

import {Errors} from "../libraries/Errors.sol";
import {Hash} from "../libraries/Hash.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";
import {Hash} from "@aztec/core/libraries/crypto/Hash.sol";

/**
* @title Merkle Library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.18;

import {Errors} from "../libraries/Errors.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";

/**
* @title SampleLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2024 Aztec Labs.
pragma solidity ^0.8.13;

import {Errors} from "./Errors.sol";
import {Errors} from "@aztec/core/libraries/Errors.sol";

library SignatureLib {
struct Signature {
Expand Down
Loading

0 comments on commit 077c410

Please sign in to comment.