-
Notifications
You must be signed in to change notification settings - Fork 246
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: add ReentrancyGuard #503
Conversation
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.
LGTM. Good job with the test coverage 💪
@@ -49,6 +49,7 @@ contract KeccakConstants { | |||
// Unstructured storage | |||
bytes32 public constant initializationBlockPosition = keccak256(abi.encodePacked("aragonOS.initializable.initializationBlock")); | |||
bytes32 public constant depositablePosition = keccak256(abi.encodePacked("aragonOS.depositableStorage.depositable")); | |||
bytes32 public constant reentrancyGuardPosition = keccak256(abi.encodePacked("aragonOS.reentrancyGuard.mutex")); |
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 is not being used for testing. Maybe we could use it in ReentrancyGuardMock
so we implicitly test that it is correct.
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.
Oops, forgot to add this to the keccak constants test. Add now in cf07f35.
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 is really cool! It's going to make my life way happier! 😉
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.
Great job @sohkai :)
|
||
it('allows entering non-entrant call from re-entrant call', async () => { | ||
await reentrancyMock.reentrantCall(reentrantActor.address) | ||
assert.equal((await reentrancyMock.callCounter()).toString(), 2, 'should have called twice') |
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.
Just to ensure consistency I'd check that the mutex variable stays in false
on successful calls when using the guard.
Adds a reusable
ReentrancyGuard
working off of its own unstructured storage slot, and makes it available toAragonApp
s.See aragon/aragon-apps#744 (comment) for context.
Bytecode comparison:
But the actual bytecode increase of adding the
nonReentrant
modifier is ~60k gas per use.