Skip to content

Logs and create3 utils#110

Closed
Streator wants to merge 11 commits intomainfrom
script-utils
Closed

Logs and create3 utils#110
Streator wants to merge 11 commits intomainfrom
script-utils

Conversation

@Streator
Copy link
Copy Markdown
Contributor

@Streator Streator commented Sep 19, 2025

PR Type

Enhancement


Description

  • Added CreateX factory wrapper for contract deployments

  • Implemented logging utility for script execution

  • Created ICreateX interface for factory interactions

  • Added core support validation function


Diagram Walkthrough

flowchart LR
  A["CreateXWrapper"] --> B["ICreateX Interface"]
  A --> C["CREATE/CREATE2/CREATE3 Deployments"]
  D["Logs Library"] --> E["Console & File Logging"]
  F["SymbioticCoreConstants"] --> G["Chain Support Validation"]
Loading

File Walkthrough

Relevant files
Enhancement
CreateXWrapper.sol
CreateX factory deployment wrapper implementation               

script/utils/CreateXWrapper.sol

  • Added wrapper contract for CreateX factory deployments
  • Implemented CREATE, CREATE2, and CREATE3 deployment methods
  • Added salt generation and address computation utilities
  • Included guarded salt variants for secure deployments
+146/-0 
Logs.sol
Script logging utility library                                                     

script/utils/Logs.sol

  • Created logging library for script execution
  • Added dual output to console and file
  • Implemented VM interface for file operations
+18/-0   
ICreateX.sol
CreateX factory interface definition                                         

script/utils/interfaces/ICreateX.sol

  • Added complete ICreateX interface definition
  • Defined deployment methods for CREATE/CREATE2/CREATE3
  • Included events, errors, and value structures
  • Added address computation functions
+166/-0 
SymbioticCoreConstants.sol
Core support validation function                                                 

test/integration/SymbioticCoreConstants.sol

  • Added coreSupported() function for chain validation
  • Checks support for mainnet, Holesky, Sepolia, and testnet
+4/-0     

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Oct 2, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
File write misuse

Description: The logging library hardcodes the Foundry VM cheatcode address and writes to a fixed
relative path, which could enable file write abuse or unintended file modification if used
beyond a trusted local Forge scripting context.
Logs.sol [8-17]

Referred Code
string internal constant LOG_FILE = "script/logs.txt";
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
Vm internal constant vm = Vm(VM_ADDRESS);

function log(
    string memory data
) public {
    console2.log(data);
    vm.writeFile(LOG_FILE, string.concat(vm.readFile(LOG_FILE), data, "\n"));
}
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Oct 2, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Use appendFile for efficient logging
Suggestion Impact:The commit changed the logging from readFile+writeFile to a single-file-write operation (writeLine) to avoid reading the whole file, aligning with the suggestion's intent to make logging more efficient, though it used writeLine instead of appendFile.

code diff:

-        vm.writeFile(LOG_FILE, string.concat(vm.readFile(LOG_FILE), data, "\n"));
+        vm.writeLine(LOG_FILE, string.concat(data, "\n"));

In the log function, replace the inefficient vm.readFile and vm.writeFile
combination with vm.appendFile to improve logging performance and reduce gas
usage.

script/utils/Logs.sol [12-17]

 function log(
     string memory data
 ) public {
     console2.log(data);
-    vm.writeFile(LOG_FILE, string.concat(vm.readFile(LOG_FILE), data, "\n"));
+    vm.appendFile(LOG_FILE, string.concat(data, "\n"));
 }

[Suggestion processed]

Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out an inefficient file operation (readFile + writeFile) and proposes a much more efficient alternative (appendFile) that avoids reading the entire file, significantly improving performance for this scripting utility.

Medium
General
Remove redundant and confusing code

In getSaltForCreate3, remove the redundant uint256(0x00) << 88 from the bitwise
OR operation, as it evaluates to zero and has no effect on the result.

script/utils/CreateXWrapper.sol [143-15]

 function getSaltForCreate3(bytes11 salt, address deployer) public pure returns (bytes32) {
-    return bytes32(uint256(uint160(deployer)) << 96 | uint256(0x00) << 88 | uint256(uint88(salt)));
+    return bytes32((uint256(uint160(deployer)) << 96) | uint256(uint88(salt)));
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 4

__

Why: The suggestion correctly identifies a redundant part of a bitwise operation that evaluates to zero. Removing it improves code clarity and conciseness without affecting functionality.

Low
  • Update

@1kresh 1kresh closed this Oct 24, 2025
@1kresh 1kresh deleted the script-utils branch December 8, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants