@aztec-foundation/l1-artifacts 6.0.0-rc.6 → 6.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dest/HonkVerifierBytecode.d.ts +1 -1
  2. package/dest/HonkVerifierBytecode.js +1 -1
  3. package/l1-contracts/cache/solidity-files-cache.json +1 -1
  4. package/l1-contracts/foundry.toml +1 -0
  5. package/l1-contracts/generated/HonkVerifier.sol +45 -45
  6. package/l1-contracts/out/AddressSnapshotLib.sol/AddressSnapshotLib.json +1 -1
  7. package/l1-contracts/out/AttestationLib.sol/AttestationLib.json +1 -1
  8. package/l1-contracts/out/AttesterExitExtLib.sol/AttesterExitExtLib.json +1 -1
  9. package/l1-contracts/out/BN254Lib.sol/BN254Lib.json +1 -1
  10. package/l1-contracts/out/Ballot.sol/BallotLib.json +1 -1
  11. package/l1-contracts/out/BlobLib.sol/BlobLib.json +1 -1
  12. package/l1-contracts/out/Bn254LibWrapper.sol/Bn254LibWrapper.json +1 -1
  13. package/l1-contracts/out/CheckpointLog.sol/CompressedTempCheckpointLogLib.json +1 -1
  14. package/l1-contracts/out/CheckpointedUintLib.sol/CheckpointedUintLib.json +1 -1
  15. package/l1-contracts/out/CoinIssuer.sol/CoinIssuer.json +1 -1
  16. package/l1-contracts/out/CompressedTimeMath.sol/CompressedTimeMath.json +1 -1
  17. package/l1-contracts/out/Configuration.sol/CompressedConfigurationLib.json +1 -1
  18. package/l1-contracts/out/ConfigurationLib.sol/ConfigurationLib.json +1 -1
  19. package/l1-contracts/out/ConstantsGen.sol/Constants.json +1 -1
  20. package/l1-contracts/out/CoordinationSignatureLib.sol/CoordinationSignatureLib.json +1 -1
  21. package/l1-contracts/out/DataStructures.sol/DataStructures.json +1 -1
  22. package/l1-contracts/out/DateGatedRelayer.sol/DateGatedRelayer.json +1 -1
  23. package/l1-contracts/out/DeployAztecL1Contracts.s.sol/DeployAztecL1Contracts.json +1 -1
  24. package/l1-contracts/out/DeployRollupForUpgrade.s.sol/DeployRollupForUpgrade.json +1 -1
  25. package/l1-contracts/out/DeployRollupForUpgradeV6.s.sol/DeployRollupForUpgradeV6.json +1 -0
  26. package/l1-contracts/out/DeployRollupLib.sol/DeployRollupLib.json +1 -1
  27. package/l1-contracts/out/DeploymentConfiguration.sol/DeploymentConfiguration.json +1 -1
  28. package/l1-contracts/out/DeploymentConfiguration.sol/IDeploymentConfiguration.json +1 -1
  29. package/l1-contracts/out/DepositDelegationLib.sol/DepositDelegationLib.json +1 -1
  30. package/l1-contracts/out/EmpireBase.sol/EmpireBase.json +1 -1
  31. package/l1-contracts/out/EpochProofExtLib.sol/EpochProofExtLib.json +1 -1
  32. package/l1-contracts/out/EpochProofLib.sol/EpochProofLib.json +1 -1
  33. package/l1-contracts/out/Errors.sol/Errors.json +1 -1
  34. package/l1-contracts/out/EscapeHatch.sol/EscapeHatch.json +1 -1
  35. package/l1-contracts/out/FeeAssetHandler.sol/FeeAssetHandler.json +1 -1
  36. package/l1-contracts/out/FeeAssetHandler.sol/IFeeAssetHandler.json +1 -1
  37. package/l1-contracts/out/FeeConfig.sol/FeeConfigLib.json +1 -1
  38. package/l1-contracts/out/FeeConfig.sol/PriceLib.json +1 -1
  39. package/l1-contracts/out/FeeJuicePortal.sol/FeeJuicePortal.json +1 -1
  40. package/l1-contracts/out/FeeLib.sol/FeeLib.json +1 -1
  41. package/l1-contracts/out/FeeStructs.sol/FeeHeaderLib.json +1 -1
  42. package/l1-contracts/out/FeeStructs.sol/FeeStructsLib.json +1 -1
  43. package/l1-contracts/out/FieldLib.sol/FieldLib.json +1 -1
  44. package/l1-contracts/out/FlushEntryQueue.s.sol/FlushEntryQueue.json +1 -1
  45. package/l1-contracts/out/FlushRewarder.sol/FlushRewarder.json +1 -1
  46. package/l1-contracts/out/GSE.sol/GSE.json +1 -1
  47. package/l1-contracts/out/GSE.sol/GSECore.json +1 -1
  48. package/l1-contracts/out/GSE.sol/IGSE.json +1 -1
  49. package/l1-contracts/out/GSE.sol/IGSECore.json +1 -1
  50. package/l1-contracts/out/GSEPayload.sol/GSEPayload.json +1 -1
  51. package/l1-contracts/out/Governance.sol/Governance.json +1 -1
  52. package/l1-contracts/out/GovernanceProposer.sol/GovernanceProposer.json +1 -1
  53. package/l1-contracts/out/Hash.sol/Hash.json +1 -1
  54. package/l1-contracts/out/HonkVerifier.sol/HonkVerifier.json +1 -1
  55. package/l1-contracts/out/HonkVerifier.sol/IVerifier.json +1 -1
  56. package/l1-contracts/out/IBn254LibWrapper.sol/IBn254LibWrapper.json +1 -1
  57. package/l1-contracts/out/ICoinIssuer.sol/ICoinIssuer.json +1 -1
  58. package/l1-contracts/out/IDateGatedRelayer.sol/IDateGatedRelayer.json +1 -1
  59. package/l1-contracts/out/IEmpire.sol/IEmperor.json +1 -1
  60. package/l1-contracts/out/IEmpire.sol/IEmpire.json +1 -1
  61. package/l1-contracts/out/IEscapeHatch.sol/IEscapeHatch.json +1 -1
  62. package/l1-contracts/out/IEscapeHatch.sol/IEscapeHatchCore.json +1 -1
  63. package/l1-contracts/out/IFeeJuicePortal.sol/IFeeJuicePortal.json +1 -1
  64. package/l1-contracts/out/IFlushRewarder.sol/IFlushRewarder.json +1 -1
  65. package/l1-contracts/out/IGovernance.sol/IGovernance.json +1 -1
  66. package/l1-contracts/out/IGovernanceProposer.sol/IGovernanceProposer.json +1 -1
  67. package/l1-contracts/out/IInbox.sol/IInbox.json +1 -1
  68. package/l1-contracts/out/IInstance.sol/IInstance.json +1 -1
  69. package/l1-contracts/out/IMintableERC20.sol/IMintableERC20.json +1 -1
  70. package/l1-contracts/out/IOutbox.sol/IOutbox.json +1 -1
  71. package/l1-contracts/out/IPayload.sol/IPayload.json +1 -1
  72. package/l1-contracts/out/IProposerPayload.sol/IProposerPayload.json +1 -1
  73. package/l1-contracts/out/IRegistry.sol/IHaveVersion.json +1 -1
  74. package/l1-contracts/out/IRegistry.sol/IRegistry.json +1 -1
  75. package/l1-contracts/out/IRewardDistributor.sol/IRewardDistributor.json +1 -1
  76. package/l1-contracts/out/IRollup.sol/IRollup.json +1 -1
  77. package/l1-contracts/out/IRollup.sol/IRollupCore.json +1 -1
  78. package/l1-contracts/out/IRootRegistry.sol/IRootRegistry.json +1 -1
  79. package/l1-contracts/out/ISequencerRewardCalculator.sol/ISequencerRewardCalculator.json +1 -1
  80. package/l1-contracts/out/ISlasher.sol/ISlasher.json +1 -1
  81. package/l1-contracts/out/IStaking.sol/IStaking.json +1 -1
  82. package/l1-contracts/out/IStaking.sol/IStakingCore.json +1 -1
  83. package/l1-contracts/out/IValidatorSelection.sol/IValidatorSelection.json +1 -1
  84. package/l1-contracts/out/IValidatorSelection.sol/IValidatorSelectionCore.json +1 -1
  85. package/l1-contracts/out/IVerifier.sol/IVerifier.json +1 -1
  86. package/l1-contracts/out/Inbox.sol/Inbox.json +1 -1
  87. package/l1-contracts/out/InputsExtractor.sol/InputsExtractor.json +1 -1
  88. package/l1-contracts/out/InvalidateLib.sol/InvalidateLib.json +1 -1
  89. package/l1-contracts/out/MerkleLib.sol/MerkleLib.json +1 -1
  90. package/l1-contracts/out/MockERC20.sol/MockERC20.json +1 -1
  91. package/l1-contracts/out/MockERC721.sol/MockERC721.json +1 -1
  92. package/l1-contracts/out/MockFeeJuicePortal.sol/MockFeeJuicePortal.json +1 -1
  93. package/l1-contracts/out/MockVerifier.sol/MockVerifier.json +1 -1
  94. package/l1-contracts/out/MockZKPassportVerifier.sol/IZKPassportVerifier.json +1 -1
  95. package/l1-contracts/out/MockZKPassportVerifier.sol/MockZKPassportVerifier.json +1 -1
  96. package/l1-contracts/out/MultiAdder.sol/IMultiAdder.json +1 -1
  97. package/l1-contracts/out/MultiAdder.sol/MultiAdder.json +1 -1
  98. package/l1-contracts/out/Outbox.sol/Outbox.json +1 -1
  99. package/l1-contracts/out/OuterCount8.sol/HonkVerifier.json +1 -1
  100. package/l1-contracts/out/Proposal.sol/CompressedProposalLib.json +1 -1
  101. package/l1-contracts/out/ProposalLib.sol/ProposalLib.json +1 -1
  102. package/l1-contracts/out/ProposeLib.sol/ProposeLib.json +1 -1
  103. package/l1-contracts/out/ProposedHeaderLib.sol/ProposedHeaderLib.json +1 -1
  104. package/l1-contracts/out/RegisterNewRollupVersionPayload.sol/RegisterNewRollupVersionPayload.json +1 -1
  105. package/l1-contracts/out/Registry.sol/Registry.json +1 -1
  106. package/l1-contracts/out/RewardBooster.sol/IBooster.json +1 -1
  107. package/l1-contracts/out/RewardBooster.sol/IBoosterCore.json +1 -1
  108. package/l1-contracts/out/RewardBooster.sol/RewardBooster.json +1 -1
  109. package/l1-contracts/out/RewardDistributor.sol/RewardDistributor.json +1 -1
  110. package/l1-contracts/out/RewardExtLib.sol/RewardExtLib.json +1 -1
  111. package/l1-contracts/out/RewardLib.sol/BpsLib.json +1 -1
  112. package/l1-contracts/out/RewardLib.sol/RewardLib.json +1 -1
  113. package/l1-contracts/out/Rollup.sol/Rollup.json +1 -1
  114. package/l1-contracts/out/RollupConfiguration.sol/IRollupConfiguration.json +1 -1
  115. package/l1-contracts/out/RollupConfiguration.sol/RollupConfiguration.json +1 -1
  116. package/l1-contracts/out/RollupCore.sol/RollupCore.json +1 -1
  117. package/l1-contracts/out/RollupOperationsExtLib.sol/RollupOperationsExtLib.json +1 -1
  118. package/l1-contracts/out/STFLib.sol/STFLib.json +1 -1
  119. package/l1-contracts/out/SampleLib.sol/SampleLib.json +1 -1
  120. package/l1-contracts/out/SequencerRewardCalculatorLib.sol/SequencerRewardCalculatorLib.json +1 -1
  121. package/l1-contracts/out/SignatureLib.sol/SignatureLib.json +1 -1
  122. package/l1-contracts/out/SlashPayload.sol/SlashPayload.json +1 -1
  123. package/l1-contracts/out/SlashPayloadCloneable.sol/SlashPayloadCloneable.json +1 -1
  124. package/l1-contracts/out/SlashPayloadLib.sol/SlashPayloadLib.json +1 -1
  125. package/l1-contracts/out/SlashRoundLib.sol/CompressedSlashRoundMath.json +1 -1
  126. package/l1-contracts/out/Slasher.sol/Slasher.json +1 -1
  127. package/l1-contracts/out/SlasherDeploymentExtLib.sol/SlasherDeploymentExtLib.json +1 -1
  128. package/l1-contracts/out/SlashingProposer.sol/SlashingProposer.json +1 -1
  129. package/l1-contracts/out/StakingAssetHandler.sol/IStakingAssetHandler.json +1 -1
  130. package/l1-contracts/out/StakingAssetHandler.sol/StakingAssetHandler.json +1 -1
  131. package/l1-contracts/out/StakingLib.sol/StakingLib.json +1 -1
  132. package/l1-contracts/out/StakingQueue.sol/StakingQueueLib.json +1 -1
  133. package/l1-contracts/out/StakingQueueConfig.sol/StakingQueueConfigLib.json +1 -1
  134. package/l1-contracts/out/StdError.sol/stdError.json +1 -1
  135. package/l1-contracts/out/TestERC20.sol/TestERC20.json +1 -1
  136. package/l1-contracts/out/TestPayloads.sol/CallAssetPayload.json +1 -1
  137. package/l1-contracts/out/TestPayloads.sol/CallRevertingPayload.json +1 -1
  138. package/l1-contracts/out/TestPayloads.sol/EmptyPayload.json +1 -1
  139. package/l1-contracts/out/TestPayloads.sol/FakeRollup.json +1 -1
  140. package/l1-contracts/out/TestPayloads.sol/RevertingCall.json +1 -1
  141. package/l1-contracts/out/TestPayloads.sol/UpgradePayload.json +1 -1
  142. package/l1-contracts/out/TimeLib.sol/TimeLib.json +1 -1
  143. package/l1-contracts/out/Tips.sol/ChainTipsLib.json +1 -1
  144. package/l1-contracts/out/V6UpgradePayload.sol/V6UpgradePayload.json +1 -0
  145. package/l1-contracts/out/V6UpgradeSimulation.sol/V6UpgradeSimulation.json +1 -0
  146. package/l1-contracts/out/ValidatorOperationsExtLib.sol/ValidatorOperationsExtLib.json +1 -1
  147. package/l1-contracts/out/ValidatorSelectionLib.sol/ValidatorSelectionLib.json +1 -1
  148. package/l1-contracts/out/ZKPassportHelper.sol/ZKPassportHelper.json +1 -1
  149. package/l1-contracts/out/ZKPassportRootVerifier.sol/ZKPassportRootVerifier.json +1 -1
  150. package/l1-contracts/out/ZKPassportSubVerifier.sol/ZKPassportSubVerifier.json +1 -1
  151. package/l1-contracts/out/build-info/ba785d07f217e383.json +1 -0
  152. package/l1-contracts/out/deploy/HonkVerifier.sol/HonkVerifier.json +1 -0
  153. package/l1-contracts/out/deploy/HonkVerifier.sol/IVerifier.json +1 -0
  154. package/l1-contracts/out/generated/HonkVerifier.sol/HonkVerifier.json +1 -1
  155. package/l1-contracts/out/libraries/Errors.sol/Errors.json +1 -1
  156. package/l1-contracts/out/rollup/BlobLib.sol/BlobLib.json +1 -1
  157. package/l1-contracts/out/src/ZKPassportHelper.sol/ZKPassportHelper.json +1 -1
  158. package/l1-contracts/out/src/ZKPassportRootVerifier.sol/ZKPassportRootVerifier.json +1 -1
  159. package/l1-contracts/out/src/ZKPassportSubVerifier.sol/ZKPassportSubVerifier.json +1 -1
  160. package/l1-contracts/script/deploy/DeployRollupForUpgradeV6.s.sol +688 -0
  161. package/l1-contracts/script/deploy/HonkVerifier.sol +5723 -0
  162. package/l1-contracts/script/deploy/V6UpgradeSimulation.sol +285 -0
  163. package/l1-contracts/script/deploy/V6_UPGRADE_RUNBOOK.md +441 -0
  164. package/l1-contracts/src/periphery/V6UpgradePayload.md +113 -0
  165. package/l1-contracts/src/periphery/V6UpgradePayload.sol +441 -0
  166. package/package.json +1 -1
  167. package/l1-contracts/out/build-info/018c24616ac5aeef.json +0 -1
