Skip to content

Commit dd3f6ba

Browse files
committed
no double postUpgradeInit
1 parent 302dd66 commit dd3f6ba

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/L2ArbitrumToken.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ contract L2ArbitrumToken is
7777
_transferOwnership(_owner);
7878
}
7979

80-
/// @notice Called at proposal #1
80+
/// @notice Called after upgrade to set the initial total delegation estimate
8181
/// The initial estimate may be manipulable with artificial delegation/undelegation prior to the upgrade.
8282
/// Since this value is only used for quorum calculation, and the quroum is clamped by the governors to an acceptable range,
8383
/// the risk/impact of manipulation is low.
8484
/// @param initialTotalDelegation The initial total delegation at the time of upgrade proposal creation.
8585
/// This is an estimate since it is chosen at proposal creation time and not effective until the proposal is executed.
8686
function postUpgradeInit(uint256 initialTotalDelegation) external onlyOwner {
87+
require(
88+
_totalDelegationHistory._checkpoints.length == 0,
89+
"ARB: POST_UPGRADE_INIT_ALREADY_CALLED"
90+
);
8791
_totalDelegationHistory.push(initialTotalDelegation);
8892
}
8993

test/L2ArbitrumToken.t.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ contract L2ArbitrumTokenTest is Test {
4949
);
5050
}
5151

52+
// test no double init
53+
function testNoDoublePostUpgradeInit() public {
54+
L2ArbitrumToken l2Token = deployAndInit();
55+
56+
// set an initial estimate
57+
vm.prank(owner);
58+
l2Token.postUpgradeInit(10);
59+
60+
// try to set it again
61+
vm.prank(owner);
62+
vm.expectRevert("ARB: POST_UPGRADE_INIT_ALREADY_CALLED");
63+
l2Token.postUpgradeInit(20);
64+
}
65+
5266
// test adjustment
5367
function testDvpAdjustment(
5468
uint64 initialEstimate,

0 commit comments

Comments
 (0)