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
Rank: 43/59
Findings: 1
Award: $444.37
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Dravee
Also found by: 0x1f8b, 0x29A, 0xalpharush, Chom, Czar102, Hawkeye, IllIllI, MaratCerby, MiloTruck, NoamYakov, OriDabush, RoiEvenHaim, Spearbit, Tadashi, TerrierLover, TomJ, asutorufos, cccz, cmichel, csanuragjain, defsec, delfin454000, djxploit, ellahi, foobar, gzeon, hake, hickuphh3, ignacio, ilan, joestakey, kaden, mayo, ming, oyc_109, peritoflores, rfa, sach1r0, sashik_eth, shung, sirhashalot, twojoy, zer0dot, zkhorse
444.3669 USDC - $444.37
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.
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
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.