Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Graph Container #98

Merged
merged 3 commits into from
Apr 22, 2020
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
1 change: 0 additions & 1 deletion aws/dev/full-node/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: "3"
services:
rollup-full-node:
image: <aws_account_id>.dkr.ecr.us-east-2.amazonaws.com/optimism/rollup-full-node:latest
depends_on: [ "geth_l2" ]
volumes:
- full-node-data:/mnt/full-node:rw
- l1-node-data:/mnt/l1-node:rw
Expand Down
2 changes: 1 addition & 1 deletion aws/dev/full-node/ecs-params.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 1
task_definition:
services:
full-node:
rollup-full-node:
cpu_shares: 25
mem_limit: 524288000
geth_l2:
Expand Down
81 changes: 68 additions & 13 deletions aws/synthetix/dev/full-node/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ version: "3"
services:
rollup-full-node:
image: <aws_account_id>.dkr.ecr.us-east-2.amazonaws.com/optimism/rollup-full-node:latest
depends_on: [ "geth_l2" ]
volumes:
- full-node-data:/mnt/full-node:rw
- l1-node-data:/mnt/l1-node:rw
- l2-node-data:/mnt/l2-node:rw
ports:
- 8545:8545
environment:
- STARTUP_WAIT_TIMEOUT=30
- CLEAR_DATA_KEY
- OPCODE_WHITELIST_MASK
- L1_SEQUENCER_MNEMONIC
- L2_TO_L1_MESSAGE_RECEIVER_ADDRESS
- L2_TO_L1_MESSAGE_FINALITY_DELAY_IN_BLOCKS
- L2_RPC_SERVER_HOST
- L2_RPC_SERVER_PORT
- L2_WALLET_MNEMONIC
- L2_WALLET_PRIVATE_KEY_PATH=/mnt/l2-node/private_key.txt
- L2_RPC_SERVER_PERSISTENT_DB_PATH=/mnt/full-node/level
- L2_WALLET_PRIVATE_KEY=0x29f3edee0ad3abf8e2699402e0e28cd6492c9be7eaab00d732a791c33552f797
- LOCAL_L1_NODE_PORT
- LOCAL_L1_NODE_PERSISTENT_DB_PATH=/mnt/l1-node
- L2_NODE_WEB3_URL=http://0.0.0.0:9545/

logging:
driver: awslogs
options:
awslogs-group: rollup-full-node
awslogs-group: synthetix-dev-full-node
awslogs-region: us-east-2
awslogs-stream-prefix: l2-rpc-server

Expand All @@ -34,30 +35,84 @@ services:
volumes:
- l2-node-data:/mnt/l2-node/l2:rw
environment:
- CLEAR_DATA_KEY
- VOLUME_PATH=/mnt/l2-node/l2
- HOSTNAME=0.0.0.0
- PORT=9545
- NETWORK_ID=108
- KEYSTORE_PATH_SUFFIX=/keystore
- SEALER_PRIVATE_KEY_PATH_SUFFIX=/sealer_private_key.txt
- PRIVATE_KEY_PATH_SUFFIX=/private_key.txt
- ADDRESS_PATH_SUFFIX=/address.txt
- SEALER_ADDRESS_PATH_SUFFIX=/sealer_address.txt
- INITIAL_BALANCE=0x200000000000000000000000000000000000000000000000000000000000000
- GENISIS_PATH=etc/rollup-fullnode.json
- SETUP_RUN_PATH_SUFFIX=/setup_run.txt
ports:
- 9545:9545

logging:
driver: awslogs
options:
awslogs-group: rollup-full-node
awslogs-group: synthetix-dev-full-node
awslogs-region: us-east-2
awslogs-stream-prefix: l2-node

