Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite assembly slot offset for consistencty #5325

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/account/utils/draft-ERC7579Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ library ERC7579Utils {
assembly ("memory-safe") {
let ptr := add(executionCalldata.offset, calldataload(executionCalldata.offset))
// Extract the ERC7579 Executions
executionBatch.offset := add(ptr, 32)
executionBatch.offset := add(ptr, 0x20)
executionBatch.length := calldataload(ptr)
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC1155/utils/ERC1155Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ library ERC1155Utils {
revert IERC1155Errors.ERC1155InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
revert(add(reason, 0x20), mload(reason))
}
}
}
Expand Down Expand Up @@ -79,7 +79,7 @@ library ERC1155Utils {
revert IERC1155Errors.ERC1155InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
revert(add(reason, 0x20), mload(reason))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC20/utils/ERC1363Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ library ERC1363Utils {
revert ERC1363InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
revert(add(reason, 0x20), mload(reason))
}
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ library ERC1363Utils {
revert ERC1363InvalidSpender(spender);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
revert(add(reason, 0x20), mload(reason))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/utils/ERC721Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library ERC721Utils {
revert IERC721Errors.ERC721InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
revert(add(reason, 0x20), mload(reason))
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions contracts/utils/Address.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ library Address {
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
revert(add(returndata, 0x20), mload(returndata))
}
} else {
revert Errors.FailedCall();
Expand Down
4 changes: 2 additions & 2 deletions contracts/utils/Strings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ library Strings {
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(buffer, add(32, length))
ptr := add(buffer, add(length, 0x20))
Amxx marked this conversation as resolved.
Show resolved Hide resolved
}
while (true) {
ptr--;
Expand Down Expand Up @@ -431,7 +431,7 @@ library Strings {
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(buffer, add(0x20, offset)))
value := mload(add(buffer, add(offset, 0x20)))
Amxx marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Loading