Skip to content

Commit

Permalink
apply final 1.6 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Mar 12, 2024
1 parent 860d4ec commit 1a0a475
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 88 deletions.
2 changes: 1 addition & 1 deletion lib/seaport-types
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seaport-core",
"version": "1.6.4",
"version": "1.6.5",
"description": "Core smart contracts for the Seaport protocol",
"main": "src/",
"repository": "https://github.com/ProjectOpenSea/seaport-core.git",
Expand All @@ -14,6 +14,6 @@
"README.md"
],
"dependencies": {
"seaport-types": "1.6.2"
"seaport-types": "1.6.3"
}
}
2 changes: 1 addition & 1 deletion src/lib/CriteriaResolution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ contract CriteriaResolution is CriteriaResolutionErrors {
ItemType newItemType;
assembly {
// Item type 4 becomes 2 and item type 5 becomes 3.
newItemType := sub(3, eq(itemType, 4))
newItemType := sub(itemType, 2)
}
offerItem.itemType = newItemType;

Expand Down
127 changes: 43 additions & 84 deletions src/lib/ReentrancyGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {
// "Loop" over three possible cases for setting the reentrancy guard
// based on tstore support and state, exiting once the respective
// state has been identified and a corresponding guard has been set.
for {

} 1 {

} {
for {} 1 {} {
// 1: handle case where tstore is supported from the start.
if tstoreInitialSupport {
// Ensure that the reentrancy guard is not already set.
Expand Down Expand Up @@ -239,11 +235,7 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {
// "Loop" over three possible cases for clearing reentrancy guard
// based on tstore support and state, exiting once the respective
// state has been identified and corresponding guard cleared.
for {

} 1 {

} {
for {} 1 {} {
// 1: handle case where tstore is supported from the start.
if tstoreInitialSupport {
// Clear the reentrancy guard.
Expand Down Expand Up @@ -285,33 +277,21 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {

// Utilize assembly to check reentrancy guard based on tstore support.
assembly {
// "Loop" over three possible cases for setting the reentrancy guard
// based on tstore support and state, exiting once the respective
// state has been identified and a corresponding guard checked.
for {

} 1 {

} {
// 1: handle case where tstore is supported from the start.
if tstoreInitialSupport {
// Ensure that the reentrancy guard is not currently set.
if tload(_REENTRANCY_GUARD_SLOT) {
// Store left-padded selector with push4,
// mem[28:32] = selector
mstore(0, NoReentrantCalls_error_selector)

// revert(abi.encodeWithSignature("NoReentrantCalls()"))
revert(
Error_selector_offset,
NoReentrantCalls_error_length
)
}
// 1: handle case where tstore is supported from the start.
if tstoreInitialSupport {
// Ensure that the reentrancy guard is not currently set.
if tload(_REENTRANCY_GUARD_SLOT) {
// Store left-padded selector with push4,
// mem[28:32] = selector
mstore(0, NoReentrantCalls_error_selector)

// Exit the loop.
break
// revert(abi.encodeWithSignature("NoReentrantCalls()"))
revert(Error_selector_offset, NoReentrantCalls_error_length)
}
}

// Handle cases where tstore is not initially supported.
if iszero(tstoreInitialSupport) {
// Retrieve the reentrancy guard sentinel value.
let reentrancyGuard := sload(_REENTRANCY_GUARD_SLOT)

Expand All @@ -329,24 +309,18 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {
NoReentrantCalls_error_length
)
}

// Exit the loop.
break
}

// 3: handle case where tstore support has not been activated.
// Ensure that the reentrancy guard is not currently set.
if iszero(eq(reentrancyGuard, _NOT_ENTERED_SSTORE)) {
if gt(reentrancyGuard, _NOT_ENTERED_SSTORE) {
// Store left-padded selector with push4 (reduces bytecode),
// mem[28:32] = selector
mstore(0, NoReentrantCalls_error_selector)

// revert(abi.encodeWithSignature("NoReentrantCalls()"))
revert(Error_selector_offset, NoReentrantCalls_error_length)
}

// Exit the loop.
break
}
}
}
Expand All @@ -361,43 +335,31 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {

// Utilize assembly to check reentrancy guard based on tstore support.
assembly {
// "Loop" over three possible cases for setting the reentrancy guard
// based on tstore support and state, exiting once the respective
// state has been identified and a corresponding guard has been set.
for {

} 1 {

} {
// 1: handle case where tstore is supported from the start.
if tstoreInitialSupport {
// Ensure reentrancy guard is set to accept native tokens.
if iszero(
eq(
tload(_REENTRANCY_GUARD_SLOT),
_ENTERED_AND_ACCEPTING_NATIVE_TOKENS_TSTORE
)
) {
// Store left-padded selector with push4,
// mem[28:32] = selector
mstore(0, InvalidMsgValue_error_selector)

// Store argument.
mstore(InvalidMsgValue_error_value_ptr, callvalue())
// 1: handle case where tstore is supported from the start.
if tstoreInitialSupport {
// Ensure reentrancy guard is set to accept native tokens.
if iszero(
eq(
tload(_REENTRANCY_GUARD_SLOT),
_ENTERED_AND_ACCEPTING_NATIVE_TOKENS_TSTORE
)
) {
// Store left-padded selector with push4,
// mem[28:32] = selector
mstore(0, InvalidMsgValue_error_selector)

// revert(abi.encodeWithSignature(
// "InvalidMsgValue(uint256)", value)
// )
revert(
Error_selector_offset,
InvalidMsgValue_error_length
)
}
// Store argument.
mstore(InvalidMsgValue_error_value_ptr, callvalue())

// Exit the loop.
break
// revert(abi.encodeWithSignature(
// "InvalidMsgValue(uint256)", value)
// )
revert(Error_selector_offset, InvalidMsgValue_error_length)
}
}

// Handle cases where tstore is not initially supported.
if iszero(tstoreInitialSupport) {
// Retrieve the reentrancy guard sentinel value.
let reentrancyGuard := sload(_REENTRANCY_GUARD_SLOT)

Expand Down Expand Up @@ -425,17 +387,17 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {
InvalidMsgValue_error_length
)
}

// Exit the loop.
break
}

// 3: handle case where tstore support has not been activated.
// Ensure reentrancy guard is set to accepting native tokens.
if iszero(
eq(
reentrancyGuard,
_ENTERED_AND_ACCEPTING_NATIVE_TOKENS_SSTORE
if and(
iszero(iszero(reentrancyGuard)),
iszero(
eq(
reentrancyGuard,
_ENTERED_AND_ACCEPTING_NATIVE_TOKENS_SSTORE
)
)
) {
// Store left-padded selector with push4 (reduces bytecode),
Expand All @@ -450,9 +412,6 @@ contract ReentrancyGuard is ReentrancyErrors, LowLevelHelpers {
// )
revert(Error_selector_offset, InvalidMsgValue_error_length)
}

// Exit the loop.
break
}
}
}
Expand Down

0 comments on commit 1a0a475

Please sign in to comment.