Skip to content

Commit

Permalink
Remove protocol gas limits
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jun 8, 2023
1 parent 451dc3d commit c387b22
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 2,021 deletions.
10 changes: 0 additions & 10 deletions contracts/interfaces/events/IBosonConfigEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ interface IBosonConfigEvents {
event BeaconProxyAddressChanged(address indexed beaconProxyAddress, address indexed executedBy);
event ProtocolFeePercentageChanged(uint256 feePercentage, address indexed executedBy);
event ProtocolFeeFlatBosonChanged(uint256 feeFlatBoson, address indexed executedBy);
event MaxExchangesPerBatchChanged(uint16 maxExchangesPerBatch, address indexed executedBy);
event MaxOffersPerGroupChanged(uint16 maxOffersPerGroup, address indexed executedBy);
event MaxOffersPerBatchChanged(uint16 maxOffersPerBatch, address indexed executedBy);
event MaxTwinsPerBundleChanged(uint16 maxTwinsPerBundle, address indexed executedBy);
event MaxOffersPerBundleChanged(uint16 maxOffersPerBundle, address indexed executedBy);
event MaxTokensPerWithdrawalChanged(uint16 maxTokensPerWithdrawal, address indexed executedBy);
event MaxFeesPerDisputeResolverChanged(uint16 maxFeesPerDisputeResolver, address indexed executedBy);
event MaxEscalationResponsePeriodChanged(uint256 maxEscalationResponsePeriod, address indexed executedBy);
event MaxDisputesPerBatchChanged(uint16 maxDisputesPerBatch, address indexed executedBy);
event MaxAllowedSellersChanged(uint16 maxAllowedSellers, address indexed executedBy);
event BuyerEscalationFeePercentageChanged(uint256 buyerEscalationFeePercentage, address indexed executedBy);
event AuthTokenContractChanged(
BosonTypes.AuthTokenType indexed authTokenType,
Expand All @@ -35,6 +26,5 @@ interface IBosonConfigEvents {
event MaxRoyaltyPercentageChanged(uint16 maxRoyaltyPecentage, address indexed executedBy);
event MaxResolutionPeriodChanged(uint256 maxResolutionPeriod, address indexed executedBy);
event MinDisputePeriodChanged(uint256 minDisputePeriod, address indexed executedBy);
event MaxPremintedVouchersChanged(uint256 maxPremintedVouchers, address indexed executedBy);
event AccessControllerAddressChanged(address indexed accessControllerAddress, address indexed executedBy);
}
196 changes: 0 additions & 196 deletions contracts/interfaces/handlers/IBosonConfigHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,126 +134,6 @@ interface IBosonConfigHandler is IBosonConfigEvents {
*/
function getProtocolFeeFlatBoson() external view returns (uint256);

/**
* @notice Sets the maximum numbers of offers that can be created in a single transaction.
*
* Emits a MaxOffersPerBatchChanged event.
*
* Reverts if _maxOffersPerBatch is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxOffersPerBatch - the maximum length of {BosonTypes.Offer[]}
*/
function setMaxOffersPerBatch(uint16 _maxOffersPerBatch) external;

/**
* @notice Gets the maximum numbers of offers that can be created in a single transaction.
*
* @return the maximum numbers of offers that can be created in a single transaction
*/
function getMaxOffersPerBatch() external view returns (uint16);

/**
* @notice Sets the maximum numbers of offers that can be added to a group in a single transaction.
*
* Emits a MaxOffersPerGroupChanged event.
*
* Reverts if _maxOffersPerGroup is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxOffersPerGroup - the maximum length of {BosonTypes.Group.offerIds}
*/
function setMaxOffersPerGroup(uint16 _maxOffersPerGroup) external;

/**
* @notice Gets the maximum numbers of offers that can be added to a group in a single transaction.
*
* @return the maximum numbers of offers that can be added to a group in a single transaction
*/
function getMaxOffersPerGroup() external view returns (uint16);

/**
* @notice Sets the maximum numbers of twins that can be added to a bundle in a single transaction.
*
* Emits a MaxTwinsPerBundleChanged event.
*
* Reverts if _maxTwinsPerBundle is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxTwinsPerBundle - the maximum length of {BosonTypes.Bundle.twinIds}
*/
function setMaxTwinsPerBundle(uint16 _maxTwinsPerBundle) external;

/**
* @notice Gets the maximum numbers of twins that can be added to a bundle in a single transaction.
*
* @return the maximum numbers of twins that can be added to a bundle in a single transaction.
*/
function getMaxTwinsPerBundle() external view returns (uint16);

/**
* @notice Sets the maximum numbers of offers that can be added to a bundle in a single transaction.
*
* Emits a MaxOffersPerBundleChanged event.
*
* Reverts if _maxOffersPerBundle is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxOffersPerBundle - the maximum length of {BosonTypes.Bundle.offerIds}
*/
function setMaxOffersPerBundle(uint16 _maxOffersPerBundle) external;

/**
* @notice Gets the maximum numbers of offers that can be added to a bundle in a single transaction.
*
* @return the maximum numbers of offers that can be added to a bundle in a single transaction
*/
function getMaxOffersPerBundle() external view returns (uint16);

/**
* @notice Sets the maximum numbers of tokens that can be withdrawn in a single transaction.
*
* Emits a MaxTokensPerWithdrawalChanged event.
*
* Reverts if _maxTokensPerWithdrawal is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxTokensPerWithdrawal - the maximum length of token list when calling {FundsHandlerFacet.withdraw}
*/
function setMaxTokensPerWithdrawal(uint16 _maxTokensPerWithdrawal) external;

/**
* @notice Gets the maximum numbers of tokens that can be withdrawn in a single transaction.
*
* @return the maximum length of token list when calling {FundsHandlerFacet.withdraw}
*/
function getMaxTokensPerWithdrawal() external view returns (uint16);

/**
* @notice Sets the maximum number of dispute resolver fee structs that can be processed in a single transaction.
*
* Emits a MaxFeesPerDisputeResolverChanged event.
*
* Reverts if _maxFeesPerDisputeResolver is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxFeesPerDisputeResolver - the maximum length of dispute resolver fees list when calling {AccountHandlerFacet.createDisputeResolver} or {AccountHandlerFacet.updateDisputeResolver}
*/
function setMaxFeesPerDisputeResolver(uint16 _maxFeesPerDisputeResolver) external;

/**
* @notice Gets the maximum number of dispute resolver fee structs that can be processed in a single transaction.
*
* @return the maximum number of dispute resolver fee structs that can be processed in a single transaction
*/
function getMaxFeesPerDisputeResolver() external view returns (uint16);

/**
* @notice Sets the maximum escalation response period a dispute resolver can specify.
*
Expand All @@ -274,26 +154,6 @@ interface IBosonConfigHandler is IBosonConfigEvents {
*/
function getMaxEscalationResponsePeriod() external view returns (uint256);

/**
* @notice Sets the maximum number of disputes that can be expired in a single transaction.
*
* Emits a MaxDisputesPerBatchChanged event.
*
* Reverts if _maxDisputesPerBatch is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxDisputesPerBatch - the maximum number of disputes that can be expired
*/
function setMaxDisputesPerBatch(uint16 _maxDisputesPerBatch) external;

/**
* @notice Gets the maximum number of disputes that can be expired in a single transaction.
*
* @return the maximum number of disputes that can be expired
*/
function getMaxDisputesPerBatch() external view returns (uint16);

/**
* @notice Sets the total offer fee percentage limit which will validate the sum of (Protocol Fee percentage + Agent Fee percentage) of an offer fee.
*
Expand All @@ -317,26 +177,6 @@ interface IBosonConfigHandler is IBosonConfigEvents {
*/
function getMaxTotalOfferFeePercentage() external view returns (uint16);

/**
* @notice Sets the maximum number of seller ids that can be added to or removed from dispute resolver seller allow list in a single transaction.
*
* Emits a MaxAllowedSellersChanged event.
*
* Reverts if _maxAllowedSellers is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxAllowedSellers - the maximum number of seller ids that can be added or removed
*/
function setMaxAllowedSellers(uint16 _maxAllowedSellers) external;

/**
* @notice Gets the maximum number of seller ids that can be added to or removed from dispute resolver seller allow list in a single transaction.
*
* @return the maximum number of seller ids that can be added or removed
*/
function getMaxAllowedSellers() external view returns (uint16);

/**
* @notice Sets the buyer escalation fee percentage.
*
Expand Down Expand Up @@ -384,26 +224,6 @@ interface IBosonConfigHandler is IBosonConfigEvents {
*/
function getAuthTokenContract(BosonTypes.AuthTokenType _authTokenType) external view returns (address);

/**
* @notice Sets the maximum number of exchanges that can be created in a single transaction.
*
* Emits a MaxExchangesPerBatchChanged event.
*
* Reverts if _maxExchangesPerBatch is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxExchangesPerBatch - the maximum length of {BosonTypes.Exchange[]}
*/
function setMaxExchangesPerBatch(uint16 _maxExchangesPerBatch) external;

/**
* @notice Gets the maximum number of exchanges that can be created in a single transaction.
*
* @return the maximum length of {BosonTypes.Exchange[]}
*/
function getMaxExchangesPerBatch() external view returns (uint16);

/**
* @notice Sets the maximum royalty percentage that can be set by the seller.
*
Expand Down Expand Up @@ -465,22 +285,6 @@ interface IBosonConfigHandler is IBosonConfigEvents {
*/
function getMinDisputePeriod() external view returns (uint256);

/**
* @notice Sets the maximum number of vouchers that can be preminted in a single transaction.
*
* Emits a MaxPremintedVouchersChanged event if successful.
*
* Reverts if the _maxPremintedVouchers is zero.
*
* @param _maxPremintedVouchers - the maximum number of vouchers
*/
function setMaxPremintedVouchers(uint256 _maxPremintedVouchers) external;

/**
* @notice Gets the maximum number of vouchers that can be preminted in a single transaction.
*/
function getMaxPremintedVouchers() external view returns (uint256);

/**
* @notice Sets the access controller address.
*
Expand Down
9 changes: 0 additions & 9 deletions contracts/protocol/bases/BundleBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ contract BundleBase is ProtocolBase, IBosonBundleEvents {
* - Any of the offers belongs to different seller
* - Any of the offers does not exist
* - Offer exists in a different bundle
* - Number of offers exceeds maximum allowed number per bundle
* - Any of the twins belongs to different seller
* - Any of the twins does not exist
* - Number of twins exceeds maximum allowed number per bundle
* - Duplicate twins added in same bundle
* - Exchange already exists for the offer id in bundle
* - Offers' total quantity is greater than twin supply when token is nonfungible
Expand All @@ -38,7 +36,6 @@ contract BundleBase is ProtocolBase, IBosonBundleEvents {
function createBundleInternal(Bundle memory _bundle) internal {
// Cache protocol lookups and limits for reference
ProtocolLib.ProtocolLookups storage lookups = protocolLookups();
ProtocolLib.ProtocolLimits storage limits = protocolLimits();

// get message sender
address sender = msgSender();
Expand All @@ -53,12 +50,6 @@ contract BundleBase is ProtocolBase, IBosonBundleEvents {
BUNDLE_REQUIRES_AT_LEAST_ONE_TWIN_AND_ONE_OFFER
);

// limit maximum number of offers to avoid running into block gas limit in a loop
require(_bundle.offerIds.length <= limits.maxOffersPerBundle, TOO_MANY_OFFERS);

// limit maximum number of twins to avoid running into block gas limit in a loop
require(_bundle.twinIds.length <= limits.maxTwinsPerBundle, TOO_MANY_TWINS);

// Get the next bundle and increment the counter
uint256 bundleId = protocolCounters().nextBundleId++;
// Sum of offers quantity available
Expand Down
17 changes: 0 additions & 17 deletions contracts/protocol/clients/voucher/BosonVoucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable
* Reverts if:
* - Offer id is not associated with a range
* - Amount to mint is more than remaining un-minted in range
* - Too many to mint in a single transaction, given current block gas limit
* - Offer already expired
* - Offer is voided
*
Expand All @@ -217,13 +216,6 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable
// Revert if no more to mint in range
require(range.length >= range.minted + _amount, INVALID_AMOUNT_TO_MINT);

// Get max amount that can be minted in a single transaction
address protocolDiamond = IClientExternalAddresses(BeaconClientLib._beacon()).getProtocolAddress();
uint256 maxPremintedVouchers = IBosonConfigHandler(protocolDiamond).getMaxPremintedVouchers();

// Revert if too many to mint in a single transaction
require(_amount <= maxPremintedVouchers, TOO_MANY_TO_MINT);

// Make sure that offer is not expired or voided
(Offer memory offer, OfferDates memory offerDates) = getBosonOffer(_offerId);
require(!offer.voided && (offerDates.validUntil > block.timestamp), OFFER_EXPIRED_OR_VOIDED);
Expand Down Expand Up @@ -283,10 +275,6 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable
(Offer memory offer, OfferDates memory offerDates) = getBosonOffer(_offerId);
require(offer.voided || (offerDates.validUntil <= block.timestamp), OFFER_STILL_VALID);

// Get max amount that can be burned in a single transaction
address protocolDiamond = IClientExternalAddresses(BeaconClientLib._beacon()).getProtocolAddress();
uint256 maxPremintedVouchers = IBosonConfigHandler(protocolDiamond).getMaxPremintedVouchers();

// Get the first token to burn
uint256 start = (range.lastBurnedTokenId == 0) ? range.start : (range.lastBurnedTokenId + 1);

Expand All @@ -296,11 +284,6 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable
// End should be greater than start
require(end > start, NOTHING_TO_BURN);

// If amount to burn is more than maxPremintedVouchers, burn only maxPremintedVouchers
if (end > start + maxPremintedVouchers) {
end = start + maxPremintedVouchers;
}

// Burn the range
address rangeOwner = range.owner;
uint256 burned;
Expand Down
Loading

0 comments on commit c387b22

Please sign in to comment.