Beginner FriendlyFoundryBridge
100 EXP
View results
Submission Details
Severity: low
Invalid

Deployment token could result on address zero

Audit Findings

1. Failure Handling for Contract Deployment

The create function is used to deploy the contract bytecode provided as contractBytecode. However, if the deployment fails for any reason, the addr variable will be set to zero, indicating a failure in contract deployment. It is crucial to handle this scenario properly and consider the potential impact on the system's functioning and data consistency.

Recommendations

Based on the findings above, we recommend the following changes to the code:

  1. Implement robust error handling mechanisms to address potential deployment failures. This includes proper logging, informative error messages, and appropriate system behavior to handle failed deployments and ensure data consistency.

    Here's a snippet illustrating the recommended change:

    function deployToken(string memory symbol, bytes memory contractBytecode) public onlyOwner returns (address addr) {
    assembly {
    addr := create(0, add(contractBytecode, 0x20), mload(contractBytecode))
    }
    // Check if the deployment was successful
    require(addr != address(0), "Contract deployment failed");
    // Update the mapping only if the deployment was successful
    s_tokenToAddress[symbol] = addr;
    emit TokenDeployed(symbol, addr);
    }

In the above code snippet, we added a require statement to validate that the contract deployment was successful. If the deployment fails and the addr variable is set to zero, the transaction will revert with an informative error message.

Conclusion

In conclusion, the concern raised regarding potential issues if the deployment fails is valid. It is crucial to handle contract deployment failures properly to ensure data consistency and appropriate system behavior. We recommend implementing robust error handling mechanisms and providing informative error messages to facilitate debugging and resolution of deployment issues.

Updates

Lead Judging Commences

0xnevi Lead Judge
almost 2 years ago
0xnevi Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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