Skip to content

Commit

Permalink
fix: remove forking
Browse files Browse the repository at this point in the history
  • Loading branch information
omurovec committed Feb 19, 2023
1 parent 22cf26b commit e103f42
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
5 changes: 0 additions & 5 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ src = 'src'
out = 'out'
libs = ['lib']
fs_permissions = [{ access = "read-write", path = "./"}]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
[rpc_endpoints]
layer_1 = "https://eth-goerli.g.alchemy.com/v2/FUPg1BQW1X2VnrAef0WIwSxqGpuSZdEo"
layer_2 = "https://zksync2-testnet.zksync.dev"
4 changes: 2 additions & 2 deletions script/Counter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ contract CounterScript is Script {
Deployer public deployer;

function setUp() public {
deployer = new Deployer("1.3.1");
deployer = new Deployer("1.3.1", address(0x1908e2BF4a88F91E4eF0DC72f02b8Ea36BEa2319));
}

function run() public {
bytes memory params;
address counter = deployer.deployContract("src/Counter.sol", params, bytes32(uint256(7357)), true, address(0x1908e2BF4a88F91E4eF0DC72f02b8Ea36BEa2319));
address counter = deployer.deployFromL1("src/Counter.sol", params, bytes32(uint256(1337)), true);
}
}
17 changes: 5 additions & 12 deletions script/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ interface _CheatCodes {
function ffi(string[] calldata) external returns (bytes memory);
function envString(string calldata key) external returns (string memory value);
function envUint(string calldata key) external returns (uint256 value);
function createFork(string calldata) external returns (uint256);
function selectFork(uint256 forkId) external;
function broadcast(uint256 privateKey) external;
function allowCheatcodes(address) external;
function addr(uint256 privateKey) external returns (address);
Expand All @@ -31,20 +29,19 @@ contract Deployer {
/* address constant HEVM_ADDRESS = address(bytes20(uint160(uint256(keccak256("hevm cheat code"))))); */
_CheatCodes cheatCodes = _CheatCodes(address(uint160(uint256(keccak256("hevm cheat code")))));

///@notice Fork IDs
uint256 public l1;
uint256 public l2;

///@notice Compiler & deployment config
string constant zksolcRepo = "https://github.com/matter-labs/zksolc-bin";
string public projectRoot;
string public zksolcPath;
address public diamondProxy;

constructor(string memory _zksolcVersion) {
l1 = cheatCodes.createFork("layer_1");
constructor(string memory _zksolcVersion, address _diamondProxy) {
///@notice install bin compiler
projectRoot = cheatCodes.projectRoot();
zksolcPath = _installCompiler(_zksolcVersion);

diamondProxy = _diamondProxy;
}

function compileContract(string memory fileName) public returns (bytes memory bytecode) {
Expand All @@ -66,7 +63,7 @@ contract Deployer {
bytecode = cheatCodes.ffi(echoCmds);
}

function deployContract(string memory fileName, bytes calldata params, bytes32 salt, bool broadcast, address diamondProxy) public returns (address) {
function deployFromL1(string memory fileName, bytes calldata params, bytes32 salt, bool broadcast) public returns (address) {
bytes memory bytecode = compileContract(fileName);

bytes32 bytecodeHash = L2ContractHelper.hashL2Bytecode(bytecode);
Expand All @@ -76,10 +73,6 @@ contract Deployer {
bytes[] memory factoryDeps = new bytes[](1);
factoryDeps[0] = bytecode;

// Switch to L1
cheatCodes.allowCheatcodes(address(this));
cheatCodes.selectFork(l1);

///@notice Deploy from Layer 1
if (broadcast) cheatCodes.broadcast(cheatCodes.envUint("PRIVATE_KEY"));
IMailbox(diamondProxy).requestL2Transaction(
Expand Down

0 comments on commit e103f42

Please sign in to comment.