Skip to content

Commit

Permalink
fix: prune at submit if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Nov 7, 2024
1 parent d7de1ba commit 73a89d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 10 additions & 1 deletion l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,18 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
bytes calldata _aggregationObject,
bytes calldata _proof
) external override(IRollup) {
if (canPrune()) {
_prune();
}

uint256 previousBlockNumber = tips.provenBlockNumber;
uint256 endBlockNumber = previousBlockNumber + _epochSize;

// @note The getEpochForBlock is expected to revert if the block is beyond pending.
// If this changes you are gonna get so rekt you won't believe it.
// I mean proving blocks that have been pruned rekt.
Epoch epochToProve = getEpochForBlock(endBlockNumber);

bytes32[] memory publicInputs =
getEpochProofPublicInputs(_epochSize, _args, _fees, _aggregationObject);

Expand Down Expand Up @@ -287,7 +296,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
}
}

if (proofClaim.epochToProve == getEpochForBlock(endBlockNumber)) {
if (proofClaim.epochToProve == epochToProve) {
PROOF_COMMITMENT_ESCROW.unstakeBond(proofClaim.bondProvider, proofClaim.bondAmount);
}

Expand Down
4 changes: 1 addition & 3 deletions l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ contract RollupTest is DecoderBase {
(bytes32 preArchive, bytes32 preBlockHash,) = rollup.blocks(0);
_submitEpochProof(rollup, 1, preArchive, archive, preBlockHash, blockHash, proverId);

vm.expectRevert(
abi.encodeWithSelector(Errors.Rollup__InvalidPreviousArchive.selector, archive, preArchive)
);
vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__InvalidBlockNumber.selector, 1, 2));
_submitEpochProof(rollup, 1, preArchive, archive, preBlockHash, blockHash, proverId);
}

Expand Down

0 comments on commit 73a89d1

Please sign in to comment.