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

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,285 @@
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 {Test} from "forge-std/Test.sol";
7
+ import {console} from "forge-std/console.sol";
8
+
9
+ import {IERC20} from "@oz/token/ERC20/IERC20.sol";
10
+
11
+ import {IInstance} from "@aztec/core/interfaces/IInstance.sol";
12
+ import {Rollup} from "@aztec/core/Rollup.sol";
13
+ import {Timestamp} from "@aztec/shared/libraries/TimeMath.sol";
14
+
15
+ import {Governance} from "@aztec/governance/Governance.sol";
16
+ import {GSEPayload} from "@aztec/governance/GSEPayload.sol";
17
+ import {GSE, IGSE} from "@aztec/governance/GSE.sol";
18
+ import {IPayload} from "@aztec/governance/interfaces/IPayload.sol";
19
+ import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol";
20
+ import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol";
21
+ import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol";
22
+ import {Proposal, ProposalState} from "@aztec/governance/interfaces/IGovernance.sol";
23
+
24
+ import {FlushRewarder} from "@aztec/periphery/FlushRewarder.sol";
25
+ import {V6UpgradePayload} from "@aztec/periphery/V6UpgradePayload.sol";
26
+
27
+ /**
28
+ * @title V6UpgradeSimulation
29
+ * @author Aztec Labs
30
+ * @notice Executes {V6UpgradePayload} through the real governance lifecycle against a state
31
+ * snapshot, asserts the resulting state, and reverts the snapshot so nothing persists.
32
+ *
33
+ * @dev Kept out of DeployRollupForUpgradeV6 on purpose: that file is a configuration table meant
34
+ * to be reviewed line by line, and this is cheatcode machinery. The deploy script calls
35
+ * {simulate} in one line after it has stopped broadcasting.
36
+ *
37
+ * Requires forked state (a real registry, GSE and governance), so it runs under `--fork-url`
38
+ * or against a live RPC in simulation mode, not against a bare anvil.
39
+ *
40
+ * What this does and does not prove: it proves the payload's actions execute correctly and
41
+ * leave the chain in the expected state. It does NOT predict whether the proposal would
42
+ * pass -- a simulation-only voter is given a majority of the voting power so execution is
43
+ * reached regardless of how power is really distributed.
44
+ */
45
+ contract V6UpgradeSimulation is Test {
46
+ error V6UpgradeSimulation__SnapshotRevertFailed(uint256 snapshotId);
47
+
48
+ /// @notice Chain state read before execution, so the assertions afterwards compare against what
49
+ /// was actually there rather than against hardcoded amounts.
50
+ struct Snapshot {
51
+ address canonicalRollup;
52
+ uint256 versions;
53
+ uint256 bonusAttesters;
54
+ uint256 rewardDistributorBalance;
55
+ uint256 rewardDistributorAvailableToNew;
56
+ uint256 earmarkAmount;
57
+ uint256 earmarkedToPredecessorBefore;
58
+ uint256 totalEarmarkedBefore;
59
+ uint256 flushFundsToMove;
60
+ uint256 oldFlushBalance;
61
+ uint256 newFlushBalance;
62
+ uint64 proofOfPossessionGasLimit;
63
+ }
64
+
65
+ /// @notice Runs the whole lifecycle and reverts the snapshot afterwards.
66
+ /// @dev Also the entry point for `forge script ... --sig 'simulate(address)' <payload>`.
67
+ /// @param _payload The deployed {V6UpgradePayload} to execute
68
+ function simulate(address _payload) public {
69
+ V6UpgradePayload payload = V6UpgradePayload(_payload);
70
+ IRegistry registry = payload.REGISTRY();
71
+ Governance governance = Governance(registry.getGovernance());
72
+ IGSE gse = IGSE(address(payload.ROLLUP().getGSE()));
73
+
74
+ Snapshot memory before = _capture(payload, registry, gse);
75
+
76
+ uint256 snapshotId = vm.snapshotState();
77
+
78
+ _executeThroughGovernance(payload, governance, gse, before.canonicalRollup);
79
+ _assertPostState(payload, registry, gse, before);
80
+
81
+ if (!vm.revertToState(snapshotId)) {
82
+ revert V6UpgradeSimulation__SnapshotRevertFailed(snapshotId);
83
+ }
84
+ console.log(unicode"[simulate] payload executes and leaves the expected state ✓");
85
+ }
86
+
87
+ function _capture(V6UpgradePayload _payload, IRegistry _registry, IGSE _gse)
88
+ internal
89
+ view
90
+ returns (Snapshot memory s)
91
+ {
92
+ s.canonicalRollup = address(_registry.getCanonicalRollup());
93
+ s.versions = _registry.numberOfVersions();
94
+ s.bonusAttesters = _gse.getAttesterCountAtTime(_gse.getBonusInstanceAddress(), Timestamp.wrap(block.timestamp));
95
+ s.proofOfPossessionGasLimit = GSE(address(_gse)).proofOfPossessionGasLimit();
96
+
97
+ IRewardDistributor distributor = _registry.getRewardDistributor();
98
+ IERC20 rewardAsset = IERC20(Rollup(address(_payload.ROLLUP())).getFeeAsset());
99
+ s.rewardDistributorBalance = rewardAsset.balanceOf(address(distributor));
100
+ s.rewardDistributorAvailableToNew = distributor.availableTo(address(_payload.ROLLUP()));
101
+
102
+ s.earmarkAmount = _payload.EARMARK_AMOUNT();
103
+ s.earmarkedToPredecessorBefore =
104
+ RewardDistributor(address(distributor)).specificRecipientBalance(_payload.PREDECESSOR());
105
+ s.totalEarmarkedBefore = RewardDistributor(address(distributor)).totalEarmarkedBalance();
106
+
107
+ FlushRewarder oldFlush = _payload.OLD_FLUSH_REWARDER();
108
+ if (address(oldFlush) != address(0)) {
109
+ IERC20 flushAsset = oldFlush.REWARD_ASSET();
110
+ s.flushFundsToMove = oldFlush.rewardsAvailable();
111
+ s.oldFlushBalance = flushAsset.balanceOf(address(oldFlush));
112
+ s.newFlushBalance = flushAsset.balanceOf(address(_payload.NEW_FLUSH_REWARDER()));
113
+ }
114
+ }
115
+
116
+ /// @dev Mirrors what GovernanceProposer does: the payload is wrapped in a GSEPayload before
117
+ /// being proposed, so the simulation exercises the same shape governance will see.
118
+ function _executeThroughGovernance(
119
+ V6UpgradePayload _payload,
120
+ Governance _governance,
121
+ IGSE _gse,
122
+ address _oldCanonical
123
+ ) internal {
124
+ GSEPayload wrapped = new GSEPayload(IPayload(address(_payload)), _gse, _payload.REGISTRY());
125
+
126
+ // A simulation-only voter holding twice the total power guarantees the proposal reaches
127
+ // execution however real power is distributed. Everything here is inside the snapshot.
128
+ address simVoter = address(uint160(uint256(keccak256("V6UpgradeSimulation.simVoter"))));
129
+ uint256 simPower = _governance.totalPowerAt(Timestamp.wrap(block.timestamp - 1)) * 2;
130
+ IERC20 govAsset = _governance.ASSET();
131
+ deal(address(govAsset), simVoter, simPower);
132
+
133
+ vm.startPrank(simVoter);
134
+ govAsset.approve(address(_governance), simPower);
135
+ _governance.deposit(simVoter, simPower);
136
+ vm.stopPrank();
137
+
138
+ vm.prank(_governance.governanceProposer());
139
+ uint256 proposalId = _governance.propose(IPayload(address(wrapped)));
140
+
141
+ Proposal memory proposal = _governance.getProposal(proposalId);
142
+ Timestamp pendingThrough =
143
+ Timestamp.wrap(Timestamp.unwrap(proposal.creation) + Timestamp.unwrap(proposal.config.votingDelay));
144
+ Timestamp queuedThrough = Timestamp.wrap(
145
+ Timestamp.unwrap(pendingThrough) + Timestamp.unwrap(proposal.config.votingDuration)
146
+ + Timestamp.unwrap(proposal.config.executionDelay)
147
+ );
148
+
149
+ vm.warp(Timestamp.unwrap(pendingThrough) + 1);
150
+ assertEq(uint256(_governance.getProposalState(proposalId)), uint256(ProposalState.Active), "proposal not active");
151
+
152
+ // The outgoing rollup votes with whatever power it and the bonus instance hold, so the
153
+ // simulation exercises the real voting path and not only the synthetic voter.
154
+ uint256 rollupPower = _gse.getVotingPowerAt(_oldCanonical, pendingThrough);
155
+ if (rollupPower > 0) {
156
+ vm.prank(_oldCanonical);
157
+ _gse.vote(proposalId, rollupPower, true);
158
+ }
159
+ uint256 bonusPower = _gse.getVotingPowerAt(_gse.getBonusInstanceAddress(), pendingThrough);
160
+ if (bonusPower > 0) {
161
+ vm.prank(_oldCanonical);
162
+ _gse.voteWithBonus(proposalId, bonusPower, true);
163
+ }
164
+ vm.prank(simVoter);
165
+ _governance.vote(proposalId, simPower, true);
166
+
167
+ vm.warp(Timestamp.unwrap(queuedThrough) + 1);
168
+
169
+ // Where execution is restricted to office hours, step to the next open slot. The proposal
170
+ // survives the wait because the longest gap (Friday 17:00 to Monday 08:00, ~63h) is well
171
+ // inside the grace period, but assert it rather than assume.
172
+ if (_payload.ENFORCE_EXECUTION_WINDOW()) {
173
+ for (uint256 i = 0; i < 7 days / 1 hours && !_payload.isWithinExecutionWindow(block.timestamp); i++) {
174
+ vm.warp(block.timestamp + 1 hours);
175
+ }
176
+ assertTrue(_payload.isWithinExecutionWindow(block.timestamp), "no execution window found within a week");
177
+ }
178
+
179
+ assertEq(
180
+ uint256(_governance.getProposalState(proposalId)), uint256(ProposalState.Executable), "proposal not executable"
181
+ );
182
+
183
+ _governance.execute(proposalId);
184
+ assertEq(
185
+ uint256(_governance.getProposalState(proposalId)), uint256(ProposalState.Executed), "proposal not executed"
186
+ );
187
+ }
188
+
189
+ function _assertPostState(V6UpgradePayload _payload, IRegistry _registry, IGSE _gse, Snapshot memory _before)
190
+ internal
191
+ view
192
+ {
193
+ address newRollup = address(_payload.ROLLUP());
194
+
195
+ assertEq(address(_registry.getCanonicalRollup()), newRollup, "new rollup is not canonical");
196
+ assertEq(_registry.numberOfVersions(), _before.versions + 1, "version count did not grow by one");
197
+
198
+ // The bonus-instance attesters follow the canonical rollup by delegation rather than by
199
+ // re-depositing, so the new rollup should see at least everything the bonus bucket held.
200
+ assertGe(
201
+ _gse.getAttesterCountAtTime(newRollup, Timestamp.wrap(block.timestamp)),
202
+ _before.bonusAttesters,
203
+ "new rollup did not inherit the bonus instance attesters"
204
+ );
205
+
206
+ // Ownership must survive the upgrade: governance owns the rollup, or none of the owner-gated
207
+ // configuration (fee margin, fee recipient, queue config) can ever be changed again.
208
+ assertEq(Rollup(newRollup).owner(), _registry.getGovernance(), "rollup owner is not governance");
209
+
210
+ // The hatch is installed by the payload, not the deploy, so this is the only place the
211
+ // installation is proved before the real execution.
212
+ assertEq(address(Rollup(newRollup).getEscapeHatch()), _payload.ESCAPE_HATCH(), "escape hatch was not installed");
213
+
214
+ // The GSE is shared, so the new cap also governs the outgoing rollup's flushes from here on.
215
+ uint64 expectedPopGasLimit = _payload.PROOF_OF_POSSESSION_GAS_LIMIT() > 0
216
+ ? _payload.PROOF_OF_POSSESSION_GAS_LIMIT()
217
+ : _before.proofOfPossessionGasLimit;
218
+ assertEq(GSE(address(_gse)).proofOfPossessionGasLimit(), expectedPopGasLimit, "GSE proof-of-possession gas cap");
219
+
220
+ _assertRewardDistributor(_payload, _registry, _before);
221
+ _assertFlushRewarder(_payload, _before);
222
+ }
223
+
224
+ /// @dev The distributor resolves the canonical rollup live, so no action moves its funds: the
225
+ /// implicit pool simply becomes claimable by the new rollup. Asserted against the captured
226
+ /// balances rather than any fixed amount.
227
+ function _assertRewardDistributor(V6UpgradePayload _payload, IRegistry _registry, Snapshot memory _before)
228
+ internal
229
+ view
230
+ {
231
+ address newRollup = address(_payload.ROLLUP());
232
+ IRewardDistributor distributor = _registry.getRewardDistributor();
233
+ IERC20 rewardAsset = IERC20(Rollup(newRollup).getFeeAsset());
234
+
235
+ assertEq(distributor.canonicalRollup(), newRollup, "distributor does not follow the new rollup");
236
+
237
+ // Unchanged whether or not an earmark ran: the reservation moves value between the
238
+ // distributor's buckets, it does not move value out of the distributor.
239
+ assertEq(
240
+ rewardAsset.balanceOf(address(distributor)),
241
+ _before.rewardDistributorBalance,
242
+ "distributor balance moved during the upgrade"
243
+ );
244
+
245
+ // The reservation landed on the OUTGOING rollup, and the payload kept nothing back.
246
+ assertEq(
247
+ RewardDistributor(address(distributor)).specificRecipientBalance(_payload.PREDECESSOR()),
248
+ _before.earmarkedToPredecessorBefore + _before.earmarkAmount,
249
+ "earmark did not reach the outgoing rollup"
250
+ );
251
+ assertEq(
252
+ RewardDistributor(address(distributor)).totalEarmarkedBalance(),
253
+ _before.totalEarmarkedBefore + _before.earmarkAmount,
254
+ "earmark not reflected in the earmarked total"
255
+ );
256
+ assertEq(rewardAsset.balanceOf(address(_payload)), 0, "payload retained reward asset");
257
+ // Anything reserved for the predecessor is exactly what the new rollup no longer sees.
258
+ assertGe(
259
+ distributor.availableTo(newRollup) + _before.earmarkAmount,
260
+ _before.rewardDistributorAvailableToNew,
261
+ "new rollup lost more than the earmark"
262
+ );
263
+ }
264
+
265
+ /// @dev The replacement rewarder should gain exactly what was movable, and the outgoing one
266
+ /// should keep the remainder it owes to unclaimed flushers.
267
+ function _assertFlushRewarder(V6UpgradePayload _payload, Snapshot memory _before) internal view {
268
+ FlushRewarder oldFlush = _payload.OLD_FLUSH_REWARDER();
269
+ if (address(oldFlush) == address(0)) {
270
+ return;
271
+ }
272
+
273
+ IERC20 flushAsset = oldFlush.REWARD_ASSET();
274
+ assertEq(
275
+ flushAsset.balanceOf(address(_payload.NEW_FLUSH_REWARDER())),
276
+ _before.newFlushBalance + _before.flushFundsToMove,
277
+ "new flush rewarder did not receive the migrated funds"
278
+ );
279
+ assertEq(
280
+ flushAsset.balanceOf(address(oldFlush)),
281
+ _before.oldFlushBalance - _before.flushFundsToMove,
282
+ "old flush rewarder did not retain exactly its unclaimed remainder"
283
+ );
284
+ }
285
+ }