Skip to content

Commit 3ed7201

Browse files
committed
Add test for submitEpochProof
1 parent 6543447 commit 3ed7201

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

l1-contracts/test/validator-selection/ValidatorSelection.t.sol

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// solhint-disable imports-order
44
pragma solidity >=0.8.27;
55

6+
import {Strings} from "@oz/utils/Strings.sol";
67
import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
78
import {
89
Signature,
@@ -37,6 +38,10 @@ import {ValidatorSelectionTestBase} from "./ValidatorSelectionBase.sol";
3738

3839
import {NaiveMerkle} from "../merkle/Naive.sol";
3940

41+
import {
42+
BlockLog, PublicInputArgs, SubmitEpochRootProofArgs
43+
} from "@aztec/core/interfaces/IRollup.sol";
44+
4045
// solhint-disable comprehensive-interface
4146

4247
/**
@@ -209,6 +214,34 @@ contract ValidatorSelectionTest is ValidatorSelectionTestBase {
209214
_testBlock("mixed_block_2", NO_REVERT, 3, 4, NO_FLAGS);
210215
}
211216

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+
212245
function testCannotInvalidateProperProposal() public setup(4, 4) progressEpochs(2) {
213246
ProposeTestData memory ree = _testBlock("mixed_block_1", NO_REVERT, 3, 4, NO_FLAGS);
214247
_invalidateByAttestationCount(ree, Errors.ValidatorSelection__InsufficientAttestations.selector);
@@ -567,6 +600,51 @@ contract ValidatorSelectionTest is ValidatorSelectionTestBase {
567600
}
568601
}
569602

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+
570648
function _createAttestation(address _signer, bytes32 _digest)
571649
internal
572650
view

0 commit comments

Comments
 (0)