Factory contracts won't work correctly on the ZKsync chain as they use Solady's LibClone
library, which is incompatible with ZKsync. The protocol has stated that it must be compatible with any EVM chain :
The contract factories, namely NexusAccountFactory.sol
, RegistryFactory.sol
, and RegistryFactory.sol
use Solady's LibClone
library, which will not work correctly on the ZKsync chain. This is because, for the create/create2
opcodes to function correctly on the ZKsync chain, the compiler must be aware of the bytecode of the deployed contract in advance.
Quoting from ZKsync docs :
"On ZKsync Era, contract deployment is performed using the hash of the bytecode, and the factoryDeps field of EIP712 transactions contains the bytecode. The actual deployment occurs by providing the contract's hash to the ContractDeployer system contract.
To guarantee that create/create2 functions operate correctly, the compiler must be aware of the bytecode of the deployed contract in advance. The compiler interprets the calldata arguments as incomplete input for ContractDeployer, as the remaining part is filled in by the compiler internally. The Yul datasize and dataoffset instructions have been adjusted to return the constant size and bytecode hash rather than the bytecode itself."
Let's look at how the contracts are cloned in the factory contracts :
They all use the LibClone.createDeterministicERC1967()
method to create clones.
Now, let's look at the LibClone.createDeterministicERC1967()
function :
As you can see, the compiler will not be aware of the bytecode at compile time since the bytecode is stored in memory only on runtime in this function. The ZKsync docs recommend against this practice.
Since the compiler is unaware of the bytecode beforehand, this will lead to unexpected results on the ZKsync chain.
NOTE: This finding is heavily inspired by this issue
Factory deployments will not work/ deploy faulty contracts on the ZKsync chain.
Since the createDeterministicERC1967()
method deploys ETH along with the contract, there will also be loss of funds.
Therefore, this is a High severity finding.
Manual Review
Make sure the compiler is aware of the bytecode beforehand.
Example (from ZKsync docs) :
Valid medium, since there is non-functionality on zkSync (cannot create accounts) since it is stated as follows > Blockchains: > - Ethereum/Any EVM
Valid medium, since there is non-functionality on zkSync (cannot create accounts) since it is stated as follows > Blockchains: > - Ethereum/Any EVM
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.