Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions scripts/ethcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import * as fs from "fs";
import { ARB_OWNER } from "./consts";
import * as TransparentUpgradeableProxy from "@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json"
import * as ExpressLaneAuctionContract from "@arbitrum/nitro-contracts/build/contracts/src/express-lane-auction/ExpressLaneAuction.sol/ExpressLaneAuction.json"
import * as StylusDeployerContract from "@arbitrum/nitro-contracts/build/contracts/src/stylus/StylusDeployer.sol/StylusDeployer.json"

const path = require("path");

async function sendTransaction(argv: any, threadId: number) {
Expand Down Expand Up @@ -185,6 +187,36 @@ async function deployWETHContract(deployerWallet: Wallet): Promise<string> {
return weth.address;
}

async function createStylusDeployer(deployerWallet: Wallet): Promise<string> {
// this factory should be deployed by the rollupcreater when deploy helper is used
const create2factory = '0x4e59b44847b379578588920ca78fbf26c0b4956c'
if (await deployerWallet.provider.getCode(create2factory) === '0x') {
// wait for 30 seconds, check again before throwing an error
await new Promise(resolve => setTimeout(resolve, 30000));
if (await deployerWallet.provider.getCode(create2factory) === '0x') {
throw new Error('Create2 factory not yet deployed')
}
}

const salt = ethers.constants.HashZero
const stylusDeployerBytecode = StylusDeployerContract.bytecode
const stylusDeployerAddress = ethers.utils.getCreate2Address(create2factory, salt, ethers.utils.keccak256(stylusDeployerBytecode))

// check if the address is already deployed
const code = await deployerWallet.provider.getCode(stylusDeployerAddress)
if (code !== '0x') {
console.log("Stylus deployer already deployed")
} else {
const stylusDeployerTx = await deployerWallet.sendTransaction({
to: create2factory,
data: ethers.utils.concat([salt, stylusDeployerBytecode])
})
await stylusDeployerTx.wait()
}

return stylusDeployerAddress
}

export const bridgeFundsCommand = {
command: "bridge-funds",
describe: "sends funds from l1 to l2",
Expand Down Expand Up @@ -592,6 +624,30 @@ export const createWETHCommand = {
},
};

export const createStylusDeployerCommand = {
command: "create-stylus-deployer",
describe: "deploys the stylus deployer contract",
builder: {
deployer: { string: true, describe: "account (see general help)" },
l3: { boolean: false, describe: "deploy on L3, otherwise deploy on L2" },
},
handler: async (argv: any) => {
console.log("create-stylus-deployer");

const provider = new ethers.providers.WebSocketProvider(argv.l3 ? argv.l3url : argv.l2url);
const deployerWallet = namedAccount(argv.deployer).connect(provider);

const stylusDeployerAddress = await createStylusDeployer(deployerWallet);
if (argv.l3) {
console.log("Stylus deployer deployed at L3 address:", stylusDeployerAddress);
} else {
console.log("Stylus deployer deployed at L2 address:", stylusDeployerAddress);
}

provider.destroy();
}
};

export const sendL1Command = {
command: "send-l1",
describe: "sends funds between l1 accounts",
Expand Down
2 changes: 2 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
createERC20Command,
deployExpressLaneAuctionContractCommand,
createWETHCommand,
createStylusDeployerCommand,
transferERC20Command,
sendL1Command,
sendL2Command,
Expand Down Expand Up @@ -56,6 +57,7 @@ async function main() {
.command(deployExpressLaneAuctionContractCommand)
.command(createFeeTokenPricerCommand)
.command(createWETHCommand)
.command(createStylusDeployerCommand)
.command(transferERC20Command)
.command(sendL1Command)
.command(sendL2Command)
Expand Down
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
"dependencies": {
"@arbitrum/nitro-contracts": "^2.1.1",
"@arbitrum/nitro-contracts": "^3.1.0",
"@arbitrum/token-bridge-contracts": "1.2.0",
"@node-redis/client": "^1.0.4",
"@openzeppelin/contracts": "^4.9.3",
Expand Down
18 changes: 17 additions & 1 deletion scripts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
optionalDependencies:
sol2uml "2.2.0"

"@arbitrum/nitro-contracts@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@arbitrum/nitro-contracts/-/nitro-contracts-3.1.0.tgz#89488e798593dd8d36f44ab1f684e47410e375a1"
integrity sha512-/nDcQ3bZ5D761vv5I2r2gS+HeMTj9A2wgKzSWGTkqJ1ewzz8b1892OLBWgNja24J5daBTgGYV4vlxT+75478+w==
dependencies:
"@offchainlabs/upgrade-executor" "1.1.0-beta.0"
"@openzeppelin/contracts" "4.7.3"
"@openzeppelin/contracts-upgradeable" "4.7.3"
patch-package "^6.5.1"
solady "0.0.182"

"@arbitrum/[email protected]":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@arbitrum/token-bridge-contracts/-/token-bridge-contracts-1.2.0.tgz#b1dc02e123393848d0d8e5c167028bafa0ac8229"
Expand Down Expand Up @@ -2198,7 +2209,7 @@ parse5@^7.0.0:
dependencies:
entities "^4.4.0"

patch-package@^6.4.7:
patch-package@^6.4.7, patch-package@^6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.5.1.tgz#3e5d00c16997e6160291fee06a521c42ac99b621"
integrity sha512-I/4Zsalfhc6bphmJTlrLoOcAF87jcxko4q0qsv4bGcurbr8IskEOtdnt9iCmsQVGL1B+iUhSQqweyTLJfCF9rA==
Expand Down Expand Up @@ -2522,6 +2533,11 @@ [email protected]:
js-graph-algorithms "^1.0.18"
klaw "^4.0.1"

[email protected]:
version "0.0.182"
resolved "https://registry.yarnpkg.com/solady/-/solady-0.0.182.tgz#bd8c47f128a3a752358ad052782773966d74c400"
integrity sha512-FW6xo1akJoYpkXMzu58/56FcNU3HYYNamEbnFO3iSibXk0nSHo0DV2Gu/zI3FPg3So5CCX6IYli1TT1IWATnvg==

solidity-ast@^0.4.51:
version "0.4.55"
resolved "https://registry.yarnpkg.com/solidity-ast/-/solidity-ast-0.4.55.tgz#00b685e6eefb2e8dfb67df1fe0afbe3b3bfb4b28"
Expand Down
6 changes: 6 additions & 0 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ if $force_init; then
echo == Deploy CacheManager on L2
docker compose run -e CHILD_CHAIN_RPC="http://sequencer:8547" -e CHAIN_OWNER_PRIVKEY=$l2ownerKey rollupcreator deploy-cachemanager-testnode

echo == Deploy Stylus Deployer on L2
docker compose run scripts create-stylus-deployer --deployer l2owner

if $l3node; then
echo == Funding l3 users
docker compose run scripts send-l2 --ethamount 1000 --to validator --wait
Expand Down Expand Up @@ -661,6 +664,9 @@ if $force_init; then
echo == Deploy CacheManager on L3
docker compose run -e CHILD_CHAIN_RPC="http://l3node:3347" -e CHAIN_OWNER_PRIVKEY=$l3ownerkey rollupcreator deploy-cachemanager-testnode

echo == Deploy Stylus Deployer on L3
docker compose run scripts create-stylus-deployer --deployer l3owner --l3

echo == create l3 traffic
docker compose run scripts send-l3 --ethamount 10 --to user_traffic_generator --wait
docker compose run scripts send-l3 --ethamount 0.0001 --from user_traffic_generator --to user_traffic_generator --wait --delay 5000 --times 1000000 > /dev/null &
Expand Down