graph-node:
image: <aws_account_id>.dkr.ecr.us-east-2.amazonaws.com/optimism/the-graph:latest
ports:
- '8000:8000'
- '8001:8001'
- '8020:8020'
- '8030:8030'
- '8040:8040'
environment:
postgres_host: 0.0.0.0:5432
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: '0.0.0.0:5001'
ethereum: 'ovm:http://0.0.0.0:8545'
RUST_LOG: info
STARTUP_WAIT_TIMEOUT: 30
OVM_URL_WITH_PORT: 'http://0.0.0.0:8545'

logging:
driver: awslogs
options:
awslogs-group: synthetix-dev-full-node
awslogs-region: us-east-2
awslogs-stream-prefix: the-graph

ipfs:
image: ipfs/go-ipfs:v0.4.23
ports:
- '5001:5001'
volumes:
- ipfs-data:/data/ipfs

logging:
driver: awslogs
options:
awslogs-group: synthetix-dev-full-node
awslogs-region: us-east-2
awslogs-stream-prefix: the-graph-ipfs

postgres:
image: postgres
ports:
- '5432:5432'
command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
environment:
POSTGRES_USER: graph-node
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph-node
volumes:
- postgres-data:/var/lib/postgresql/data

logging:
driver: awslogs
options:
awslogs-group: synthetix-dev-full-node
awslogs-region: us-east-2
awslogs-stream-prefix: the-graph-postgres

volumes:
full-node-data:
l1-node-data:
l2-node-data:
postgres-data:
ipfs-data:

28 changes: 23 additions & 5 deletions aws/synthetix/dev/full-node/ecs-params.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
version: 1
task_definition:
services:
full-node:
cpu_shares: 25
rollup-full-node:
cpu_shares: 20
mem_limit: 524288000
geth_l2:
cpu_shares: 75
mem_limit: 1523288000
cpu_shares: 60
mem_limit: 1597847999
graph-node:
cpu_shares: 10
mem_limit: 524288000
ipfs:
cpu_shares: 5
mem_limit: 524288000
postgres:
cpu_shares: 5
mem_limit: 524288000


# This is all local for now -- eventually will change
ecs_network_mode: host
docker_volumes:
Expand All @@ -22,4 +33,11 @@ task_definition:
scope: shared
autoprovision: true
driver: 'local'

- name: postgres-data
scope: shared
autoprovision: true
driver: 'local'
- name: ipfs-data
scope: shared
autoprovision: true
driver: 'local'
32 changes: 32 additions & 0 deletions docker/publish-the-graph-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# Publish The Graph Container
# Optional 1st argument is tag name. Default is 'latest'.

set -e

