Add _reentrancyGuardStorageSlot() #5688
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5681 for ReentrancyGuardTransient.
This PR introduces a pure virtual function
_reentrancyGuardStorageSlot()
inReentrancyGuardTransient.sol
, mirroring the pattern used in the upgradeable Initializable.solMotivation
As discussed in #5681, storage slot collisions can occur when using OpenZeppelin contracts in delegatecall-based modular systems (e.g., the Diamond Standard). While this issue was originally raised in the context of upgradeable contracts,
ReentrancyGuardTransient.sol
in the non-upgradeable repo is in fact already upgrade-safe due to its use of a named storage slot.Adding
_reentrancyGuardStorageSlot()
as apure virtual
function allows advanced users to override the default slot location safely in derived contracts, which is essential when using multiple delegatecall modules that each instantiateReentrancyGuardTransient
.Summary of Changes
_reentrancyGuardStorageSlot()
, markedinternal pure virtual
REENTRANCY_GUARD_STORAGE
with calls to this new function