diff --git a/src/core/lib/ZoneInteraction.sol b/src/core/lib/ZoneInteraction.sol index 4816649..f49c2ad 100644 --- a/src/core/lib/ZoneInteraction.sol +++ b/src/core/lib/ZoneInteraction.sol @@ -170,11 +170,11 @@ contract ZoneInteraction is // Retrieve the parameters of the order in question. OrderParameters memory parameters = advancedOrder.parameters; - // OrderType 2-3 require zone to be caller or approve via validateOrder. + // OrderType 2-3 require zone to be caller or approve via authorizeOrder. if ( _isRestrictedAndCallerNotZone(parameters.orderType, parameters.zone) ) { - // Encode the `validateOrder` call in memory. + // Encode the `authorizeOrder` call in memory. (MemoryPointer callData, uint256 size) = _encodeAuthorizeOrder( orderHash, parameters, diff --git a/src/main/test/HashValidationZoneOfferer.sol b/src/main/test/HashValidationZoneOfferer.sol index 279ae64..34c2029 100644 --- a/src/main/test/HashValidationZoneOfferer.sol +++ b/src/main/test/HashValidationZoneOfferer.sol @@ -244,6 +244,11 @@ contract HashValidationZoneOfferer is // Get the orderHash from zoneParameters bytes32 orderHash = zoneParameters.orderHash; + if (authorizeFailureReasons[orderHash] == OffererZoneFailureReason.Zone_authorizeRevertsMatchReverts) + { + revert HashValidationZoneOffererAuthorizeOrderReverts(); + } + // Get the length of msg.data uint256 dataLength = msg.data.length; @@ -296,7 +301,7 @@ contract HashValidationZoneOfferer is // Get the orderHash from zoneParameters bytes32 orderHash = zoneParameters.orderHash; - if (validateFailureReasons[orderHash] == OffererZoneFailureReason.Zone_reverts) + if (validateFailureReasons[orderHash] == OffererZoneFailureReason.Zone_validateReverts) { revert HashValidationZoneOffererValidateOrderReverts(); } diff --git a/src/main/test/OffererZoneFailureReason.sol b/src/main/test/OffererZoneFailureReason.sol index 9a6484a..41c3252 100644 --- a/src/main/test/OffererZoneFailureReason.sol +++ b/src/main/test/OffererZoneFailureReason.sol @@ -11,7 +11,8 @@ enum OffererZoneFailureReason { ContractOfferer_ExcessMaximumSpent, // too many maximum spent items ContractOfferer_IncorrectMaximumSpent, // incorrect (too many, wrong token, etc.) maximum spent items ContractOfferer_InvalidMagicValue, // Offerer did not return correct magic value - Zone_reverts, // Zone validateOrder call reverts + Zone_authorizeRevertsMatchReverts, // Zone authorizeOrder call reverts, which triggers a top level revert only on match* + Zone_validateReverts, // Zone validateOrder call reverts Zone_authorizeInvalidMagicValue, // Zone authorizeOrder call returns invalid magic value Zone_validateInvalidMagicValue // Zone validateOrder call returns invalid magic value } diff --git a/test/foundry/new/helpers/FuzzMutationSelectorLib.sol b/test/foundry/new/helpers/FuzzMutationSelectorLib.sol index e34c9b2..4f12dae 100644 --- a/test/foundry/new/helpers/FuzzMutationSelectorLib.sol +++ b/test/foundry/new/helpers/FuzzMutationSelectorLib.sol @@ -103,6 +103,7 @@ enum Failure { InvalidContractOrder_ExcessMaximumSpent, // too many maximum spent items InvalidContractOrder_IncorrectMaximumSpent, // incorrect (too many, wrong token, etc.) maximum spent items InvalidContractOrder_InvalidMagicValue, // Offerer did not return correct magic value + InvalidRestrictedOrder_authorizeReverts_matchReverts, // Zone authorizeOrder call reverts and triggers a top level match* revert InvalidRestrictedOrder_validateReverts, // Zone validateOrder call reverts InvalidRestrictedOrder_authorizeInvalidMagicValue, // Zone authorizeOrder call returns invalid magic value InvalidRestrictedOrder_validateInvalidMagicValue, // Zone validateOrder call returns invalid magic value @@ -347,6 +348,12 @@ library FuzzMutationSelectorLib { .ineligibleWhenNotActiveTimeOrNotContractOrderOrNoConsideration ); + failuresAndFilters[i++] = Failure + .InvalidRestrictedOrder_authorizeReverts_matchReverts + .withOrder( + MutationFilters.ineligibleWhenNotAvailableOrNotRestrictedOrNotMatch + ); + failuresAndFilters[i++] = Failure.InvalidRestrictedOrder_authorizeInvalidMagicValue.and( Failure.InvalidRestrictedOrder_validateReverts) .and(Failure.InvalidRestrictedOrder_validateInvalidMagicValue @@ -871,6 +878,17 @@ library FailureDetailsLib { details_withOrderHash ); + failureDetailsArray[i++] = HashValidationZoneOfferer + .HashValidationZoneOffererAuthorizeOrderReverts + .selector + .withOrder( + "InvalidRestrictedOrder_authorizeReverts_matchReverts", + FuzzMutations + .mutation_invalidRestrictedOrderAuthorizeRevertsMatchReverts + .selector, + details_withOrderHash + ); + failureDetailsArray[i++] = HashValidationZoneOfferer .HashValidationZoneOffererValidateOrderReverts .selector diff --git a/test/foundry/new/helpers/FuzzMutations.sol b/test/foundry/new/helpers/FuzzMutations.sol index 1592eb2..c5ba819 100644 --- a/test/foundry/new/helpers/FuzzMutations.sol +++ b/test/foundry/new/helpers/FuzzMutations.sol @@ -279,6 +279,22 @@ library MutationFilters { return ineligibleWhenUnavailable(context, orderIndex); } + function ineligibleWhenNotAvailableOrNotRestrictedOrNotMatch( + AdvancedOrder memory order, + uint256 orderIndex, + FuzzTestContext memory context + ) internal view returns (bool) { + if (ineligibleWhenNotRestrictedOrder(order)) { + return true; + } + + if (ineligibleWhenNotMatch(context)) { + return true; + } + + return ineligibleWhenUnavailable(context, orderIndex); + } + function ineligibleWhenNotActiveTime(AdvancedOrder memory order) internal view @@ -1931,6 +1947,24 @@ contract FuzzMutations is Test, FuzzExecutor { exec(context); } + function mutation_invalidRestrictedOrderAuthorizeRevertsMatchReverts( + FuzzTestContext memory context, + MutationState memory mutationState + ) external { + AdvancedOrder memory order = mutationState.selectedOrder; + bytes32 orderHash = mutationState.selectedOrderHash; + + // This mutation triggers a revert by setting a failure reason that gets + // stored in the HashValidationZone. Note that only match* functions + // revert at the seaport level when the zone reverts on authorize. + HashValidationZoneOfferer(payable(order.parameters.zone)) + .setAuthorizeFailureReason( + orderHash, OffererZoneFailureReason.Zone_authorizeRevertsMatchReverts + ); + + exec(context); + } + function mutation_invalidRestrictedOrderReverts( FuzzTestContext memory context, MutationState memory mutationState @@ -1941,7 +1975,7 @@ contract FuzzMutations is Test, FuzzExecutor { // This mutation triggers a revert by setting a failure reason that gets // stored in the HashValidationZoneOfferer. HashValidationZoneOfferer(payable(order.parameters.zone)) - .setValidateFailureReason(orderHash, OffererZoneFailureReason.Zone_reverts); + .setValidateFailureReason(orderHash, OffererZoneFailureReason.Zone_validateReverts); exec(context); }