diff --git a/.env b/.env index 26d7f53..ec37fc6 100644 --- a/.env +++ b/.env @@ -1,13 +1,26 @@ +#chain params CHAIN_PREFIX=bostrom +RPC_URL=http://localhost:26657 +GRPC_URL=http://localhost:9090 +GPRC_INSECURE=true + +#database params POSTGRES_FOLDER=$HOME/.cyberindex/postgres POSTGRES_HOST=localhost POSTGRES_PORT=5432 +POSTGRES_DB=cyberindex POSTGRES_USER=cyber POSTGRES_PASSWORD=1cyberindex1 POSTGRES_SSL=false + +#hasura params HASURA_PORT=8090 HASURA_ADMIN_SECRET=1hasura1 + +#indexing settings INDEX_WORKERS=1 -RPC_URL=http://localhost:26657 -GRPC_URL=http://localhost:9090 START_HEIGHT=1 +LISTEN_NEW_BLOCKS=true +PARSE_OLD_BLOCKS=true +PARSE_GENESIS=true +LOG_LEVEL=debug \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ccd6d60..fa1a07b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,11 +19,9 @@ ENV PATH="/usr/local/go/bin:$PATH" COPY . . -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a - RUN go mod download -RUN LINK_STATICALLY=true BUILD_TAGS="muslc" make build +RUN make build FROM ubuntu:22.04 @@ -33,7 +31,7 @@ WORKDIR /app COPY --from=builder /app/build/cyberindex /usr/bin/cyberindex -#COPY --from=builder /root/go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.5.0/internal/api/libwasmvm.x86_64.so /root/go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.5.0/internal/api/libwasmvm.x86_64.so +COPY --from=builder /root/go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.5.2/internal/api/libwasmvm.x86_64.so /root/go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.5.2/internal/api/libwasmvm.x86_64.so COPY ./entrypoint.sh /entrypoint.sh diff --git a/database/schema/gift_db.py b/database/create_cybergift_py/gift_db.py similarity index 100% rename from database/schema/gift_db.py rename to database/create_cybergift_py/gift_db.py diff --git a/database/schema/requirements.txt b/database/create_cybergift_py/requirements.txt similarity index 100% rename from database/schema/requirements.txt rename to database/create_cybergift_py/requirements.txt diff --git a/database/schema/00-cosmos.sql b/database/schema/000-cosmos.sql similarity index 100% rename from database/schema/00-cosmos.sql rename to database/schema/000-cosmos.sql diff --git a/database/schema/01-auth.sql b/database/schema/001-auth.sql similarity index 100% rename from database/schema/01-auth.sql rename to database/schema/001-auth.sql diff --git a/database/schema/02-bank.sql b/database/schema/002-bank.sql similarity index 100% rename from database/schema/02-bank.sql rename to database/schema/002-bank.sql diff --git a/database/schema/03-modules.sql b/database/schema/003-modules.sql similarity index 100% rename from database/schema/03-modules.sql rename to database/schema/003-modules.sql diff --git a/database/schema/04-consensus.sql b/database/schema/004-consensus.sql similarity index 100% rename from database/schema/04-consensus.sql rename to database/schema/004-consensus.sql diff --git a/database/schema/04-graph.sql b/database/schema/005-graph.sql similarity index 100% rename from database/schema/04-graph.sql rename to database/schema/005-graph.sql diff --git a/database/schema/05-grid.sql b/database/schema/006-grid.sql similarity index 100% rename from database/schema/05-grid.sql rename to database/schema/006-grid.sql diff --git a/database/schema/06-resources.sql b/database/schema/007-resources.sql similarity index 100% rename from database/schema/06-resources.sql rename to database/schema/007-resources.sql diff --git a/database/schema/08-liquidity.sql b/database/schema/008-liquidity.sql similarity index 100% rename from database/schema/08-liquidity.sql rename to database/schema/008-liquidity.sql diff --git a/database/schema/07-wasm.sql b/database/schema/009-wasm.sql similarity index 100% rename from database/schema/07-wasm.sql rename to database/schema/009-wasm.sql diff --git a/database/schema/cyber_gift.sql b/database/schema/010-cyber_gift.sql similarity index 100% rename from database/schema/cyber_gift.sql rename to database/schema/010-cyber_gift.sql diff --git a/database/schema/views.sql b/database/schema/011-views.sql similarity index 100% rename from database/schema/views.sql rename to database/schema/011-views.sql diff --git a/database/schema/setup.sh b/database/schema/setup.sh deleted file mode 100755 index 74a536c..0000000 --- a/database/schema/setup.sh +++ /dev/null @@ -1,11 +0,0 @@ -psql -f 00-cosmos.sql && -psql -f 01-auth.sql && -psql -f 02-bank.sql && -psql -f 03-modules.sql && -psql -f 04-consensus.sql && -psql -f 04-graph.sql && -psql -f 05-grid.sql && -psql -f 06-resources.sql && -psql -f 07-wasm.sql && -psql -f 08-liquidity.sql && -psql -f views.sql \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cbc0e07..c60fb6f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: container_name: cyberindex_postgres volumes: - $HOME/.cyberindex/postgres:/var/lib/postgresql/data - - ./database/schema/:/root/schema + - ./database/schema/:/docker-entrypoint-initdb.d/ environment: - POSTGRES_DB=${POSTGRES_DB} - POSTGRES_USER=${POSTGRES_USER} @@ -16,7 +16,7 @@ services: networks: - cyberindex-net ports: - - 127.0.0.1:${POSTGRES_DB_PORT}:5432 + - 127.0.0.1:${POSTGRES_PORT}:5432 hasura: image: hasura/graphql-engine:latest restart: always @@ -24,7 +24,7 @@ services: depends_on: - "postgres" environment: - HASURA_GRAPHQL_DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@172.28.1.2:${POSTGRES_PORT}/${POSTGRES_USER} + HASURA_GRAPHQL_DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@172.28.1.2:${POSTGRES_PORT}/${POSTGRES_DB} HASURA_GRAPHQL_ENABLE_CONSOLE: "true" HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log HASURA_GRAPHQL_ADMIN_SECRET: $HASURA_ADMIN_SECRET @@ -34,16 +34,15 @@ services: ports: - 127.0.0.1:${HASURA_PORT}:8080 cyberindex: - image: cyberd/cyberindex:v2.0.0-rc1 + image: cyberd/cyberindex:v2.0.0 restart: always + shm_size: 1g container_name: cyberindex volumes: - $HOME/.cyberindex/:/root/.cyberindex - .env:/.env networks: - cyberindex-net - ports: - - 127.0.0.1:${POSTGRES_DB_PORT}:5432 depends_on: - "postgres" networks: diff --git a/entrypoint.sh b/entrypoint.sh index 0b6120c..ddd3f3f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,20 +4,13 @@ if [ ! -d "/root/.cyberindex/" ] then export $(cat /.env) mkdir /root/.cyberindex - echo -e "chain:\n bech32_prefix: $CHAIN_PREFIX\n modules:\n - modules\n - messages\n - auth\n - consensus\n - daily refetch\n - message_type\n - bank\n - graph\n - grid\n - resources\n - wasm\nnode:\n type: remote\n config:\n rpc:\n client_name: \"cyberindex\"\n max_connections: 10\n address: \"$RPC_URL\"\n grpc:\n address: \"$GRPC_URL\"\n insecure: true\nparsing:\n workers: $INDEX_WORKERS\n start_height: $START_HEIGHT\n average_block_time: 5s\n listen_new_blocks: true\n parse_old_blocks: true\n parse_genesis: true\ndatabase:\n url: postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_USER?sslmode=disable&search_path=public\n max_open_connections: 1\n max_idle_connections: 1\n partition_size: 100000\n partition_batch: 1000\n ssl_mode_enable: \"$POSTGRES_SSL\"\n ssl_root_cert: \"\"\n ssl_cert: \"\"\n ssl_key: \"\"\nlogging:\n level: debug\n format: text\nactions:\n host: 127.0.0.1\n port: 3000" >> /root/.cyberindex/config.yaml -fi - -if [ -f "/root/.cyberindex/config.yaml" ] -then - export $(cat /.env) - rm /root/.cyberindex/config.yaml - echo -e "chain:\n bech32_prefix: $CHAIN_PREFIX\n modules:\n - modules\n - messages\n - auth\n - consensus\n - daily refetch\n - message_type\n - bank\n - graph\n - grid\n - resources\n - wasm\nnode:\n type: remote\n config:\n rpc:\n client_name: \"cyberindex\"\n max_connections: 10\n address: \"$RPC_URL\"\n grpc:\n address: \"$GRPC_URL\"\n insecure: true\nparsing:\n workers: $INDEX_WORKERS\n start_height: $START_HEIGHT\n average_block_time: 5s\n listen_new_blocks: true\n parse_old_blocks: true\n parse_genesis: true\ndatabase:\n url: postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_USER?sslmode=disable&search_path=public\n max_open_connections: 1\n max_idle_connections: 1\n partition_size: 100000\n partition_batch: 1000\n ssl_mode_enable: \"$POSTGRES_SSL\"\n ssl_root_cert: \"\"\n ssl_cert: \"\"\n ssl_key: \"\"\nlogging:\n level: debug\n format: text\nactions:\n host: 127.0.0.1\n port: 3000" > /root/.cyberindex/config.yaml + echo -e "chain:\n bech32_prefix: $CHAIN_PREFIX\n modules:\n - modules\n - messages\n - auth\n - consensus\n - daily refetch\n - message_type\n - bank\n - graph\n - grid\n - resources\n - wasm\nnode:\n type: remote\n config:\n rpc:\n client_name: \"cyberindex\"\n max_connections: 10\n address: \"$RPC_URL\"\n grpc:\n address: \"$GRPC_URL\"\n insecure: $GPRC_INSECURE\n workers: $INDEX_WORKERS\n start_height: $START_HEIGHT\n average_block_time: 5s\n listen_new_blocks: $LISTEN_NEW_BLOCKS\n parse_old_blocks: $PARSE_OLD_BLOCKS\n parse_genesis: $PARSE_GENESIS\ndatabase:\n url: postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB?sslmode=disable&search_path=public\n max_open_connections: 1\n max_idle_connections: 1\n partition_size: 100000\n partition_batch: 1000\n ssl_mode_enable: \"$POSTGRES_SSL\"\n ssl_root_cert: \"\"\n ssl_cert: \"\"\n ssl_key: \"\"\nlogging:\n level: $LOG_LEVEL\n format: text\nactions:\n host: 127.0.0.1\n port: 3000" >> /root/.cyberindex/config.yaml fi if [ ! -f "/root/.cyberindex/config.yaml" ] then export $(cat /.env) - echo -e "chain:\n bech32_prefix: $CHAIN_PREFIX\n modules:\n - modules\n - messages\n - auth\n - consensus\n - daily refetch\n - message_type\n - bank\n - graph\n - grid\n - resources\n - wasm\nnode:\n type: remote\n config:\n rpc:\n client_name: \"cyberindex\"\n max_connections: 10\n address: \"$RPC_URL\"\n grpc:\n address: \"$GRPC_URL\"\n insecure: true\nparsing:\n workers: $INDEX_WORKERS\n start_height: $START_HEIGHT\n average_block_time: 5s\n listen_new_blocks: true\n parse_old_blocks: true\n parse_genesis: true\ndatabase:\n url: postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_USER?sslmode=disable&search_path=public\n max_open_connections: 1\n max_idle_connections: 1\n partition_size: 100000\n partition_batch: 1000\n ssl_mode_enable: \"$POSTGRES_SSL\"\n ssl_root_cert: \"\"\n ssl_cert: \"\"\n ssl_key: \"\"\nlogging:\n level: debug\n format: text\nactions:\n host: 127.0.0.1\n port: 3000" >> /root/.cyberindex/config.yaml + echo -e "chain:\n bech32_prefix: $CHAIN_PREFIX\n modules:\n - modules\n - messages\n - auth\n - consensus\n - daily refetch\n - message_type\n - bank\n - graph\n - grid\n - resources\n - wasm\nnode:\n type: remote\n config:\n rpc:\n client_name: \"cyberindex\"\n max_connections: 10\n address: \"$RPC_URL\"\n grpc:\n address: \"$GRPC_URL\"\n insecure: $GPRC_INSECURE\n workers: $INDEX_WORKERS\n start_height: $START_HEIGHT\n average_block_time: 5s\n listen_new_blocks: $LISTEN_NEW_BLOCKS\n parse_old_blocks: $PARSE_OLD_BLOCKS\n parse_genesis: $PARSE_GENESIS\ndatabase:\n url: postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB?sslmode=disable&search_path=public\n max_open_connections: 1\n max_idle_connections: 1\n partition_size: 100000\n partition_batch: 1000\n ssl_mode_enable: \"$POSTGRES_SSL\"\n ssl_root_cert: \"\"\n ssl_cert: \"\"\n ssl_key: \"\"\nlogging:\n level: $LOG_LEVEL\n format: text\nactions:\n host: 127.0.0.1\n port: 3000" >> /root/.cyberindex/config.yaml fi exec "$@" diff --git a/scripts/start-docker.sh b/scripts/start-docker.sh deleted file mode 100644 index 8863216..0000000 --- a/scripts/start-docker.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/bash - -echo "Please put use your onw passwords in .env file. Do you want to proceed with current .env (y / n)?" -read -r CONT -echo -if [ "$CONT" = "y" ] -then - # temporeraly import variables - export $(cat .env) - - # build cyberindexer and run it in container - docker build -t cyberindex:latest . - - # run postgres and hasura in containers - docker-compose up -d postgres - sleep 10 - - docker-compose up -d graphql-engine - sleep 10 - - # init database with basic tables - docker exec -ti cyberindex_postgres psql -f /root/schema/00-cosmos.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/01-auth.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/02-bank.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/03-modules.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/04-graph.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/05-grid.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/06-resources.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/07-wasm.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - docker exec -ti cyberindex_postgres psql -f /root/schema/08-liquidity.sql -d $POSTGRES_DB_NAME -U $POSTGRES_USER_NAME - - docker run -d --name cyberindex --network="host" -v $HOME/.cyberindex:/root/.cyberindex cyberindex:latest - -else - echo "Done." -fi \ No newline at end of file diff --git a/scripts/stop-rm.sh b/scripts/stop-rm.sh deleted file mode 100755 index 6f9d131..0000000 --- a/scripts/stop-rm.sh +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/bash - -# Stops and rm all cyberindex docker containers - -docker stop cyberindex -docker stop cyberindex_postgres -docker stop cyberindex_hasura -docker rm cyberindex -docker rm cyberindex_postgres -docker rm cyberindex_hasura -docker network rm cyberindex_cyberindex-net -docker rmi cyberindex:latest -# rm -rf $HOME/.cyberindex # remove home directory with db \ No newline at end of file