diff --git a/foundry.toml b/foundry.toml index 25b918f..6eb5092 100644 --- a/foundry.toml +++ b/foundry.toml @@ -3,4 +3,6 @@ src = "src" out = "out" libs = ["lib"] +evm_version = 'cancun' + # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/src/hub/Hub.sol b/src/hub/Hub.sol index b264553..69f8870 100644 --- a/src/hub/Hub.sol +++ b/src/hub/Hub.sol @@ -143,14 +143,6 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors { */ mapping(address => mapping(address => TrustMarker)) public trustMarkers; - /** - * @dev Normal storage slot for the reentrancy guard. - * todo: the original task was to use a transient storage slot, - * but solc v0.8.24 still didn't recognize the tload/tstore assembly. - * see - */ - bool private _reentrancyGuard; - // Events event RegisterHuman(address indexed avatar); @@ -191,25 +183,14 @@ contract Hub is Circles, MetadataDefinitions, IHubErrors { * see https://soliditylang.org/blog/2024/01/26/transient-storage/ */ modifier nonReentrant(uint8 _code) { - // todo: this should use a transient storage slot - // but doesn't compile through `forge build`, but does compile with solc directly - // assembly { - // if tload(0) { revert(0, 0) } - // tstore(0, 1) - // } - // _; - // assembly { - // tstore(0, 0) - // } - - // for now, default to normal storage slot - // replace this later with transient storage slot - if (_reentrancyGuard) { - revert CirclesReentrancyGuard(_code); + assembly { + if tload(0) { revert(0, 0) } + tstore(0, 1) } - _reentrancyGuard = true; _; - _reentrancyGuard = false; + assembly { + tstore(0, 0) + } } // Constructor