-
Notifications
You must be signed in to change notification settings - Fork 0
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: capped minter v2 pause #11
feat: capped minter v2 pause #11
Conversation
f96ae77
to
29362c9
Compare
7483d1f
to
f417601
Compare
b3e1cb4
to
ca259f4
Compare
bbaec92
to
31d626f
Compare
ca259f4
to
004c789
Compare
af16880
to
007784b
Compare
…ter-v2-pause and update to use oz errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial thoughts
@@ -46,6 +57,7 @@ contract Mint is ZkCappedMinterV2Test { | |||
uint256 _amount | |||
) public { | |||
_cap = bound(_cap, 0, MAX_MINT_SUPPLY); | |||
vm.assume(_cap > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use bound for this assume as it is more efficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
originally had because it's implied that the cap can indeed be 0.
given that this is a permissioned minter where admins are deploying it, and a zero cap would be caught quickly in testing/first use, we probably don't need to check this in the contract or the factory, but just want to call out. omitting a zero cap check here, but lemme know if you think otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
originally had because it's implied that the cap can indeed be 0.
I thought this assume will remove the possibility of the cap being 0 because it must be greater than 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removes the possibility of the cap being 0 in the test, but you can init the capped minter with a cap of 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how we set the bounds now with the bound starting at 1, it's implied that the cap can't be zero, but it can (was how i was thinking bout it).
_cap = bound(_cap, 0, MAX_MINT_SUPPLY); | ||
ZkCappedMinterV2 cappedMinter = createCappedMinter(_cappedMinterAdmin, _cap); | ||
vm.assume(_admin != address(0)); | ||
vm.assume(_nonMinter != address(0) && _nonMinter != _admin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't both of these addresses non minters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
truth; remove all unnecessary assumptions including the above:
) | ||
) | ||
); | ||
vm.expectRevert(_formatAccessControlError(_admin, MINTER_ROLE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the receiver assume can be removed as there should be no restriction on address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint256 _amount | ||
) public { | ||
_cap = bound(_cap, 0, MAX_MINT_SUPPLY); | ||
vm.assume(_cap > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed if the bound above starts with 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vm.assume(_cap > 0); | ||
_amount = bound(_amount, 1, _cap); | ||
vm.assume(_admin != address(0)); | ||
vm.assume(_minter != address(0) && _minter != _admin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is nothing stopping the minter from being these values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_amount = bound(_amount, 1, _cap); | ||
vm.assume(_admin != address(0)); | ||
vm.assume(_minter != address(0) && _minter != _admin); | ||
vm.assume(_receiver != address(0) && _receiver != initMintReceiver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
vm.prank(_minter); | ||
cappedMinter.mint(_receiver, _amount); | ||
assertEq(token.balanceOf(_receiver), _amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed as it is tested in another test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_cap = bound(_cap, 0, MAX_MINT_SUPPLY); | ||
vm.assume(_admin != address(0)); | ||
|
||
ZkCappedMinterV2 cappedMinter = createCappedMinter(_admin, _cap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating the capped minter is a bit redundant. It may be good to move this setup to a helper or the setup and transfer admin role when necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
contract Unpause is ZkCappedMinterV2Test { | ||
function testFuzz_CorrectlyAllowsNewMintsWhenUnpaused( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would take a look at this test with some of the recommendations above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if addressing all of the comments above doesn't resolve this comment, lemme know (not sure what exactly you were talking bout here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems resolved, was asking to cleanup test assumes etc..
} | ||
} | ||
|
||
contract Pause is ZkCappedMinterV2Test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have a test case for pause, unpause and then pause again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking close a couple small changes left I think
@@ -8,29 +8,46 @@ import {ZkCappedMinterV2} from "src/ZkCappedMinterV2.sol"; | |||
import {console2} from "forge-std/Test.sol"; | |||
|
|||
contract ZkCappedMinterV2Test is ZkTokenTest { | |||
ZkCappedMinterV2 public cappedMinter; | |||
uint256 constant DEFAULT_CAP = 1000e18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would increase this default cap to be more realistic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 100_000_000_000e18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_amount1 = bound(_amount1, 1, DEFAULT_CAP / 2); | ||
_amount2 = bound(_amount2, 1, DEFAULT_CAP / 2); | ||
vm.assume(_amount1 + _amount2 < DEFAULT_CAP); | ||
vm.assume(_receiver1 != address(0) && _receiver2 != address(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to assume this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am seeing this in a bunch of spots and I think it can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
receiver being address zero? erc20 throws an error on zero address receiver
} | ||
|
||
contract Unpause is ZkCappedMinterV2Test { | ||
function testFuzz_CorrectlyAllowsNewMintsWhenUnpaused( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems resolved, was asking to cleanup test assumes etc..
8289ce2
into
feat/capped-minter-v2-minter-role
No description provided.