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

Introduce ReentrancyGuardLib allowing more agile function accessibility control #3846

Open
wants to merge 2 commits into
base: next-v5.0
Choose a base branch
from

Conversation

k06a
Copy link
Contributor

@k06a k06a commented Dec 2, 2022

Consider having this kind of library, this would allow to have reentrancy guard in different smart contracts and will make it more agile in case of inheriting from multiple contract who use it for different purposes.

PR Checklist

To be done...

  • Tests
  • Documentation
  • Changelog entry

@k06a k06a changed the base branch from master to next-v5.0 December 2, 2022 09:35
@k06a
Copy link
Contributor Author

k06a commented Dec 25, 2022

@frangio what do you think?

@k06a
Copy link
Contributor Author

k06a commented Jul 7, 2023

@Amxx please check out the PR, I believe it is good improvement because it can bring more granular support to this feature.

Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How ironic that @k06a asks me to review that when I'm probably the one person in the entire ethereum space that is fundamentally against ReentrancyGuard.

Still, some devs want to use them because they think its a good solution to they improper design. /s

This could be interesting, I'm not really convinced by the data structure.

@frangio, @ernestognw ?

Comment on lines +29 to +31
struct Data {
uint256 _status;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that the structure is usefull to pass storage pointers to the methods. But it also means that is will use a full slot.

If devs need multiple independant guards, being able to put them in a single slot would be a big plus!

I would do that using a UDVT that is a uint8 ... but then you lose the storage pointer design.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits guardians makes a lot of sense, will consider if it’s possible to have handy API

}

function init(Data storage self) internal {
require(self._status == _NOT_INITIALIZED, "ReentrancyGuard: init already called");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ever do that, we'll do custom errors (we don't do revert strings anymore)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, this PR is half-year old, BTW :)

@k06a
Copy link
Contributor Author

k06a commented Jul 7, 2023

We used this guardian in one of ERC20 extensions, it’s obvious not a good idea to use singleton guardian for multiple different extensions, so using separate struct makes a lot of sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants