From 22586a04bf7f5e7ddae09a24095b5781ed8e4025 Mon Sep 17 00:00:00 2001 From: Louis Holbrook Date: Fri, 12 Feb 2021 02:27:29 +0000 Subject: [PATCH] Correct db names and ports --- apps/cic-eth/cic_eth/eth/util.py | 4 ++ apps/cic-eth/cic_eth/queue/tx.py | 19 ++++------ apps/cic-eth/cic_eth/runnable/dispatcher.py | 2 +- apps/cic-eth/docker/Dockerfile | 5 +++ apps/contract-migration/reset.sh | 4 +- apps/contract-migration/seed_cic_eth.sh | 8 +++- docker-compose.yml | 42 +++++++++++++-------- 7 files changed, 53 insertions(+), 31 deletions(-) diff --git a/apps/cic-eth/cic_eth/eth/util.py b/apps/cic-eth/cic_eth/eth/util.py index 4bd2dea..d90c322 100644 --- a/apps/cic-eth/cic_eth/eth/util.py +++ b/apps/cic-eth/cic_eth/eth/util.py @@ -35,6 +35,10 @@ def unpack_signed_raw_tx(tx_raw_bytes, chain_id): if chain_id != 0: v = int.from_bytes(d[6], 'big') vb = v - (chain_id * 2) - 35 + while len(d[7]) < 32: + d[7] = b'\x00' + d[7] + while len(d[8]) < 32: + d[8] = b'\x00' + d[8] s = b''.join([d[7], d[8], bytes([vb])]) so = KeyAPI.Signature(signature_bytes=s) diff --git a/apps/cic-eth/cic_eth/queue/tx.py b/apps/cic-eth/cic_eth/queue/tx.py index bcc2bed..6dd72eb 100644 --- a/apps/cic-eth/cic_eth/queue/tx.py +++ b/apps/cic-eth/cic_eth/queue/tx.py @@ -557,27 +557,26 @@ def get_upcoming_tx(status=StatusEnum.READYSEND, recipient=None, before=None, ch :rtype: dict, with transaction hash as key, signed raw transaction as value """ session = SessionBase.create_session() - q = session.query( + q_outer = session.query( TxCache.sender, func.min(Otx.nonce).label('nonce'), ) - q = q.join(TxCache) - q = q.join(Lock, isouter=True) - q = q.filter(or_(Lock.flags==None, Lock.flags.op('&')(LockEnum.SEND.value)==0)) + q_outer = q_outer.join(TxCache) + q_outer = q_outer.join(Lock, isouter=True) + q_outer = q_outer.filter(or_(Lock.flags==None, Lock.flags.op('&')(LockEnum.SEND.value)==0)) if status >= StatusEnum.SENT: raise ValueError('not a valid non-final tx value: {}'.format(s)) - q = q.filter(Otx.status==status) + q_outer = q_outer.filter(Otx.status==status.value) if recipient != None: - q = q.filter(TxCache.recipient==recipient) + q_outer = q_outer.filter(TxCache.recipient==recipient) - q = q.group_by(TxCache.sender) + q_outer = q_outer.group_by(TxCache.sender) txs = {} - results = q.all() - for r in results: + for r in q_outer.all(): q = session.query(Otx) q = q.join(TxCache) q = q.filter(TxCache.sender==r.sender) @@ -587,7 +586,6 @@ def get_upcoming_tx(status=StatusEnum.READYSEND, recipient=None, before=None, ch q = q.filter(TxCache.date_checked $init_level_file +echo -n 1 > $init_level_file # Abort on any error (including if wait-for-it fails). set -e @@ -68,6 +68,6 @@ cat $CIC_DATA_DIR/envlist | bash from_env.sh > $CIC_DATA_DIR/.env_all set +a set +e -echo -n 1 > $init_level_file +echo -n 2 > $init_level_file exec "$@" diff --git a/apps/contract-migration/seed_cic_eth.sh b/apps/contract-migration/seed_cic_eth.sh index 4d0ecab..d5ccf91 100644 --- a/apps/contract-migration/seed_cic_eth.sh +++ b/apps/contract-migration/seed_cic_eth.sh @@ -1,6 +1,12 @@ #!/bin/bash # defaults +initlevel=`cat ${CIC_DATA_DIR}/.init` +echo $inilevel +if [ $initlevel -lt 2 ]; then + >&2 echo "initlevel too low $initlevel" + exit 1 +fi source ${CIC_DATA_DIR}/.env source ${CIC_DATA_DIR}/.env_all DEV_PIP_EXTRA_INDEX_URL=${DEV_PIP_EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433} @@ -136,7 +142,7 @@ token_description_two=0x54686973206973207468652053617261667520746f6b656e00000000 >&2 echo "add keystore account $keystore_file to accounts index writers" >&2 eth-accounts-index-add -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -r $CIC_ACCOUNTS_INDEX_ADDRESS --writer $DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER -w $debug -echo -n 2 > $init_level_file +echo -n 0 > $init_level_file set +a set +e diff --git a/docker-compose.yml b/docker-compose.yml index 476beae..a51435e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,8 +35,8 @@ services: context: apps/bloxbergValidatorSetup restart: unless-stopped ports: - - ${DEV_ETH_PORT_HTTP:-8545}:8545 - - ${DEV_ETH_PORT_WS-8546}:8546 + - ${DEV_ETH_PORT_HTTP:-63545}:8545 + - ${DEV_ETH_PORT_WS-63546}:8546 - 30303 volumes: - ./apps/bloxbergValidatorSetup/keys:/root/keys # stores the signing key locally @@ -49,7 +49,7 @@ services: POSTGRES_HOST_AUTH_METHOD: trust # for postgres user access w/o password. Obvioulsy not safe but allows easy elevated debugging. # PGDATA: /tmp/cic/postgres ports: - - ${DEV_POSTGRES_PORT:-5432}:5432 + - ${DEV_POSTGRES_PORT:-63432}:5432 volumes: - ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql - ./apps/cic-meta/scripts/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh @@ -58,7 +58,7 @@ services: redis: image: redis:6.0.9-alpine ports: - - ${DEV_REDIS_PORT:-6379}:6379 + - ${DEV_REDIS_PORT:-63379}:6379 command: "--loglevel verbose" bee: @@ -68,8 +68,8 @@ services: BEE_NETWORK_ID: ${BEE_NETWORK_ID:-313} BEE_PASSWORD: ${BEE_PASSWORD:-password} ports: - - ${DEV_BEE_PORT:-1633}:1633 - - ${DEV_BEE_PORT_DEBUG:-1635}:1635 + - ${DEV_BEE_PORT:-63633}:1633 + - ${DEV_BEE_PORT_DEBUG:-63635}:1635 command: "start --swap-enable=false --standalone" volumes: - bee-data:/tmp/cic/bee @@ -117,8 +117,14 @@ services: CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis:6379} DEV_PIP_EXTRA_INDEX_URL: ${DEV_PIP_EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433} command: ["./seed_cic_eth.sh"] + deploy: + restart_policy: + condition: on-failure depends_on: - eth + - postgres + - redis + - cic-eth-tasker volumes: - contract-config:/tmp/cic/config @@ -227,7 +233,7 @@ services: DATABASE_USER: ${DATABASE_USER:-grassroots} DATABASE_HOST: ${DATABASE_HOST:-postgres} DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala} - DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_cache} + DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_eth} DATABASE_PORT: ${DATABASE_PORT:-5432} DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres} DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2} @@ -263,7 +269,7 @@ services: DATABASE_USER: ${DATABASE_USER:-grassroots} DATABASE_HOST: ${DATABASE_HOST:-postgres} DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala} - DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_cache} + DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_eth} DATABASE_PORT: ${DATABASE_PORT:-5432} DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres} DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2} @@ -299,7 +305,7 @@ services: DATABASE_USER: ${DATABASE_USER:-grassroots} DATABASE_HOST: ${DATABASE_HOST:-postgres} DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala} - DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_cache} + DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_eth} DATABASE_PORT: ${DATABASE_PORT:-5432} DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres} DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2} @@ -309,6 +315,7 @@ services: CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis} CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis} TASKS_TRANSFER_CALLBACKS: $TASKS_TRANSFER_CALLBACKS + DATABASE_DEBUG: ${DATABASE_DEBUG:-true} depends_on: - eth @@ -337,7 +344,7 @@ services: DATABASE_USER: ${DATABASE_USER:-grassroots} DATABASE_HOST: ${DATABASE_HOST:-postgres} DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala} - DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_cache} + DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_eth} DATABASE_PORT: ${DATABASE_PORT:-5432} DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres} DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2} @@ -347,6 +354,7 @@ services: CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis} CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis} TASKS_TRANSFER_CALLBACKS: $TASKS_TRANSFER_CALLBACKS + CIC_TX_RETRY_DELAY: 15 depends_on: - eth - postgres @@ -373,11 +381,13 @@ services: CIC_CHAIN_SPEC: $CIC_CHAIN_SPEC CELERY_BROKER_URL: $CELERY_BROKER_URL CELERY_RESULT_URL: $CELERY_RESULT_URL - SERVER_PORT: 80 + SERVER_PORT: 8000 depends_on: - eth - postgres - redis + ports: + - ${HTTP_PORT_CIC_ETH:-63314}:8000 deploy: restart_policy: condition: on-failure @@ -440,8 +450,8 @@ services: DATABASE_USER: ${DATABASE_USER:-grassroots} DATABASE_HOST: ${DATABASE_HOST:-postgres} DATABASE_PORT: ${DATABASE_PORT:-5432} - SERVER_HOST: ${SERVER_HOST:-localhost} - SERVER_PORT: ${SERVER_HOST:-80} + SERVER_HOST: localhost + SERVER_PORT: 8000 DATABASE_SCHEMA_SQL_PATH: "" PGP_EXPORTS_DIR: /tmp/src/cic-meta/tests/ PGP_PRIVATEKEY_FILE: privatekeys.asc @@ -450,7 +460,7 @@ services: PGP_PUBLICKEY_ACTIVE_FILE: publickeys.asc PGP_PUBLICKEY_ENCRYPT_FILE: publickeys.asc ports: - - ${HTTP_PORT_CIC_META:-63380}:${SERVER_PORT:-80} + - ${HTTP_PORT_CIC_META:-63380}:8000 depends_on: - postgres deploy: @@ -473,9 +483,9 @@ services: DATABASE_NAME: cic_ussd DATABASE_ENGINE: postgresql DATABASE_DRIVER: psycopg2 - SERVER_PORT: 9000 + SERVER_PORT: 8000 ports: - - 9000:8082 + - ${HTTP_PORT_CIC_USSD:-63315}:8000 depends_on: - postgres - redis