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

chore(protocol): with transient storage, the default should be 0, not 1 #15745

Closed
wants to merge 2 commits into from

Conversation

dantaik
Copy link
Contributor

@dantaik dantaik commented Feb 12, 2024

With this change, the transient slot is actually cleared earlier in the call frames rather than at the end of the tx. But realisticly, it makes no difference.

@dantaik dantaik marked this pull request as ready for review February 12, 2024 07:25
@dantaik dantaik changed the title chore(protocoL): with transient storage, the default should be 0, not 1 chore(protocol): with transient storage, the default should be 0, not 1 Feb 12, 2024
@@ -44,7 +44,7 @@ abstract contract OwnerUUPSUpgradable is UUPSUpgradeable, OwnableUpgradeable {
if (_loadReentryLock() == _TRUE) revert REENTRANT_CALL();
_storeReentryLock(_TRUE);
_;
_storeReentryLock(_FALSE);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if this _storeReentryLock(_FALSE) call is even necessary. A transient storage is cleared automatically at the end of the transition, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Transient stroage cleared when transaction ends (for all the contracts). But contract A might call B's function (which is nonReentrant) multiple times. So if we don't clear, the second call would fail.

kép

@dantaik dantaik closed this Feb 12, 2024
@dantaik dantaik reopened this Feb 12, 2024
@dantaik dantaik changed the base branch from brecht-review to additional_changes February 12, 2024 12:34
@@ -44,7 +44,7 @@ abstract contract OwnerUUPSUpgradable is UUPSUpgradeable, OwnableUpgradeable {
if (_loadReentryLock() == _TRUE) revert REENTRANT_CALL();
_storeReentryLock(_TRUE);
_;
_storeReentryLock(_FALSE);
_storeReentryLock(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

using 0 is the same as clearing the storage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that this is less confusing, only a single false value now instead of both 0 and _FALSE.

@adaki2004
Copy link
Contributor

Cannot we make:
uint8 private constant _FALSE = 1;
to
uint8 private constant _FALSE = 0; ? 🤔

@Brechtpd
Copy link
Contributor

That makes pausing slightly more expensive, but yeah that doesn't matter, so simply changing the false value does seem like a good approach as well.

@dantaik
Copy link
Contributor Author

dantaik commented Feb 13, 2024

A second thought is that we should not merge this PR....

@dantaik
Copy link
Contributor Author

dantaik commented Feb 13, 2024

Cannot we make: uint8 private constant _FALSE = 1; to uint8 private constant _FALSE = 0; ? 🤔

@dantaik dantaik closed this Feb 13, 2024
@dantaik dantaik deleted the change_reentrance_value branch March 1, 2024 04:01
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.

3 participants