Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b4033be
Revert "fix: Revert "feat: blobs. (#9302)" (#10187)"
MirandaWood Nov 25, 2024
de14c32
chore: comments/renaming in Rollup.sol
MirandaWood Nov 27, 2024
b75a6f7
feat: give up and make blob oracle for simulation
MirandaWood Nov 27, 2024
3391096
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Nov 27, 2024
624c36d
fix: post merge fixes, fmt, fixtures
MirandaWood Nov 28, 2024
ccb82b2
chore: dummy change to fix ci runner
MirandaWood Nov 28, 2024
fe6fa68
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Nov 28, 2024
64586d8
fix: do horrible things to reduce contract size
MirandaWood Nov 28, 2024
21e8c3a
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Nov 28, 2024
24f2f0e
chore: post merge fixes, add libs to gen contracts, comments
MirandaWood Nov 28, 2024
566c2fc
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Nov 29, 2024
fc03321
feat: integrate private logs, add blob oracle issue num, regen fixtur…
MirandaWood Nov 30, 2024
5c5a655
chore: update proof fixture
MirandaWood Nov 30, 2024
4bd1312
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 2, 2024
f5aac25
fix: revert merge changes, compile time down from 90 to 10 mins (#10341)
MirandaWood Dec 3, 2024
d4bf371
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 3, 2024
78ca2ab
chore: post merge fixes, fmt
MirandaWood Dec 3, 2024
18a66b0
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 3, 2024
b14a892
chore: post merge fixes + update proof fixture
MirandaWood Dec 3, 2024
25d5ba0
chore: some orch cleanup
MirandaWood Dec 3, 2024
a325000
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 3, 2024
933191b
chore: remake consts after merge
MirandaWood Dec 3, 2024
64a4724
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 4, 2024
07449a3
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 4, 2024
5dd97e3
feat: redo blob publishing
MirandaWood Dec 4, 2024
359758f
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 4, 2024
6c0a22a
feat: rearrange all blob l1 logic, replicate in ts
MirandaWood Dec 5, 2024
681b53a
feat: add gas estimation for blob txs, cleanup contracts, increase he…
MirandaWood Dec 5, 2024
1153bf8
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 5, 2024
8511d52
chore: typos, comments clarifications
MirandaWood Dec 5, 2024
ede52a6
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 5, 2024
4d927d2
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 5, 2024
c44e158
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 6, 2024
5506aa2
chore: fix bad noir merge formatting
MirandaWood Dec 6, 2024
f71874b
fix: change slot overrides after merge
MirandaWood Dec 6, 2024
110692f
chore: update timeouts, comment, grab custom error from ext lib
MirandaWood Dec 6, 2024
389a596
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 6, 2024
dff8962
chore: post merge formatting
MirandaWood Dec 6, 2024
a01595d
chore: add leolib abi to error handling
MirandaWood Dec 6, 2024
9a89e75
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 6, 2024
5f5a10d
chore: inc test timeout after sync
MirandaWood Dec 7, 2024
c8c8758
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 7, 2024
03f4ce1
chore: inc timeout
MirandaWood Dec 7, 2024
7fd775f
chore: increase! those! timeouts!
MirandaWood Dec 7, 2024
a9bfda5
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 7, 2024
ba713cd
chore: header -> block_header to match merge
MirandaWood Dec 7, 2024
2daaa48
chore: guess what.
MirandaWood Dec 8, 2024
c6cde5d
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 9, 2024
ec0d50d
chore: fixture + comment out slower test
MirandaWood Dec 9, 2024
be805b6
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 10, 2024
09bcff3
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 10, 2024
949090f
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 11, 2024
a74377b
chore: remove some warnings from blob code
MirandaWood Dec 11, 2024
426f376
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 11, 2024
dc2955f
chore: post merge formatting
MirandaWood Dec 11, 2024
aa3d368
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 12, 2024
728d784
chore: remake constants after merge
MirandaWood Dec 12, 2024
0332bb8
fix: bad merge
MirandaWood Dec 12, 2024
59148e2
chore: proof fixture
MirandaWood Dec 12, 2024
76da0d4
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 12, 2024
e8685ac
feat: reduce the number unconstrained boundary hops in bloblib (#10603)
TomAFrench Dec 12, 2024
7827a73
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 13, 2024
e6fc5b5
fix: add temp brillig skip to run CI
MirandaWood Dec 13, 2024
c423c90
chore: update prover.tomls, ensure block-root is populated
MirandaWood Dec 13, 2024
f420a79
chore: add brillig gates skip to earthfile
MirandaWood Dec 13, 2024
36efe51
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 13, 2024
313c3d8
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 13, 2024
448187e
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 13, 2024
436b7d6
chore: reenable test
MirandaWood Dec 13, 2024
f096e25
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 13, 2024
b8699a2
Merge remote-tracking branch 'origin/master' into mw/blob-circuit-2
MirandaWood Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ jobs:
runner=$(./scripts/ci/select_runner.sh ${{ matrix.test }})
echo "type=$runner" >> $GITHUB_OUTPUT
- name: Setup and Test
timeout-minutes: 40
timeout-minutes: 50
uses: ./.github/ensure-tester-with-images
env:
USERNAME: ${{ needs.configure.outputs.username }}
Expand Down Expand Up @@ -667,7 +667,7 @@ jobs:
with:
concurrency_key: prover-client-test-x86
- name: "Prover Client Tests"
timeout-minutes: 40
timeout-minutes: 60
run: earthly-ci --no-output ./yarn-project/+prover-client-test

network-transfer-test:
Expand Down
171 changes: 96 additions & 75 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {MockVerifier} from "@aztec/mock/MockVerifier.sol";
import {Ownable} from "@oz/access/Ownable.sol";
import {IERC20} from "@oz/token/ERC20/IERC20.sol";
import {EIP712} from "@oz/utils/cryptography/EIP712.sol";
import {Vm} from "forge-std/Vm.sol";

struct Config {
uint256 aztecSlotDuration;
Expand All @@ -59,6 +58,7 @@ struct Config {
* @author Aztec Labs
* @notice Rollup contract that is concerned about readability and velocity of development
* not giving a damn about gas costs.
* @dev WARNING: This contract is VERY close to the size limit (500B at time of writing).
*/
contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITestRollup {
using SlotLib for Slot;
Expand All @@ -80,6 +80,8 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes

address public constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
bool public immutable IS_FOUNDRY_TEST;
// @note Always true, exists to override to false for testing only
bool public checkBlob = true;

uint256 public immutable CLAIM_DURATION_IN_L2_SLOTS;
uint256 public immutable L1_BLOCK_AT_GENESIS;
Expand Down Expand Up @@ -148,7 +150,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
});
rollupStore.l1GasOracleValues = L1GasOracleValues({
pre: L1FeeData({baseFee: 1 gwei, blobFee: 1}),
post: L1FeeData({baseFee: block.basefee, blobFee: _getBlobBaseFee()}),
post: L1FeeData({baseFee: block.basefee, blobFee: ExtRollupLib.getBlobBaseFee(VM_ADDRESS)}),
slotOfChange: LIFETIME
});
}
Expand Down Expand Up @@ -230,15 +232,18 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
*
* @param _args - The arguments to propose the block
* @param _signatures - Signatures from the validators
* // TODO(#9101): The below _body should be removed once we can extract blobs. It's only here so the archiver can extract tx effects.
* @param _body - The body of the L2 block
* @param _blobInput - The blob evaluation KZG proof, challenge, and opening required for the precompile.
*/
function proposeAndClaim(
ProposeArgs calldata _args,
Signature[] memory _signatures,
bytes calldata _body,
bytes calldata _blobInput,
SignedEpochProofQuote calldata _quote
) external override(IRollup) {
propose(_args, _signatures, _body);
propose(_args, _signatures, _body, _blobInput);
claimEpochProofRight(_quote);
}

Expand All @@ -260,6 +265,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
* _epochSize - The size of the epoch (to be promoted to a constant)
* _args - Array of public inputs to the proof (previousArchive, endArchive, previousBlockHash, endBlockHash, endTimestamp, outHash, proverId)
* _fees - Array of recipient-value pairs with fees to be distributed for the epoch
* _blobPublicInputs - The blob public inputs for the proof
* _aggregationObject - The aggregation object for the proof
* _proof - The proof to verify
*/
Expand Down Expand Up @@ -346,10 +352,11 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
uint256 _epochSize,
bytes32[7] calldata _args,
bytes32[] calldata _fees,
bytes calldata _blobPublicInputs,
bytes calldata _aggregationObject
) external view override(IRollup) returns (bytes32[] memory) {
return ExtRollupLib.getEpochProofPublicInputs(
rollupStore, _epochSize, _args, _fees, _aggregationObject
rollupStore, _epochSize, _args, _fees, _blobPublicInputs, _aggregationObject
);
}

Expand Down Expand Up @@ -400,23 +407,41 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
* @param _signatures - The signatures to validate
* @param _digest - The digest to validate
* @param _currentTime - The current time
* @param _blobsHash - The blobs hash for this block
* @param _flags - The flags to validate
*/
function validateHeader(
bytes calldata _header,
Signature[] memory _signatures,
bytes32 _digest,
Timestamp _currentTime,
bytes32 _txsEffectsHash,
bytes32 _blobsHash,
DataStructures.ExecutionFlags memory _flags
) external view override(IRollup) {
uint256 manaBaseFee = getManaBaseFeeAt(_currentTime, true);
Header memory header = ExtRollupLib.decodeHeader(_header);
_validateHeader(
header, _signatures, _digest, _currentTime, manaBaseFee, _txsEffectsHash, _flags
ExtRollupLib.decodeHeader(_header),
_signatures,
_digest,
_currentTime,
getManaBaseFeeAt(_currentTime, true),
_blobsHash,
_flags
);
}

/**
* @notice Validate blob transactions against given inputs.
* @dev Only exists here for gas estimation.
*/
function validateBlobs(bytes calldata _blobsInput)
external
view
override(IRollup)
returns (bytes32, bytes32)
{
return ExtRollupLib.validateBlobs(_blobsInput, checkBlob);
}

/**
* @notice Get the next epoch that can be claimed
* @dev Will revert if the epoch has already been claimed or if there is no epoch to prove
Expand All @@ -436,15 +461,6 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
return epochToProve;
}

function computeTxsEffectsHash(bytes calldata _body)
external
pure
override(IRollup)
returns (bytes32)
{
return ExtRollupLib.computeTxsEffectsHash(_body);
}

function claimEpochProofRight(SignedEpochProofQuote calldata _quote) public override(IRollup) {
validateEpochProofRightClaimAtTime(Timestamp.wrap(block.timestamp), _quote);

Expand Down Expand Up @@ -475,21 +491,26 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
*
* @param _args - The arguments to propose the block
* @param _signatures - Signatures from the validators
* @param _body - The body of the L2 block
* // TODO(#9101): The below _body should be removed once we can extract blobs. It's only here so the archiver can extract tx effects.
* @param - The body of the L2 block
* @param _blobInput - The blob evaluation KZG proof, challenge, and opening required for the precompile.
*/
function propose(ProposeArgs calldata _args, Signature[] memory _signatures, bytes calldata _body)
public
override(IRollup)
{
function propose(
ProposeArgs calldata _args,
Signature[] memory _signatures,
// TODO(#9101): Extract blobs from beacon chain => remove below body input
bytes calldata,
bytes calldata _blobInput
) public override(IRollup) {
if (canPrune()) {
_prune();
}
updateL1GasFeeOracle();

// The `body` is passed outside the "args" as it does not directly need to be in the digest
// as long as the `txsEffectsHash` is included and matches what is in the header.
// Which we are checking in the `_validateHeader` call below.
bytes32 txsEffectsHash = ExtRollupLib.computeTxsEffectsHash(_body);
// Since an invalid blob hash here would fail the consensus checks of
// the header, the `blobInput` is implicitly accepted by consensus as well.
(bytes32 blobsHash, bytes32 blobPublicInputsHash) =
ExtRollupLib.validateBlobs(_blobInput, checkBlob);

// Decode and validate header
Header memory header = ExtRollupLib.decodeHeader(_args.header);
Expand All @@ -504,34 +525,18 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
_digest: _args.digest(),
_currentTime: Timestamp.wrap(block.timestamp),
_manaBaseFee: manaBaseFee,
_txEffectsHash: txsEffectsHash,
_blobsHash: blobsHash,
_flags: DataStructures.ExecutionFlags({ignoreDA: false, ignoreSignatures: false})
});

uint256 blockNumber = ++rollupStore.tips.pendingBlockNumber;

{
FeeHeader memory parentFeeHeader = rollupStore.blocks[blockNumber - 1].feeHeader;
uint256 excessMana = IntRollupLib.computeExcessMana(parentFeeHeader);

rollupStore.blocks[blockNumber] = BlockLog({
archive: _args.archive,
blockHash: _args.blockHash,
slotNumber: Slot.wrap(header.globalVariables.slotNumber),
feeHeader: FeeHeader({
excessMana: excessMana,
feeAssetPriceNumerator: parentFeeHeader.feeAssetPriceNumerator.clampedAdd(
_args.oracleInput.feeAssetPriceModifier
),
manaUsed: header.totalManaUsed,
provingCostPerManaNumerator: parentFeeHeader.provingCostPerManaNumerator.clampedAdd(
_args.oracleInput.provingCostModifier
),
congestionCost: components.congestionCost
})
});
rollupStore.blocks[blockNumber] = _toBlockLog(_args, blockNumber, components.congestionCost);
}

rollupStore.blobPublicInputsHashes[blockNumber] = blobPublicInputsHash;

// @note The block number here will always be >=1 as the genesis block is at 0
{
bytes32 inHash = INBOX.consume(blockNumber);
Expand All @@ -544,8 +549,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
// TODO(#7218): Revert to fixed height tree for outbox, currently just providing min as interim
// Min size = smallest path of the rollup tree + 1
(uint256 min,) = MerkleLib.computeMinMaxPathLength(header.contentCommitment.numTxs);
uint256 l2ToL1TreeMinHeight = min + 1;
OUTBOX.insert(blockNumber, header.contentCommitment.outHash, l2ToL1TreeMinHeight);
OUTBOX.insert(blockNumber, header.contentCommitment.outHash, min + 1);

emit L2BlockProposed(blockNumber, _args.archive);

Expand Down Expand Up @@ -585,7 +589,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes

rollupStore.l1GasOracleValues.pre = rollupStore.l1GasOracleValues.post;
rollupStore.l1GasOracleValues.post =
L1FeeData({baseFee: block.basefee, blobFee: _getBlobBaseFee()});
L1FeeData({baseFee: block.basefee, blobFee: ExtRollupLib.getBlobBaseFee(VM_ADDRESS)});
rollupStore.l1GasOracleValues.slotOfChange = slot + LAG;
}

Expand All @@ -606,11 +610,9 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
override(IRollup)
returns (L1FeeData memory)
{
Slot slot = getSlotAt(_timestamp);
if (slot < rollupStore.l1GasOracleValues.slotOfChange) {
return rollupStore.l1GasOracleValues.pre;
}
return rollupStore.l1GasOracleValues.post;
return getSlotAt(_timestamp) < rollupStore.l1GasOracleValues.slotOfChange
? rollupStore.l1GasOracleValues.pre
: rollupStore.l1GasOracleValues.post;
}

/**
Expand Down Expand Up @@ -719,6 +721,15 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
return rollupStore.blocks[_blockNumber];
}

function getBlobPublicInputsHash(uint256 _blockNumber)
public
view
override(IRollup)
returns (bytes32)
{
return rollupStore.blobPublicInputsHashes[_blockNumber];
}

function getEpochForBlock(uint256 _blockNumber) public view override(IRollup) returns (Epoch) {
require(
_blockNumber <= rollupStore.tips.pendingBlockNumber,
Expand Down Expand Up @@ -752,10 +763,9 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
* @return bytes32 - The archive root of the block
*/
function archiveAt(uint256 _blockNumber) public view override(IRollup) returns (bytes32) {
if (_blockNumber <= rollupStore.tips.pendingBlockNumber) {
return rollupStore.blocks[_blockNumber].archive;
}
return bytes32(0);
return _blockNumber <= rollupStore.tips.pendingBlockNumber
? rollupStore.blocks[_blockNumber].archive
: bytes32(0);
}

function canPrune() public view override(IRollup) returns (bool) {
Expand Down Expand Up @@ -814,6 +824,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
* @param _signatures - The signatures for the attestations
* @param _digest - The digest that signatures signed
* @param _currentTime - The time of execution
* @param _blobsHash - The blobs hash for this block
* @dev - This value is provided to allow for simple simulation of future
* @param _flags - Flags specific to the execution, whether certain checks should be skipped
*/
Expand All @@ -823,7 +834,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
bytes32 _digest,
Timestamp _currentTime,
uint256 _manaBaseFee,
bytes32 _txEffectsHash,
bytes32 _blobsHash,
DataStructures.ExecutionFlags memory _flags
) internal view {
uint256 pendingBlockNumber = canPruneAtTime(_currentTime)
Expand All @@ -835,7 +846,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
header: _header,
currentTime: _currentTime,
manaBaseFee: _manaBaseFee,
txsEffectsHash: _txEffectsHash,
blobsHash: _blobsHash,
pendingBlockNumber: pendingBlockNumber,
flags: _flags,
version: VERSION,
Expand Down Expand Up @@ -888,6 +899,31 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
_validateLeonidas(_slot, _signatures, _digest, _flags);
}

// Helper to avoid stack too deep
function _toBlockLog(ProposeArgs calldata _args, uint256 _blockNumber, uint256 _congestionCost)
internal
view
returns (BlockLog memory)
{
FeeHeader memory parentFeeHeader = rollupStore.blocks[_blockNumber - 1].feeHeader;
return BlockLog({
archive: _args.archive,
blockHash: _args.blockHash,
slotNumber: Slot.wrap(uint256(bytes32(_args.header[0x0194:0x01b4]))),
feeHeader: FeeHeader({
excessMana: IntRollupLib.computeExcessMana(parentFeeHeader),
feeAssetPriceNumerator: parentFeeHeader.feeAssetPriceNumerator.clampedAdd(
_args.oracleInput.feeAssetPriceModifier
),
manaUsed: uint256(bytes32(_args.header[0x0268:0x0288])),
provingCostPerManaNumerator: parentFeeHeader.provingCostPerManaNumerator.clampedAdd(
_args.oracleInput.provingCostModifier
),
congestionCost: _congestionCost
})
});
}

function _fakeBlockNumberAsProven(uint256 _blockNumber) private {
if (
_blockNumber > rollupStore.tips.provenBlockNumber
Expand All @@ -912,19 +948,4 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, Leonidas, IRollup, ITes
}
}
}

/**
* @notice Get the blob base fee
*
* @dev If we are in a foundry test, we use the cheatcode to get the blob base fee.
* Otherwise, we use the `block.blobbasefee`
*
* @return uint256 - The blob base fee
*/
function _getBlobBaseFee() private view returns (uint256) {
if (IS_FOUNDRY_TEST) {
return Vm(VM_ADDRESS).getBlobBaseFee();
}
return block.blobbasefee;
}
}
Loading