if [ $# -eq 1 ]; then
THE_GRAPH_TAG=$1
echo "Found tag '$THE_GRAPH_TAG'. Using this as the container tag."
fi

BASE_DIR=$(dirname $0)
TAG=${THE_GRAPH_TAG:-latest}

if [ -z "$AWS_ACCOUNT_NUMBER" ]; then
echo "No AWS_ACCOUNT_NUMBER env variable is set. Please set it to use this script."
exit 1
fi

echo "\nAuthenticating within ECR...\n"
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/the-graph"

echo "\nBuilding The Graph container...\n"
docker build -t "optimism/the-graph:$TAG" "$BASE_DIR/the-graph/."

echo "\nTagging The Graph container as $TAG in ECR...\n"
docker tag "optimism/the-graph:$TAG" "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/the-graph:$TAG"

echo "\nPushing The Graph container to ECR...\n"
docker push "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/the-graph:$TAG"

echo "\nPublish complete!"
67 changes: 67 additions & 0 deletions docker/the-graph/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM rust:latest

# Replace this with the graph-node branch you want to build the image from;
# Note: Docker Hub substitutes this automatically using our hooks/post_checkout script.
ENV SOURCE_BRANCH "master"

# Install clang (required for dependencies)
RUN apt-get update \
&& apt-get install -y clang libclang-dev

# Clone and build the graph-node repository
RUN git clone https://github.com/ethereum-optimism/graph-node.git \
&& cd graph-node \
&& git checkout "$SOURCE_BRANCH" \
&& cargo install --locked --path node \
&& cp docker/start-node /usr/local/bin \
&& cd .. \
&& rm -rf graph-node

# Clone and install wait-for-it
RUN git clone https://github.com/vishnubob/wait-for-it.git \
&& cp wait-for-it/wait-for-it.sh /usr/local/bin \
&& chmod +x /usr/local/bin/wait-for-it.sh \
&& rm -rf wait-for-it

ENV RUST_LOG ""
ENV GRAPH_LOG ""
ENV EARLY_LOG_CHUNK_SIZE ""
ENV ETHEREUM_RPC_PARALLEL_REQUESTS ""
ENV ETHEREUM_BLOCK_CHUNK_SIZE ""

ENV postgres_host ""
ENV postgres_user ""
ENV postgres_pass ""
ENV postgres_db ""
ENV ipfs ""
ENV ethereum ""

# HTTP port
EXPOSE 8000

# WebSocket port
EXPOSE 8001

# JSON-RPC port
EXPOSE 8020

RUN apt-get install gawk

COPY wait-for-ovm.sh /usr/local/bin

# Wait for IPFS and Postgres to start up.
#
# The awk commands below take the IPFS and Postgres and extract
# hostname:port from them. The IPFS port defaults to 443 for HTTPS
# and 80 for HTTP. The Postgres port defaults to 5432.
CMD wait-for-ovm.sh \
&& wait-for-it.sh \
$(echo $ipfs | \
gawk 'match($0, /^([a-z]+:\/\/)?([^\/:]+)(:([0-9]+))?.*$/, m) { print m[2]":"(m[4] ? m[4] : (m[1] == "https://" ? 443 : 80)) }') \
-t 30 \
&& wait-for-it.sh \
$(echo $postgres_host | \
gawk 'match($0, /^([a-z]+:\/\/)?([^\/:]+)(:([0-9]+))?.*$/, m) { print m[2]":"(m[4] ? m[4] : 5432) }') \
-t 30 \
&& sleep 5 \
&& start-node
34 changes: 34 additions & 0 deletions docker/the-graph/wait-for-ovm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
# wait-for-ovm.sh <ovm url with port>

set -e

if [ -z "$OVM_URL_WITH_PORT" ]; then
echo "Must set environment variable OVM_URL_WITH_PORT"
exit 1
fi

STARTUP_WAIT_TIMEOUT=${STARTUP_WAIT_TIMEOUT:-20}

wait_for_server_to_be_reachable()
{
if [ -n "$1" ]; then
COUNT=1
until $(curl --output /dev/null --silent --fail -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "id": 9999999, "method": "net_version"}' $1); do
sleep 1
echo "Slept $COUNT times for $1 to be up..."

if [ "$COUNT" -ge "$STARTUP_WAIT_TIMEOUT" ]; then
echo "Timeout waiting for server at $1"
exit 1
fi
COUNT=$(($COUNT+1))
done
fi


}

wait_for_server_to_be_reachable $OVM_URL_WITH_PORT

>&2 echo "OVM is up!"
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ class SimpleStorageStressTest extends FullNodeStressTest {
}
}

new SimpleStorageStressTest(100, 'http://0.0.0.0:8545').run()
new SimpleStorageStressTest(10, 'http://0.0.0.0:8545').runBatches(1000)
14 changes: 14 additions & 0 deletions packages/test-ovm-full-node/src/stress-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ export abstract class FullNodeStressTest {
return results
}

/**
* Runs numBatches consecutive stress tests of numberOfRequests.
*
* @param numBatches The number of batches to run
* @returns The TestResult for each batch
*/
public async runBatches(numBatches: number): Promise<Array<TestResult>> {
const toReturn: TestResult[] = []
for (let i = 0; i < numBatches; i++) {
toReturn.push(await this.run())
}
return toReturn
}

/**
* Deploys the contract to be used for this stress test.
*/
Expand Down