This repo has been superseded by https://github.com/cerc-io/stack-orchestrator
Table of contents generated with markdown-toc
This repository serves many functions, but the primary function is to test various applications within the stack. Foundry is utilized primarily for testing geth within a test net.
The current applications that we can build using stack-orchestrator are:
lighthouse.vulcanize/go-ethereum.ipld-eth-db.prometheus.grafana.ipld-eth-beacon-indexer.ipld-eth-server.
This section will highlight how users can build the stack.
If you want to quickly get all the applications mentioned above cloned and running. Use the following guide.
-
Clone the stack-orchestrator repository.
# It is recommended that you utilize the directory below. mkdir -p ~/vulcanize cd ~/vulcanize git clone [email protected]:vulcanize/stack-orchestrator.git
-
Create a
config.shfile.cd stack-orchestrator/helper-scripts ./create-config.sh ## Optional flags # ./create-config.sh -b ~/GitHub/cerc -p ../local-config.sh
-
Run the setup script.
./setup-repositories.sh ## Optional Flags # ./setup-repositories.sh -c ../config.sh -p ssh # ./setup-repositories.sh -c ../local-config.sh -p ssh # ./setup-repositories.sh -c ../config.sh -p https
-
Optional - If you did not initially use
~/vulcanize, move thestack-orchestratordirectory to~/vulcanize. -
Optional - If you already have the repositories that the
setup-repositories.shscript clones for you, you can create alocal-config.shfile.# Example command ./create-config.sh -b ~/GitHub/cerc -p ../local-config.sh # Update all the file as you wish you reflect the location of each repository. vim local-config.sh
-
Checkout certain repositories to their desired branches: At a minimum perform the following (the branches below might be outdated, if you suspect they are, reach out to a core developer).
source config.sh
cd $vulcanize_test_contract ; git checkout sharding ; cd -
cd $vulcanize_eth_statediff_fill_service ; git checkout sharding; cd -
cd $vulcanize_go_ethereum ; git checkout v1.10.19-statediff-v4 ; cd -If you plan on doing local development, figure out a combination that works for you!
-
Build the entire stack. The
wrapper.shscript does all the heavy lifting. You can specify various flags and configurations to it (its helpful to run the script with the-hflag to see your options). Ultimately, you can string together various docker-compose files and spin up all the applications at once, or you can use certain shortcuts to build the entire stack.-
For building part of the stack.
./wrapper.sh -e docker \ -d ../docker/latest/docker-compose-db-sharding.yml \ -d ../docker/local/docker-compose-ipld-eth-server.yml \ -d ../docker/latest/docker-compose-lighthouse.yml \ -d ../docker/local/docker-compose-ipld-eth-beacon-indexer.yml \ -d ../docker/local/docker-compose-go-ethereum.yml \ -v remove \ -p ../config.sh
Remove lines for the parts of the stack you don’t want to build.
-
For building full stack with specified DB version (v3 or v4)
./wrapper.sh -f true \ -s v4 \ -l latest \ -p ../config.sh -
For building stack with auto mining of blocks
./wrapper.sh -f true \ -m true \ -s v4 \ -l latest \ -p ../config.sh
-
-
When you want to clean up your local environment, hit
ctrl + c. The bash script will remove all containers and any volumes created (if you specifyv remove).
A few important components for building the stack.
When building various parts of the stack, two main concepts are local and latest builds.
local- This option will build the specified component from a local repository.latest- This option will utilize the latest remote docker image.
We can only build several applications locally.
There is a local configuration file config.sh. When the applications are built locally, they find the path to the repository using this file. When working with the application locally, it is recommended to update the values in this file with your local paths.
This script does all the heavy lifting. It will do the following for you:
- (Optional) - Build
gethfor you. Either locally, on a remote server, or in a docker container. - Utilize
docker-composeto start the necessary services. - Stop and remove all containers when you do
ctrl + c.- (Optional) - Remove all volumes.
The docker-compose files found in docker/local and docker/latest are meant to be stand-alone files. You can pass in as many files as you want to the wrapper.sh script. A few notes on this:
- This lets you build as many services as you want and mix and match
localandlatestservices. - Be careful that you don’t spin up the
localandlatestservice at the same time.- For example, if you attempt to build pass
docker/local/docker-compose-db.ymlanddocker/latest/docker-compose-db.ymlat the same time you will run into an error. They both try to expose the same ports and share the same service name.
- For example, if you attempt to build pass
If you want to utilize stack-orchestrator within your CI/CD, you will do it as follows:
- Create a
Dockerfilewithin your repository. This Dockerfile should start you application. - Create a
docker-composefile forlocalandlatestwithin thedocker/directory instack-orchestrator. - Create a Github Action that is triggered by
pull_requestandworkflow_dispatch.- You must merge this file into
master/mainbefore being able to use it.workflow_dispatchwill not work unless it is inmaster/mainfirst. This is a design fault.
- You must merge this file into
- When referencing the stack-orchestrator repository, use a commit hash instead of using a branch name.
I followed this process for ipld-eth-beacon-indexer. Here are a few key files.
vulcanize/ipld-eth-beacon-indexer:Dockerfile- Compiles and starts the applicationvulcanize/stack-orchestrator:docker/local/docker-compose-ipld-eth-beacon-indexer.yml- Adocker-composefile to start the container.vulcanize/ipld-eth-beacon-indexer:.github/workflows/on-pr.yml- Automatically triggered onpull_request. If users ever need to reference a specific branch foripld-eth-dborstack-orchestrator, they can easily do so in theenvvariable.- You can also easily run this GHA manually and provide input parameters.
Here are a few notes to keep in mind. I highly recommend reading every bullet for all first-time users.
- If you want to build
gethremotely, talk to Shane to create a user onalabaster(or any other server you want).- I prefer to build remotely because the builds are performed on a Linux machine. When I try to build locally, I get portability issues.
- The command to deploy the smart contract is:
forge create --keystore $(cat ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE) --rpc-url http://127.0.0.1:8545 --constructor-args 1 --password $(cat ${ETHDIR}/config/password) --legacy /root/stateful/src/Stateful.sol:Stateful - The command to create a transaction (which will create a new block) is:
cast send --keystore $(cat ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE) --rpc-url http://127.0.0.1:8545 --password $(cat $(cat ~/transaction_info/ETHDIR)) --legacy $(cat ~/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS) "inc()" - To manually send a transaction (which will trigger the mining of a new block), simply run the following script:
~/transaction_info/NEW_TRANSACTION.- This script is only populated after the
start-private-network.shscript has been completed successfully.
- This script is only populated after the
- The
Dockerfilecompilescastandforge. - The
start-up-files/deploy-local-network.shfile does most heavy lifting for building a private network. It spins up geth and triggers various events. - The
start-up-files/start-private-network.shfile triggersdeploy-local-network.sh. This file runs all the tests. - The
gethnode will stay running even after the tests are terminated. - If you wish to use a local
genesis.jsonfile, do not add theallocorextra_datablock. The start-up script will do it for you.
- If you want to utilize Prometheus and Grafana. Do the following:
- Within your local
vulcanize/opsrepo, update the following filemetrics/etc/prometheus.yml. Update[localhost:6060]—>go-ethereum:6060.
- Within your local
Users might notice issues when attempting to build ipld-eth-server. If you are unable to build the application due to file permissions, it can be related to absolute path v relative path. Users might need to update local configurations, or update SELinux with the following command:
sudo su -c "setenforce 0"
Users might notice issues when attempting to build go-ethereum on M1 Macs. If this happens, you will either need to manually install geth in your helper-scripts directory OR run ./wrapper.sh using the -e remote flag to build the stack on a remote server:
cd helper-scripts
wget https://github.com/vulcanize/go-ethereum/releases/download/v1.10.19-statediff-4.0.3-alpha/geth-linux-amd64
Then rename it using:
mv geth-linux-amd64.1 geth-linux-amd64
./wrapper.sh \
-e remote \
-u <USERNAME> \
-n <HOSTNAME> \
-d "../docker/latest/docker-compose-db-sharding.yml" \
-d "../docker/local/docker-compose-go-ethereum.yml" \
-d "../docker/local/docker-compose-contract.yml" \
-v remove \
-p ../config.sh