Skip to content

Commit b7beb02

Browse files
committed
fix: address comments + linter + fmt
1 parent 0d540ab commit b7beb02

20 files changed

Lines changed: 118 additions & 116 deletions

l1-contracts/src/core/RollupCore.sol

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -257,58 +257,6 @@ contract RollupCore is EIP712("Aztec Rollup", "1"), Ownable, IStakingCore, IVali
257257
FeeLib.initialize(_config.manaTarget, _config.provingCostPerMana, _config.initialEthPerFeeAsset);
258258
}
259259

260-
function _deploySlasher(RollupConfigInput memory _config, address _governance) internal returns (ISlasher slasher) {
261-
// We call one external library or another based on the slasher flavor
262-
// This allows us to keep the slash flavors in separate external libraries so we do not exceed max contract size
263-
// Note that we do not deploy a slasher if we run with no committees (i.e. targetCommitteeSize == 0)
264-
if (_config.targetCommitteeSize == 0 || _config.slasherFlavor == SlasherFlavor.NONE) {
265-
return ISlasher(address(0));
266-
}
267-
268-
if (_config.slasherFlavor == SlasherFlavor.TALLY) {
269-
return TallySlasherDeploymentExtLib.deployTallySlasher(address(this), _governance, _config);
270-
}
271-
272-
return EmpireSlasherDeploymentExtLib.deployEmpireSlasher(address(this), _governance, _config);
273-
}
274-
275-
function _initializeRewards(RollupConfigInput memory _config) internal {
276-
RewardConfig memory rewardConfig = _config.rewardConfig;
277-
278-
if (address(rewardConfig.booster) == address(0)) {
279-
rewardConfig.booster = RewardExtLib.deployRewardBooster(_config.rewardBoostConfig);
280-
}
281-
282-
RewardExtLib.initialize(_config.earliestRewardsClaimableTimestamp);
283-
RewardExtLib.setConfig(rewardConfig);
284-
}
285-
286-
function _initializeStore(
287-
IERC20 _feeAsset,
288-
IVerifier _epochProofVerifier,
289-
GenesisState memory _genesisState,
290-
RollupConfigInput memory _config
291-
) internal {
292-
STFLib.initialize(_genesisState);
293-
RollupStore storage rollupStore = STFLib.getStorage();
294-
295-
rollupStore.config.feeAsset = _feeAsset;
296-
rollupStore.config.epochProofVerifier = _epochProofVerifier;
297-
rollupStore.config.version = _config.version;
298-
299-
IInbox inbox = IInbox(
300-
address(
301-
new Inbox(
302-
address(this), _feeAsset, _config.version, Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT, _config.inboxLag
303-
)
304-
)
305-
);
306-
307-
rollupStore.config.inbox = inbox;
308-
rollupStore.config.outbox = IOutbox(address(new Outbox(address(this), _config.version)));
309-
rollupStore.config.feeAssetPortal = IFeeJuicePortal(inbox.getFeeAssetPortal());
310-
}
311-
312260
/**
313261
* @notice Updates the reward configuration for sequencers and provers
314262
* @dev Only callable by the contract owner. Updates how rewards are calculated and distributed.
@@ -642,4 +590,54 @@ contract RollupCore is EIP712("Aztec Rollup", "1"), Ownable, IStakingCore, IVali
642590
function getActiveAttesterCount() public view override(IStakingCore) returns (uint256) {
643591
return StakingLib.getAttesterCountAtTime(Timestamp.wrap(block.timestamp));
644592
}
593+
594+
function _deploySlasher(RollupConfigInput memory _config, address _governance) internal returns (ISlasher slasher) {
595+
// We call one external library or another based on the slasher flavor
596+
// This allows us to keep the slash flavors in separate external libraries so we do not exceed max contract size
597+
// Note that we do not deploy a slasher if we run with no committees (i.e. targetCommitteeSize == 0)
598+
if (_config.targetCommitteeSize == 0 || _config.slasherFlavor == SlasherFlavor.NONE) {
599+
return ISlasher(address(0));
600+
}
601+
602+
if (_config.slasherFlavor == SlasherFlavor.TALLY) {
603+
return TallySlasherDeploymentExtLib.deployTallySlasher(address(this), _governance, _config);
604+
}
605+
606+
return EmpireSlasherDeploymentExtLib.deployEmpireSlasher(address(this), _governance, _config);
607+
}
608+
609+
function _initializeRewards(RollupConfigInput memory _config) internal {
610+
RewardConfig memory rewardConfig = _config.rewardConfig;
611+
612+
if (address(rewardConfig.booster) == address(0)) {
613+
rewardConfig.booster = RewardExtLib.deployRewardBooster(_config.rewardBoostConfig);
614+
}
615+
616+
RewardExtLib.initialize(_config.earliestRewardsClaimableTimestamp);
617+
RewardExtLib.setConfig(rewardConfig);
618+
}
619+
620+
function _initializeStore(
621+
IERC20 _feeAsset,
622+
IVerifier _epochProofVerifier,
623+
GenesisState memory _genesisState,
624+
RollupConfigInput memory _config
625+
) internal {
626+
STFLib.initialize(_genesisState);
627+
RollupStore storage rollupStore = STFLib.getStorage();
628+
629+
rollupStore.config.feeAsset = _feeAsset;
630+
rollupStore.config.epochProofVerifier = _epochProofVerifier;
631+
rollupStore.config.version = _config.version;
632+
633+
IInbox inbox = IInbox(
634+
address(
635+
new Inbox(address(this), _feeAsset, _config.version, Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT, _config.inboxLag)
636+
)
637+
);
638+
639+
rollupStore.config.inbox = inbox;
640+
rollupStore.config.outbox = IOutbox(address(new Outbox(address(this), _config.version)));
641+
rollupStore.config.feeAssetPortal = IFeeJuicePortal(inbox.getFeeAssetPortal());
642+
}
645643
}

l1-contracts/src/core/libraries/rollup/EmpireSlasherDeploymentExtLib.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ import {EmpireSlashingProposer} from "@aztec/core/slashing/EmpireSlashingPropose
1818
* initialization to resolve circular dependency between Slasher and EmpireSlashingProposer.
1919
*/
2020
library EmpireSlasherDeploymentExtLib {
21-
function deployEmpireSlasher(
22-
address _rollup,
23-
address _governance,
24-
RollupConfigInput memory _config
25-
) external returns (ISlasher) {
21+
function deployEmpireSlasher(address _rollup, address _governance, RollupConfigInput memory _config)
22+
external
23+
returns (ISlasher)
24+
{
2625
// Deploy slasher first
2726
Slasher slasher = new Slasher(_config.slashingVetoer, _governance, _config.slashingDisableDuration);
2827

l1-contracts/src/core/libraries/rollup/TallySlasherDeploymentExtLib.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ import {TallySlashingProposer} from "@aztec/core/slashing/TallySlashingProposer.
1717
* to resolve the circular dependency between Slasher and TallySlashingProposer.
1818
*/
1919
library TallySlasherDeploymentExtLib {
20-
function deployTallySlasher(
21-
address _rollup,
22-
address _governance,
23-
RollupConfigInput memory _config
24-
) external returns (ISlasher) {
20+
function deployTallySlasher(address _rollup, address _governance, RollupConfigInput memory _config)
21+
external
22+
returns (ISlasher)
23+
{
2524
// Deploy slasher first
2625
Slasher slasher = new Slasher(_config.slashingVetoer, _governance, _config.slashingDisableDuration);
2726

l1-contracts/src/mock/coverage/zkpassport/ZKPassportHelper.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
// Coverage-only mock with intentionally minimal interface behavior.
3+
// solhint-disable imports-order
4+
// solhint-disable immutable-vars-naming
5+
// solhint-disable comprehensive-interface
26
pragma solidity >=0.8.27;
37

48
import {BoundData} from "./Types.sol";

l1-contracts/src/mock/coverage/zkpassport/ZKPassportRootVerifier.sol

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
// Coverage-only mock with intentionally minimal interface behavior.
3+
// solhint-disable imports-order
4+
// solhint-disable immutable-vars-naming
5+
// solhint-disable comprehensive-interface
6+
// solhint-disable no-empty-blocks
7+
// solhint-disable ordering
8+
// solhint-disable reason-string
9+
// solhint-disable gas-custom-errors
210
pragma solidity >=0.8.27;
311

412
import {ProofVerificationParams} from "./Types.sol";
@@ -27,16 +35,13 @@ contract ZKPassportRootVerifier {
2735
helpers[_version] = _helper;
2836
}
2937

30-
function verify(ProofVerificationParams calldata _params)
31-
external
32-
view
33-
returns (bool, bytes32, ZKPassportHelper)
34-
{
38+
function verify(ProofVerificationParams calldata _params) external view returns (bool, bytes32, ZKPassportHelper) {
3539
uint256 proofExpiry = PROOF_GENERATION_TIMESTAMP + _params.serviceConfig.validityPeriodInSeconds;
3640
require(block.timestamp <= proofExpiry, "The proof was generated outside the validity period");
3741

3842
uint256 publicInputsLength = _params.proofVerificationData.publicInputs.length;
39-
bytes32 nullifier = publicInputsLength == 0 ? bytes32(0) : _params.proofVerificationData.publicInputs[publicInputsLength - 1];
43+
bytes32 nullifier =
44+
publicInputsLength == 0 ? bytes32(0) : _params.proofVerificationData.publicInputs[publicInputsLength - 1];
4045
address helper = helpers[_params.version];
4146
return (true, nullifier, ZKPassportHelper(helper));
4247
}

l1-contracts/src/mock/coverage/zkpassport/ZKPassportSubVerifier.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
// Coverage-only mock with intentionally minimal interface behavior.
3+
// solhint-disable immutable-vars-naming
4+
// solhint-disable comprehensive-interface
5+
// solhint-disable no-empty-blocks
26
pragma solidity >=0.8.27;
37

48
import {ProofVerifier} from "./Types.sol";
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity >=0.8.27;
3+
import {IVerifier} from "@aztec/core/interfaces/IVerifier.sol";
34

4-
contract HonkVerifier {
5-
function verify(bytes calldata, bytes32[] calldata) external pure returns (bool) {
5+
contract HonkVerifier is IVerifier {
6+
function verify(bytes calldata, bytes32[] calldata) external pure override(IVerifier) returns (bool) {
67
return true;
78
}
89
}

l1-contracts/test/RollupGetters.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ contract RollupShouldBeGetters is ValidatorSelectionTestBase {
141141
(, bytes32[] memory writes) = vm.accesses(address(rollup.getGSE()));
142142
assertEq(writes.length, 0, "No writes should be done");
143143

144-
if (vm.envOr("FORGE_COVERAGE", false)) {
144+
if (isCoverage()) {
145145
return;
146146
}
147147

@@ -207,7 +207,7 @@ contract RollupShouldBeGetters is ValidatorSelectionTestBase {
207207
emit log_named_uint("gasSmall", gasSmall);
208208
emit log_named_uint("gasBig", gasBig);
209209

210-
if (vm.envOr("FORGE_COVERAGE", false)) {
210+
if (isCoverage()) {
211211
return;
212212
}
213213

l1-contracts/test/base/Base.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ contract TestBase is Test {
1414
AppendOnlyTreeSnapshot EMPTY_APPENDONLY_TREE_SNAPSHOT =
1515
AppendOnlyTreeSnapshot({root: bytes32(0), nextAvailableLeafIndex: 0});
1616

17+
modifier skipWhenCoverage() {
18+
if (isCoverage()) {
19+
vm.skip(true);
20+
}
21+
_;
22+
}
23+
24+
function isCoverage() internal view returns (bool) {
25+
return vm.envOr("FORGE_COVERAGE", false);
26+
}
27+
1728
function assertGt(Timestamp a, Timestamp b) internal {
1829
if (a <= b) {
1930
emit log("Error: a > b not satisfied [Timestamp]");

l1-contracts/test/escape-hatch/unit/selectCandidates.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ contract EscapeHatchSelectCandidatesTest is EscapeHatchBase {
206206
// 3. remove active (5 sstore :skull:)
207207
// 4. status update (1 sstore)
208208
// 5. exitable at update (1 sstore, same slot as above)
209-
uint256 expectedWrites = vm.envOr("FORGE_COVERAGE", false) ? 12 : 9;
209+
uint256 expectedWrites = isCoverage() ? 12 : 9;
210210
assertEq(writes.length, expectedWrites, "invalid number of writes");
211211

212212
// Verify hatch is prepared

0 commit comments

Comments
 (0)