@@ -0,0 +1,688 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright 2024 Aztec Labs.
3
+ // solhint-disable comprehensive-interface
4
+ pragma solidity >=0.8.27;
5
+
6
+ import {Script} from "forge-std/Script.sol";
7
+ import {StdAssertions} from "forge-std/StdAssertions.sol";
8
+ import {console} from "forge-std/console.sol";
9
+
10
+ import {IERC20} from "@oz/token/ERC20/IERC20.sol";
11
+
12
+ import {Rollup} from "@aztec/core/Rollup.sol";
13
+ import {EscapeHatch} from "@aztec/core/EscapeHatch.sol";
14
+ import {IEscapeHatch} from "@aztec/core/interfaces/IEscapeHatch.sol";
15
+ import {IInstance} from "@aztec/core/interfaces/IInstance.sol";
16
+ import {IVerifier} from "@aztec/core/interfaces/IVerifier.sol";
17
+ import {GenesisState, RollupConfigInput} from "@aztec/core/interfaces/IRollup.sol";
18
+ import {EthValue, EthPerFeeAssetE12} from "@aztec/core/libraries/rollup/FeeLib.sol";
19
+ import {RewardConfig, Bps} from "@aztec/core/libraries/rollup/RewardLib.sol";
20
+ import {IBoosterCore, RewardBoostConfig} from "@aztec/core/reward-boost/RewardBooster.sol";
21
+ import {StakingQueueConfig} from "@aztec/core/libraries/compressed-data/StakingQueueConfig.sol";
22
+ import {Inbox, INBOX_BUCKET_RING_SIZE} from "@aztec/core/messagebridge/Inbox.sol";
23
+ import {Outbox} from "@aztec/core/messagebridge/Outbox.sol";
24
+ import {Slasher} from "@aztec/core/slashing/Slasher.sol";
25
+ import {SlashingProposer} from "@aztec/core/slashing/SlashingProposer.sol";
26
+ import {Timestamp} from "@aztec/shared/libraries/TimeMath.sol";
27
+
28
+ import {GSE} from "@aztec/governance/GSE.sol";
29
+ import {Registry} from "@aztec/governance/Registry.sol";
30
+ import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol";
31
+
32
+ import {HonkVerifier} from "./HonkVerifier.sol";
33
+
34
+ import {FlushRewarder} from "@aztec/periphery/FlushRewarder.sol";
35
+ import {V6UpgradePayload} from "@aztec/periphery/V6UpgradePayload.sol";
36
+
37
+ import {V6UpgradeSimulation} from "./V6UpgradeSimulation.sol";
38
+
39
+ /**
40
+ * @title DeployRollupForUpgradeV6
41
+ * @author Aztec Labs
42
+ * @notice Deploys the v6 rollup and the governance payload that makes it canonical.
43
+ *
44
+ * @dev Usage:
45
+ * REGISTRY_ADDRESS=0x... forge script script/deploy/DeployRollupForUpgradeV6.s.sol \
46
+ * --rpc-url $L1_RPC_URL --private-key $KEY --broadcast
47
+ * Re-check an already deployed rollup without deploying anything:
48
+ * REGISTRY_ADDRESS=0x... forge script ... --sig 'verify(address)' <rollup>
49
+ *
50
+ * `REGISTRY_ADDRESS` is the only environment input. Every configuration value is a literal in
51
+ * {_config} below, so reviewing this file is sufficient to review the deployment: there are no
52
+ * env-var defaults and no `network-defaults.json` fallbacks that could change what is
53
+ * deployed. {verify} reads values back off the deployed contracts and asserts they match the
54
+ * table, so a typo in the table or a drift in how the Rollup consumes it fails loudly. It does
55
+ * not read back the entry-queue config, the reward-boost parameters, `ethereumSlotDuration`
56
+ * or the verifier's bytecode and `VK_HASH`; check those against the table and the pinned
57
+ * ./HonkVerifier.sol by other means.
58
+ *
59
+ * The rollup is constructed owned by governance, so the deployer never holds owner rights
60
+ * over it and nothing owner-gated happens in this script. The EscapeHatch is deployed here
61
+ * but installed by the payload, and anything else owner-gated needs a governance proposal.
62
+ *
63
+ * Not covered here, deliberately: the protocol fee margin and recipient keep their
64
+ * constructor values (0 and a placeholder address). Setting them is a governance call, so it
65
+ * belongs in {V6UpgradePayload}.
66
+ */
67
+ contract DeployRollupForUpgradeV6 is Script, StdAssertions {
68
+ /// @notice Thrown when run against a chain this script has no configuration for.
69
+ error DeployRollupForUpgradeV6__UnsupportedChain(uint256 chainId);
70
+
71
+ uint256 internal constant MAINNET_CHAIN_ID = 1;
72
+ uint256 internal constant SEPOLIA_CHAIN_ID = 11_155_111;
73
+
74
+ /// @notice Every value that determines what the v6 rollup is. One field per configurable knob.
75
+ struct Config {
76
+ // Genesis state of the protocol circuits. Produced by the v6 noir-projects build, not chosen.
77
+ // {run} refuses to deploy while any of them is zero, because the Rollup accepts zeros silently
78
+ // and a wrong genesis is only detectable after the fact.
79
+ bytes32 vkTreeRoot;
80
+ bytes32 protocolContractsHash;
81
+ bytes32 genesisArchiveRoot;
82
+ // Time. `ethereumSlotDuration` is the L1 slot length and is used to derive the inbox
83
+ // censorship cutoff; the rest define the Aztec slot/epoch clock.
84
+ uint256 ethereumSlotDuration;
85
+ uint256 aztecSlotDuration;
86
+ uint256 aztecEpochDuration;
87
+ uint256 aztecProofSubmissionEpochs;
88
+ // Committee selection.
89
+ uint256 targetCommitteeSize;
90
+ uint256 lagInEpochsForValidatorSet;
91
+ uint256 lagInEpochsForRandao;
92
+ // Staking. `localEjectionThreshold` is in staking-asset units and is the only one of these
93
+ // three the rollup sets. The other two are immutables of the existing GSE that this rollup
94
+ // inherits by being constructed against it: they are recorded here so {verify} fails if the
95
+ // GSE behind `REGISTRY_ADDRESS` is not the one these numbers were chosen against. Nothing in
96
+ // the contracts enforces a relationship between the three, so this file is the only place the
97
+ // choice of `localEjectionThreshold` can be checked against the thresholds it sits between.
98
+ uint256 localEjectionThreshold;
99
+ uint256 expectedGseActivationThreshold;
100
+ uint256 expectedGseEjectionThreshold;
101
+ uint256 exitDelaySeconds;
102
+ // Entry queue. Bootstrap values apply until the validator set reaches
103
+ // `bootstrapValidatorSetSize`; afterwards each flush admits
104
+ // max(normalFlushSizeMin, setSize / normalFlushSizeQuotient), capped by `maxFlushSize`.
105
+ uint256 entryQueueBootstrapValidatorSetSize;
106
+ uint256 entryQueueBootstrapFlushSize;
107
+ uint256 entryQueueNormalFlushSizeMin;
108
+ uint256 entryQueueNormalFlushSizeQuotient;
109
+ uint256 entryQueueMaxFlushSize;
110
+ // Fees. `initialEthPerFeeAsset` is an E12 fixed-point ETH-per-fee-asset price, a point-in-time
111
+ // market value; the mainnet literal records where and when it was read.
112
+ uint256 manaTarget;
113
+ uint256 provingCostPerMana;
114
+ uint256 initialEthPerFeeAsset;
115
+ // Rewards. `sequencerBps` is the sequencer's share of each checkpoint reward in basis points;
116
+ // the remainder goes to provers. A fresh RewardBooster is deployed with `rewardBoost`.
117
+ uint16 sequencerBps;
118
+ uint96 checkpointReward;
119
+ RewardBoostConfig rewardBoost;
120
+ // The initial ISequencerRewardCalculator, or zero for none. Per-registry reward policy is no
121
+ // longer built into the rollup (AZIP-31): the rollup instead calls a governance-set calculator
122
+ // once per epoch proof. Zero means every proposer receives the default sequencer share, which
123
+ // is also what the rollup falls back to if a configured calculator reverts, runs out of its
124
+ // stipend, or answers in the wrong shape -- so a wrong value here fails silently, not loudly.
125
+ // Governance can install or replace the calculator later via `setSequencerRewardCalculator`,
126
+ // so this does not have to be final at deploy.
127
+ address sequencerRewardCalculator;
128
+ // Slashing. `slashingRoundSizeInEpochs` is multiplied by `aztecEpochDuration` to get the round
129
+ // size in slots, which is what the SlashingProposer actually stores.
130
+ bool slasherEnabled;
131
+ uint256 slashingRoundSizeInEpochs;
132
+ uint256 slashingQuorum;
133
+ uint256 slashingLifetimeInRounds;
134
+ uint256 slashingExecutionDelayInRounds;
135
+ uint256 slashingOffsetInRounds;
136
+ uint256 slashingDisableDuration;
137
+ address slashingVetoer;
138
+ uint256 slashAmountSmall;
139
+ uint256 slashAmountMedium;
140
+ uint256 slashAmountLarge;
141
+ // Escape hatch. The bond is denominated in the staking asset. The EscapeHatch constructor
142
+ // rejects a configuration that breaks any of these, so they are constraints, not preferences:
143
+ // `escapeHatchActiveDuration` >= `aztecProofSubmissionEpochs` + 1, `escapeHatchFrequency` >
144
+ // both `EscapeHatch.LAG_IN_EPOCHS_FOR_SET_SIZE` (a constant 2) and `escapeHatchActiveDuration`,
145
+ // `escapeHatchLagInHatches` >= 1, withdrawal tax and failed-hatch punishment <= bond size, and
146
+ // `escapeHatchProposingExitDelay` <= 30 days.
147
+ uint96 escapeHatchBondSize;
148
+ uint96 escapeHatchWithdrawalTax;
149
+ uint96 escapeHatchFailedHatchPunishment;
150
+ uint256 escapeHatchFrequency;
151
+ uint256 escapeHatchActiveDuration;
152
+ uint256 escapeHatchLagInHatches;
153
+ uint256 escapeHatchProposingExitDelay;
154
+ // Restricts governance execution of the payload to UK office hours (Mon-Fri, 08:00-17:00
155
+ // London, DST-aware). Enforced as the payload's first action, so a rejected attempt reverts
156
+ // the whole execution and leaves the proposal executable again when the window next opens.
157
+ bool enforcePayloadExecutionWindow;
158
+ // The proof-of-possession gas cap the payload sets on the shared GSE, which applies to every
159
+ // rollup it serves, the outgoing one included. Zero omits the action and leaves the cap alone;
160
+ // otherwise the payload constructor rejects anything not above the GSE's cap at deployment.
161
+ uint64 proofOfPossessionGasLimit;
162
+ // Reward-pool balance the payload reserves for the OUTGOING rollup before it stops being
163
+ // canonical. Zero omits the reservation. Whatever is reserved is subtracted from what the new
164
+ // rollup can claim, and the pool is live, so this must be set against the balance at execution
165
+ // time rather than a figure from deploy day. The distributor and the reward asset are NOT
166
+ // configured: the payload reads both off the registry and the rollup, which is what makes this
167
+ // work unchanged on a chain whose distributor and fee asset differ.
168
+ uint256 earmarkAmountForPredecessor;
169
+ // Rewrites the OUTGOING rollup's reward split as part of the upgrade. Nothing here touches the
170
+ // new rollup, which keeps `sequencerBps` and `checkpointReward` from this same table. Gated by
171
+ // a flag because both 0 and 10000 bps are real splits, so no value can mean "leave it alone".
172
+ bool retunePredecessorRewards;
173
+ uint16 predecessorSequencerBps;
174
+ uint96 predecessorCheckpointReward;
175
+ // The flush rewarder serving the rollup being replaced, or zero on a chain that has none.
176
+ // A FlushRewarder is immutably bound to one rollup, so v6 needs its own; the payload deploys
177
+ // the replacement and moves the outgoing one's unowed balance across.
178
+ address oldFlushRewarder;
179
+ }
180
+
181
+ /**
182
+ * @notice The configuration this script deploys. This is the table to review.
183
+ * @dev The literal below is the mainnet configuration; Sepolia is expressed as a short list of
184
+ * overrides underneath it, so the only thing a reviewer has to check for Sepolia is that
185
+ * list. A chain with neither branch reverts rather than silently deploying mainnet values.
186
+ * Values track v5 production unless a comment says otherwise; each line records the v5
187
+ * value so any intentional v6 divergence is visible as a divergence.
188
+ */
189
+ /// @dev `virtual` so a test can zero the genesis roots and exercise `run()`'s refusal to deploy
190
+ /// without them. Nothing else about it is overridable, and nothing in the deploy path
191
+ /// overrides it.
192
+ function _config() internal view virtual returns (Config memory c) {
193
+ c = Config({
194
+ // Read off the v6 release build at 42fae4eb3feb5a493f2e8a2baf78b4716e323c40, the same build
195
+ // the pinned ./HonkVerifier.sol and ConstantsGen.sol come from; all of them move together.
196
+ // `run()` only guards against zero, so a root from a different build deploys silently. See
197
+ // "Fill in the inputs" in V6_UPGRADE_RUNBOOK.md.
198
+ // Source: `getVKTreeRoot()` and `protocolContractsHash` from the built packages,
199
+ // `GENESIS_ARCHIVE_ROOT` from the protocol constants.
200
+ vkTreeRoot: 0x22fff5de6ce590153df4468f7f0b152188a803d91b3c9c648b91d93d5913f219,
201
+ protocolContractsHash: 0x0f54271c52865841a77aaa66036eed901aff22fdce9f08e123ec8b205c9854d7,
202
+ genesisArchiveRoot: 0x29eb2c527f8d45276430363214e6c8d709ef3f657a3670ebac3179373d41e5c4,
203
+ ethereumSlotDuration: 12, // L1 slot time; no v5 equivalent, the v5 inbox took an explicit lag instead
204
+ aztecSlotDuration: 72,
205
+ aztecEpochDuration: 32,
206
+ aztecProofSubmissionEpochs: 1,
207
+ targetCommitteeSize: 48,
208
+ lagInEpochsForValidatorSet: 2,
209
+ lagInEpochsForRandao: 1,
210
+ localEjectionThreshold: 190_000e18, // v5 production: 190_000e18 (mainnet), 199_000e18 (sepolia)
211
+ expectedGseActivationThreshold: 200_000e18, // not set here; asserted against the existing GSE. v5 production:
212
+ // 200_000e18
213
+ expectedGseEjectionThreshold: 100_000e18, // not set here; asserted against the existing GSE. v5 production:
214
+ // 100_000e18
215
+ exitDelaySeconds: 345_600, // 4 days. v5 production: 345_600 (mainnet), 172_800 (sepolia)
216
+ entryQueueBootstrapValidatorSetSize: 500, // v5 production: 500.
217
+ entryQueueBootstrapFlushSize: 4, // v5 production: 4
218
+ entryQueueNormalFlushSizeMin: 1, // v5 production: 1
219
+ entryQueueNormalFlushSizeQuotient: 400, // v5 production: 400
220
+ entryQueueMaxFlushSize: 4, // v5 production: 4
221
+ manaTarget: 75_000_000, // v5 production: 75_000_000
222
+ provingCostPerMana: 12_500_000, // v5 production: 12_500_000 (set by AZIP-16)
223
+ // AZTEC/ETH Uniswap v4 pool 0xce2899b16743cfd5a954d8122d5e07f410305b1aebee39fd73d9f3b9ebf10c2f
224
+ // at mainnet block 26148995 (2026-10-08): 0.0000059342 ETH per AZTEC. v5 production: 9_512_195.
225
+ initialEthPerFeeAsset: 5_934_240,
226
+ sequencerBps: 9000, // 90% sequencer / 10% prover. v5 production: 7000
227
+ checkpointReward: 500e18, // same as v5
228
+ rewardBoost: RewardBoostConfig({
229
+ increment: 101_400, maxScore: 367_500, a: 250_000, minimum: 10_000, k: 1_000_000
230
+ }), // AZIP-5; same as v5
231
+ sequencerRewardCalculator: address(0),
232
+ slasherEnabled: true,
233
+ slashingRoundSizeInEpochs: 4,
234
+ slashingQuorum: 65, // of the 128-slot round (4 epochs x 32 slots)
235
+ slashingLifetimeInRounds: 34, // v5 production: 34 (mainnet), 5 (sepolia)
236
+ slashingExecutionDelayInRounds: 28, // v5 production: 28 (mainnet), 2 (sepolia)
237
+ slashingOffsetInRounds: 2,
238
+ slashingDisableDuration: 259_200, // 3 days. v5 production: 259_200 (mainnet), 432_000 (sepolia)
239
+ slashingVetoer: 0xBbB4aF368d02827945748b28CD4b2D42e4A37480, // v5 production (mainnet)
240
+ slashAmountSmall: 2000e18, // v5 production: 2000e18 (mainnet), 100_000e18 (sepolia)
241
+ slashAmountMedium: 5000e18, // v5 production: 5000e18 (mainnet), 250_000e18 (sepolia)
242
+ slashAmountLarge: 5000e18, // v5 production: 5000e18 (mainnet), 250_000e18 (sepolia)
243
+ escapeHatchBondSize: 332_000_000e18, // v5 production
244
+ escapeHatchWithdrawalTax: 1_660_000e18, // v5 production
245
+ escapeHatchFailedHatchPunishment: 9_600_000e18, // v5 production
246
+ escapeHatchFrequency: 112, // epochs between hatches. v5 production
247
+ escapeHatchActiveDuration: 2, // epochs. v5 production; also the minimum allowed here, being
248
+ // aztecProofSubmissionEpochs + 1
249
+ escapeHatchLagInHatches: 1, // v5 production
250
+ escapeHatchProposingExitDelay: 30 days, // v5 production; also the maximum the constructor allows
251
+ enforcePayloadExecutionWindow: true,
252
+ // Up from the GSE's 250_000, which honest keys whose hashToPoint loop runs long exceed under
253
+ // Osaka modexp pricing (EIP-7883): about 1 in 28.6k keys at 250k, about 1 in 2.5M at 300k. A
254
+ // deposit that fails verification can burn at most 50k more gas in a flush as a result.
255
+ proofOfPossessionGasLimit: 300_000,
256
+ earmarkAmountForPredecessor: 1_800_000e18,
257
+ retunePredecessorRewards: true,
258
+ predecessorSequencerBps: 7000, // v5 keeps the 7000 it already runs; only the reward below moves
259
+ predecessorCheckpointReward: 50e18, // down from the 500e18 v5 runs on, and the 500e18 v6 starts on
260
+ oldFlushRewarder: 0x5B98cA4dcE7b59CCf241D12f81d3d2eCF14e410e // bound to the v5 rollup
261
+ });
262
+
263
+ if (block.chainid == MAINNET_CHAIN_ID) {
264
+ return c;
265
+ }
266
+
267
+ if (block.chainid == SEPOLIA_CHAIN_ID) {
268
+ // Every field Sepolia diverges on, and nothing else. Values are v5's Sepolia production
269
+ // values;
270
+ c.localEjectionThreshold = 199_000e18;
271
+ c.exitDelaySeconds = 172_800; // 2 days
272
+ c.slashingLifetimeInRounds = 5;
273
+ c.slashingExecutionDelayInRounds = 2;
274
+ c.slashingDisableDuration = 432_000; // 5 days
275
+ c.slashingVetoer = 0xdfe19Da6a717b7088621d8bBB66be59F2d78e924;
276
+ c.slashAmountSmall = 100_000e18;
277
+ c.slashAmountMedium = 250_000e18;
278
+ c.slashAmountLarge = 250_000e18;
279
+ // Testnet upgrades are executed on demand, so the office-hours restriction is mainnet only.
280
+ c.enforcePayloadExecutionWindow = false;
281
+ // The Sepolia distributor was funded with ~100.98M FEE, all of it un-earmarked, so this
282
+ // draws from the implicit pool with room to spare.
283
+ c.earmarkAmountForPredecessor = 5_000_000e18;
284
+ // Set here rather than inherited from the mainnet market price: testnet fees are not priced
285
+ // against a real market, and this value only sets the starting point the fee oracle moves from.
286
+ c.initialEthPerFeeAsset = 10_000_000;
287
+ c.retunePredecessorRewards = true;
288
+ c.predecessorSequencerBps = 8000; // 80% sequencer / 20% prover, down from the 9000 v6 runs on
289
+ c.predecessorCheckpointReward = 100e18; // down from the 500e18 v6 runs on
290
+ // Sepolia has no flush rewarder to migrate, so the payload skips that action entirely.
291
+ // Leaving the mainnet address here would make the payload constructor revert, since it
292
+ // reads the outgoing rewarder's asset and rate.
293
+ c.oldFlushRewarder = address(0);
294
+ // No sequencer reward calculator on Sepolia either, matching mainnet.
295
+ c.sequencerRewardCalculator = address(0);
296
+ // Admit 12 validators per epoch rather than mainnet's 4, so testnet's queue drains at a
297
+ // rate that suits testing. All three move together: the bootstrap phase returns
298
+ // `bootstrapFlushSize` directly, the normal phase floors at `normalFlushSizeMin`, and
299
+ // `maxFlushSize` caps both, so raising fewer than three leaves the old value binding.
300
+ // `normalFlushSizeQuotient` stays at 400: `setSize / 400` only passes 12 above 4800
301
+ // validators, and the cap holds it at 12 there anyway.
302
+ c.entryQueueBootstrapFlushSize = 12; // v5 Sepolia production: 4
303
+ c.entryQueueNormalFlushSizeMin = 12; // v5 Sepolia production: 1
304
+ c.entryQueueMaxFlushSize = 12; // v5 Sepolia production: 4
305
+ return c;
306
+ }
307
+
308
+ revert DeployRollupForUpgradeV6__UnsupportedChain(block.chainid);
309
+ }
310
+
311
+ /// @notice The rollup {run} deployed. Zero until it has run.
312
+ /// @dev Mirrors `rollupOutput()` on DeployRollupForUpgrade: the addresses are logged for an
313
+ /// operator, and exposed here for anything that has to read them back -- a test, or tooling
314
+ /// that follows the deploy.
315
+ Rollup public deployedRollup;
316
+
317
+ /// @notice The payload {run} deployed. Zero until it has run.
318
+ V6UpgradePayload public deployedPayload;
319
+
320
+ /// @notice Deploys the verifier, the rollup, and the governance payload, then verifies the result.
321
+ function run() public {
322
+ Config memory c = _config();
323
+
324
+ // The three genesis roots are the only values the Rollup accepts silently when wrong, so they
325
+ // are gated here rather than trusted.
326
+ require(c.vkTreeRoot != bytes32(0), "vkTreeRoot not set");
327
+ require(c.protocolContractsHash != bytes32(0), "protocolContractsHash not set");
328
+ require(c.genesisArchiveRoot != bytes32(0), "genesisArchiveRoot not set");
329
+
330
+ Registry registry = Registry(vm.envAddress("REGISTRY_ADDRESS"));
331
+ // Everything the new rollup must share with the old one is read off the chain rather than
332
+ // configured, so the new rollup cannot be pointed at the wrong asset or GSE by a typo.
333
+ IInstance current = IInstance(address(registry.getCanonicalRollup()));
334
+ address governance = registry.getGovernance();
335
+
336
+ // The account `--private-key` / `--sender` resolves to. Every contract below is deployed by it.
337
+ address deployer = msg.sender;
338
+
339
+ vm.startBroadcast(deployer);
340
+
341
+ // Always the real verifier: this script exists for upgrades of live networks.
342
+ IVerifier verifier = IVerifier(address(new HonkVerifier()));
343
+
344
+ // The 5th argument is GOVERNANCE, and it is load-bearing twice: it becomes the Rollup's
345
+ // `Ownable` owner AND the Slasher's immutable `GOVERNANCE`, which may execute any slash
346
+ // payload with no vote, no round and no delay (Slasher.sol:58).
347
+ //
348
+ // So it MUST be governance, not the deployer. `transferOwnership` moves only the Ownable
349
+ // half; the Slasher's copy is immutable and would leave the deploy key able to slash every
350
+ // validator for the life of the rollup. Recovery would take 60 days to queue a replacement
351
+ // Slasher plus a 30-day window in which the old one still works.
352
+ //
353
+ // The cost is that no owner-gated setup can happen here. `setEscapeHatch` therefore moved
354
+ // into the payload, where governance performs it.
355
+ Rollup rollup = new Rollup(
356
+ current.getFeeAsset(),
357
+ current.getStakingAsset(),
358
+ current.getGSE(),
359
+ verifier,
360
+ governance,
361
+ _genesisState(c),
362
+ _rollupConfigInput(c, registry.getRewardDistributor())
363
+ );
364
+
365
+ // Deployed after the rollup because its constructor reads `getProofSubmissionEpochs()` off it
366
+ // to check `escapeHatchActiveDuration`, and because it must be built for this exact rollup.
367
+ EscapeHatch escapeHatch = new EscapeHatch(
368
+ address(rollup),
369
+ address(current.getStakingAsset()),
370
+ c.escapeHatchBondSize,
371
+ c.escapeHatchWithdrawalTax,
372
+ c.escapeHatchFailedHatchPunishment,
373
+ c.escapeHatchFrequency,
374
+ c.escapeHatchActiveDuration,
375
+ c.escapeHatchLagInHatches,
376
+ c.escapeHatchProposingExitDelay
377
+ );
378
+
379
+ // The rollup has been owned by governance since construction, so nothing owner-gated happens
380
+ // here and there is no ownership to transfer. The hatch is installed by the payload.
381
+ // Constructed in a helper purely to keep `run` inside the stack limit.
382
+ V6UpgradePayload payload = _deployPayload(c, registry, rollup, escapeHatch);
383
+
384
+ vm.stopBroadcast();
385
+
386
+ verify(address(rollup));
387
+
388
+ console.log("rollup ", address(rollup));
389
+ console.log("verifier ", address(verifier));
390
+ console.log("inbox ", address(rollup.getInbox()));
391
+ console.log("outbox ", address(rollup.getOutbox()));
392
+ console.log("feeJuicePortal ", address(rollup.getFeeAssetPortal()));
393
+ console.log("slasher ", rollup.getSlasher());
394
+ console.log("escapeHatch ", address(escapeHatch), "(installed by the payload)");
395
+ console.log("rewardBooster ", address(rollup.getRewardConfig().booster));
396
+ console.log("payload ", address(payload));
397
+ console.log("newFlushRewarder ", address(payload.NEW_FLUSH_REWARDER()));
398
+ verifyEscapeHatch(address(rollup), address(payload));
399
+ verifyFlushRewarder(address(rollup), address(payload));
400
+
401
+ _simulate(address(payload));
402
+ console.log("version ", rollup.getVersion());
403
+
404
+ deployedRollup = rollup;
405
+ deployedPayload = payload;
406
+ }
407
+
408
+ /**
409
+ * @notice Runs the payload through the real governance lifecycle against a state snapshot and
410
+ * reverts it, so a deploy cannot succeed while producing a payload that would fail.
411
+ * @dev Requires FORKED state -- it needs a governance with real voters and mainnet timings; see
412
+ * V6UpgradeSimulation. `virtual` so a test exercising the config table against a local stack
413
+ * can skip it, which is the only thing in `run()` that a local stack cannot satisfy.
414
+ */
415
+ function _simulate(address _payload) internal virtual {
416
+ new V6UpgradeSimulation().simulate(_payload);
417
+ }
418
+
419
+ /// @notice Asserts every configurable value of an already-deployed rollup against {_config}.
420
+ function verify(address _rollup) public view {
421
+ Config memory c = _config();
422
+ Rollup rollup = Rollup(_rollup);
423
+ Registry registry = Registry(vm.envAddress("REGISTRY_ADDRESS"));
424
+
425
+ _verifyGenesisAndTime(rollup, c);
426
+ _verifyStakingAndFees(rollup, c);
427
+ _verifyRewards(rollup, c);
428
+ _verifySlashing(rollup, c, registry.getGovernance());
429
+ _verifySubContracts(rollup, registry);
430
+ }
431
+
432
+ /// @notice Asserts the payload's replacement flush rewarder is wired to this rollup.
433
+ /// @dev Separate from {verify} because it needs the payload address, which {verify} is not given.
434
+ function verifyFlushRewarder(address _rollup, address _payload) public view {
435
+ Config memory c = _config();
436
+ FlushRewarder newRewarder = V6UpgradePayload(_payload).NEW_FLUSH_REWARDER();
437
+
438
+ assertEq(
439
+ V6UpgradePayload(_payload).ENFORCE_EXECUTION_WINDOW(),
440
+ c.enforcePayloadExecutionWindow,
441
+ "payload execution window flag"
442
+ );
443
+
444
+ // The earmark wiring: the amount is configured, the other three are derived, so asserting them
445
+ // is what proves the payload is pointed at this chain's distributor rather than another's.
446
+ V6UpgradePayload p = V6UpgradePayload(_payload);
447
+ Registry registry = Registry(vm.envAddress("REGISTRY_ADDRESS"));
448
+ assertEq(p.EARMARK_AMOUNT(), c.earmarkAmountForPredecessor, "earmark amount");
449
+ assertEq(p.PREDECESSOR(), address(registry.getCanonicalRollup()), "earmark recipient is not the outgoing rollup");
450
+ assertEq(p.RETUNE_PREDECESSOR_REWARDS(), c.retunePredecessorRewards, "retune flag");
451
+ assertEq(p.PREDECESSOR_SEQUENCER_BPS(), c.predecessorSequencerBps, "predecessor sequencerBps");
452
+ assertEq(p.PREDECESSOR_CHECKPOINT_REWARD(), c.predecessorCheckpointReward, "predecessor checkpointReward");
453
+ assertEq(p.PROOF_OF_POSSESSION_GAS_LIMIT(), c.proofOfPossessionGasLimit, "proofOfPossessionGasLimit");
454
+
455
+ if (c.earmarkAmountForPredecessor > 0) {
456
+ assertEq(address(p.REWARD_DISTRIBUTOR()), address(registry.getRewardDistributor()), "earmark distributor");
457
+ assertEq(address(p.REWARD_ASSET()), address(Rollup(_rollup).getFeeAsset()), "earmark reward asset");
458
+ }
459
+
460
+ if (c.oldFlushRewarder == address(0)) {
461
+ assertEq(address(newRewarder), address(0), "flush rewarder deployed on a chain with none to migrate");
462
+ return;
463
+ }
464
+
465
+ FlushRewarder oldRewarder = FlushRewarder(c.oldFlushRewarder);
466
+ assertEq(address(newRewarder.ROLLUP()), _rollup, "new flush rewarder bound to another rollup");
467
+ assertEq(address(newRewarder.REWARD_ASSET()), address(oldRewarder.REWARD_ASSET()), "flush reward asset");
468
+ assertEq(newRewarder.rewardPerInsertion(), oldRewarder.rewardPerInsertion(), "rewardPerInsertion");
469
+ // Governance must own it, or the reward rate can never be changed again.
470
+ assertEq(newRewarder.owner(), Registry(vm.envAddress("REGISTRY_ADDRESS")).getGovernance(), "flush rewarder owner");
471
+ }
472
+
473
+ /**
474
+ * @notice Asserts the payload's escape hatch is built for this rollup.
475
+ * @dev Separate from {verify} for the same reason as {verifyFlushRewarder}: the hatch is
476
+ * installed BY the payload, so the rollup does not point at it until governance executes.
477
+ * Installation itself is asserted post-execution by V6UpgradeSimulation.
478
+ */
479
+ function verifyEscapeHatch(address _rollup, address _payload) public view {
480
+ _verifyEscapeHatch(EscapeHatch(V6UpgradePayload(_payload).ESCAPE_HATCH()), Rollup(_rollup), _config());
481
+ }
482
+
483
+ function _verifyEscapeHatch(EscapeHatch hatch, Rollup _rollup, Config memory _c) private view {
484
+ assertTrue(address(hatch) != address(0), "payload has no escape hatch");
485
+ assertEq(hatch.getRollup(), address(_rollup), "escape hatch points at another rollup");
486
+ assertEq(hatch.getBondToken(), address(_rollup.getStakingAsset()), "escape hatch bond token");
487
+ assertEq(hatch.getBondSize(), _c.escapeHatchBondSize, "escapeHatchBondSize");
488
+ assertEq(hatch.getWithdrawalTax(), _c.escapeHatchWithdrawalTax, "escapeHatchWithdrawalTax");
489
+ assertEq(hatch.getFailedHatchPunishment(), _c.escapeHatchFailedHatchPunishment, "escapeHatchFailedHatchPunishment");
490
+ assertEq(hatch.getFrequency(), _c.escapeHatchFrequency, "escapeHatchFrequency");
491
+ assertEq(hatch.getActiveDuration(), _c.escapeHatchActiveDuration, "escapeHatchActiveDuration");
492
+ assertEq(hatch.getLagInHatches(), _c.escapeHatchLagInHatches, "escapeHatchLagInHatches");
493
+ assertEq(hatch.getProposingExitDelay(), _c.escapeHatchProposingExitDelay, "escapeHatchProposingExitDelay");
494
+ }
495
+
496
+ function _verifyGenesisAndTime(Rollup _rollup, Config memory _c) private view {
497
+ assertEq(_rollup.getVkTreeRoot(), _c.vkTreeRoot, "vkTreeRoot mismatch");
498
+ assertEq(_rollup.getProtocolContractsHash(), _c.protocolContractsHash, "protocolContractsHash");
499
+ // The genesis archive root is not exposed by a named getter; it is the archive of checkpoint 0.
500
+ assertEq(_rollup.archiveAt(0), _c.genesisArchiveRoot, "genesisArchiveRoot mismatch");
501
+ assertEq(_rollup.getSlotDuration(), _c.aztecSlotDuration, "aztecSlotDuration mismatch");
502
+ assertEq(_rollup.getEpochDuration(), _c.aztecEpochDuration, "aztecEpochDuration mismatch");
503
+ assertEq(_rollup.getProofSubmissionEpochs(), _c.aztecProofSubmissionEpochs, "aztecProofSubmissionEpochs mismatch");
504
+ assertEq(_rollup.getTargetCommitteeSize(), _c.targetCommitteeSize, "targetCommitteeSize mismatch");
505
+ assertEq(
506
+ _rollup.getLagInEpochsForValidatorSet(), _c.lagInEpochsForValidatorSet, "lagInEpochsForValidatorSet mismatch"
507
+ );
508
+ assertEq(_rollup.getLagInEpochsForRandao(), _c.lagInEpochsForRandao, "lagInEpochsForRandao");
509
+ }
510
+
511
+ function _verifyStakingAndFees(Rollup _rollup, Config memory _c) private view {
512
+ assertEq(_rollup.getLocalEjectionThreshold(), _c.localEjectionThreshold, "localEjectionThreshold mismatch");
513
+ // These two read straight off the GSE's immutables, so they are readable as soon as the rollup
514
+ // is constructed and do not depend on the GSE or Registry having registered it.
515
+ assertEq(_rollup.getActivationThreshold(), _c.expectedGseActivationThreshold, "gse activationThreshold mismatch");
516
+ assertEq(_rollup.getEjectionThreshold(), _c.expectedGseEjectionThreshold, "gse ejectionThreshold mismatch");
517
+ assertEq(Timestamp.unwrap(_rollup.getExitDelay()), _c.exitDelaySeconds, "exitDelaySeconds mismatch");
518
+ assertEq(_rollup.getManaTarget(), _c.manaTarget, "manaTarget mismatch");
519
+ assertEq(
520
+ EthValue.unwrap(_rollup.getProvingCostPerManaInEth()), _c.provingCostPerMana, "provingCostPerMana mismatch"
521
+ );
522
+ assertEq(EthPerFeeAssetE12.unwrap(_rollup.getEthPerFeeAsset()), _c.initialEthPerFeeAsset, "initialEthPerFeeAsset");
523
+
524
+ // The protocol fee margin and recipient are not deploy-time config; these assertions record
525
+ // that the rollup starts with the constructor's values and still needs a governance call.
526
+ assertEq(_rollup.getProtocolFeeMargin(), 0, "protocol fee margin should start at 0");
527
+ assertEq(
528
+ _rollup.getProtocolFeeRecipient(),
529
+ address(bytes20("CUAUHXICALLI")),
530
+ "protocol fee recipient should still be the constructor placeholder"
531
+ );
532
+ }
533
+
534
+ function _verifyRewards(Rollup _rollup, Config memory _c) private view {
535
+ RewardConfig memory rc = _rollup.getRewardConfig();
536
+ assertEq(Bps.unwrap(rc.sequencerBps), _c.sequencerBps, "sequencerBps");
537
+ assertEq(rc.checkpointReward, _c.checkpointReward, "checkpointReward");
538
+ // A booster address of zero in the config makes the Rollup deploy a fresh one, so a non-zero
539
+ // address here confirms that happened.
540
+ assertTrue(address(rc.booster) != address(0), "reward booster not deployed");
541
+
542
+ // Unlike the rest of this config, the calculator is mutable after deployment, so this asserts
543
+ // what the rollup launches with rather than something fixed at construction. Zero is the
544
+ // intended launch value; a non-zero address here would mean a calculator was wired in without
545
+ // the config saying so.
546
+ assertEq(_rollup.getSequencerRewardCalculator(), _c.sequencerRewardCalculator, "sequencerRewardCalculator");
547
+ }
548
+
549
+ function _verifySlashing(Rollup _rollup, Config memory _c, address _governance) private view {
550
+ // With slashing disabled the Rollup deploys no slasher at all, so there is nothing else to read.
551
+ if (!_c.slasherEnabled) {
552
+ assertEq(_rollup.getSlasher(), address(0), "slasher deployed despite slasherEnabled = false");
553
+ return;
554
+ }
555
+
556
+ Slasher slasher = Slasher(_rollup.getSlasher());
557
+ // The one that matters most and is easiest to get wrong: GOVERNANCE is immutable and is taken
558
+ // from the Rollup constructor's owner argument, so a rollup constructed by the deployer hands
559
+ // the deploy key unilateral, permanent slashing power that no later transfer can revoke.
560
+ assertEq(slasher.GOVERNANCE(), _governance, "slasher GOVERNANCE is not governance");
561
+ assertEq(slasher.VETOER(), _c.slashingVetoer, "slashingVetoer");
562
+ assertEq(slasher.SLASHING_DISABLE_DURATION(), _c.slashingDisableDuration, "slashingDisableDuration");
563
+
564
+ SlashingProposer proposer = SlashingProposer(slasher.PROPOSER());
565
+ assertEq(proposer.INSTANCE(), address(_rollup), "slashing proposer points at another rollup");
566
+ assertEq(proposer.QUORUM(), _c.slashingQuorum, "slashingQuorum");
567
+ assertEq(proposer.ROUND_SIZE_IN_EPOCHS(), _c.slashingRoundSizeInEpochs, "slashingRoundSizeInEpochs");
568
+ assertEq(proposer.ROUND_SIZE(), _c.slashingRoundSizeInEpochs * _c.aztecEpochDuration, "slashingRoundSize");
569
+ assertEq(proposer.LIFETIME_IN_ROUNDS(), _c.slashingLifetimeInRounds, "slashingLifetimeInRounds");
570
+ assertEq(proposer.EXECUTION_DELAY_IN_ROUNDS(), _c.slashingExecutionDelayInRounds, "slashingExecutionDelayInRounds");
571
+ assertEq(proposer.SLASH_OFFSET_IN_ROUNDS(), _c.slashingOffsetInRounds, "slashingOffsetInRounds");
572
+ assertEq(proposer.SLASH_AMOUNT_SMALL(), _c.slashAmountSmall, "slashAmountSmall");
573
+ assertEq(proposer.SLASH_AMOUNT_MEDIUM(), _c.slashAmountMedium, "slashAmountMedium");
574
+ assertEq(proposer.SLASH_AMOUNT_LARGE(), _c.slashAmountLarge, "slashAmountLarge");
575
+ }
576
+
577
+ function _verifySubContracts(Rollup _rollup, Registry _registry) private view {
578
+ IInstance current = IInstance(address(_registry.getCanonicalRollup()));
579
+ uint256 version = _rollup.getVersion();
580
+
581
+ // Inherited from the chain, not configured: assert they match the rollup being replaced.
582
+ assertEq(address(_rollup.getFeeAsset()), address(current.getFeeAsset()), "feeAsset");
583
+ assertEq(address(_rollup.getStakingAsset()), address(current.getStakingAsset()), "stakingAsset");
584
+ assertEq(address(_rollup.getGSE()), address(current.getGSE()), "gse");
585
+ assertEq(address(_rollup.getRewardDistributor()), address(_registry.getRewardDistributor()), "rewardDistributor");
586
+
587
+ // The Inbox and Outbox are deployed by the Rollup's constructor and are only correct if they
588
+ // point back at it and carry its version, which is what scopes L1<>L2 messages to this rollup.
589
+ Inbox inbox = Inbox(address(_rollup.getInbox()));
590
+ assertEq(inbox.ROLLUP(), address(_rollup), "inbox rollup");
591
+ assertEq(inbox.VERSION(), version, "inbox version");
592
+ assertEq(inbox.BUCKET_RING_SIZE(), INBOX_BUCKET_RING_SIZE, "inbox bucket ring size");
593
+ assertEq(inbox.FEE_ASSET_PORTAL(), address(_rollup.getFeeAssetPortal()), "fee juice portal");
594
+
595
+ Outbox outbox = Outbox(address(_rollup.getOutbox()));
596
+ assertEq(address(outbox.ROLLUP()), address(_rollup), "outbox rollup");
597
+ assertEq(outbox.VERSION(), version, "outbox version");
598
+
599
+ // The deploy is only safe to hand to governance if governance actually controls it.
600
+ assertEq(_rollup.owner(), _registry.getGovernance(), "rollup owner should be governance");
601
+ }
602
+
603
+ /// @dev Split out of {run} only so that function stays within the EVM stack limit.
604
+ function _deployPayload(Config memory _c, Registry _registry, Rollup _rollup, EscapeHatch _escapeHatch)
605
+ private
606
+ returns (V6UpgradePayload)
607
+ {
608
+ return new V6UpgradePayload(
609
+ _registry,
610
+ IInstance(address(_rollup)),
611
+ IEscapeHatch(address(_escapeHatch)),
612
+ FlushRewarder(_c.oldFlushRewarder),
613
+ _c.enforcePayloadExecutionWindow,
614
+ _c.earmarkAmountForPredecessor,
615
+ _c.retunePredecessorRewards,
616
+ _c.predecessorSequencerBps,
617
+ _c.predecessorCheckpointReward,
618
+ _c.proofOfPossessionGasLimit
619
+ );
620
+ }
621
+
622
+ function _genesisState(Config memory _c) private pure returns (GenesisState memory) {
623
+ return GenesisState({
624
+ vkTreeRoot: _c.vkTreeRoot,
625
+ protocolContractsHash: _c.protocolContractsHash,
626
+ genesisArchiveRoot: _c.genesisArchiveRoot
627
+ });
628
+ }
629
+
630
+ function _rollupConfigInput(Config memory _c, IRewardDistributor _rewardDistributor)
631
+ private
632
+ pure
633
+ returns (RollupConfigInput memory config)
634
+ {
635
+ config.ethereumSlotDuration = _c.ethereumSlotDuration;
636
+ config.aztecSlotDuration = _c.aztecSlotDuration;
637
+ config.aztecEpochDuration = _c.aztecEpochDuration;
638
+ config.aztecProofSubmissionEpochs = _c.aztecProofSubmissionEpochs;
639
+ config.targetCommitteeSize = _c.targetCommitteeSize;
640
+ config.lagInEpochsForValidatorSet = _c.lagInEpochsForValidatorSet;
641
+ config.lagInEpochsForRandao = _c.lagInEpochsForRandao;
642
+ config.localEjectionThreshold = _c.localEjectionThreshold;
643
+ config.exitDelaySeconds = _c.exitDelaySeconds;
644
+ config.manaTarget = _c.manaTarget;
645
+ config.provingCostPerMana = EthValue.wrap(_c.provingCostPerMana);
646
+ config.initialEthPerFeeAsset = EthPerFeeAssetE12.wrap(_c.initialEthPerFeeAsset);
647
+
648
+ config.slasherEnabled = _c.slasherEnabled;
649
+ config.slashingVetoer = _c.slashingVetoer;
650
+ config.slashingDisableDuration = _c.slashingDisableDuration;
651
+ config.slashingQuorum = _c.slashingQuorum;
652
+ // The Rollup stores the round size in slots; epochs are the reviewable unit.
653
+ config.slashingRoundSize = _c.slashingRoundSizeInEpochs * _c.aztecEpochDuration;
654
+ config.slashingLifetimeInRounds = _c.slashingLifetimeInRounds;
655
+ config.slashingExecutionDelayInRounds = _c.slashingExecutionDelayInRounds;
656
+ config.slashingOffsetInRounds = _c.slashingOffsetInRounds;
657
+ config.slashAmounts = [_c.slashAmountSmall, _c.slashAmountMedium, _c.slashAmountLarge];
658
+
659
+ config.stakingQueueConfig = StakingQueueConfig({
660
+ bootstrapValidatorSetSize: _c.entryQueueBootstrapValidatorSetSize,
661
+ bootstrapFlushSize: _c.entryQueueBootstrapFlushSize,
662
+ normalFlushSizeMin: _c.entryQueueNormalFlushSizeMin,
663
+ normalFlushSizeQuotient: _c.entryQueueNormalFlushSizeQuotient,
664
+ maxQueueFlushSize: _c.entryQueueMaxFlushSize
665
+ });
666
+
667
+ config.rewardConfig = RewardConfig({
668
+ rewardDistributor: _rewardDistributor,
669
+ sequencerBps: Bps.wrap(_c.sequencerBps),
670
+ // Zero makes the Rollup's constructor deploy a fresh RewardBooster from `rewardBoostConfig`.
671
+ booster: IBoosterCore(address(0)),
672
+ checkpointReward: _c.checkpointReward
673
+ });
674
+ config.rewardBoostConfig = _c.rewardBoost;
675
+
676
+ // Assigned explicitly even though the config's zero value matches the struct's: this field is
677
+ // the last one on `RollupConfigInput`, and leaving it out would read as an oversight rather
678
+ // than the decision it is.
679
+ config.sequencerRewardCalculator = _c.sequencerRewardCalculator;
680
+
681
+ // The version identifies this rollup in the Registry and scopes its Inbox/Outbox messages. It
682
+ // is derived from the configuration so that two rollups with different configuration cannot
683
+ // collide. `config.version` is still zero at this point (memory structs start zeroed and
684
+ // nothing above assigns it), which is what `RollupConfiguration._computeConfigVersion` also
685
+ // hashes over, so the two agree.
686
+ config.version = uint32(bytes4(keccak256(abi.encode(config, _genesisState(_c)))));
687
+ }
688
+ }