Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
93 lines
4.4 KiB
Solidity
Executable File
93 lines
4.4 KiB
Solidity
Executable File
// SPDX-License-Identifier: MIT
|
|
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Create2.sol)
|
|
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {Errors} from "./Errors.sol";
|
|
|
|
/**
|
|
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
|
|
* `CREATE2` can be used to compute in advance the address where a smart
|
|
* contract will be deployed, which allows for interesting new mechanisms known
|
|
* as 'counterfactual interactions'.
|
|
*
|
|
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
|
|
* information.
|
|
*/
|
|
library Create2 {
|
|
/**
|
|
* @dev There's no code to deploy.
|
|
*/
|
|
error Create2EmptyBytecode();
|
|
|
|
/**
|
|
* @dev Deploys a contract using `CREATE2`. The address where the contract
|
|
* will be deployed can be known in advance via {computeAddress}.
|
|
*
|
|
* The bytecode for a contract can be obtained from Solidity with
|
|
* `type(contractName).creationCode`.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - `bytecode` must not be empty.
|
|
* - `salt` must have not been used for `bytecode` already.
|
|
* - the factory must have a balance of at least `amount`.
|
|
* - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
|
|
*/
|
|
function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
|
|
if (address(this).balance < amount) {
|
|
revert Errors.InsufficientBalance(address(this).balance, amount);
|
|
}
|
|
if (bytecode.length == 0) {
|
|
revert Create2EmptyBytecode();
|
|
}
|
|
assembly ("memory-safe") {
|
|
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
|
|
// if no address was created, and returndata is not empty, bubble revert
|
|
if and(iszero(addr), not(iszero(returndatasize()))) {
|
|
let p := mload(0x40)
|
|
returndatacopy(p, 0, returndatasize())
|
|
revert(p, returndatasize())
|
|
}
|
|
}
|
|
if (addr == address(0)) {
|
|
revert Errors.FailedDeployment();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
|
|
* `bytecodeHash` or `salt` will result in a new destination address.
|
|
*/
|
|
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
|
|
return computeAddress(salt, bytecodeHash, address(this));
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
|
|
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
|
|
*/
|
|
function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
|
|
assembly ("memory-safe") {
|
|
let ptr := mload(0x40) // Get free memory pointer
|
|
|
|
// | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |
|
|
// |-------------------|---------------------------------------------------------------------------|
|
|
// | bytecodeHash | CCCCCCCCCCCCC...CC |
|
|
// | salt | BBBBBBBBBBBBB...BB |
|
|
// | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |
|
|
// | 0xFF | FF |
|
|
// |-------------------|---------------------------------------------------------------------------|
|
|
// | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
|
|
// | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |
|
|
|
|
mstore(add(ptr, 0x40), bytecodeHash)
|
|
mstore(add(ptr, 0x20), salt)
|
|
mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
|
|
let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
|
|
mstore8(start, 0xff)
|
|
addr := and(keccak256(start, 85), 0xffffffffffffffffffffffffffffffffffffffff)
|
|
}
|
|
}
|
|
}
|