diff --git a/.github/scripts/replace-aws-account-id.sh b/.github/scripts/replace-aws-account-id.sh new file mode 100755 index 000000000000..7fee21a441aa --- /dev/null +++ b/.github/scripts/replace-aws-account-id.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +sed -iE 's//'"$AWS_ACCOUNT_ID"'/g' ./docker-compose.ci.yml + diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 000000000000..25b5af2a9781 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,44 @@ +name: Setup & Run Integration Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + name: Setup & Run Integration Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-node@v1 + + - name: Replace Placeholder With AWS Account ID + env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_CI_AWS_ACCOUNT_ID }} + run: | + ./.github/scripts/replace-aws-account-id.sh + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_CI_USER_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_CI_USER_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Run Tests with Docker Compose + run: | + docker-compose -f docker-compose.ci.yml up --abort-on-container-exit --exit-code-from integration_tests + + - name: Logout of Amazon ECR + if: always() + run: docker logout ${{ steps.login-ecr.outputs.registry }} diff --git a/docker-compose.ci.env b/docker-compose.ci.env new file mode 100644 index 000000000000..108f546a1719 --- /dev/null +++ b/docker-compose.ci.env @@ -0,0 +1,103 @@ +######### LOCAL DEV ######### +REBUILD=1 # Set to anything to rebuild when running locally in Docker +FETCH_DEPS= # Set to anything to fetch deps when rebuilding locally in Docker + + +######### SHARED ######### +POSTGRES_PORT=5432 # (Required) Should almost always be 5432 +POSTGRES_USER=test # (Required) The user to use to connect to the db +POSTGRES_PASSWORD=test # (Required) The password to use to connect to the db + + +######### L2 GETH VARS ######### +TARGET_GAS_LIMIT +VOLUME_PATH=/mnt/l2-node/l2 +HOSTNAME=geth_l2 +PORT=8545 +NETWORK_ID=108 + + +######### MICROSERVICES ######### +### DEPLOYMENT ### +SHOULD_DEPLOY_CONTRACTS=1 +L1_CONTRACT_DEPLOYMENT_PRIVATE_KEY=df8b81d840b9cafc8cd68cf94f093726b174b5f109eba11a3f2a559e5f9e8bce +L1_SEQUENCER_ADDRESS=0xaaa6c3FBA9be28B4e4777Cdcb9Ed781199083358 +L1_CONTRACT_OWNER_ADDRESS=0xbbb3F0b64561dC149bf9c10e95f2D10AE552F25b +FORCE_INCLUSION_PERIOD_SECONDS=1500 + +LOG_NEW_LINES=1 # Logs new lines instead of <\n> + +# Container +STARTUP_WAIT_TIMEOUT=30 # The amount of times to attempt to connect to L2 geth before failing (set to -1 if not to wait for L2 geth). + +# Logging +DEBUG=info*,error*,warn*,debug* # The comma-separated logging patterns to match (common options are `error*`, `info*`, `warn*`, and `debug*`) + +# Postgres +POSTGRES_HOST=postgres # (Required) The host DNS entry / IP for the postgres DB +POSTGRES_DATABASE=rollup # (Required) The database name to connect to (should be `rollup`) +POSTGRES_CONNECTION_POOL_SIZE # The connection pool size for postgres (defaults to 20) +POSTGRES_USE_SSL # Set to anything to indicate that SSL should be used in the connection + +# L1 Node +L1_NODE_WEB3_URL=http://l1_chain:9545 # The URL of the L1 node +FINALITY_DELAY_IN_BLOCKS=1 # The number of block confirmations required to consider a transaction final on L1 + +# L2 Node +L2_NODE_WEB3_URL=http://geth_l2:8545 # The URL of the L2 node + +# L1 Submitters +L1_SEQUENCER_PRIVATE_KEY=df8b81d840b9cafc8cd68cf94f093726b174b5f109eba11a3f2a559e5f9e8bce # Address= 0xaaa6c3FBA9be28B4e4777Cdcb9Ed781199083358 # The private key to use to submit Sequencer Transaction Batches +L1_STATE_ROOT_SUBMITTER_PRIVATE_KEY=06caa6f48604a58872e27db8c2980584e20faab37613f51383bb5be62db80c50 # Address= 0xbbb3F0b64561dC149bf9c10e95f2D10AE552F25b # The private key to use to submit State Root Batches + +# Shared Contracts +CANONICAL_TRANSACTION_CHAIN_CONTRACT_ADDRESS=0xed31Ba5446D983cC6B128EEcd349D10bc0F80a66 # (Required) The address of the CanonicalTransactionChain contract +STATE_COMMITMENT_CHAIN_CONTRACT_ADDRESS=0x3A098b2982EC25772f16C57f2C1D0463E052ec59 # (Required) The address of the StateCommitmentChain contract + +# L1 Chain Data Persister (needs Postgres & L1 Node vars above) +L1_TO_L2_TRANSACTION_QUEUE_CONTRACT_ADDRESS=0xA1B22bF35196AFCE0927D94ce8ad4C4b7bb6F005 # (Required) The address of the L1ToL2TransactionQueue contract +SAFETY_TRANSACTION_QUEUE_CONTRACT_ADDRESS=0x3a3BEFB4942cF20A69C8eb4FDB8957223Da57fa2 # (Required) The address of the SafetyTransactionQueue contract +L1_CHAIN_DATA_PERSISTER_DB_PATH=/mnt/l1-node # (Required) The filepath where to locate (or create) the L1 Chain Data Persister LevelDB database +L1_EARLIEST_BLOCK=0 # (Required) The earliest block to sync on L1 to start persisting data + +# L2 Chain Data Persister (needs Postgres & L2 Node vars above) +L2_CHAIN_DATA_PERSISTER_DB_PATH=/mnt/l2-node # (Required) The filepath where to locate (or create) the L2 Chain Data Persister LevelDB database + +# Geth Submission Queuer (needs Postgres vars above) +IS_SEQUENCER_STACK=1 # (Required) Set if this is queueing Geth submissions for a sequencer (and not _just_ a verifier) +GETH_SUBMISSION_QUEUER_PERIOD_MILLIS=1000 # The period in millis at which the GethSubmissionQueuer should attempt to queue an L2 Geth submission (defaults to 10,000) + +# Queued Geth Submitter (needs Postgres & L2 Node vars above) +SUBMIT_TO_L2_PRIVATE_KEY=65b2a66430ebe04afd0471cfb309f1cd327f61bdfef6ba3cb082f3f85bc1264f # (Required) The PK to use to sign batches to send to geth (deprecated) +QUEUED_GETH_SUBMITTER_PERIOD_MILLIS=1000 # The period in millis at which the QueuedGethSubmitter should attempt to send L2 Geth submissions (defaults to 10,000) + +# Canonical Transaction Chain Batch Creator (needs Postgres vars above) +CANONICAL_CHAIN_MIN_BATCH_SIZE=1 # The minimum batch size to build -if fewer than this number of transactions are ready, a batch will not be created (defaults to 10) +CANONICAL_CHAIN_MAX_BATCH_SIZE=2 # The maximum batch size to build -if more than this number of transactions are ready, they will be split into multiple batches of at most this size (defaults to 100) +CANONICAL_CHAIN_BATCH_CREATOR_PERIOD_MILLIS=1000 # The period in millis at which the CanonicalChainBatchCreator should attempt to create Canonical Chain Batches (defaults to 10,000) + +# Canonical Transaction Chain Batch Submitter (needs Postgres, L1 Node, L1 Submitters, and CANONICAL_TRANSACTION_CHAIN_CONTRACT_ADDRESS vars above) +CANONICAL_CHAIN_BATCH_SUBMITTER_PERIOD_MILLIS=1000 # The period in millis at which the CanonicalChainBatchCreator should attempt to create Canonical Chain Batches (defaults to 10,000) + +# State Commitment Chain Batch Creator (needs Postgres vars above) +STATE_COMMITMENT_CHAIN_MIN_BATCH_SIZE=1 # The minimum batch size to build -if fewer than this number of transactions are ready, a batch will not be created (defaults to 10) +STATE_COMMITMENT_CHAIN_MAX_BATCH_SIZE=4 # The maximum batch size to build -if more than this number of transactions are ready, they will be split into multiple batches of at most this size (defaults to 100) +STATE_COMMITMENT_CHAIN_BATCH_CREATOR_PERIOD_MILLIS=1000 # The period in millis at which the StateCommitmentChainBatchCreator should attempt to create StateCommitmentChain Batches (defaults to 10,000) + +# State Commitment Chain Batch Submitter (needs Postgres, L1 Node, L1 Submitters, STATE_COMMITMENT_CHAIN_CONTRACT_ADDRESS vars above) +STATE_COMMITMENT_CHAIN_BATCH_SUBMITTER_PERIOD_MILLIS=1000 # The period in millis at which the StateCommitmentChainBatchCreator should attempt to create StateCommitmentChain Batches (defaults to 10,000) + +# Fraud Detector +FRAUD_DETECTOR_PERIOD_MILLIS=1000 # The period in millis at which the FraudDetector should run (defaults to 10,000) +REALERT_ON_UNRESOLVED_FRAUD_EVERY_N_FRAUD_DETECTOR_RUNS # The number of runs after which a detected fraud, if still present, should re-alert (via error logs) (defaults to 10) + +# Which Services to run (respective vars must be configured above) +RUN_L1_CHAIN_DATA_PERSISTER=1 # Set to anything to run L1 Chain Data Persister +RUN_L2_CHAIN_DATA_PERSISTER=1 # Set to anything to run L2 Chain Data Persister +RUN_GETH_SUBMISSION_QUEUER=1 # Set to anything to run Geth Submission Queuer +RUN_QUEUED_GETH_SUBMITTER=1 # Set to anything to run Queued Geth Submitter +RUN_CANONICAL_CHAIN_BATCH_CREATOR=1 # Set to anything to run Canonical Chain Batch Creator +RUN_CANONICAL_CHAIN_BATCH_SUBMITTER=1 # Set to anything to run Canonical Chain Batch Submitter +RUN_STATE_COMMITMENT_CHAIN_BATCH_CREATOR=1 # Set to anything to run State Commitment Chain Batch Creator +RUN_STATE_COMMITMENT_CHAIN_BATCH_SUBMITTER=1 # Set to anything to run State Commitment Chain Batch Submitter +RUN_FRAUD_DETECTOR=1 # Set to anything to run Fraud Detector diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml new file mode 100644 index 000000000000..390a226056b0 --- /dev/null +++ b/docker-compose.ci.yml @@ -0,0 +1,43 @@ +version: "3" + +services: + geth_l2: + build: + context: . + dockerfile: Dockerfile + volumes: + - l2-node-data:/mnt/l2-node/l2:rw + env_file: + - docker-compose.ci.env + ports: + - 8545:8545 + + microservices: + image: .dkr.ecr.us-east-2.amazonaws.com/optimism/rollup-microservices:latest + volumes: + - l1-node-data:/mnt/l1-node:rw + - l2-node-data:/mnt/l2-node:rw + env_file: + - docker-compose.ci.env + + integration_tests: + image: .dkr.ecr.us-east-2.amazonaws.com/optimism/integration-tests:latest + env_file: + - docker-compose.ci.env + + l1_chain: + image: trufflesuite/ganache-cli:latest + entrypoint: node /app/ganache-core.docker.cli.js -p 9545 --gasPrice="0x0" --callGasLimit="0x1fffffffffffff" --gasLimit="0x1fffffffffffff" --account="0xdf8b81d840b9cafc8cd68cf94f093726b174b5f109eba11a3f2a559e5f9e8bce,1000000000000000000000" --account="0x06caa6f48604a58872e27db8c2980584e20faab37613f51383bb5be62db80c50,100000000000000000000" + ports: + - 9545:9545 + + postgres: + image: .dkr.ecr.us-east-2.amazonaws.com/optimism/postgres:latest + env_file: + - docker-compose.ci.env + ports: + - 5432:5432 + +volumes: + l1-node-data: + l2-node-data: