Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Disable Initializer #576

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/governance/deployers/LockingDeployerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ library LockingDeployerLib {
* @return The address of the new Locking contract
*/
function deploy() external returns (Locking) {
return new Locking();
return new Locking(true);
}
}
6 changes: 6 additions & 0 deletions contracts/governance/locking/Locking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import "./interfaces/ILocking.sol";
contract Locking is ILocking, LockingBase, LockingRelock, LockingVotes {
using LibBrokenLine for LibBrokenLine.BrokenLine;

constructor(bool disableInitializers) {
if (disableInitializers) {
_disableInitializers();
}
}

/**
* @notice Initializes the locking contract.
* @dev Sets up the base locking parameters and initializes ownership and context setup
Expand Down
2 changes: 1 addition & 1 deletion test/fork/upgrades/LockingUpgradeForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract LockingUpgradeForkTest is BaseForkTest {
mentoGovernor = governanceFactory.mentoGovernor();
mentoToken = governanceFactory.mentoToken();

newLockingImplementation = address(new Locking());
newLockingImplementation = address(new Locking(true));
vm.prank(multisig);
proxyAdmin.upgrade(ITransparentUpgradeableProxy(address(locking)), newLockingImplementation);

Expand Down
4 changes: 2 additions & 2 deletions test/integration/governance/GovernanceIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ contract GovernanceIntegrationTest is GovernanceTest {
function test_governor_propose_whenExecutedForImplementationUpgrade_shouldUpgradeTheContracts() public s_governance {
// create new implementations
address[] memory newImplementations = addresses(
address(new LockingHarness()),
address(new LockingHarness(true)),
address(new TimelockController()),
address(new MentoGovernor()),
address(new Emission(false))
address(new Emission(true))
);

address[] memory proxies = addresses(
Expand Down
2 changes: 1 addition & 1 deletion test/unit/governance/GovernanceFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ contract GovernanceFactoryTest is GovernanceTest {
assertEq(initialImpl, precalculatedAddress, "Factory: lockingProxy should have an implementation");

// deploy and upgrade to new implementation
LockingHarness newImplContract = new LockingHarness();
LockingHarness newImplContract = new LockingHarness(true);
vm.prank(address(factory.governanceTimelock()));
proxyAdmin.upgrade(proxy, address(newImplContract));

Expand Down
2 changes: 1 addition & 1 deletion test/unit/governance/Locking/Locking.fuzz.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract FuzzTestLocking is Test {
vm.deal(user1, 100 ether);
testERC20 = new TestERC20("Test", "TST");

locking = new LockingHarness();
locking = new LockingHarness(false);
locking.__Locking_init(IERC20Upgradeable(address(testERC20)), 0, 1, 3);
locking.incrementBlock(locking.WEEK() + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/governance/Locking/LockingTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract LockingTest is GovernanceTest {

function setUp() public virtual {
mentoToken = new MockMentoToken();
locking = new LockingHarness();
locking = new LockingHarness(false);

vm.prank(owner);
locking.__Locking_init(IERC20Upgradeable(address(mentoToken)), 0, 0, 0);
Expand Down
2 changes: 2 additions & 0 deletions test/utils/harnesses/LockingHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ contract LockingHarness is Locking {
uint32 public blockNumberMocked;
uint32 public epochShift;

constructor(bool disableInitializers) Locking(disableInitializers) {}

function incrementBlock(uint32 _amount) external {
blockNumberMocked = blockNumberMocked + _amount;
}
Expand Down
Loading