|
3 | 3 | // solhint-disable imports-order |
4 | 4 | pragma solidity >=0.8.27; |
5 | 5 |
|
| 6 | +import {Strings} from "@oz/utils/Strings.sol"; |
6 | 7 | import {Constants} from "@aztec/core/libraries/ConstantsGen.sol"; |
7 | 8 | import { |
8 | 9 | Signature, |
@@ -37,6 +38,10 @@ import {ValidatorSelectionTestBase} from "./ValidatorSelectionBase.sol"; |
37 | 38 |
|
38 | 39 | import {NaiveMerkle} from "../merkle/Naive.sol"; |
39 | 40 |
|
| 41 | +import { |
| 42 | + BlockLog, PublicInputArgs, SubmitEpochRootProofArgs |
| 43 | +} from "@aztec/core/interfaces/IRollup.sol"; |
| 44 | + |
40 | 45 | // solhint-disable comprehensive-interface |
41 | 46 |
|
42 | 47 | /** |
@@ -209,6 +214,34 @@ contract ValidatorSelectionTest is ValidatorSelectionTestBase { |
209 | 214 | _testBlock("mixed_block_2", NO_REVERT, 3, 4, NO_FLAGS); |
210 | 215 | } |
211 | 216 |
|
| 217 | + function testProveWithAttestations() public setup(4, 4) progressEpochs(2) { |
| 218 | + _testBlock("mixed_block_1", NO_REVERT, 3, 4, NO_FLAGS); |
| 219 | + ProposeTestData memory ree2 = _testBlock("mixed_block_2", NO_REVERT, 3, 4, NO_FLAGS); |
| 220 | + uint256 blockNumber = rollup.getPendingBlockNumber(); |
| 221 | + |
| 222 | + _proveBlocks( |
| 223 | + "mixed_block_", |
| 224 | + blockNumber - 1, |
| 225 | + blockNumber, |
| 226 | + SignatureLib.packAttestations(ree2.attestations), |
| 227 | + NO_REVERT |
| 228 | + ); |
| 229 | + } |
| 230 | + |
| 231 | + function testProveFailWithoutCorrectAttestations() public setup(4, 4) progressEpochs(2) { |
| 232 | + ProposeTestData memory ree1 = _testBlock("mixed_block_1", NO_REVERT, 3, 4, NO_FLAGS); |
| 233 | + _testBlock("mixed_block_2", NO_REVERT, 3, 4, NO_FLAGS); |
| 234 | + uint256 blockNumber = rollup.getPendingBlockNumber(); |
| 235 | + |
| 236 | + _proveBlocks( |
| 237 | + "mixed_block_", |
| 238 | + blockNumber - 1, |
| 239 | + blockNumber, |
| 240 | + SignatureLib.packAttestations(ree1.attestations), |
| 241 | + Errors.Rollup__InvalidAttestations.selector |
| 242 | + ); |
| 243 | + } |
| 244 | + |
212 | 245 | function testCannotInvalidateProperProposal() public setup(4, 4) progressEpochs(2) { |
213 | 246 | ProposeTestData memory ree = _testBlock("mixed_block_1", NO_REVERT, 3, 4, NO_FLAGS); |
214 | 247 | _invalidateByAttestationCount(ree, Errors.ValidatorSelection__InsufficientAttestations.selector); |
@@ -567,6 +600,51 @@ contract ValidatorSelectionTest is ValidatorSelectionTestBase { |
567 | 600 | } |
568 | 601 | } |
569 | 602 |
|
| 603 | + function _proveBlocks( |
| 604 | + string memory _name, |
| 605 | + uint256 _start, |
| 606 | + uint256 _end, |
| 607 | + CommitteeAttestations memory _attestations, |
| 608 | + bytes4 _revertData |
| 609 | + ) internal { |
| 610 | + // Logic is mostly duplicated from RollupBase._proveBlocks |
| 611 | + DecoderBase.Full memory startFull = load(string.concat(_name, Strings.toString(_start))); |
| 612 | + DecoderBase.Full memory endFull = load(string.concat(_name, Strings.toString(_end))); |
| 613 | + |
| 614 | + uint256 startBlockNumber = uint256(startFull.block.blockNumber); |
| 615 | + uint256 endBlockNumber = uint256(endFull.block.blockNumber); |
| 616 | + |
| 617 | + assertEq(startBlockNumber, _start, "Invalid start block number"); |
| 618 | + assertEq(endBlockNumber, _end, "Invalid end block number"); |
| 619 | + |
| 620 | + BlockLog memory parentBlockLog = rollup.getBlock(startBlockNumber - 1); |
| 621 | + address prover = address(0xcafe); |
| 622 | + |
| 623 | + PublicInputArgs memory args = PublicInputArgs({ |
| 624 | + previousArchive: parentBlockLog.archive, |
| 625 | + endArchive: endFull.block.archive, |
| 626 | + proverId: prover |
| 627 | + }); |
| 628 | + |
| 629 | + bytes32[] memory fees = new bytes32[](Constants.AZTEC_MAX_EPOCH_DURATION * 2); |
| 630 | + |
| 631 | + if (_revertData != NO_REVERT) { |
| 632 | + vm.expectPartialRevert(_revertData); |
| 633 | + } |
| 634 | + |
| 635 | + rollup.submitEpochRootProof( |
| 636 | + SubmitEpochRootProofArgs({ |
| 637 | + start: startBlockNumber, |
| 638 | + end: endBlockNumber, |
| 639 | + args: args, |
| 640 | + fees: fees, |
| 641 | + attestations: _attestations, |
| 642 | + blobInputs: endFull.block.batchedBlobInputs, |
| 643 | + proof: "" |
| 644 | + }) |
| 645 | + ); |
| 646 | + } |
| 647 | + |
570 | 648 | function _createAttestation(address _signer, bytes32 _digest) |
571 | 649 | internal |
572 | 650 | view |
|
0 commit comments