Skip to content

Commit

Permalink
revert uin256 for __reentry and __paused
Browse files Browse the repository at this point in the history
  • Loading branch information
Keszey Dániel authored and Keszey Dániel committed Apr 8, 2024
1 parent 024dd7f commit aa5d36f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 3 additions & 2 deletions packages/protocol/contracts/L1/hooks/AssignmentHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "../../common/EssentialContract.sol";
import "../../libs/LibAddress.sol";
import "../libs/LibConstStrings.sol";
import "../ITaikoL1.sol";
import "./IHook.sol";

Expand Down Expand Up @@ -105,7 +106,7 @@ contract AssignmentHook is EssentialContract, IHook {
}

// Send the liveness bond to the Taiko contract
IERC20 tko = IERC20(resolve(TKO, false));
IERC20 tko = IERC20(resolve(LibConstStrings.BYTES32_STR_TKO, false));

// Note that we don't have to worry about
// https://github.com/crytic/slither/wiki/Detector-Documentation#arbitrary-from-in-transferfrom
Expand Down Expand Up @@ -175,7 +176,7 @@ contract AssignmentHook is EssentialContract, IHook {

return keccak256(
abi.encodePacked(
PROVER_ASSIGNMENT,
LibConstStrings.BYTES32_STR_PROVER_ASSIGNMENT,
ITaikoL1(_taikoL1Address).getConfig().chainId,
_taikoL1Address,
_blockProposer,
Expand Down
12 changes: 5 additions & 7 deletions packages/protocol/contracts/common/EssentialContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable,
bytes32 private constant _REENTRY_SLOT =
0xa5054f728453d3dbe953bdc43e4d0cb97e662ea32d7958190f3dc2da31d9721b;

/// @dev Slot 1&2 - not optimized if we store them in 1 slot, because they neither read nor
/// written at the same time.
uint256 private __reentry;
uint256 private __paused;
/// @dev Slot 3.
/// @dev Slot 1.
uint8 private __reentry;
uint8 private __paused;
uint64 public lastUnpausedAt;

uint256[49] private __gap;
Expand Down Expand Up @@ -115,7 +113,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable,
function _authorizePause(address, bool) internal virtual onlyOwner { }

// Stores the reentry lock
function _storeReentryLock(uint256 _reentry) internal virtual {
function _storeReentryLock(uint8 _reentry) internal virtual {
if (LibNetwork.isDencunSupported(block.chainid)) {
assembly {
tstore(_REENTRY_SLOT, _reentry)
Expand All @@ -126,7 +124,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable,
}

// Loads the reentry lock
function _loadReentryLock() internal view virtual returns (uint256 reentry_) {
function _loadReentryLock() internal view virtual returns (uint8 reentry_) {
if (LibNetwork.isDencunSupported(block.chainid)) {
assembly {
reentry_ := tload(_REENTRY_SLOT)
Expand Down

0 comments on commit aa5d36f

Please sign in to comment.