diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index 7e8aec2f39b..d9d26527873 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -48,11 +48,8 @@ contract Rollup is Leonidas, IRollup, ITestRollup { uint128 slotNumber; } - // @note The number of slots within which a block must be proven - // This number is currently pulled out of thin air and should be replaced when we are not blind - // @todo #8018 - uint256 public constant TIMELINESS_PROVING_IN_SLOTS = 100; - + // See https://github.com/AztecProtocol/engineering-designs/blob/main/in-progress/8401-proof-timeliness/proof-timeliness.ipynb + // for justification of CLAIM_DURATION_IN_L2_SLOTS. uint256 public constant CLAIM_DURATION_IN_L2_SLOTS = 13; uint256 public constant PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST = 1000; @@ -110,27 +107,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup { setupEpoch(); } - function status(uint256 myHeaderBlockNumber) - external - view - override(IRollup) - returns ( - uint256 provenBlockNumber, - bytes32 provenArchive, - uint256 pendingBlockNumber, - bytes32 pendingArchive, - bytes32 archiveOfMyBlock - ) - { - return ( - tips.provenBlockNumber, - blocks[tips.provenBlockNumber].archive, - tips.pendingBlockNumber, - blocks[tips.pendingBlockNumber].archive, - archiveAt(myHeaderBlockNumber) - ); - } - /** * @notice Prune the pending chain up to the last proven block * @@ -222,7 +198,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup { // 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. - address bondProvider = PROOF_COMMITMENT_ESCROW.stakeBond(_quote); + address bondProvider = PROOF_COMMITMENT_ESCROW.stakeBond(_quote.signature, _quote.bondAmount); proofClaim = DataStructures.EpochProofClaim({ epochToProve: epochToProve, @@ -452,6 +428,27 @@ contract Rollup is Leonidas, IRollup, ITestRollup { emit L2ProofVerified(header.globalVariables.blockNumber, _proverId); } + function status(uint256 myHeaderBlockNumber) + external + view + override(IRollup) + returns ( + uint256 provenBlockNumber, + bytes32 provenArchive, + uint256 pendingBlockNumber, + bytes32 pendingArchive, + bytes32 archiveOfMyBlock + ) + { + return ( + tips.provenBlockNumber, + blocks[tips.provenBlockNumber].archive, + tips.pendingBlockNumber, + blocks[tips.pendingBlockNumber].archive, + archiveAt(myHeaderBlockNumber) + ); + } + /** * @notice Check if msg.sender can propose at a given time * @@ -555,7 +552,22 @@ contract Rollup is Leonidas, IRollup, ITestRollup { } } + /** + * @notice Get the archive root of a specific block + * + * @param _blockNumber - The block number to get the archive root of + * + * @return bytes32 - The archive root of the block + */ + function archiveAt(uint256 _blockNumber) public view override(IRollup) returns (bytes32) { + if (_blockNumber <= tips.pendingBlockNumber) { + return blocks[_blockNumber].archive; + } + return bytes32(0); + } + function _prune() internal { + // TODO #8656 delete proofClaim; uint256 pending = tips.pendingBlockNumber; @@ -595,20 +607,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup { return true; } - /** - * @notice Get the archive root of a specific block - * - * @param _blockNumber - The block number to get the archive root of - * - * @return bytes32 - The archive root of the block - */ - function archiveAt(uint256 _blockNumber) public view override(IRollup) returns (bytes32) { - if (_blockNumber <= tips.pendingBlockNumber) { - return blocks[_blockNumber].archive; - } - return bytes32(0); - } - /** * @notice Validates the header for submission * diff --git a/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol b/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol index 8ef52a2e670..77b3fba206c 100644 --- a/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol +++ b/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol @@ -2,12 +2,14 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.18; -import {DataStructures} from "../libraries/DataStructures.sol"; +import {SignatureLib} from "../libraries/SignatureLib.sol"; interface IProofCommitmentEscrow { function deposit(uint256 _amount) external; function withdraw(uint256 _amount) external; // returns the address of the bond provider - function stakeBond(DataStructures.EpochProofQuote calldata _quote) external returns (address); - function unstakeBond(uint256 _amount) external; + function stakeBond(SignatureLib.Signature calldata _signature, uint256 _bondAmount) + external + returns (address); + function unstakeBond(uint256 _bondAmount) external; } diff --git a/l1-contracts/src/core/libraries/DataStructures.sol b/l1-contracts/src/core/libraries/DataStructures.sol index dcfa1b75888..f22eb10cd0d 100644 --- a/l1-contracts/src/core/libraries/DataStructures.sol +++ b/l1-contracts/src/core/libraries/DataStructures.sol @@ -87,7 +87,6 @@ library DataStructures { uint256 epochToProve; uint256 validUntilSlot; uint256 bondAmount; - address rollup; uint32 basisPointFee; } diff --git a/l1-contracts/src/mock/MockProofCommitmentEscrow.sol b/l1-contracts/src/mock/MockProofCommitmentEscrow.sol index d7bc1d847e4..9f62f7b76c7 100644 --- a/l1-contracts/src/mock/MockProofCommitmentEscrow.sol +++ b/l1-contracts/src/mock/MockProofCommitmentEscrow.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.18; -import {DataStructures} from "../core/libraries/DataStructures.sol"; +import {SignatureLib} from "../core/libraries/SignatureLib.sol"; import {IProofCommitmentEscrow} from "../core/interfaces/IProofCommitmentEscrow.sol"; contract MockProofCommitmentEscrow is IProofCommitmentEscrow { @@ -18,7 +18,7 @@ contract MockProofCommitmentEscrow is IProofCommitmentEscrow { // do nothing } - function stakeBond(DataStructures.EpochProofQuote calldata) + function stakeBond(SignatureLib.Signature calldata, uint256) external pure override diff --git a/l1-contracts/test/Rollup.t.sol b/l1-contracts/test/Rollup.t.sol index 0a9eacf8bf4..5c318419316 100644 --- a/l1-contracts/test/Rollup.t.sol +++ b/l1-contracts/test/Rollup.t.sol @@ -91,7 +91,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 1, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -116,7 +115,6 @@ contract RollupTest is DecoderBase { epochToProve: 1, validUntilSlot: 1, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -134,7 +132,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 1, bondAmount: 0, - rollup: address(0), basisPointFee: 0 }); @@ -156,7 +153,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 0, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -176,7 +172,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 1, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -212,7 +207,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 1, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -248,7 +242,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 1, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -272,7 +265,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 2 * Constants.AZTEC_EPOCH_DURATION, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -294,7 +286,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 2 * Constants.AZTEC_EPOCH_DURATION, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -322,7 +313,6 @@ contract RollupTest is DecoderBase { epochToProve: 0, validUntilSlot: 2 * Constants.AZTEC_EPOCH_DURATION, bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), - rollup: address(0), basisPointFee: 0 }); @@ -398,7 +388,7 @@ contract RollupTest is DecoderBase { rollup.prune(); } - function testPruneDuringPropose() public setUpFor("mixed_block_1") { + function testPrune() public setUpFor("mixed_block_1") { _testBlock("mixed_block_1", false); assertEq(inbox.inProgress(), 3, "Invalid in progress"); @@ -427,12 +417,16 @@ contract RollupTest is DecoderBase { assertNotEq(rootMixed, bytes32(0), "Invalid root"); assertNotEq(minHeightMixed, 0, "Invalid min height"); + rollup.prune(); + assertEq(inbox.inProgress(), 3, "Invalid in progress"); + assertEq(rollup.getPendingBlockNumber(), 0, "Invalid pending block number"); + assertEq(rollup.getProvenBlockNumber(), 0, "Invalid proven block number"); + // @note We alter what slot is specified in the empty block! // This means that we keep the `empty_block_1` mostly as is, but replace the slot number // and timestamp as if it was created at a different point in time. This allow us to insert it // as if it was the first block, even after we had originally inserted the mixed block. // An example where this could happen would be if no-one could prove the mixed block. - // @note We prune the pending chain as part of the propose call. _testBlock("empty_block_1", false, prunableAt); assertEq(inbox.inProgress(), 3, "Invalid in progress"); @@ -451,6 +445,15 @@ contract RollupTest is DecoderBase { assertNotEq(minHeightEmpty, minHeightMixed, "Invalid min height"); } + function testPruneDuringPropose() public setUpFor("mixed_block_1") { + _testBlock("mixed_block_1", false); + warpToL2Slot(Constants.AZTEC_EPOCH_DURATION * 2); + _testBlock("mixed_block_1", false, Constants.AZTEC_EPOCH_DURATION * 2); + + assertEq(rollup.getPendingBlockNumber(), 1, "Invalid pending block number"); + assertEq(rollup.getProvenBlockNumber(), 0, "Invalid proven block number"); + } + function testBlockFee() public setUpFor("mixed_block_1") { uint256 feeAmount = 2e18; diff --git a/yarn-project/end-to-end/src/e2e_synching.test.ts b/yarn-project/end-to-end/src/e2e_synching.test.ts index 2cbb21530fa..a0f980bab34 100644 --- a/yarn-project/end-to-end/src/e2e_synching.test.ts +++ b/yarn-project/end-to-end/src/e2e_synching.test.ts @@ -451,7 +451,7 @@ describe('e2e_synching', () => { const pendingBlockNumber = await rollup.read.getPendingBlockNumber(); await rollup.write.setAssumeProvenThroughBlockNumber([pendingBlockNumber - BigInt(variant.blockCount) / 2n]); - const timeliness = await rollup.read.TIMELINESS_PROVING_IN_SLOTS(); + const timeliness = (await rollup.read.EPOCH_DURATION()) * 2n; const [, , slot] = await rollup.read.blocks([(await rollup.read.getProvenBlockNumber()) + 1n]); const timeJumpTo = await rollup.read.getTimestampForSlot([slot + timeliness]);