Skip to content

Commit

Permalink
Merge pull request #2 from EspressoSystems/jh/deploy
Browse files Browse the repository at this point in the history
Local dev env with Espresso Sequencer
  • Loading branch information
ImJeremyHe authored Nov 16, 2023
2 parents 179cf31 + af0a81d commit 7c8b39a
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -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
117 changes: 117 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions espresso.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS="0x217788c286797d56cd59af5e493f3699c39cbbe8"
4 changes: 3 additions & 1 deletion scripts/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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))
Expand Down
14 changes: 12 additions & 2 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ function writeConfigs(argv: any) {
"execution": {
"sequencer": {
"enable": false,
}
"espresso": false,
"hotshot-url": "",
"espresso-namespace": 100,
},
},
"node": {
"staker": {
Expand All @@ -185,6 +188,7 @@ function writeConfigs(argv: any) {
"strategy": "MakeNodes",
},
"sequencer": false,
"espresso": false,
"delayed-sequencer": {
"enable": false
},
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 19 additions & 1 deletion test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ consensusclient=false
redundantsequencers=0
dev_build_nitro=false
dev_build_blockscout=false
espresso=false
batchposters=1
devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
l1chainid=1337
Expand Down Expand Up @@ -75,6 +76,10 @@ while [[ $# -gt 0 ]]; do
done
fi
;;
--espresso)
espresso=true
shift
;;
--build)
force_build=true
shift
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tokenbridge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 7c8b39a

Please sign in to comment.