Skip to content

Commit

Permalink
Merge branch 'integration' into espresso-demo-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nomaxg committed Sep 21, 2023
2 parents e81b66f + c6f2a6e commit 38449bb
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,14 @@ jobs:
description: The make target to use to test the devnet
type: string
default: devnet-test
devnet-up-2:
description: A make target to start an optional second devnet
type: string
default: ""
devnet-test-2:
description: A make target to test the optional second devnet
type: string
default: ""
steps:
- checkout
- check-changed:
Expand Down Expand Up @@ -1011,9 +1019,21 @@ jobs:
- run:
name: Bring up the stack
command: make <<parameters.devnet-up>>
- when:
condition: <<parameters.devnet-up-2>>
steps:
- run:
name: Bring up the second stack
command: make <<parameters.devnet-up-2>>
- run:
name: Test the stack
command: make <<parameters.devnet-test>>
- when:
condition: <<parameters.devnet-test-2>>
steps:
- run:
name: Test the second stack
command: make <<parameters.devnet-test-2>>
- run:
name: Dump op-node logs
command: |
Expand Down Expand Up @@ -1216,6 +1236,8 @@ workflows:
name: devnet-espresso
devnet-up: devnet-up-espresso
devnet-test: devnet-test-espresso
devnet-up-2: devnet-up-espresso2
devnet-test-2: devnet-test-espresso2
requires:
- pnpm-monorepo
- go-lint-test-build:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ COMPOSEFLAGS=-d
ITESTS_L2_HOST=http://localhost:9545
BEDROCK_TAGS_REMOTE?=origin
DEVNET_ESPRESSO_FLAGS=--espresso --deploy-config="devnetL1-espresso.json" --deploy-config-template="devnetL1-espresso-template.json" --deployment="devnetL1-espresso" --devnet-dir=".devnet-espresso" --l2-provider-url="http://localhost:19090"
DEVNET_ESPRESSO_OP2_FLAGS=--espresso --deploy-config="devnetL1-espresso2.json" --deploy-config-template="devnetL1-espresso2-template.json" --deployment="devnetL1-espresso2" --devnet-dir=".devnet-espresso2" --l2-provider-url="http://localhost:29090" --l2="op2"
DEVNET_ESPRESSO_DEMO_FLAGS=--espresso --deploy-config="espresso-demo.json" --deploy-config-template="espresso-demo-template.json" --deployment="espresso-demo" --devnet-dir=".espresso-demo" --l2-provider-url="http://localhost:19090" --l2="op" --compose-file "demo-docker-compose.yml"
DEVNET_ESPRESSO_OP2_FLAGS=--espresso --deploy-config="devnetL1-espresso2.json" --deploy-config-template="devnetL1-espresso2-template.json" --deployment="devnetL1-espresso2" --devnet-dir=".devnet-espresso2" --l2-provider-url="http://localhost:29090" --faucet-url="http://localhost:28111" --l2="op2"
DEVNET_ESPRESSO_DEMO_FLAGS=--espresso --deploy-config="espresso-demo.json" --deploy-config-template="espresso-demo-template.json" --deployment="espresso-demo" --devnet-dir=".espresso-demo" --l2-provider-url="http://localhost:19090" --l2="op" --compose-file "demo-docker-compose.yml" --faucet-url="http://localhost:28111"
monorepo-base := $(realpath .)

build: build-go build-ts
Expand Down
13 changes: 10 additions & 3 deletions bedrock-devnet/devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
parser.add_argument('--test', help='Tests the deployment, must already be deployed', type=bool, action=argparse.BooleanOptionalAction)
parser.add_argument('--l2', help='Which L2 to run', type=str, default='op1')
parser.add_argument('--l2-provider-url', help='URL for the L2 RPC node', type=str, default='http://localhost:19545')
parser.add_argument('--faucet-url', help='URL for the L2 faucet', type=str, default='http://localhost:18111')
parser.add_argument('--deploy-l2', help='Deploy the L2 onto a running L1 and sequencer network', type=bool, action=argparse.BooleanOptionalAction)
parser.add_argument('--deploy-config', help='Deployment config, relative to packages/contracts-bedrock/deploy-config', default='devnetL1.json')
parser.add_argument('--deploy-config-template', help='Deployment config template, relative to packages/contracts-bedrock/deploy-config', default='devnetL1-template.json')
Expand Down Expand Up @@ -94,7 +95,7 @@ def main():

