Skip to content

Commit 71e376a

Browse files
committed
Solhint
1 parent d934c42 commit 71e376a

File tree

7 files changed

+65
-74
lines changed

7 files changed

+65
-74
lines changed

l1-contracts/src/core/RollupCore.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ contract RollupCore is
247247
CommitteeAttestations memory _attestations,
248248
address[] memory _committee,
249249
uint256 _invalidIndex
250-
) external {
250+
) external override(IRollupCore) {
251251
ExtRollupLib2.invalidateBadAttestation(_blockNumber, _attestations, _committee, _invalidIndex);
252252
}
253253

254254
function invalidateInsufficientAttestations(
255255
uint256 _blockNumber,
256256
CommitteeAttestations memory _attestations,
257257
address[] memory _committee
258-
) external {
258+
) external override(IRollupCore) {
259259
ExtRollupLib2.invalidateInsufficientAttestations(_blockNumber, _attestations, _committee);
260260
}
261261

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

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import {
66
SubmitEpochRootProofArgs,
77
PublicInputArgs,
88
IRollupCore,
9-
RollupStore,
10-
BlockHeaderValidationFlags
9+
RollupStore
1110
} from "@aztec/core/interfaces/IRollup.sol";
12-
import {ChainTipsLib, CompressedChainTips} from "@aztec/core/libraries/compressed-data/Tips.sol";
1311
import {TempBlockLog} from "@aztec/core/libraries/compressed-data/BlockLog.sol";
12+
import {ChainTipsLib, CompressedChainTips} from "@aztec/core/libraries/compressed-data/Tips.sol";
1413
import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
1514
import {Errors} from "@aztec/core/libraries/Errors.sol";
1615
import {BlobLib} from "@aztec/core/libraries/rollup/BlobLib.sol";
@@ -215,6 +214,31 @@ library EpochProofLib {
215214
return publicInputs;
216215
}
217216

