Skip to content

Commit

Permalink
implement fixes to fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Mar 9, 2024
1 parent 4240dc6 commit 762fdde
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 73 deletions.
20 changes: 10 additions & 10 deletions reference/lib/ReferenceReentrancyGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
} from "seaport-types/src/interfaces/ReentrancyErrors.sol";

import {
_ENTERED_AND_ACCEPTING_NATIVE_TOKENS,
_ENTERED,
_NOT_ENTERED
_ENTERED_AND_ACCEPTING_NATIVE_TOKENS_SSTORE,
_ENTERED_SSTORE,
_NOT_ENTERED_SSTORE
} from "seaport-types/src/lib/ConsiderationConstants.sol";

/**
Expand All @@ -33,15 +33,15 @@ contract ReferenceReentrancyGuard is
*/
constructor() {
// Initialize the reentrancy guard in a cleared state.
_reentrancyGuard = _NOT_ENTERED;
_reentrancyGuard = _NOT_ENTERED_SSTORE;
}

/**
* @dev Modifier to check that the sentinel value for the reentrancy guard
* is not currently set by a previous call.
*/
modifier notEntered() {
if (_reentrancyGuard != _NOT_ENTERED) {
if (_reentrancyGuard != _NOT_ENTERED_SSTORE) {
revert NoReentrantCalls();
}

Expand All @@ -56,19 +56,19 @@ contract ReferenceReentrancyGuard is
* be received during execution or not.
*/
modifier nonReentrant(bool acceptNativeTokens) {
if (_reentrancyGuard != _NOT_ENTERED) {
if (_reentrancyGuard != _NOT_ENTERED_SSTORE) {
revert NoReentrantCalls();
}

if (acceptNativeTokens) {
_reentrancyGuard = _ENTERED_AND_ACCEPTING_NATIVE_TOKENS;
_reentrancyGuard = _ENTERED_AND_ACCEPTING_NATIVE_TOKENS_SSTORE;
} else {
_reentrancyGuard = _ENTERED;
_reentrancyGuard = _ENTERED_SSTORE;
}

_;

_reentrancyGuard = _NOT_ENTERED;
_reentrancyGuard = _NOT_ENTERED_SSTORE;
}

/**
Expand All @@ -77,7 +77,7 @@ contract ReferenceReentrancyGuard is
*/
function _assertAcceptingNativeTokens() internal view {
// Ensure that the reentrancy guard is not currently set.
if (_reentrancyGuard != _ENTERED_AND_ACCEPTING_NATIVE_TOKENS) {
if (_reentrancyGuard != _ENTERED_AND_ACCEPTING_NATIVE_TOKENS_SSTORE) {
revert InvalidMsgValue(msg.value);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/lib/BasicOrderFulfiller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
AdditionalRecipient_size_shift,
AdditionalRecipient_size,
BasicOrder_additionalRecipients_data_cdPtr,
BasicOrder_additionalRecipients_length_cdPtr,
BasicOrder_addlRecipients_length_cdPtr,
BasicOrder_basicOrderType_cdPtr,
BasicOrder_common_params_size,
BasicOrder_considerationAmount_cdPtr,
Expand Down Expand Up @@ -474,7 +474,7 @@ contract BasicOrderFulfiller is OrderValidator {

// Ensure consideration array length isn't less than total original.
if lt(
calldataload(BasicOrder_additionalRecipients_length_cdPtr),
calldataload(BasicOrder_addlRecipients_length_cdPtr),
calldataload(BasicOrder_totalOriginalAdditionalRecipients_cdPtr)
) {
// Store left-padded selector with push4 (reduces bytecode),
Expand Down Expand Up @@ -567,7 +567,7 @@ contract BasicOrderFulfiller is OrderValidator {
// This variable will later be repurposed to track the total
// original additional recipients instead of the total supplied.
let totalAdditionalRecipients :=
calldataload(BasicOrder_additionalRecipients_length_cdPtr)
calldataload(BasicOrder_addlRecipients_length_cdPtr)

// Calculate pointer to length of OrderFulfilled consideration
// array. Note that this is based on total original additional
Expand Down Expand Up @@ -753,7 +753,7 @@ contract BasicOrderFulfiller is OrderValidator {

// Overwrite length to length of the additionalRecipients array.
totalAdditionalRecipients :=
calldataload(BasicOrder_additionalRecipients_length_cdPtr)
calldataload(BasicOrder_addlRecipients_length_cdPtr)

for { } lt(i, totalAdditionalRecipients) { i := add(i, 1) } {
// Retrieve calldata pointer for additional recipient.
Expand Down Expand Up @@ -1046,7 +1046,7 @@ contract BasicOrderFulfiller is OrderValidator {
OrderFulfilled_baseSize,
mul(
calldataload(
BasicOrder_additionalRecipients_length_cdPtr
BasicOrder_addlRecipients_length_cdPtr
),
ReceivedItem_size
)
Expand Down Expand Up @@ -1250,7 +1250,7 @@ contract BasicOrderFulfiller is OrderValidator {
totalAdditionalRecipientsDataSize :=
shl(
AdditionalRecipient_size_shift,
calldataload(BasicOrder_additionalRecipients_length_cdPtr)
calldataload(BasicOrder_addlRecipients_length_cdPtr)
)
}

Expand Down Expand Up @@ -1391,7 +1391,7 @@ contract BasicOrderFulfiller is OrderValidator {
totalAdditionalRecipientsDataSize :=
shl(
AdditionalRecipient_size_shift,
calldataload(BasicOrder_additionalRecipients_length_cdPtr)
calldataload(BasicOrder_addlRecipients_length_cdPtr)
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/lib/ConsiderationEncoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
authorizeOrder_selector_offset,
authorizeOrder_selector,
authorizeOrder_zoneParameters_offset,
BasicOrder_additionalRecipients_length_cdPtr,
BasicOrder_addlRecipients_length_cdPtr,
BasicOrder_common_params_size,
BasicOrder_consideration_offset_from_offer,
BasicOrder_offerer_cdPtr,
Expand Down Expand Up @@ -632,7 +632,7 @@ contract ConsiderationEncoder {

// Retrieve the length of additional recipients.
uint256 additionalRecipientsLength = CalldataPointer.wrap(
BasicOrder_additionalRecipients_length_cdPtr
BasicOrder_addlRecipients_length_cdPtr
).readUint256();

// Derive size of offer and consideration data.
Expand Down
Loading

0 comments on commit 762fdde

Please sign in to comment.