Skip to content

Commit 7203810

Browse files
authored
chore: rename _onCanonical to _moveWithLatestRollup (#15972)
Only changed comments/argument names.
1 parent 9e45ef1 commit 7203810

File tree

16 files changed

+64
-47
lines changed

16 files changed

+64
-47
lines changed

l1-contracts/src/core/RollupCore.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ contract RollupCore is
202202
ExtRollupLib2.vote(_proposalId);
203203
}
204204

205-
function deposit(address _attester, address _withdrawer, bool _onCanonical)
205+
function deposit(address _attester, address _withdrawer, bool _moveWithLatestRollup)
206206
external
207207
override(IStakingCore)
208208
{
209-
ExtRollupLib2.deposit(_attester, _withdrawer, _onCanonical);
209+
ExtRollupLib2.deposit(_attester, _withdrawer, _moveWithLatestRollup);
210210
}
211211

212212
function flushEntryQueue() external override(IStakingCore) {

l1-contracts/src/core/interfaces/IStaking.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface IStakingCore {
1919
event StakingQueueConfigUpdated(StakingQueueConfig config);
2020

2121
function setSlasher(address _slasher) external;
22-
function deposit(address _attester, address _withdrawer, bool _onCanonical) external;
22+
function deposit(address _attester, address _withdrawer, bool _moveWithLatestRollup) external;
2323
function flushEntryQueue() external;
2424
function initiateWithdraw(address _attester, address _recipient) external returns (bool);
2525
function finaliseWithdraw(address _attester) external;

l1-contracts/src/core/libraries/StakingQueue.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Errors} from "./Errors.sol";
66
struct DepositArgs {
77
address attester;
88
address withdrawer;
9-
bool onCanonical;
9+
bool moveWithLatestRollup;
1010
}
1111

1212
struct StakingQueue {
@@ -29,12 +29,15 @@ library StakingQueueLib {
2929
StakingQueue storage self,
3030
address _attester,
3131
address _withdrawer,
32-
bool _onCanonical
32+
bool _moveWithLatestRollup
3333
) internal returns (uint256) {
3434
uint128 queueLocation = self.last;
3535

36-
self.validators[queueLocation] =
37-
DepositArgs({attester: _attester, withdrawer: _withdrawer, onCanonical: _onCanonical});
36+
self.validators[queueLocation] = DepositArgs({
37+
attester: _attester,
38+
withdrawer: _withdrawer,
39+
moveWithLatestRollup: _moveWithLatestRollup
40+
});
3841
self.last = queueLocation + 1;
3942

4043
return queueLocation;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ library ExtRollupLib2 {
4848
StakingLib.vote(_proposalId);
4949
}
5050

51-
function deposit(address _attester, address _withdrawer, bool _onCanonical) external {
52-
StakingLib.deposit(_attester, _withdrawer, _onCanonical);
51+
function deposit(address _attester, address _withdrawer, bool _moveWithLatestRollup) external {
52+
StakingLib.deposit(_attester, _withdrawer, _moveWithLatestRollup);
5353
}
5454

5555
function flushEntryQueue(uint256 _maxAddableValidators) external {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ library StakingLib {
217217
}
218218
}
219219

220-
function deposit(address _attester, address _withdrawer, bool _onCanonical) internal {
220+
function deposit(address _attester, address _withdrawer, bool _moveWithLatestRollup) internal {
221221
require(
222222
_attester != address(0) && _withdrawer != address(0),
223223
Errors.Staking__InvalidDeposit(_attester, _withdrawer)
@@ -228,7 +228,7 @@ library StakingLib {
228228
uint256 amount = store.gse.DEPOSIT_AMOUNT();
229229

230230
store.stakingAsset.transferFrom(msg.sender, address(this), amount);
231-
store.entryQueue.enqueue(_attester, _withdrawer, _onCanonical);
231+
store.entryQueue.enqueue(_attester, _withdrawer, _moveWithLatestRollup);
232232
emit IStakingCore.ValidatorQueued(_attester, _withdrawer);
233233
}
234234

@@ -252,7 +252,7 @@ library StakingLib {
252252
DepositArgs memory args = store.entryQueue.dequeue();
253253
(bool success, bytes memory data) = address(store.gse).call(
254254
abi.encodeWithSelector(
255-
IStakingCore.deposit.selector, args.attester, args.withdrawer, args.onCanonical
255+
IStakingCore.deposit.selector, args.attester, args.withdrawer, args.moveWithLatestRollup
256256
)
257257
);
258258
if (success) {

l1-contracts/src/governance/GSE.sol

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface IGSECore {
3636

3737
function setGovernance(Governance _governance) external;
3838
function addRollup(address _rollup) external;
39-
function deposit(address _attester, address _withdrawer, bool _onBonus) external;
39+
function deposit(address _attester, address _withdrawer, bool _moveWithLatestRollup) external;
4040
function withdraw(address _attester, uint256 _amount) external returns (uint256, bool, uint256);
4141
function delegate(address _instance, address _attester, address _delegatee) external;
4242
function vote(uint256 _proposalId, uint256 _amount, bool _support) external;
@@ -255,38 +255,40 @@ contract GSECore is IGSECore, Ownable {
255255
*
256256
* @dev Transfers STAKING_ASSET from msg.sender to the GSE, and then into Governance.
257257
*
258-
* @dev if _onBonus is true, then msg.sender must be the latest rollup.
258+
* @dev if _moveWithLatestRollup is true, then msg.sender must be the latest rollup.
259259
*
260260
* @dev The same attester may deposit on multiple *instances*, so long as the invariant described
261261
* above BONUS_INSTANCE_ADDRESS holds.
262262
*
263263
* E.g. Suppose the registered rollups are A, then B, then C, so C's effective attesters are
264264
* those associated with C and the bonus address.
265265
*
266-
* Alice may come along now and deposit on A, and B, with _onBonus=false in both cases.
266+
* Alice may come along now and deposit on A, and B, with _moveWithLatestRollup=false in both cases.
267267
*
268-
* For depositing into C, she can deposit *either* with _onBonus = true OR false.
269-
* If she deposits with _onBonus = false, then she is associated with C's address.
270-
* If she deposits with _onBonus = true, then she is associated with the bonus address.
268+
* For depositing into C, she can deposit *either* with _moveWithLatestRollup = true OR false.
269+
* If she deposits with _moveWithLatestRollup = false, then she is associated with C's address.
270+
* If she deposits with _moveWithLatestRollup = true, then she is associated with the bonus address.
271271
*
272-
* Suppose she deposits with _onBonus = true, and a new rollup D is added to the rollups.
272+
* Suppose she deposits with _moveWithLatestRollup = true, and a new rollup D is added to the rollups.
273273
*
274274
* Now she cannot deposit through D AT ALL, since she is already in D's effective attesters.
275-
* But she CAN go back and deposit directly into C, with _onBonus = false.
275+
* But she CAN go back and deposit directly into C, with _moveWithLatestRollup = false.
276276
*
277277
* @param _attester - The attester address of the attester
278278
* @param _withdrawer - The withdrawer address of the attester
279-
* @param _onBonus - Whether to deposit into the specific instance, or the bonus instance
279+
* @param _moveWithLatestRollup - Whether to deposit into the specific instance, or the bonus instance
280280
*/
281-
function deposit(address _attester, address _withdrawer, bool _onBonus)
281+
function deposit(address _attester, address _withdrawer, bool _moveWithLatestRollup)
282282
external
283283
override(IGSECore)
284284
onlyRollup
285285
{
286286
bool isMsgSenderLatestRollup = getLatestRollup() == msg.sender;
287287

288-
// If _onBonus is true, then msg.sender must be the latest rollup.
289-
require(!_onBonus || isMsgSenderLatestRollup, Errors.GSE__NotLatestRollup(msg.sender));
288+
// If _moveWithLatestRollup is true, then msg.sender must be the latest rollup.
289+
require(
290+
!_moveWithLatestRollup || isMsgSenderLatestRollup, Errors.GSE__NotLatestRollup(msg.sender)
291+
);
290292

291293
// Ensure that we are not already attesting on the rollup
292294
require(
@@ -300,12 +302,12 @@ contract GSECore is IGSECore, Ownable {
300302
);
301303

302304
// Set the recipient instance address, i.e. the one that will receive the attester.
303-
// From above, we know that if we are here, and _onBonus is true,
305+
// From above, we know that if we are here, and _moveWithLatestRollup is true,
304306
// then msg.sender is the latest instance,
305307
// but the user is targeting the bonus address.
306308
// Otherwise, we use the msg.sender, which we know is a registered rollup
307309
// thanks to the modifier.
308-
address recipientInstance = _onBonus ? BONUS_INSTANCE_ADDRESS : msg.sender;
310+
address recipientInstance = _moveWithLatestRollup ? BONUS_INSTANCE_ADDRESS : msg.sender;
309311

310312
// Add the attester to the instance's checkpointed set of attesters.
311313
require(

l1-contracts/src/governance/GSEPayload.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {IProposerPayload} from "./interfaces/IProposerPayload.sol";
2929
*
3030
* In such an event, your recourse is either:
3131
* - wait for the canonical rollup to have at least 2/3 of the total stake
32-
* - `GSE.proposeWithLock`, which bypasses the GovernaceProposer
32+
* - `GSE.proposeWithLock`, which bypasses the GovernanceProposer
3333
*/
3434
contract GSEPayload is IProposerPayload {
3535
IPayload public immutable ORIGINAL;

l1-contracts/test/delegation/base.t.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,21 @@ contract GSEBase is TestBase {
4343
vm.label(address(registry), "registry");
4444
}
4545

46-
function help__deposit(address _attester, address _withdrawer, bool _onCanonical) internal {
46+
function help__deposit(address _attester, address _withdrawer, bool _moveWithLatestRollup)
47+
internal
48+
{
4749
uint256 depositAmount = ROLLUP.getDepositAmount();
4850
vm.prank(stakingAsset.owner());
4951
stakingAsset.mint(address(this), depositAmount);
5052
stakingAsset.approve(address(ROLLUP), depositAmount);
5153

5254
uint256 balance = stakingAsset.balanceOf(address(governance));
5355

54-
ROLLUP.deposit({_attester: _attester, _withdrawer: _withdrawer, _onCanonical: _onCanonical});
56+
ROLLUP.deposit({
57+
_attester: _attester,
58+
_withdrawer: _withdrawer,
59+
_moveWithLatestRollup: _moveWithLatestRollup
60+
});
5561
ROLLUP.flushEntryQueue();
5662

5763
assertEq(

l1-contracts/test/staking/15050.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ contract Test15050 is StakingBase {
2626
stakingAsset.mint(address(this), DEPOSIT_AMOUNT);
2727
stakingAsset.approve(address(staking), DEPOSIT_AMOUNT);
2828

29-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
29+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
3030
staking.flushEntryQueue();
3131

3232
address[] memory validators = new address[](1);

l1-contracts/test/staking/deposit.t.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ contract DepositTest is StakingBase {
2828
)
2929
);
3030

31-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
31+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
3232
}
3333

3434
modifier givenCallerHasSufficientAllowance() {
@@ -45,7 +45,7 @@ contract DepositTest is StakingBase {
4545
)
4646
);
4747

48-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
48+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
4949
}
5050

5151
modifier givenCallerHasSufficientFunds() {
@@ -60,7 +60,7 @@ contract DepositTest is StakingBase {
6060
{
6161
// it reverts
6262

63-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
63+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
6464
staking.flushEntryQueue();
6565

6666
mint(address(this), DEPOSIT_AMOUNT);
@@ -70,7 +70,7 @@ contract DepositTest is StakingBase {
7070
stdstore.enable_packed_slots().target(address(staking)).sig(
7171
IStaking.getNextFlushableEpoch.selector
7272
).depth(0).checked_write(uint256(0));
73-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
73+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
7474

7575
// The real error gets caught by the flushEntryQueue call
7676
// address magicAddress = address(staking.getGSE().getCanonicalMagicAddress());
@@ -86,12 +86,12 @@ contract DepositTest is StakingBase {
8686
assertEq(uint256(staking.getStatus(ATTESTER)), uint256(Status.ZOMBIE));
8787

8888
vm.expectRevert(abi.encodeWithSelector(Errors.Staking__AlreadyExiting.selector, ATTESTER));
89-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
89+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
9090

9191
vm.prank(WITHDRAWER);
9292
staking.initiateWithdraw(ATTESTER, WITHDRAWER);
9393
vm.expectRevert(abi.encodeWithSelector(Errors.Staking__AlreadyExiting.selector, ATTESTER));
94-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
94+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
9595
}
9696

9797
modifier givenAttesterIsNotRegistered() {
@@ -122,7 +122,7 @@ contract DepositTest is StakingBase {
122122
vm.expectEmit(true, true, true, true, address(staking));
123123
emit IStakingCore.ValidatorQueued(ATTESTER, WITHDRAWER);
124124

125-
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _onCanonical: true});
125+
staking.deposit({_attester: ATTESTER, _withdrawer: WITHDRAWER, _moveWithLatestRollup: true});
126126
// the money is in the staking contract
127127
assertEq(stakingAsset.balanceOf(address(staking)), DEPOSIT_AMOUNT);
128128
// the money is not in the GSE

0 commit comments

Comments
 (0)