217+
/**
218+
* @notice Verifies the attestations for the last block in the epoch
219+
* @param _endBlockNumber The last block number in the epoch
220+
* @param _attestations The attestations to verify
221+
*/
222+
function verifyLastBlockAttestations(
223+
uint256 _endBlockNumber,
224+
CommitteeAttestations memory _attestations
225+
) private {
226+
// Get the stored attestation hash and payload digest for the last block
227+
TempBlockLog memory blockLog = STFLib.getTempBlockLog(_endBlockNumber);
228+
229+
// Verify that the provided attestations match the stored hash
230+
bytes32 providedAttestationsHash = keccak256(abi.encode(_attestations));
231+
require(
232+
providedAttestationsHash == blockLog.attestationsHash, Errors.Rollup__InvalidAttestations()
233+
);
234+
235+
// Get the slot and epoch for the last block
236+
Slot slot = blockLog.slotNumber;
237+
Epoch epoch = STFLib.getEpochForBlock(_endBlockNumber);
238+
239+
ValidatorSelectionLib.verify(slot, epoch, _attestations, blockLog.payloadDigest);
240+
}
241+
218242
function assertAcceptable(uint256 _start, uint256 _end) private view returns (Epoch) {
219243
RollupStore storage rollupStore = STFLib.getStorage();
220244

@@ -294,29 +318,4 @@ library EpochProofLib {
294318
function addressToField(address _a) private pure returns (bytes32) {
295319
return bytes32(uint256(uint160(_a)));
296320
}
297-
298-
/**
299-
* @notice Verifies the attestations for the last block in the epoch
300-
* @param _endBlockNumber The last block number in the epoch
301-
* @param _attestations The attestations to verify
302-
*/
303-
function verifyLastBlockAttestations(
304-
uint256 _endBlockNumber,
305-
CommitteeAttestations memory _attestations
306-
) private {
307-
// Get the stored attestation hash and payload digest for the last block
308-
TempBlockLog memory blockLog = STFLib.getTempBlockLog(_endBlockNumber);
309-
310-
// Verify that the provided attestations match the stored hash
311-
bytes32 providedAttestationsHash = keccak256(abi.encode(_attestations));
312-
require(
313-
providedAttestationsHash == blockLog.attestationsHash, Errors.Rollup__InvalidAttestations()
314-
);
315-
316-
// Get the slot and epoch for the last block
317-
Slot slot = blockLog.slotNumber;
318-
Epoch epoch = STFLib.getEpochForBlock(_endBlockNumber);
319-
320-
ValidatorSelectionLib.verify(slot, epoch, _attestations, blockLog.payloadDigest);
321-
}
322321
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ pragma solidity >=0.8.27;
55

66
import {Errors} from "@aztec/core/libraries/Errors.sol";
77
import {SubmitEpochRootProofArgs, PublicInputArgs} from "@aztec/core/interfaces/IRollup.sol";
8-
import {TempBlockLog} from "@aztec/core/libraries/compressed-data/BlockLog.sol";
98
import {STFLib} from "@aztec/core/libraries/rollup/STFLib.sol";
109
import {Timestamp, TimeLib, Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol";
1110
import {BlobLib} from "./BlobLib.sol";
1211
import {EpochProofLib} from "./EpochProofLib.sol";
13-
import {InvalidateLib} from "./InvalidateLib.sol";
1412
import {SignatureLib} from "@aztec/shared/libraries/SignatureLib.sol";
1513
import {
1614
ProposeLib,
@@ -55,6 +53,11 @@ library ExtRollupLib {
5553
ProposeLib.propose(_args, _attestations, _blobInput, _checkBlob);
5654
}
5755

56+
function prune() external {
57+
require(STFLib.canPruneAtTime(Timestamp.wrap(block.timestamp)), Errors.Rollup__NothingToPrune());
58+
STFLib.prune();
59+
}
60+
5861
function getEpochProofPublicInputs(
5962
uint256 _start,
6063
uint256 _end,
@@ -80,9 +83,4 @@ library ExtRollupLib {
8083
function getBlobBaseFee() external view returns (uint256) {
8184
return BlobLib.getBlobBaseFee();
8285
}
83-
84-
function prune() external {
85-
require(STFLib.canPruneAtTime(Timestamp.wrap(block.timestamp)), Errors.Rollup__NothingToPrune());
86-
STFLib.prune();
87-
}
8886
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ library ExtRollupLib2 {
8383
InvalidateLib.invalidateInsufficientAttestations(_blockNumber, _attestations, _committee);
8484
}
8585

86+
function slash(address _attester, uint256 _amount) external returns (bool) {
87+
return StakingLib.trySlash(_attester, _amount);
88+
}
89+
8690
function canProposeAtTime(Timestamp _ts, bytes32 _archive) external returns (Slot, uint256) {
8791
return ValidatorSelectionLib.canProposeAtTime(_ts, _archive);
8892
}
@@ -110,8 +114,4 @@ library ExtRollupLib2 {
110114
function getEntryQueueFlushSize() external view returns (uint256) {
111115
return StakingLib.getEntryQueueFlushSize();
112116
}
113-
114-
function slash(address _attester, uint256 _amount) external returns (bool) {
115-
return StakingLib.trySlash(_attester, _amount);
116-
}
117117
}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22
// Copyright 2024 Aztec Labs.
33
pragma solidity >=0.8.27;
44

5-
import {
6-
IRollupCore, RollupStore, BlockHeaderValidationFlags
7-
} from "@aztec/core/interfaces/IRollup.sol";
8-
import {
9-
TempBlockLog, CompressedTempBlockLog
10-
} from "@aztec/core/libraries/compressed-data/BlockLog.sol";
5+
import {IRollupCore, RollupStore} from "@aztec/core/interfaces/IRollup.sol";
6+
import {CompressedTempBlockLog} from "@aztec/core/libraries/compressed-data/BlockLog.sol";
117
import {ChainTipsLib, CompressedChainTips} from "@aztec/core/libraries/compressed-data/Tips.sol";
128
import {Errors} from "@aztec/core/libraries/Errors.sol";
139
import {STFLib} from "@aztec/core/libraries/rollup/STFLib.sol";
1410
import {ValidatorSelectionLib} from "@aztec/core/libraries/rollup/ValidatorSelectionLib.sol";
1511
import {Timestamp, Slot, Epoch, TimeLib} from "@aztec/core/libraries/TimeLib.sol";
12+
import {CompressedSlot, CompressedTimeMath} from "@aztec/shared/libraries/CompressedTimeMath.sol";
1613
import {
1714
CommitteeAttestations, SignatureLib, Signature
1815
} from "@aztec/shared/libraries/SignatureLib.sol";
1916
import {ECDSA} from "@oz/utils/cryptography/ECDSA.sol";
2017
import {MessageHashUtils} from "@oz/utils/cryptography/MessageHashUtils.sol";
21-
import {CompressedSlot, CompressedTimeMath} from "@aztec/shared/libraries/CompressedTimeMath.sol";
2218

2319
library InvalidateLib {
2420
using TimeLib for Timestamp;

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

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
pragma solidity >=0.8.27;
44

55
import {RollupStore} from "@aztec/core/interfaces/IRollup.sol";
6-
import {STFLib} from "@aztec/core/libraries/rollup/STFLib.sol";
7-
8-
import {BlockHeaderValidationFlags} from "@aztec/core/interfaces/IRollup.sol";
96
import {ValidatorSelectionStorage} from "@aztec/core/interfaces/IValidatorSelection.sol";
107
import {SampleLib} from "@aztec/core/libraries/crypto/SampleLib.sol";
118
import {Errors} from "@aztec/core/libraries/Errors.sol";
129
import {StakingLib} from "@aztec/core/libraries/rollup/StakingLib.sol";
10+
import {STFLib} from "@aztec/core/libraries/rollup/STFLib.sol";
1311
import {Timestamp, Slot, Epoch, TimeLib} from "@aztec/core/libraries/TimeLib.sol";
1412
import {
1513
SignatureLib, Signature, CommitteeAttestations
@@ -354,6 +352,28 @@ library ValidatorSelectionLib {
354352
}
355353
}
356354

355+
function canProposeAtTime(Timestamp _ts, bytes32 _archive) internal returns (Slot, uint256) {
356+
Slot slot = _ts.slotFromTimestamp();
357+
RollupStore storage rollupStore = STFLib.getStorage();
358+
359+
uint256 pendingBlockNumber = STFLib.getEffectivePendingBlockNumber(_ts);
360+
361+
Slot lastSlot = STFLib.getSlotNumber(pendingBlockNumber);
362+
363+
require(slot > lastSlot, Errors.Rollup__SlotAlreadyInChain(lastSlot, slot));
364+
365+
// Make sure that the proposer is up to date and on the right chain (ie no reorgs)
366+
bytes32 tipArchive = rollupStore.archives[pendingBlockNumber];
367+
require(tipArchive == _archive, Errors.Rollup__InvalidArchive(tipArchive, _archive));
368+
369+
(address proposer,) = getProposerAt(slot);
370+
require(
371+
proposer == msg.sender, Errors.ValidatorSelection__InvalidProposer(proposer, msg.sender)
372+
);
373+
374+
return (slot, pendingBlockNumber + 1);
375+
}
376+
357377
function getCachedProposer(Slot _slot)
358378
internal
359379
view
@@ -400,28 +420,6 @@ library ValidatorSelectionLib {
400420
}
401421
}
402422

403-
function canProposeAtTime(Timestamp _ts, bytes32 _archive) internal returns (Slot, uint256) {
404-
Slot slot = _ts.slotFromTimestamp();
405-
RollupStore storage rollupStore = STFLib.getStorage();
406-
407-
uint256 pendingBlockNumber = STFLib.getEffectivePendingBlockNumber(_ts);
408-
409-
Slot lastSlot = STFLib.getSlotNumber(pendingBlockNumber);
410-
411-
require(slot > lastSlot, Errors.Rollup__SlotAlreadyInChain(lastSlot, slot));
412-
413-
// Make sure that the proposer is up to date and on the right chain (ie no reorgs)
414-
bytes32 tipArchive = rollupStore.archives[pendingBlockNumber];
415-
require(tipArchive == _archive, Errors.Rollup__InvalidArchive(tipArchive, _archive));
416-
417-
(address proposer,) = getProposerAt(slot);
418-
require(
419-
proposer == msg.sender, Errors.ValidatorSelection__InvalidProposer(proposer, msg.sender)
420-
);
421-
422-
return (slot, pendingBlockNumber + 1);
423-
}
424-
425423
/**
426424
* @notice Computes the nextSeed for an epoch
427425
*

l1-contracts/src/mock/StakingAssetHandler.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface IStakingAssetHandler {
5757
// Add validator methods
5858
function addValidator(
5959
address _attester,
60-
bytes32[] memory merkleProof,
60+
bytes32[] memory _merkleProof,
6161
ProofVerificationParams memory _params
6262
) external;
6363
function reenterExitedValidator(address _attester) external;

0 commit comments

Comments
 (0)