-
Notifications
You must be signed in to change notification settings - Fork 8
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
Remove protocol gas limits #675
Conversation
7864f56
to
9e0329a
Compare
9e0329a
to
bb09e94
Compare
c28078a
to
9f8dd8e
Compare
89a2629
to
f10aa66
Compare
f10aa66
to
f09ed28
Compare
74b929b
to
0efcc36
Compare
0efcc36
to
939e256
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things:
- We should keep
maxTwinsPerBundle
. Length of_bundle.twinIds
is not problematic during increateBundleInternal
, but later intransferTwins
. Transfer twins should limit the gas it passes to twin contract when making a transfer #687 will add a max gas that a single twin transfer can consume, but if there is a large number of twins, they could collectively still reach the block gas limit and effectively DoSredeemVoucher
. If we keepmaxTwinsPerBundle
we can ensure thatmaxTwinsPerBundle * maxGasPerTwinTransfer
will always be low enough thatredeemVoucher
will succeed. burnPremintedVouchers(uint256 _offerId)
must also acceptuint256 _amount
, so the seller can regulate how many vouchers are burned. Currentlyend = range.start + range.minted;
can be so high that the gas limit is reached. It should beend = range.start + amount;
instead.- [just a remark, nothing to do].
createTwinInternal
can run into a block gas limit since the following value can be arbitrarily high.
boson-protocol-contracts/contracts/protocol/bases/TwinBase.sol
Lines 78 to 81 in 939e256
uint256 twinRangesLength = twinRanges.length; // Checks if token range isn't being used in any other twin of seller for (uint256 i = 0; i < twinRangesLength; i++) {
The problem is alleviated with Fix twin inefficiencies #656 but we cannot say it won't exist anymore. In theory, a seller could have so many twins, that creating a new twin won't be possible anymore (around 11,500 at current gas limits). We could introducemaxActiveTwins
, so if the seller reached it, they could not create a new twin until they remove some of the existing ones. But that check would be part ofcreateTwinInternal
again, so the overall behaviour is the same:- Without check (as it is now) they run into a block gas limit when creating a twin. If they remove a few of them, they can again create new ones.
- With a check in place they would get a revert reason instead when creating a twin. But then they would still need to remove a few of them to be able to create new ones.
getAvailableFunds
can run into a gas block limit iftokenList
gets too long.
boson-protocol-contracts/contracts/protocol/facets/FundsHandlerFacet.sol
Lines 166 to 171 in 939e256
availableFunds = new Funds[](tokenList.length); // Get entity's availableFunds storage pointer mapping(address => uint256) storage entityFunds = lookups.availableFunds[_entityId]; for (uint256 i = 0; i < tokenList.length; i++) {
We need a separate issue to fix it. Probably accepting a_tokenList
would do.- [just a remark, nothing to do].
removeTwins
can run into a block gas limit since the following value can be arbitrarily high.
uint256 lastIndex = twinRanges.length - 1; for (uint256 index = 0; index <= lastIndex; index++) {
This is fixed in Fix twin inefficiencies #656 - I agree that scripts to estimate limits are not necessary anymore. But they still might be valuable to get a feeling of how much the protocol can handle. Maybe you can remove them for now, but at some point, they can be refreshed and the docs rearrange to not talk about the limits (as protocol values) but rather just about protocol capabilities.
contracts/protocol/facets/ProtocolInitializationHandlerFacet.sol
Outdated
Show resolved
Hide resolved
1b3488e
to
0bfe075
Compare
contracts/protocol/facets/ProtocolInitializationHandlerFacet.sol
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix #668