diff --git a/.env b/.env new file mode 100644 index 00000000..4cc05cca --- /dev/null +++ b/.env @@ -0,0 +1,29 @@ +# Environment for local demo network. +# This file is meant to work with docker-compose.yaml + +RUST_LOG=info,libp2p=off +RUST_LOG_FORMAT=full + +L1_BLOCK_TIME_SEC=3 + +# Internal port inside container +ESPRESSO_WEB_SERVER_PORT=40000 +ESPRESSO_ORCHESTRATOR_PORT=40001 +ESPRESSO_CONSENSUS_SERVER_PORT=40002 +ESPRESSO_DA_SERVER_PORT=40003 +ESPRESSO_SEQUENCER_DA_SERVER_URL=http://da-server:$ESPRESSO_WEB_SERVER_PORT +ESPRESSO_SEQUENCER_CONSENSUS_SERVER_URL=http://consensus-server:$ESPRESSO_WEB_SERVER_PORT +ESPRESSO_SEQUENCER_ORCHESTRATOR_URL=http://orchestrator:$ESPRESSO_ORCHESTRATOR_PORT +ESPRESSO_SEQUENCER_API_PORT=50000 +ESPRESSO_SEQUENCER1_API_PORT=50001 +ESPRESSO_SEQUENCER_URL=http://espresso-sequencer0:$ESPRESSO_SEQUENCER_API_PORT +ESPRESSO_SEQUENCER_STORAGE_PATH=/store/sequencer +ESPRESSO_SEQUENCER_L1_PORT=8545 +ESPRESSO_SEQUENCER_L1_WS_PORT=8546 +ESPRESSO_SEQUENCER_L1_PROVIDER=http://geth:$ESPRESSO_SEQUENCER_L1_PORT +ESPRESSO_SEQUENCER_L1_WS_PROVIDER=ws://geth:$ESPRESSO_SEQUENCER_L1_WS_PORT +ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG=true +# A special account for `espresso-sequencer`, check `scripts/accounts.ts` for details. +ESPRESSO_SEQUENCER_ETH_MNEMONIC="indoor dish desk flag debris potato excuse depart ticket judge file exit" +ESPRESSO_SEQUENCER_HOTSHOT_ACCOUNT_INDEX=5 +ESPRESSO_COMMITMENT_TASK_PORT=60000 diff --git a/docker-compose.yaml b/docker-compose.yaml index 7f76bb9f..a2c28e04 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -337,6 +337,123 @@ services: - "sdk-data:/workspace" - /var/run/docker.sock:/var/run/docker.sock + orchestrator: + image: ghcr.io/espressosystems/espresso-sequencer/orchestrator:main + ports: + - "$ESPRESSO_ORCHESTRATOR_PORT:$ESPRESSO_ORCHESTRATOR_PORT" + environment: + - ESPRESSO_ORCHESTRATOR_PORT + - ESPRESSO_ORCHESTRATOR_NUM_NODES=2 + - ESPRESSO_ORCHESTRATOR_START_DELAY=5s + - ESPRESSO_ORCHESTRATOR_NEXT_VIEW_TIMEOUT=30s + - ESPRESSO_ORCHESTRATOR_MIN_TRANSACTIONS=1 + - ESPRESSO_ORCHESTRATOR_MIN_PROPOSE_TIME=0s + - ESPRESSO_ORCHESTRATOR_MAX_PROPOSE_TIME=1s + - RUST_LOG + - RUST_LOG_FORMAT + + da-server: + image: ghcr.io/espressosystems/espresso-sequencer/web-server:main + ports: + - "$ESPRESSO_DA_SERVER_PORT:$ESPRESSO_WEB_SERVER_PORT" + environment: + - ESPRESSO_WEB_SERVER_PORT + - RUST_LOG=error + - RUST_LOG_FORMAT + depends_on: + orchestrator: + condition: service_healthy + + consensus-server: + image: ghcr.io/espressosystems/espresso-sequencer/web-server:main + ports: + - "$ESPRESSO_CONSENSUS_SERVER_PORT:$ESPRESSO_WEB_SERVER_PORT" + environment: + - ESPRESSO_WEB_SERVER_PORT + - RUST_LOG=error + - RUST_LOG_FORMAT + depends_on: + orchestrator: + condition: service_healthy + + espresso-sequencer0: + image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main + ports: + - "$ESPRESSO_SEQUENCER_API_PORT:$ESPRESSO_SEQUENCER_API_PORT" + # Run the API server (with options taken from the environment) and the optional submission API + command: sequencer -- http -- query -- submit + environment: + - ESPRESSO_SEQUENCER_ORCHESTRATOR_URL + - ESPRESSO_SEQUENCER_DA_SERVER_URL + - ESPRESSO_SEQUENCER_CONSENSUS_SERVER_URL + - ESPRESSO_SEQUENCER_API_PORT + - ESPRESSO_SEQUENCER_STORAGE_PATH + - ESPRESSO_SEQUENCER_L1_WS_PROVIDER + - ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG + - RUST_LOG + - RUST_LOG_FORMAT + depends_on: + orchestrator: + condition: service_healthy + consensus-server: + condition: service_healthy + da-server: + condition: service_healthy + geth: + condition: service_started + + espresso-sequencer1: + image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main + ports: + - "$ESPRESSO_SEQUENCER1_API_PORT:$ESPRESSO_SEQUENCER_API_PORT" + # Run the API server (with options taken from the environment) + command: sequencer -- http -- query + environment: + - ESPRESSO_SEQUENCER_ORCHESTRATOR_URL + - ESPRESSO_SEQUENCER_DA_SERVER_URL + - ESPRESSO_SEQUENCER_CONSENSUS_SERVER_URL + - ESPRESSO_SEQUENCER_API_PORT + - ESPRESSO_SEQUENCER_STORAGE_PATH + - ESPRESSO_SEQUENCER_L1_WS_PROVIDER + - ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG + - RUST_LOG + - RUST_LOG_FORMAT + depends_on: + orchestrator: + condition: service_healthy + consensus-server: + condition: service_healthy + da-server: + condition: service_healthy + geth: + condition: service_started + + commitment-task: + image: ghcr.io/espressosystems/espresso-sequencer/commitment-task:main + ports: + - "$ESPRESSO_COMMITMENT_TASK_PORT:$ESPRESSO_COMMITMENT_TASK_PORT" + command: commitment-task --deploy + env_file: + - espresso.env + environment: + - ESPRESSO_SEQUENCER_ETH_MNEMONIC + - ESPRESSO_SEQUENCER_HOTSHOT_ACCOUNT_INDEX + - ESPRESSO_COMMITMENT_TASK_PORT + - ESPRESSO_SEQUENCER_URL + - ESPRESSO_SEQUENCER_L1_PROVIDER + - ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG + - RUST_LOG + - RUST_LOG_FORMAT + depends_on: + espresso-sequencer0: + condition: service_healthy + consensus-server: + condition: service_healthy + da-server: + condition: service_healthy + geth: + condition: service_started + volumes: l1data: consensus: diff --git a/espresso.env b/espresso.env new file mode 100644 index 00000000..0cec9def --- /dev/null +++ b/espresso.env @@ -0,0 +1 @@ +ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS="0x217788c286797d56cd59af5e493f3699c39cbbe8" diff --git a/scripts/accounts.ts b/scripts/accounts.ts index ae3cdf6e..1bbe4f77 100644 --- a/scripts/accounts.ts +++ b/scripts/accounts.ts @@ -5,7 +5,7 @@ import * as crypto from "crypto"; import { runStress } from "./stress"; const path = require("path"); -const specialAccounts = 5; +const specialAccounts = 6; async function writeAccounts() { for (let i = 0; i < specialAccounts; i++) { @@ -44,6 +44,8 @@ export function namedAccount( if (name == "l3sequencer") { return specialAccount(4); } + if (name == "espresso-sequencer") + return specialAccount(5); if (name.startsWith("user_")) { return new ethers.Wallet( ethers.utils.sha256(ethers.utils.toUtf8Bytes(name)) diff --git a/scripts/config.ts b/scripts/config.ts index be440671..a795056d 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -171,7 +171,10 @@ function writeConfigs(argv: any) { "execution": { "sequencer": { "enable": false, - } + "espresso": false, + "hotshot-url": "", + "espresso-namespace": 100, + }, }, "node": { "staker": { @@ -185,6 +188,7 @@ function writeConfigs(argv: any) { "strategy": "MakeNodes", }, "sequencer": false, + "espresso": false, "delayed-sequencer": { "enable": false }, @@ -246,8 +250,14 @@ function writeConfigs(argv: any) { let sequencerConfig = JSON.parse(baseConfJSON) sequencerConfig.execution.sequencer.enable = true sequencerConfig.node.sequencer = true - sequencerConfig.node["seq-coordinator"].enable = true sequencerConfig.node["delayed-sequencer"].enable = true + if (argv.espresso) { + sequencerConfig.node.espresso = true + sequencerConfig.execution.sequencer.espresso = true + sequencerConfig.execution.sequencer["hotshot-url"] = argv.espressoUrl + } else { + sequencerConfig.node["seq-coordinator"].enable = true + } fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(sequencerConfig)) let posterConfig = JSON.parse(baseConfJSON) diff --git a/scripts/index.ts b/scripts/index.ts index 62f3d49d..b919f788 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -28,6 +28,10 @@ async function main() { l2owner: { string: true, default: "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E" }, }) .options(stressOptions) + .options({ + espresso: { boolean: true, decription: 'use Espresso Sequencer for sequencing and DA', default: false }, + espressoUrl: { string: true, description: 'Espresso Sequencer url', default: 'http://espresso-sequencer0:50000' }, + }) .command(bridgeFundsCommand) .command(bridgeToL3Command) .command(sendL1Command) diff --git a/test-node.bash b/test-node.bash index 34c361e8..276b86ec 100755 --- a/test-node.bash +++ b/test-node.bash @@ -40,6 +40,7 @@ consensusclient=false redundantsequencers=0 dev_build_nitro=false dev_build_blockscout=false +espresso=false batchposters=1 devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 l1chainid=1337 @@ -75,6 +76,10 @@ while [[ $# -gt 0 ]]; do done fi ;; + --espresso) + espresso=true + shift + ;; --build) force_build=true shift @@ -200,6 +205,10 @@ fi if $blockscout; then NODES="$NODES blockscout" fi +if $espresso; then + NODES="$NODES orchestrator da-server consensus-server espresso-sequencer0 espresso-sequencer1 commitment-task" + +fi if $force_build; then echo == Building.. if $dev_build_nitro; then @@ -292,6 +301,7 @@ if $force_init; then echo == Funding validator and sequencer docker-compose run scripts send-l1 --ethamount 1000 --to validator --wait docker-compose run scripts send-l1 --ethamount 1000 --to sequencer --wait + docker-compose run scripts send-l1 --ethamount 1000 --to espresso-sequencer --wait echo == create l1 traffic docker-compose run scripts send-l1 --ethamount 1000 --to user_l1user --wait @@ -305,8 +315,16 @@ if $force_init; then docker-compose run --entrypoint /usr/local/bin/deploy poster --l1conn ws://geth:8546 --l1keystore /home/user/l1keystore --sequencerAddress $sequenceraddress --ownerAddress $sequenceraddress --l1DeployAccount $sequenceraddress --l1deployment /config/deployment.json --authorizevalidators 10 --wasmrootpath /home/user/target/machines --l1chainid=$l1chainid --l2chainconfig /config/l2_chain_config.json --l2chainname arb-dev-test --l2chaininfo /config/deployed_chain_info.json docker-compose run --entrypoint sh poster -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json" + + if $espresso; then + echo == Deploying Espresso Contract + echo "" > espresso.env + docker-compose up -d commitment-task espresso-sequencer0 espresso-sequencer1 --wait + espressol1contract=`curl http://localhost:60000/api/hotshot_contract` + echo "ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS=$espressol1contract" > espresso.env + fi echo == Writing configs - docker-compose run scripts write-config + docker-compose run scripts write-config --espresso $espresso echo == Initializing redis docker-compose run scripts redis-init --redundancy $redundantsequencers diff --git a/tokenbridge/Dockerfile b/tokenbridge/Dockerfile index 09156556..3cbc4d78 100644 --- a/tokenbridge/Dockerfile +++ b/tokenbridge/Dockerfile @@ -2,6 +2,6 @@ FROM node:16-bullseye-slim RUN apt-get update && \ apt-get install -y git docker.io WORKDIR /workspace -RUN git clone --depth 1 -b v3.1.4 https://github.com/OffchainLabs/arbitrum-sdk.git ./ +RUN git clone --depth 1 -b main https://github.com/EspressoSystems/arbitrum-sdk.git ./ RUN yarn install ENTRYPOINT ["yarn"]