Better to catch and revert early in the EscrowFactory
than to first do address computation of Escrow
and then fail in Escrow
constructor.
The following tests are preformed in Escrow
constructor:
The values checked are all available in EscrowFactory.newEscrow()
as well. As such, it is more gas efficient to check them in EscrowFactory.newEscrow()
before an Escrow
address is even computed.
Gas
Forge, Foundry Toolkit (gas report, gas snapshots)
Move the checks on Escrow constructor arguments to EscrowFactory.newEscrow()
. This change saved a significant 135729
across all tests. As an example, the tests testRevertIfFeeGreaterThanPrice
andtestSellerZeroReverts
saved ~55000
gas each. The deployment cost for Escrow
fell by 1158
gas. All of this will add up to notable gas savings in the long term.
Note that to achieve this, I moved all errors and the enum to a new IErrors
interface file, and inherited that in the other two interfaces.
Changes also need to be made to tests so they access the enum and errors from IErrors
directly.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.