Beginner FriendlyFoundryBridge
100 EXP
View results
Submission Details
Severity: high
Valid

Incompatibility of `deployToken` Function with zkSync's Contract Deployment Mechanism

Vulnerability Details

The deployToken function in the TokenFactory contract is not compatible with zkSync's contract deployment mechanism. zkSync Era requires contract deployment to be executed using the hash of the bytecode. The factoryDeps field in EIP712 transactions must contain the bytecode, and the actual deployment happens by providing the contract's hash to the ContractDeployer system contract. The deployToken function, as currently implemented, does not conform to these requirements. see ZKSync docs Differences with Ethereum

function deployToken(string memory symbol, bytes memory contractBytecode) public onlyOwner returns (address addr) {
assembly {
addr := create(0, add(contractBytecode, 0x20), mload(contractBytecode))
}
s_tokenToAddress[symbol] = addr;
emit TokenDeployed(symbol, addr);
}

Impact

This incompatibility restricts the deployToken function from functioning as intended on zkSync Era. This limitation hampers the contract's usability and interoperability within the zkSync ecosystem, potentially impacting its effectiveness and applicability on this platform.

Recommendations

  1. Revise Deployment Method: Adapt the deployToken function to align with zkSync's contract deployment requirements, particularly the use of bytecode hashes and handling the factoryDeps field appropriately.

  2. Include Comprehensive Testing: It is crucial to include tests for any factory functionality that deploys child contracts, especially using type(T).creationCode, to ensure compatibility and correct functionality on zkSync Era.

By implementing these changes, the TokenFactory contract can be made compatible with zkSync's unique deployment mechanism, ensuring successful operation on this platform.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

deployToken(): zksync compatibility issues

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.