Skip to content

Commit

Permalink
make storage write conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Mar 11, 2024
1 parent 762fdde commit 4701602
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/core/lib/ReentrancyGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,22 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {
revert TloadTestContractDeploymentFailed();
}

// Determine if TSTORE is supported & store the result as an immutable.
_tstoreInitialSupport = _testTload(tloadTestContract);
// Determine if TSTORE is supported.
bool tstoreInitialSupport = _testTload(tloadTestContract);

// Store the result as an immutable.
_tstoreInitialSupport = tstoreInitialSupport;

// Set the address of the deployed TLOAD test contract as an immutable.
_tloadTestContract = tloadTestContract;

// Initialize storage for the reentrancy guard in a cleared state.
assembly {
sstore(_REENTRANCY_GUARD_SLOT, _NOT_ENTERED_SSTORE)
// If not using TSTORE (where _NOT_ENTERED_TSTORE = 0), set initial
// sentinel value (where _NOT_ENTERED_SSTORE = 1).
if (!tstoreInitialSupport) {
// Initialize storage for the reentrancy guard in a cleared state.
assembly {
sstore(_REENTRANCY_GUARD_SLOT, _NOT_ENTERED_SSTORE)
}
}
}

Expand Down

0 comments on commit 4701602

Please sign in to comment.