Skip to content

Commit efd1878

Browse files
authored
ReentrancyGuard & ReentrancyGuardTransient are stateless (#5944)
1 parent 1078ecb commit efd1878

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
- `ERC6909` and the its extensions (`ERC6909ContentURI`, `ERC6909Metadata` and `ERC6909TokenSupply`) are no longer marked as draft since [EIP-6909](https://eips.ethereum.org/EIPS/eip-6909) is now final. Developers must update the import paths. Contracts behavior is not modified.
1010
- `SignerERC7702` is renamed as `SignerEIP7702`. Imports and inheritance must be updated to that new name and path. Behavior is unmodified.
11-
- `ERC721Holder` and `ERC1155Holder` are flagged as stateless and are no longer transpiled. Developers using their upgradeable variants from `@openzeppelin/contracts-upgradeable` (i.e. `ERC712HolderUpgradeable` and `ERC1155HolderUpgradeable`) must update their imports to use the equivalent version available in `@openzeppelin/contracts`.
11+
- `ERC721Holder`, `ERC1155Holder`, `ReentrancyGuard` and `ReentrancyGuardTransient` are flagged as stateless and are no longer transpiled. Developers using their upgradeable variants from `@openzeppelin/contracts-upgradeable` must update their imports to use the equivalent version available in `@openzeppelin/contracts`.
1212
- Update minimum pragma to 0.8.24 in `Votes`, `VotesExtended`, `ERC20Votes`, `Strings`, `ERC1155URIStorage`, `MessageHashUtils`, `ERC721URIStorage`, `ERC721Votes`, `ERC721Wrapper`, `ERC721Burnable`, `ERC721Consecutive`, `ERC721Enumerable`, `ERC721Pausable`, `ERC721Royalty`, `ERC721Wrapper`, `EIP712`, `ERC4626` and `ERC7739`. ([#5726](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/5726))
1313

1414
### Deprecation

contracts/utils/ReentrancyGuard.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {StorageSlot} from "./StorageSlot.sol";
2626
*
2727
* IMPORTANT: Deprecated. This storage-based reentrancy guard will be removed and replaced
2828
* by the {ReentrancyGuardTransient} variant in v6.0.
29+
*
30+
* @custom:stateless
2931
*/
3032
abstract contract ReentrancyGuard {
3133
using StorageSlot for bytes32;

contracts/utils/ReentrancyGuardTransient.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {TransientSlot} from "./TransientSlot.sol";
1111
* NOTE: This variant only works on networks where EIP-1153 is available.
1212
*
1313
* _Available since v5.1._
14+
*
15+
* @custom:stateless
1416
*/
1517
abstract contract ReentrancyGuardTransient {
1618
using TransientSlot for *;

scripts/upgradeable/upgradeable.patch

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ index 8ccb9465e..509cd7f05 100644
140140
+ }
141141
}
142142
diff --git a/contracts/utils/ReentrancyGuard.sol b/contracts/utils/ReentrancyGuard.sol
143-
index f958d5e8f..845209bc8 100644
143+
index 6e44894dc..7b076aaa7 100644
144144
--- a/contracts/utils/ReentrancyGuard.sol
145145
+++ b/contracts/utils/ReentrancyGuard.sol
146146
@@ -36,6 +36,11 @@ abstract contract ReentrancyGuard {
@@ -155,6 +155,17 @@ index f958d5e8f..845209bc8 100644
155155
// Booleans are more expensive than uint256 or any type that takes up a full
156156
// word because each write operation emits an extra SLOAD to first read the
157157
// slot's contents, replace the bits taken up by the boolean, and then write
158+
@@ -55,10 +60,6 @@ abstract contract ReentrancyGuard {
159+
*/
160+
error ReentrancyGuardReentrantCall();
161+
162+
- constructor() {
163+
- _reentrancyGuardStorageSlot().getUint256Slot().value = NOT_ENTERED;
164+
- }
165+
-
166+
/**
167+
* @dev Prevents a contract from calling itself, directly or indirectly.
168+
* Calling a `nonReentrant` function from another `nonReentrant`
158169
diff --git a/contracts/utils/cryptography/EIP712.sol b/contracts/utils/cryptography/EIP712.sol
159170
index 0eaef9d27..01f1b5f58 100644
160171
--- a/contracts/utils/cryptography/EIP712.sol
@@ -330,7 +341,7 @@ index 0eaef9d27..01f1b5f58 100644
330341
}
331342
}
332343
diff --git a/package.json b/package.json
333-
index 285a074ed..d48cc8e4b 100644
344+
index f6960972a..369e2e1e6 100644
334345
--- a/package.json
335346
+++ b/package.json
336347
@@ -35,7 +35,7 @@

0 commit comments

Comments
 (0)