From 5b81ca3da1fd018cb193c1571afab2e525bb4aaa Mon Sep 17 00:00:00 2001 From: Eric Forgy Date: Thu, 15 May 2025 22:21:09 -0700 Subject: [PATCH 1/2] Added: _reentrancyGuardStorageSlot() --- contracts/utils/ReentrancyGuardTransient.sol | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contracts/utils/ReentrancyGuardTransient.sol b/contracts/utils/ReentrancyGuardTransient.sol index a1318c86f3c..9863b333f16 100644 --- a/contracts/utils/ReentrancyGuardTransient.sol +++ b/contracts/utils/ReentrancyGuardTransient.sol @@ -44,11 +44,11 @@ abstract contract ReentrancyGuardTransient { } // Any calls to nonReentrant after this point will fail - REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true); + _reentrancyGuardStorageSlot().asBoolean().tstore(true); } function _nonReentrantAfter() private { - REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false); + _reentrancyGuardStorageSlot().asBoolean().tstore(false); } /** @@ -56,6 +56,10 @@ abstract contract ReentrancyGuardTransient { * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { - return REENTRANCY_GUARD_STORAGE.asBoolean().tload(); + return _reentrancyGuardStorageSlot().asBoolean().tload(); + } + + function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) { + return REENTRANCY_GUARD_STORAGE; } } From 750a60b92d62ecbb87f58a95062cc08bc4e22b67 Mon Sep 17 00:00:00 2001 From: Eric Forgy Date: Thu, 15 May 2025 22:47:00 -0700 Subject: [PATCH 2/2] Add changeset --- .changeset/three-parents-argue.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/three-parents-argue.md diff --git a/.changeset/three-parents-argue.md b/.changeset/three-parents-argue.md new file mode 100644 index 00000000000..95517262fb9 --- /dev/null +++ b/.changeset/three-parents-argue.md @@ -0,0 +1,5 @@ +--- +'openzeppelin-solidity': patch +--- + +Add `_reentrancyGuardStorageSlot()` to `ReentrancyGuardTransient` as a `pure virtual` function to allow slot overrides for diamond-compatible modular usage. Related to #5681.