8000 GitHub - evm20/safe-infrastructure: One `docker-compose.yml` file to rule them all
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

evm20/safe-infrastructure

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Safe Services Main Docker

This repository contains the minimum viable local setup for our backend services. The setup presented here, assumes that only L2 safes will be used. Additionally, we have tested this setup with the following versions:

  • CFG_VERSION=v2.6.0
  • CGW_VERSION=v3.10.0
  • TXS_VERSION=v3.4.7

You can change them to the version you are interested available in docker-hub but be aware that not all versions of our services are compatible with each other, so do so at your own risk.

Step 0: docker crash course (optional)

Building and running the whole setup can be done with the following commands:

docker compose build --force-rm
docker compose up
  • Accessing bash in your web containers can be achieved by:
docker exec -it safe-infrastructure_cfg-web_1 bash
docker exec -it safe-infrastructure_txs-web_1 bash

Ctrl+d will end interactive mode.

  • Accessing redis-cli in either redis can be achieved like so"
docker exec -it safe-infrastructure_cgw-redis_1 redis-cli
docker exec -it safe-infrastructure_txs-redis_1 redis-cli
  • Accessing postgres. The Safe Config and Safe transaction services share the same instance
docker exec -it safe-infrastructure_db_1 psql -U postgres

Step 1: setup your .env

We recommend using what is available in the .env.sample file as it contains versions of our services guaranteed to be compatible with each other:

cp .env.sample .env

Simply, edit your .env and set RPC_NODE_URL to the chain you want the services running against. Important Note: Only L2 safes are supported in the setup provided. Change this at your own risk.

Step 2: Setup djando superusers

You will need to identify the ID or name of the containers using docker ps. To create the default super user for the Safe Config Service, we run the following command:

docker exec safe-infrastructure_cfg-web_1 python src/manage.py createsuperuser --noinput

You can now access http://localhost:8000/cfg/admin/ and login using the credentials root/admin.

To achieve the same for the Safe Transaction service:

docker exec safe-infrastructure_txs-web_1 python manage.py createsuperuser --noinput

Note 1: note that the path to manage.py is different. In case you need to run other commands.

Note 2: remember to replace your container ID or name.

Step 3: Add your ChainInfo

We need to be able to define a ChainInfo object in the Safe Config service so that the Client Gateway knows the URL of the Safe Transaction service instance it needs to request against for a given safe.

In order to do this, we need to use manage.py from the Safe Config serivce. We start an interactive console like so:

docker exec -it safe-infrastructure_cfg-web_1 bash

Once inside the container, you have to define the object in the database. You can find an example for Rinkeby in this repository in the file json/rinkeby.json.

Now follow these steps:

  1. Put the json of your ChainInfo in your clipboard (cmd + c or ctrl + c), you can use the contents of json/rinkeby.json if you are setting up for rinkeby. Otherwise, be aware that the field pk in the json needs to correspond to the chain_id
  2. In your terminal where you have docker exec -it running paste the following:
cd src # this is where your "manage.py" file will be located
echo '[
    {
        "model": "chains.chain",
        "pk": 15555,
        "fields": {
            "relevance": 100,
            "name": "TrustEVMtestnet",
            "short_name": "Trust",
            "description": "Testnet for trustevm",
            "l2": true,
            "rpc_authentication": "NO_AUTHENTICATION",
            "rpc_uri": "https://api.testnet-dev.trust.one",
            "safe_apps_rpc_authentication": "NO_AUTHENTICATION",
            "safe_apps_rpc_uri": "https://api.testnet-dev.trust.one",
            "block_explorer_uri_address_template": "https://trustscan.one/address/{{address}}",
            "block_explorer_uri_tx_hash_template": "https://trustscan.one/tx/{{txHash}}",
            "currency_name": "EVM",
            "currency_symbol": "EVM",
            "currency_decimals": 18,
            "currency_logo_uri": "chains/123/currency_logo.jpg",
            "transaction_service_uri": "http://nginx:8000/txs",
            "vpc_transaction_service_uri": "http://nginx:8000/txs",
            "theme_text_color": "#0d004d",
            "theme_background_color": "#a3eb71",
            "ens_registry_address": null,
            "recommended_master_copy_version": "1.3.0"
        }
    }
]' > chain.json
python manage.py loaddata chain.json
  1. Verify that your ChainInfo was successfully added by going to http://localhost:8000/cfg/api/v1/chains.

Step 4: Add your webhooks

Our services invalidate the caches of the client gateway using webhooks. Both the Config and Transaction service need to be configured. For the Config service, unless you've changed the values in cgw.env and cfg.env then you don't need to do anything, otherwise:

# Inside the file "container_env_files/cfg.env"
#...
CGW_URL=http://nginx:8000/cgw
CGW_FLUSH_TOKEN=some_random_token

# Inside the file "container_env_files/cgw.env"
WEBHOOK_TOKEN=some_random_token

WEBHOOK_TOKEN and CGW_FLUSH_TOKEN must be the same.

For the Transactions service open a terminal in the container:

docker exec -it safe-infrastructure_txs-web_1 bash

Then use manage.py and the custom command for adding a webhook like so:

python manage.py add_webhook --url=http://nginx:8000/cgw/v1/hook/update/some_random_token

About

One `docker-compose.yml` file to rule them all

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%
0