if args.test:
log.info('Testing deployed devnet')
devnet_test(paths, args.l2_provider_url)
devnet_test(paths, args.l2_provider_url, args.faucet_url)
return

os.makedirs(devnet_dir, exist_ok=True)
Expand Down Expand Up @@ -304,7 +305,7 @@ def devnet_deploy(paths, args):
# If we are deploying onto an existing L1, don't restart the services that are already
# running.
command.append('--no-recreate')
services = [f'{l2}-node', f'{l2}-proposer', f'{l2}-batcher']
services = [f'{l2}-node', f'{l2}-proposer', f'{l2}-batcher', f'{l2}-faucet']
run_command(command + services, cwd=paths.ops_bedrock_dir, env={
'PWD': paths.ops_bedrock_dir,
'L2OO_ADDRESS': l2_output_oracle,
Expand Down Expand Up @@ -369,7 +370,7 @@ def deploy_erc20(paths, l2_provider_url):
timeout=60,
)

def devnet_test(paths, l2_provider_url):
def devnet_test(paths, l2_provider_url, faucet_url):
# Check the L2 config
run_command(
['go', 'run', 'cmd/check-l2/main.go', '--l2-rpc-url', l2_provider_url, '--l1-rpc-url', 'http://localhost:8545'],
Expand All @@ -388,6 +389,12 @@ def devnet_test(paths, l2_provider_url):
timeout=8*60,
)

run_command(
['npx', 'hardhat', 'faucet-request', '--network', 'devnetL1', '--l2-provider-url', l2_provider_url, '--faucet-url', faucet_url],
cwd=paths.sdk_dir,
timeout=8*60,
)

def run_command(args, check=True, shell=False, cwd=None, env=None, timeout=None, capture_output=False):
env = env if env else {}
return subprocess.run(
Expand Down
2 changes: 2 additions & 0 deletions ops-bedrock/.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OP1_BATCHER_DEBUG_PORT=16061
OP1_BATCHER_METRICS_PORT=17301
OP1_BATCHER_RPC_PORT=16545
OP1_GETH_PROXY_PORT=19090
OP1_FAUCET_PORT=18111

### Rollup 901 block explorer
OP1_BLOCKSCOUT_PORT=14000
Expand All @@ -41,6 +42,7 @@ OP2_BATCHER_DEBUG_PORT=26061
OP2_BATCHER_METRICS_PORT=27301
OP2_BATCHER_RPC_PORT=26545
OP2_GETH_PROXY_PORT=29090
OP2_FAUCET_PORT=28111

### Rollup 902 block explorer
OP2_BLOCKSCOUT_PORT=24000
Expand Down
17 changes: 17 additions & 0 deletions ops-bedrock/demo-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ services:
networks:
- espresso-sequencer

op-faucet:
image: ghcr.io/espressosystems/discord-faucet:main
ports:
- "$OP1_FAUCET_PORT:8111"
environment:
- ESPRESSO_DISCORD_FAUCET_NUM_CLIENTS=1
- ESPRESSO_DISCORD_FAUCET_MNEMONIC=test test test test test test test test test test test junk
- ESPRESSO_DISCORD_FAUCET_FIRST_ACCOUNT_INDEX=5
- ESPRESSO_DISCORD_FAUCET_GRANT_AMOUNT_ETHERS=0.1
- ESPRESSO_DISCORD_FAUCET_WEB3_PROVIDER_URL_HTTP=http://op-geth-proxy:9090
- ESPRESSO_DISCORD_FAUCET_POLL_INTERVAL=2s
- RUST_LOG
depends_on:
- op-geth-proxy
networks:
- espresso-sequencer

artifact-server:
image: nginx:1.25-alpine
ports:
Expand Down
30 changes: 30 additions & 0 deletions ops-bedrock/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"

op1-faucet:
image: ghcr.io/espressosystems/discord-faucet:main
ports:
- "$OP1_FAUCET_PORT:8111"
environment:
- ESPRESSO_DISCORD_FAUCET_NUM_CLIENTS=1
- ESPRESSO_DISCORD_FAUCET_MNEMONIC=test test test test test test test test test test test junk
- ESPRESSO_DISCORD_FAUCET_FIRST_ACCOUNT_INDEX=5
- ESPRESSO_DISCORD_FAUCET_GRANT_AMOUNT_ETHERS=0.1
- ESPRESSO_DISCORD_FAUCET_WEB3_PROVIDER_URL_HTTP=http://op1-geth-proxy:9090
- ESPRESSO_DISCORD_FAUCET_POLL_INTERVAL=2s
- RUST_LOG
depends_on:
- op1-geth-proxy

artifact-server:
depends_on:
- l1
Expand Down Expand Up @@ -420,6 +435,21 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"

op2-faucet:
image: ghcr.io/espressosystems/discord-faucet:main
ports:
- "$OP2_FAUCET_PORT:8111"
environment:
- ESPRESSO_DISCORD_FAUCET_NUM_CLIENTS=1
- ESPRESSO_DISCORD_FAUCET_MNEMONIC=test test test test test test test test test test test junk
- ESPRESSO_DISCORD_FAUCET_FIRST_ACCOUNT_INDEX=5
- ESPRESSO_DISCORD_FAUCET_GRANT_AMOUNT_ETHERS=0.1
- ESPRESSO_DISCORD_FAUCET_WEB3_PROVIDER_URL_HTTP=http://op2-geth-proxy:9090
- ESPRESSO_DISCORD_FAUCET_POLL_INTERVAL=2s
- RUST_LOG
depends_on:
- op2-geth-proxy

##################################################################################################
# OP stack 902 block explorer
#
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"hardhat-deploy": "^0.11.4",
"isomorphic-fetch": "^3.0.0",
"mocha": "^10.2.0",
"node-fetch": "^2.6.7",
"nyc": "^15.1.0",
"ts-node": "^10.9.1",
"typedoc": "^0.25.1",
Expand Down
55 changes: 55 additions & 0 deletions packages/sdk/tasks/faucet-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { task, types } from 'hardhat/config'
import { providers, utils } from 'ethers'
import fetch from 'node-fetch'

const GRANT_AMOUNT = utils.parseEther('0.1')

task('faucet-request', 'Deposits WETH9 onto L2.')
.addParam(
'l2ProviderUrl',
'L2 provider URL.',
'http://localhost:9545',
types.string
)
.addParam(
'faucetUrl',
'L2 faucet URL',
'http://localhost:18111',
types.string
)
.setAction(async (args, hre) => {
const signers = await hre.ethers.getSigners()
if (signers.length === 0) {
throw new Error('No configured signers')
}
// Use the last configured signer so we don't conflict with some other task
const provider = new providers.StaticJsonRpcProvider(args.l2ProviderUrl)
const signer = new hre.ethers.Wallet(
hre.network.config.accounts[0],
provider
)
const address = await signer.getAddress()
console.log(`Using signer ${address}`)

// Check the signer's balance before we do anything
const initialBalance = await signer.getBalance()
console.log(`Signer initial balance is ${initialBalance}`)

// Request from the faucet
const res = await fetch(`${args.faucetUrl}/faucet/request/${address}`, {
method: 'POST',
})
if (res.status !== 200) {
throw new Error(`Request failed with status ${res.status}`)
}

// Wait for our balance to increase.
for (;;) {
const balance = await signer.getBalance()
console.log(`Signer balance is ${balance}`)
if (balance >= initialBalance + GRANT_AMOUNT) {
break
}
await new Promise((resolve) => setTimeout(resolve, 1000))
}
})
1 change: 1 addition & 0 deletions packages/sdk/tasks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './deploy-erc20'
import './deposit-eth'
import './deposit-erc20'
import './faucet-request'
import './finalize-withdrawal'
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38449bb

Please sign in to comment.