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

Fix: Removing unnecessary initialization #155

Merged
merged 1 commit into from
Aug 28, 2024
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
54 changes: 0 additions & 54 deletions script/deploys/BucketRateLimiter.s.sol

This file was deleted.

14 changes: 2 additions & 12 deletions src/BucketRateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ contract BucketRateLimiter is IRateLimiter, IPausable, Initializable, PausableUp
BucketLimiter.Limit public limit;
address public consumer;

mapping(address => bool) public DEPRECATED_admins;
mapping(address => bool) public DEPRECATED_pausers;

mapping(address => BucketLimiter.Limit) public limitsPerToken;

RoleRegistry public roleRegistry;
Expand All @@ -32,19 +29,12 @@ contract BucketRateLimiter is IRateLimiter, IPausable, Initializable, PausableUp
_disableInitializers();
}

function initialize() external initializer {
function initialize(address _roleRegistry) external initializer {
__Pausable_init();
__Ownable_init();
__UUPSUpgradeable_init();

limit = BucketLimiter.create(0, 0);
}

function initializeV2dot5(address _roleRegistry) external onlyOwner {
require(address(roleRegistry) == address(0x00), "already initialized");

// TODO: compile list of values in DEPRECATED_pausers to clear out
// TODO: compile list of values in DEPRECATED_admins to clear out
roleRegistry = RoleRegistry(_roleRegistry);
}

Expand Down Expand Up @@ -116,4 +106,4 @@ contract BucketRateLimiter is IRateLimiter, IPausable, Initializable, PausableUp

function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}

}
}
9 changes: 6 additions & 3 deletions test/BucketRaterLimiter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract BucketRateLimiterTest is TestSetup {
BucketRateLimiter impl = new BucketRateLimiter();
UUPSProxy proxy = new UUPSProxy(address(impl), "");
limiter = BucketRateLimiter(address(proxy));
limiter.initialize();
limiter.initialize(address(roleRegistry));

limiter.updateConsumer(owner);
limiter.setCapacity(200 ether);
Expand Down Expand Up @@ -106,8 +106,11 @@ contract BucketRateLimiterTest is TestSetup {
function test_pauser() public {
// Test pausing logic with V2.5 upgrade
setUpTests();
vm.prank(limiter.owner());
limiter.initializeV2dot5(address(roleRegistry));
// deploy a new bucket rate limiter to initialize against the role registry
BucketRateLimiter impl = new BucketRateLimiter();
UUPSProxy proxy = new UUPSProxy(address(impl), "");
limiter = BucketRateLimiter(address(proxy));
limiter.initialize(address(roleRegistry));

vm.prank(chad);
vm.expectRevert(BucketRateLimiter.IncorrectRole.selector);
Expand Down
2 changes: 1 addition & 1 deletion test/TestSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ contract TestSetup is Test {

address impl = address(new BucketRateLimiter());
bucketRateLimiter = BucketRateLimiter(address(new UUPSProxy(impl, "")));
bucketRateLimiter.initialize();
bucketRateLimiter.initialize(address(roleRegistry));
bucketRateLimiter.updateConsumer(address(liquifierInstance));

bucketRateLimiter.setCapacity(40 ether);
Expand Down
Loading