OpenSea Seaport contest - 0xalpharush's results

A marketplace contract for safely and efficiently creating and fulfilling orders for ERC721 and ERC1155 items.

General Information

Platform: Code4rena

Start Date: 20/05/2022

Pot Size: $1,000,000 USDC

Total HM: 4

Participants: 59

Period: 14 days

Judge: leastwood

Id: 128

League: ETH

OpenSea

Findings Distribution

Researcher Performance

Rank: 37/59

Findings: 1

Award: $570.27

🌟 Selected for report: 0

🚀 Solo Findings: 0

Gas Report

I identified a loop invariant code motion optimization in _prepareBasicFulfillmentFromCalldata which saves roughly 150 gas on average and reduces the max cost 450 whenever the method fulfillBasicOrder is called. Note, this is based on the hardhat test cases provided in the repo and calculated using yarn profile.

Before: | Min: 93563 | Max: 1624267 | Avg: 665051 After: | Min: 93577 | Max: 1623834 | Avg: 664908 Change: | +14 | -433 | -143

I found that removing the induction variable, i, as shown below was not cheaper, on average. However, it may be useful if, on mainnet, many tips are sent and outweigh the cost of the the hoisted expression.

totalAdditionalRecipients := calldataload(BasicOrder_totalOriginalAdditionalRecipients_cdPtr) let additionalRecipientCdPtr := 0x244 let max := add(mul(totalAdditionalRecipients, 0x40), additionalRecipientCdPtr) for {} lt(additionalRecipientCdPtr, max) {} {/ * loop body */ }

The patch required to apply this optimization is available here: https://gist.github.com/0xalpharush/15f4c3eeec9367a853e494daee36150b

#0 - HardlyDifficult

2022-06-26T15:43:52Z

This optimization offers a small but non-trivial savings and may be worth considering.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter