Address collusion may occur with create2 with low probability.
In case newescrow function fails cause of address collusion user lose huge amount of gas . if we check the codesize before deployment and see if any contract deployment exist with the computed address we can revert with a low gas loss.
In the test case which is testSameSaltReverts in EscrowFactory test suit in case same salt used can lead to same address so in revert phase with customized code-block ; loss of gas minimal.Down below you can see the difference of gas in test suits
//EscrowFactoryTest:testSameSaltReverts() (gas: 8937393460516713538) --> before implementation!
//EscrowFactoryTest:testSameSaltReverts() (gas: 765957) --> after implementation!
uint codesz;
assembly {
codesz := extcodesize(computedAddress)
}
if(codesz !=0) revert EscrowFactory__ContractAlreadyDeployed();
code update down below
Foundry-test suits
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.