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

Contract Deployment Vulnerability in zkSync L2 Environment

Contract Deployment Vulnerability in zkSync L2 Environment

##Summary
The deployToken function, designed for contract deployment on zkSync L2, has been identified with a critical incompatibility issue. This stems from zkSync's unique contract deployment requirements, which are not met by the current implementation.

Vulnerability Analysis

Function Mechanism:

  • The function dynamically deploys contracts using provided bytecode at runtime. However, zkSync's compiler requires knowing the full bytecode at compile time for correct operation.

zkSync Deployment Requirements:

  • zkSync utilizes the hash of contract bytecode for deployment, contrasting with Ethereum's model. This requirement ensures that the bytecode of all deployable contracts is known before deployment, which is not the case in the deployToken function.

Potential Consequences:

  • Deployment Failure: Any attempt to deploy contracts through this function on zkSync will result in failure, as the bytecode is not pre-known to the compiler.

  • Operational Breakdown: The factory pattern used in deployToken is ineffective under zkSync's architecture, leading to a breakdown in the intended functionality of the contract.

Recommendations for Remediation

Code Restructuring:

  • Refactor deployToken to include the bytecode of deployable contracts within the contract. This ensures the compiler knows the bytecode in advance.

// Example of static bytecode inclusion
bytes memory staticBytecode = ...; // Bytecode of the contract to be deployed

Compatibility Review:

  • Perform a comprehensive compatibility review to ensure all aspects of the contract align with zkSync's unique operational model.

Conclusion

To ensure successful deployment and functionality on zkSync L2, significant modifications to the deployToken function are required. Adapting to zkSync's deployment method is essential for the contract's effective operation in this environment.

Updates

Lead Judging Commences

0xnevi Lead Judge almost 2 years 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.