OpenSea Seaport contest - zer0dot'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: 43/59

Findings: 1

Award: $444.37

🌟 Selected for report: 0

🚀 Solo Findings: 0

Gas Optimizations

To prevent repeated code revision reverting, the following gas optimizations are done cumulatively, meaning each one adds to the last's codebase. These are also from running forge test --gas-report with a custom Foundry profile that limits fuzz runs to 100 and disables the IR pipeline.

1 - Use shr instead of dividing by 4

Replace the line here with:

route := shr(2, calldataload(BasicOrder_basicOrderType_cdPtr))

Saves on average 3 gas per fulfillBasicOrder() call according to tests. Saves 1 gas on median.

Before: fulfillBasicOrder ┆ 753 ┆ 578873 ┆ 214735 ┆ 3437148
After: fulfillBasicOrder ┆ 751 ┆ 578870 ┆ 214734 ┆ 3437146

2 - Short-Circuit a reverting inequality check

Replace the block starting here, copied below:

if (amount != 1) { revert InvalidERC721TransferAmount(); } // Perform transfer via the token contract directly. _performERC721Transfer(token, from, to, identifier);

With the following:

if (amount == 1) { // Perform transfer via the token contract directly. _performERC721Transfer(token, from, to, identifier); } else { revert InvalidERC721TransferAmount(); }

This again saves extremely small amounts of gas on fulfillBasicOrder(), but hey, it's something.

Before: fulfillBasicOrder ┆ 751 ┆ 578870 ┆ 214734 ┆ 3437146
After: fulfillBasicOrder ┆ 751 ┆ 578870 ┆ 214733 ┆ 3437145

#0 - HardlyDifficult

2022-06-26T16:26:42Z

These are extremely small savings, but seem like valid suggestions that could be considered.

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