mark assembly blocks as memory-safe

This commit is contained in:
hueso 2023-05-24 14:43:33 -03:00
parent e2ae92563e
commit 8adccd2739
3 changed files with 26 additions and 26 deletions

View File

@ -20,7 +20,7 @@ abstract contract BaseUtils is
/// Helper FX
function _setUsedTransactions(bytes32 message) internal {
assembly {
assembly ("memory-safe") {
sstore(message, true)
}
}
@ -28,7 +28,7 @@ abstract contract BaseUtils is
function usedTransactions(
bytes32 message
) public view returns (bool used) {
assembly {
assembly ("memory-safe") {
used := sload(message)
}
}
@ -71,7 +71,7 @@ abstract contract BaseUtils is
function _castBool(
bool _valid
) internal pure returns (uint256 _validCasted) {
assembly {
assembly ("memory-safe") {
_validCasted := _valid
}
}
@ -80,7 +80,7 @@ abstract contract BaseUtils is
string memory str
) public pure returns (bytes32 strEnc) {
bytes memory enc = bytes(abi.encodePacked(str));
assembly {
assembly ("memory-safe") {
if lt(0x20, mload(enc)) {
invalid()
}
@ -94,7 +94,7 @@ abstract contract BaseUtils is
uint256 _packed,
bytes32 _pixTarget
) internal {
assembly {
assembly ("memory-safe") {
mstore(0x20, _erc20)
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
mstore(0x00, _sellerKey)
@ -109,7 +109,7 @@ abstract contract BaseUtils is
ERC20 _erc20,
uint256 _packed
) internal {
assembly {
assembly ("memory-safe") {
mstore(0x20, _erc20)
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
mstore(0x00, _sellerKey)
@ -123,7 +123,7 @@ abstract contract BaseUtils is
ERC20 _erc20,
uint256 _amount
) internal {
assembly {
assembly ("memory-safe") {
mstore(0x20, _erc20)
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
mstore(0x00, _sellerKey)
@ -137,7 +137,7 @@ abstract contract BaseUtils is
ERC20 _erc20,
uint256 _amount
) internal {
assembly {
assembly ("memory-safe") {
mstore(0x20, _erc20)
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
mstore(0x00, _sellerKey)
@ -150,7 +150,7 @@ abstract contract BaseUtils is
address _sellerKey,
ERC20 _erc20
) internal view returns (uint256 _packed) {
assembly {
assembly ("memory-safe") {
mstore(0x20, _erc20)
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
mstore(0x00, _sellerKey)
@ -165,7 +165,7 @@ abstract contract BaseUtils is
address _addr
) public pure returns (uint256 _key) {
// _key = uint256(uint160(address(_addr))) << 12;
assembly {
assembly ("memory-safe") {
_key := shl(0xc, _addr)
}
}
@ -174,7 +174,7 @@ abstract contract BaseUtils is
uint256 _key
) public pure returns (address _addr) {
// _addr = address(uint160(uint256(_key >> 12)));
assembly {
assembly ("memory-safe") {
_addr := shr(0xc, _key)
}
}

View File

@ -46,7 +46,7 @@ abstract contract OwnerSettings is
address[] memory forwarders,
bool[] memory states
) external onlyOwner {
assembly {
assembly ("memory-safe") {
// first 32 bytes eq to array's length
let fLen := mload(forwarders)
// halts execution if forwarders.length eq 0
@ -95,7 +95,7 @@ abstract contract OwnerSettings is
function setReputation(
IReputation _reputation
) public onlyOwner {
assembly {
assembly ("memory-safe") {
sstore(reputation.slot, _reputation)
}
emit ReputationUpdated(address(_reputation));
@ -104,7 +104,7 @@ abstract contract OwnerSettings is
function setDefaultLockBlocks(
uint256 _blocks
) public onlyOwner {
assembly {
assembly ("memory-safe") {
sstore(defaultLockBlocks.slot, _blocks)
}
emit LockBlocksUpdated(_blocks);
@ -113,7 +113,7 @@ abstract contract OwnerSettings is
function setValidSigners(
address[] memory _validSigners
) public onlyOwner {
assembly {
assembly ("memory-safe") {
let i := add(_validSigners, 0x20)
let end := add(i, shl(0x05, mload(_validSigners)))
for {
@ -137,7 +137,7 @@ abstract contract OwnerSettings is
bool[] memory _states
) public onlyOwner {
/* Yul Impl */
assembly {
assembly ("memory-safe") {
// first 32 bytes eq to array's length
let tLen := mload(_tokens)
// NoTokens()
@ -181,7 +181,7 @@ abstract contract OwnerSettings is
function validBacenSigners(
uint256 signer
) public view returns (bool valid) {
assembly {
assembly ("memory-safe") {
valid := sload(signer)
}
}
@ -189,7 +189,7 @@ abstract contract OwnerSettings is
function sellerAllowList(
address sellerKey
) public view returns (bytes32 root) {
assembly {
assembly ("memory-safe") {
mstore(0x0c, _SELLER_ALLOWLIST_SLOT_SEED)
mstore(0x00, sellerKey)
root := sload(keccak256(0x00, 0x20))
@ -199,7 +199,7 @@ abstract contract OwnerSettings is
function allowedERC20s(
ERC20 erc20
) public view returns (bool state) {
assembly {
assembly ("memory-safe") {
mstore(0x0c, _ALLOWED_ERC20_SLOT_SEED)
mstore(0x00, erc20)
state := sload(keccak256(0x0c, 0x20))
@ -215,7 +215,7 @@ abstract contract OwnerSettings is
_userCredit
);
bool success;
assembly {
assembly ("memory-safe") {
success := staticcall(
// gas
gas(),

View File

@ -297,7 +297,7 @@ contract P2PIX is BaseUtils {
}
}
assembly {
assembly ("memory-safe") {
if lt(i, locksSize) {
// LoopOverflow()
mstore(0x00, 0xdfb035c9)
@ -344,7 +344,7 @@ contract P2PIX is BaseUtils {
function setRoot(address addr, bytes32 merkleroot)
public
{
assembly {
assembly ("memory-safe") {
// if (addr != msg.sender)
if iszero(eq(addr, caller())) {
// revert OnlySeller()
@ -404,7 +404,7 @@ contract P2PIX is BaseUtils {
ERC20 _t,
address _k
) private {
assembly {
assembly ("memory-safe") {
if iszero(
iszero(
or(
@ -428,7 +428,7 @@ contract P2PIX is BaseUtils {
view
returns (uint256 bal)
{
assembly {
assembly ("memory-safe") {
for {
/* */
} iszero(returndatasize()) {
@ -451,7 +451,7 @@ contract P2PIX is BaseUtils {
view
returns (bool valid)
{
assembly {
assembly ("memory-safe") {
for {
/* */
} iszero(returndatasize()) {
@ -477,7 +477,7 @@ contract P2PIX is BaseUtils {
view
returns (bytes32 pixTarget)
{
assembly {
assembly ("memory-safe") {
for {
/* */
} iszero(returndatasize()) {