-
Notifications
You must be signed in to change notification settings - Fork 598
Expand file tree
/
Copy pathIRollup.sol
More file actions
242 lines (209 loc) · 9.61 KB
/
IRollup.sol
File metadata and controls
242 lines (209 loc) · 9.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Aztec Labs.
pragma solidity >=0.8.27;
import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol";
import {SlasherFlavor} from "@aztec/core/interfaces/ISlasher.sol";
import {IVerifier} from "@aztec/core/interfaces/IVerifier.sol";
import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol";
import {IOutbox} from "@aztec/core/interfaces/messagebridge/IOutbox.sol";
import {CheckpointLog, CompressedTempCheckpointLog} from "@aztec/core/libraries/compressed-data/CheckpointLog.sol";
import {FeeAssetPerEthE9, EthValue, FeeAssetValue} from "@aztec/core/libraries/compressed-data/fees/FeeConfig.sol";
import {FeeHeader, L1FeeData} from "@aztec/core/libraries/compressed-data/fees/FeeStructs.sol";
import {StakingQueueConfig} from "@aztec/core/libraries/compressed-data/StakingQueueConfig.sol";
import {CompressedChainTips, ChainTips} from "@aztec/core/libraries/compressed-data/Tips.sol";
import {CommitteeAttestations} from "@aztec/core/libraries/rollup/AttestationLib.sol";
import {ManaMinFeeComponents} from "@aztec/core/libraries/rollup/FeeLib.sol";
import {ProposedHeader} from "@aztec/core/libraries/rollup/ProposedHeaderLib.sol";
import {ProposeArgs} from "@aztec/core/libraries/rollup/ProposeLib.sol";
import {RewardConfig} from "@aztec/core/libraries/rollup/RewardLib.sol";
import {RewardBoostConfig} from "@aztec/core/reward-boost/RewardBooster.sol";
import {IHaveVersion} from "@aztec/governance/interfaces/IRegistry.sol";
import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol";
import {Signature} from "@aztec/shared/libraries/SignatureLib.sol";
import {Timestamp, Slot, Epoch} from "@aztec/shared/libraries/TimeMath.sol";
import {IERC20} from "@oz/token/ERC20/IERC20.sol";
struct PublicInputArgs {
bytes32 previousArchive;
bytes32 endArchive;
bytes32 outHash;
address proverId;
}
struct SubmitEpochRootProofArgs {
uint256 start; // inclusive
uint256 end; // inclusive
PublicInputArgs args;
bytes32[] fees;
CommitteeAttestations attestations; // attestations for the last checkpoint in epoch
bytes blobInputs;
bytes proof;
}
/**
* @notice Struct for storing flags for checkpoint header validation
* @param ignoreDA - True will ignore DA check, otherwise checks
*/
struct CheckpointHeaderValidationFlags {
bool ignoreDA;
}
struct GenesisState {
bytes32 vkTreeRoot;
bytes32 protocolContractsHash;
bytes32 genesisArchiveRoot;
}
struct RollupConfigInput {
uint256 aztecSlotDuration;
uint256 aztecEpochDuration;
uint256 targetCommitteeSize;
uint256 lagInEpochsForValidatorSet;
uint256 lagInEpochsForRandao;
uint256 aztecProofSubmissionEpochs;
uint256 slashingQuorum;
uint256 slashingRoundSize;
uint256 slashingLifetimeInRounds;
uint256 slashingExecutionDelayInRounds;
uint256[3] slashAmounts;
uint256 slashingOffsetInRounds;
SlasherFlavor slasherFlavor;
address slashingVetoer;
uint256 slashingDisableDuration;
uint256 manaTarget;
uint256 exitDelaySeconds;
uint32 version;
EthValue provingCostPerMana;
RewardConfig rewardConfig;
RewardBoostConfig rewardBoostConfig;
StakingQueueConfig stakingQueueConfig;
uint256 localEjectionThreshold;
Timestamp earliestRewardsClaimableTimestamp;
uint256 inboxLag;
}
struct RollupConfig {
bytes32 vkTreeRoot;
bytes32 protocolContractsHash;
uint32 version;
IERC20 feeAsset;
IFeeJuicePortal feeAssetPortal;
IVerifier epochProofVerifier;
IInbox inbox;
IOutbox outbox;
}
struct RollupStore {
CompressedChainTips tips; // put first such that the struct slot structure is easy to follow for cheatcodes
mapping(uint256 checkpointNumber => bytes32 archive) archives;
// The following represents a circular buffer. Key is `checkpointNumber % size`.
mapping(uint256 circularIndex => CompressedTempCheckpointLog temp) tempCheckpointLogs;
RollupConfig config;
}
interface IRollupCore {
event CheckpointProposed(
uint256 indexed checkpointNumber,
bytes32 indexed archive,
bytes32[] versionedBlobHashes,
bytes32 payloadDigest,
bytes32 attestationsHash
);
event L2ProofVerified(uint256 indexed checkpointNumber, address indexed proverId);
event CheckpointInvalidated(uint256 indexed checkpointNumber);
event RewardConfigUpdated(RewardConfig rewardConfig);
event ManaTargetUpdated(uint256 indexed manaTarget);
event PrunedPending(uint256 provenCheckpointNumber, uint256 pendingCheckpointNumber);
event RewardsClaimableUpdated(bool isRewardsClaimable);
function setRewardsClaimable(bool _isRewardsClaimable) external;
function claimSequencerRewards(address _recipient) external returns (uint256);
function claimProverRewards(address _recipient, Epoch[] memory _epochs) external returns (uint256);
function prune() external;
function updateL1GasFeeOracle() external;
function setProvingCostPerMana(EthValue _provingCostPerMana) external;
function propose(
ProposeArgs calldata _args,
CommitteeAttestations memory _attestations,
address[] memory _signers,
Signature memory _attestationsAndSignersSignature,
bytes calldata _blobInput
) external;
function submitEpochRootProof(SubmitEpochRootProofArgs calldata _args) external;
function invalidateBadAttestation(
uint256 _checkpointNumber,
CommitteeAttestations memory _attestations,
address[] memory _committee,
uint256 _invalidIndex
) external;
function invalidateInsufficientAttestations(
uint256 _checkpointNumber,
CommitteeAttestations memory _attestations,
address[] memory _committee
) external;
function setRewardConfig(RewardConfig memory _config) external;
function updateManaTarget(uint256 _manaTarget) external;
// solhint-disable-next-line func-name-mixedcase
function L1_BLOCK_AT_GENESIS() external view returns (uint256);
}
interface IRollup is IRollupCore, IHaveVersion {
function validateHeaderWithAttestations(
ProposedHeader calldata _header,
CommitteeAttestations memory _attestations,
address[] memory _signers,
Signature memory _attestationsAndSignersSignature,
bytes32 _digest,
bytes32 _blobsHash,
CheckpointHeaderValidationFlags memory _flags
) external;
function canProposeAtTime(Timestamp _ts, bytes32 _archive, address _who) external returns (Slot, uint256);
function getTips() external view returns (ChainTips memory);
function status(uint256 _myHeaderCheckpointNumber)
external
view
returns (
uint256 provenCheckpointNumber,
bytes32 provenArchive,
uint256 pendingCheckpointNumber,
bytes32 pendingArchive,
bytes32 archiveOfMyCheckpoint,
Epoch provenEpochNumber
);
function getEpochProofPublicInputs(
uint256 _start,
uint256 _end,
PublicInputArgs calldata _args,
bytes32[] calldata _fees,
bytes calldata _blobPublicInputs
) external view returns (bytes32[] memory);
function validateBlobs(bytes calldata _blobsInputs) external view returns (bytes32[] memory, bytes32, bytes[] memory);
function getManaMinFeeComponentsAt(Timestamp _timestamp, bool _inFeeAsset)
external
view
returns (ManaMinFeeComponents memory);
function getManaMinFeeAt(Timestamp _timestamp, bool _inFeeAsset) external view returns (uint256);
function getL1FeesAt(Timestamp _timestamp) external view returns (L1FeeData memory);
function getFeeAssetPerEth() external view returns (FeeAssetPerEthE9);
function getEpochForCheckpoint(uint256 _checkpointNumber) external view returns (Epoch);
function canPruneAtTime(Timestamp _ts) external view returns (bool);
function archive() external view returns (bytes32);
function archiveAt(uint256 _checkpointNumber) external view returns (bytes32);
function getProvenCheckpointNumber() external view returns (uint256);
function getPendingCheckpointNumber() external view returns (uint256);
function getCheckpoint(uint256 _checkpointNumber) external view returns (CheckpointLog memory);
function getFeeHeader(uint256 _checkpointNumber) external view returns (FeeHeader memory);
function getBlobCommitmentsHash(uint256 _checkpointNumber) external view returns (bytes32);
function getCurrentBlobCommitmentsHash() external view returns (bytes32);
function getSharesFor(address _prover) external view returns (uint256);
function getSequencerRewards(address _sequencer) external view returns (uint256);
function getCollectiveProverRewardsForEpoch(Epoch _epoch) external view returns (uint256);
function getSpecificProverRewardsForEpoch(Epoch _epoch, address _prover) external view returns (uint256);
function getHasSubmitted(Epoch _epoch, uint256 _length, address _prover) external view returns (bool);
function getHasClaimed(address _prover, Epoch _epoch) external view returns (bool);
function getProofSubmissionEpochs() external view returns (uint256);
function getManaTarget() external view returns (uint256);
function getManaLimit() external view returns (uint256);
function getProvingCostPerManaInEth() external view returns (EthValue);
function getProvingCostPerManaInFeeAsset() external view returns (FeeAssetValue);
function getFeeAsset() external view returns (IERC20);
function getFeeAssetPortal() external view returns (IFeeJuicePortal);
function getRewardDistributor() external view returns (IRewardDistributor);
function getBurnAddress() external view returns (address);
function getInbox() external view returns (IInbox);
function getOutbox() external view returns (IOutbox);
function getRewardConfig() external view returns (RewardConfig memory);
function getCheckpointReward() external view returns (uint256);
function getEarliestRewardsClaimableTimestamp() external view returns (Timestamp);
function isRewardsClaimable() external view returns (bool);
}