Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7374db1
validator snapshots
Maddiaa0 Mar 26, 2025
e74a472
test: add cheating time
Maddiaa0 Mar 26, 2025
dfbddb2
checkpoint
Maddiaa0 Mar 27, 2025
0b4038a
chore: shift sampling
Maddiaa0 Mar 27, 2025
50d96e3
fix: other tests
Maddiaa0 Mar 27, 2025
642572d
clean
Maddiaa0 Mar 27, 2025
0829959
include tree
Maddiaa0 Mar 27, 2025
6f72dd2
chore: remove redundant test
Maddiaa0 Mar 27, 2025
30bbf83
clean
Maddiaa0 Mar 27, 2025
a9c4263
fix: post rebase
Maddiaa0 Mar 27, 2025
93c6939
chore: embed time cheater into staking cheater + prev linting rules
Maddiaa0 Mar 27, 2025
76b0454
include: benchmarks, it gets worse before it gets better
Maddiaa0 Mar 27, 2025
3c85b8f
chore: include setupepoch in view function
Maddiaa0 Mar 27, 2025
d166a5f
chore: more isolated tree testing
Maddiaa0 Apr 14, 2025
7243887
Merge branch 'master' into md/val-snapshot
Maddiaa0 Apr 14, 2025
ee20cc5
chore: remove old tests
Maddiaa0 Apr 14, 2025
633839c
feat: also snapshot size of set
Maddiaa0 Apr 15, 2025
bb0868a
chore: update other tests
Maddiaa0 Apr 15, 2025
b485608
fix: staking asset handler tests
Maddiaa0 Apr 15, 2025
dd2869d
fmt
Maddiaa0 Apr 15, 2025
80160f5
fix: bench test
Maddiaa0 Apr 15, 2025
90200fd
Merge branch 'master' into md/val-snapshot
Maddiaa0 Apr 15, 2025
91796ff
chore: update bench
Maddiaa0 Apr 15, 2025
5186c39
chore: add length and values at epoch test
Maddiaa0 Apr 15, 2025
999c6b7
chore: less optimizer runs
Maddiaa0 Apr 15, 2025
2b111ed
chore: remove bytecode hash
Maddiaa0 Apr 15, 2025
c912aa1
chore: remove unneeded setup epoch calls
Maddiaa0 Apr 15, 2025
1c9822d
chore: expect revert wrapper lib
Maddiaa0 Apr 15, 2025
52050cf
Merge branch 'master' into md/val-snapshot
Maddiaa0 Apr 15, 2025
4869a41
fix: merge update
Maddiaa0 Apr 15, 2025
c57c437
Merge branch 'master' into md/val-snapshot
Maddiaa0 Apr 16, 2025
8eb8e35
fix: migrate to checkpoint lib
Maddiaa0 Apr 16, 2025
8d774e7
exp: remove foundry changes
Maddiaa0 Apr 16, 2025
e2213d1
comments
Maddiaa0 Apr 16, 2025
d165b11
fmt
Maddiaa0 Apr 16, 2025
2141087
WARNING: NO ATTESTERS ON THE ORIGINAL COMMITTEE
Maddiaa0 Apr 16, 2025
42c147f
Merge branch 'master' into md/val-snapshot
Maddiaa0 Apr 16, 2025
9e7579c
fix: update slashing tesst
Maddiaa0 Apr 16, 2025
698e969
fix: slashing test take 2
Maddiaa0 Apr 17, 2025
4c5086c
chore: update
Maddiaa0 Apr 17, 2025
86b1bd3
fmt
Maddiaa0 Apr 17, 2025
5de3410
test: add tests for new guards
Maddiaa0 Apr 17, 2025
c082c86
chore: extra test case
Maddiaa0 Apr 17, 2025
0500342
chore: remove length query from future epoch
Maddiaa0 Apr 17, 2025
28cc590
chore: fuzz tests for add.t.sol
Maddiaa0 Apr 17, 2025
b51dcd5
fix: prop test suite
Maddiaa0 Apr 17, 2025
39de094
ordering
Maddiaa0 Apr 17, 2025
8fa9dc9
chore: use l1 tx utils
Maddiaa0 Apr 18, 2025
001c2b4
Merge branch 'master' into md/val-snapshot
Maddiaa0 Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions l1-contracts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function inspect {
done
}


function gas_report {
check=${1:-"no"}
echo_header "l1-contracts gas report"
Expand Down
92 changes: 32 additions & 60 deletions l1-contracts/gas_benchmark.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,34 @@
| src/core/Rollup.sol:Rollup Contract | | | | | |
| src/core/Rollup.sol:Rollup contract | | | | | |
|-------------------------------------|-----------------|----------|----------|----------|---------|
| Deployment Cost | Deployment Size | | | | |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| 13939212 | 72687 | | | | |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| | | | | | |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| cheat__InitialiseValidatorSet | 13825170 | 13825170 | 13825170 | 13825170 | 1 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getBlock | 2028 | 2028 | 2028 | 2028 | 12 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getBurnAddress | 543 | 543 | 543 | 543 | 1 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getCurrentEpoch | 1662 | 1662 | 1662 | 1662 | 397 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getCurrentProposer | 142276 | 147339 | 142555 | 304940 | 200 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getCurrentSlot | 1308 | 1318 | 1308 | 5308 | 397 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getEpochCommittee | 147323 | 152191 | 147335 | 309356 | 100 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getEpochForBlock | 1776 | 1776 | 1776 | 1776 | 196 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getFeeAssetPortal | 881 | 881 | 881 | 881 | 1 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getFeeHeader | 2890 | 2890 | 2890 | 2890 | 95 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getManaBaseFeeAt | 33313 | 53419 | 54478 | 55593 | 195 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getPendingBlockNumber | 666 | 670 | 666 | 2666 | 401 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getProvenBlockNumber | 644 | 644 | 644 | 644 | 3 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getTimestampForSlot | 1599 | 1599 | 1599 | 1599 | 195 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| getVersion | 648 | 668 | 648 | 2648 | 100 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| setProvingCostPerMana | 26257 | 26284 | 26257 | 29057 | 101 |
|-------------------------------------+-----------------+----------+----------+----------+---------|
| submitEpochRootProof | 1189968 | 1200782 | 1189992 | 1222388 | 3 |
| src/core/messagebridge/Inbox.sol:Inbox Contract | | | | | |
| 8905012 | 44009 | | | | |
| Function Name | min | avg | median | max | # calls |
| cheat__InitialiseValidatorSet | 14773538 | 14773538 | 14773538 | 14773538 | 1 |
| getBlock | 1252 | 1252 | 1252 | 1252 | 12 |
| getBurnAddress | 280 | 280 | 280 | 280 | 1 |
| getCurrentEpoch | 870 | 870 | 870 | 870 | 490 |
| getCurrentProposer | 137000 | 164906 | 137000 | 1532365 | 200 |
| getCurrentSlot | 625 | 629 | 625 | 2625 | 490 |
| getEpochCommittee | 138682 | 138682 | 138682 | 138682 | 100 |
| getEpochForBlock | 1087 | 1087 | 1087 | 1087 | 196 |
| getFeeAssetPortal | 541 | 541 | 541 | 541 | 1 |
| getFeeHeader | 1479 | 1479 | 1479 | 1479 | 95 |
| getManaBaseFeeAt | 15466 | 20025 | 20350 | 24662 | 195 |
| getPendingBlockNumber | 398 | 402 | 398 | 2398 | 494 |
| getProvenBlockNumber | 512 | 512 | 512 | 512 | 3 |
| getTimestampForSlot | 824 | 824 | 824 | 824 | 195 |
| getVersion | 404 | 424 | 404 | 2404 | 100 |
| setProvingCostPerMana | 25937 | 25964 | 25937 | 28737 | 101 |
| submitEpochRootProof | 783299 | 796011 | 783311 | 821423 | 3 |
| src/core/messagebridge/Inbox.sol:Inbox contract | | | | | |
|-------------------------------------------------|-----------------|-----|--------|-----|---------|
| Deployment Cost | Deployment Size | | | | |
|-------------------------------------------------+-----------------+-----+--------+-----+---------|
| 0 | 12636 | | | | |
|-------------------------------------------------+-----------------+-----+--------+-----+---------|
| | | | | | |
|-------------------------------------------------+-----------------+-----+--------+-----+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------------------+-----------------+-----+--------+-----+---------|
| getFeeAssetPortal | 402 | 402 | 402 | 402 | 1 |
| src/periphery/Forwarder.sol:Forwarder Contract | | | | | |
| Deployment Cost | Deployment Size | | | | |
|------------------------------------------------+-----------------+--------+--------+---------+---------|
| 583246 | 2909 | | | | |
|------------------------------------------------+-----------------+--------+--------+---------+---------|
| | | | | | |
|------------------------------------------------+-----------------+--------+--------+---------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|------------------------------------------------+-----------------+--------+--------+---------+---------|
| forward | 758446 | 831897 | 792800 | 2103821 | 100 |
| 0 | 0 | | | | |
| Function Name | min | avg | median | max | # calls |
| getFeeAssetPortal | 234 | 234 | 234 | 234 | 1 |
| src/periphery/Forwarder.sol:Forwarder contract | | | | | |
|------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 358690 | 1553 | | | | |
| Function Name | min | avg | median | max | # calls |
| forward | 624506 | 630841 | 629469 | 640840 | 100 |
15 changes: 7 additions & 8 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ import {
FeeHeader,
RollupConfigInput
} from "@aztec/core/interfaces/IRollup.sol";
import {
IStaking,
ValidatorInfo,
Exit,
OperatorInfo,
EnumerableSet
} from "@aztec/core/interfaces/IStaking.sol";
import {IStaking, ValidatorInfo, Exit, OperatorInfo} from "@aztec/core/interfaces/IStaking.sol";
import {IValidatorSelection} from "@aztec/core/interfaces/IValidatorSelection.sol";
import {
FeeLib, FeeHeaderLib, FeeAssetValue, PriceLib
} from "@aztec/core/libraries/rollup/FeeLib.sol";
import {HeaderLib} from "@aztec/core/libraries/rollup/HeaderLib.sol";
import {
AddressSnapshotLib,
SnapshottedAddressSet
} from "@aztec/core/libraries/staking/AddressSnapshotLib.sol";

import {EpochProofLib} from "./libraries/rollup/EpochProofLib.sol";
import {ProposeLib, ValidateHeaderArgs} from "./libraries/rollup/ProposeLib.sol";
import {ValidatorSelectionLib} from "./libraries/validator-selection/ValidatorSelectionLib.sol";
Expand Down Expand Up @@ -59,7 +58,7 @@ import {
* about the state of the rollup and test it.
*/
contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
using EnumerableSet for EnumerableSet.AddressSet;
using AddressSnapshotLib for SnapshottedAddressSet;

using TimeLib for Timestamp;
using TimeLib for Slot;
Expand Down
2 changes: 0 additions & 2 deletions l1-contracts/src/core/RollupCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ contract RollupCore is
external
override(IStakingCore)
{
setupEpoch();
StakingLib.deposit(_attester, _proposer, _withdrawer, _amount);
}

Expand All @@ -185,7 +184,6 @@ contract RollupCore is
override(IStakingCore)
returns (bool)
{
setupEpoch();
return StakingLib.initiateWithdraw(_attester, _recipient);
}

Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/src/core/interfaces/IStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.27;

import {SnapshottedAddressSet} from "@aztec/core/libraries/staking/AddressSnapshotLib.sol";
import {Timestamp} from "@aztec/core/libraries/TimeMath.sol";
import {IERC20} from "@oz/token/ERC20/IERC20.sol";
import {EnumerableSet} from "@oz/utils/structs/EnumerableSet.sol";

// None -> Does not exist in our setup
// Validating -> Participating as validator
Expand Down Expand Up @@ -40,7 +40,7 @@ struct StakingStorage {
address slasher;
uint256 minimumStake;
Timestamp exitDelay;
EnumerableSet.AddressSet attesters;
SnapshottedAddressSet attesters;
mapping(address attester => ValidatorInfo) info;
mapping(address attester => Exit) exits;
}
Expand Down
1 change: 1 addition & 0 deletions l1-contracts/src/core/interfaces/IValidatorSelection.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol";
* @param nextSeed - The seed used to influence the NEXT epoch
*/
struct EpochData {
// TODO: remove in favor of commitment to comittee
address[] committee;
uint256 sampleSeed;
uint256 nextSeed;
Expand Down
3 changes: 3 additions & 0 deletions l1-contracts/src/core/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@ library Errors {

// FeeLib
error FeeLib__InvalidFeeAssetPriceModifier(); // 0xf2fb32ad

// AddressSnapshotLib
error AddressSnapshotLib__IndexOutOfBounds(uint256 index, uint256 size); // 0xd789b71a
}
17 changes: 11 additions & 6 deletions l1-contracts/src/core/libraries/TimeLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ pragma solidity >=0.8.27;
// solhint-disable-next-line no-unused-import
import {Timestamp, Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol";

import {SafeCast} from "@oz/utils/math/SafeCast.sol";

struct TimeStorage {
uint256 genesisTime;
uint256 slotDuration; // Number of seconds in a slot
uint256 epochDuration; // Number of slots in an epoch
uint128 genesisTime;
uint32 slotDuration; // Number of seconds in a slot
uint32 epochDuration; // Number of slots in an epoch
}

library TimeLib {
using SafeCast for uint256;

bytes32 private constant TIME_STORAGE_POSITION = keccak256("aztec.time.storage");

function initialize(uint256 _genesisTime, uint256 _slotDuration, uint256 _epochDuration) internal {
TimeStorage storage store = getStorage();
store.genesisTime = _genesisTime;
store.slotDuration = _slotDuration;
store.epochDuration = _epochDuration;
store.genesisTime = _genesisTime.toUint128();
store.slotDuration = _slotDuration.toUint32();
store.epochDuration = _epochDuration.toUint32();
}

function toTimestamp(Slot _a) internal view returns (Timestamp) {
Expand All @@ -45,6 +49,7 @@ library TimeLib {

function epochFromTimestamp(Timestamp _a) internal view returns (Epoch) {
TimeStorage storage store = getStorage();

return Epoch.wrap(
(Timestamp.unwrap(_a) - store.genesisTime) / (store.epochDuration * store.slotDuration)
);
Expand Down
Loading