Skip to content
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

Gas Optimizations #209

Open
code423n4 opened this issue Jun 3, 2022 · 1 comment
Open

Gas Optimizations #209

code423n4 opened this issue Jun 3, 2022 · 1 comment
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Utilise uncheck block for gas savings

End should be greater than start time
so use unchecked block to save gas

https://github.com/code-423n4/2022-05-opensea-seaport/blob/4140473b1f85d0df602548ad260b1739ddd734a5/contracts/lib/OrderFulfiller.sol#L163

https://github.com/code-423n4/2022-05-opensea-seaport/blob/4140473b1f85d0df602548ad260b1739ddd734a5/contracts/lib/OrderCombiner.sol#L235

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/reference/lib/ReferenceOrderCombiner.sol#L241

If statement ensures no underflow :

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/contracts/lib/FulfillmentApplier.sol#L100

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/contracts/lib/FulfillmentApplier.sol#L112

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/reference/lib/ReferenceBasicOrderFulfiller.sol#L867

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/reference/lib/ReferenceFulfillmentApplier.sol#L109

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/reference/lib/ReferenceFulfillmentApplier.sol#L120

Cache advancedOrder.parameters.endTime in a local variable

https://github.com/code-423n4/2022-05-opensea-seaport/blob/4140473b1f85d0df602548ad260b1739ddd734a5/contracts/lib/OrderCombiner.sol#L235

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/reference/lib/ReferenceOrderCombiner.sol#L241

Variables are their default types

No need to assign them :

https://github.com/code-423n4/2022-05-opensea-seaport/blob/4140473b1f85d0df602548ad260b1739ddd734a5/contracts/lib/OrderCombiner.sol#L470

https://github.com/code-423n4/2022-05-opensea-seaport/blob/4140473b1f85d0df602548ad260b1739ddd734a5/contracts/lib/OrderCombiner.sol#L751

https://github.com/code-423n4/2022-05-opensea-seaport/blob/9d7ce4d08bf3c3010304a0476a785c70c0e90ae7/reference/lib/ReferenceAmountDeriver.sol#L46

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jun 3, 2022
code423n4 added a commit that referenced this issue Jun 3, 2022
@HardlyDifficult
Copy link
Collaborator

Utilise uncheck block for gas savings

Since _verifyTime requires startTime <= endTime it may be worth using unchecked here for a small savings. Same for the others so long as it is confirmed that the appropriate checks have already been peformed.

Cache advancedOrder.parameters.endTime in a local variable

Since the endTime does not appear to be read a second time here, it's not clear this change would offer any benefit.

Variables are their default types

The compiler seems to mostly handle this automatically. In my testing, not setting defaults offered very little savings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

2 participants