From 958bd9af962b9544bdfa5140891c3ecfef7e0e08 Mon Sep 17 00:00:00 2001 From: nolash Date: Fri, 12 Mar 2021 09:36:57 +0100 Subject: [PATCH] Move signer from middleware to dedicated connection --- apps/cic-eth/cic_eth/eth/task.py | 11 ++++++++--- apps/cic-eth/cic_eth/eth/tx.py | 3 ++- apps/cic-eth/cic_eth/version.py | 2 +- apps/cic-eth/crypto_dev_signer_config/config.ini | 2 +- apps/cic-eth/docker/start_tasker.sh | 2 +- apps/cic-eth/requirements.txt | 7 ++++--- apps/contract-migration/docker/Dockerfile | 2 +- apps/contract-migration/scripts/requirements.txt | 4 ++-- apps/contract-migration/seed_cic_eth.sh | 2 +- apps/requirements.txt | 4 ++-- docker-compose.yml | 2 +- 11 files changed, 24 insertions(+), 17 deletions(-) diff --git a/apps/cic-eth/cic_eth/eth/task.py b/apps/cic-eth/cic_eth/eth/task.py index 42bce354..956c952a 100644 --- a/apps/cic-eth/cic_eth/eth/task.py +++ b/apps/cic-eth/cic_eth/eth/task.py @@ -2,10 +2,15 @@ import logging # external imports +import sha3 import celery from cic_registry.chain import ChainSpec from chainlib.eth.sign import sign_transaction from chainlib.eth.connection import RPCConnection +from hexathon import ( + strip_0x, + add_0x, + ) # local imports from cic_eth.eth import RpcClient @@ -40,10 +45,10 @@ def sign_tx(tx, chain_str): raise SignerError('sign tx {}: {}'.format(tx, e)) logg.debug('tx_transfer_signed {}'.format(tx_transfer_signed)) h = sha3.keccak_256() - h.update(tx_transfer_signed['raw']) - g = h.digest() + h.update(bytes.fromhex(strip_0x(tx_transfer_signed['raw']))) + tx_hash = h.digest() #tx_hash = c.w3.keccak(hexstr=tx_transfer_signed['raw']) - tx_hash_hex = tx_hash.hex() + tx_hash_hex = add_0x(tx_hash.hex()) return (tx_hash_hex, tx_transfer_signed['raw'],) diff --git a/apps/cic-eth/cic_eth/eth/tx.py b/apps/cic-eth/cic_eth/eth/tx.py index c5f21676..9aa9da39 100644 --- a/apps/cic-eth/cic_eth/eth/tx.py +++ b/apps/cic-eth/cic_eth/eth/tx.py @@ -410,7 +410,8 @@ def send(self, txs, chain_str): queue=queue, ) try: - r = c.w3.eth.send_raw_transaction(tx_hex) + #r = c.w3.eth.send_raw_transaction(tx_hex) + r = c.w3.eth.sendRawTransaction(tx_hex) except requests.exceptions.ConnectionError as e: raise(e) except Exception as e: diff --git a/apps/cic-eth/cic_eth/version.py b/apps/cic-eth/cic_eth/version.py index 6da7a124..7b6d83f3 100644 --- a/apps/cic-eth/cic_eth/version.py +++ b/apps/cic-eth/cic_eth/version.py @@ -10,7 +10,7 @@ version = ( 0, 10, 0, - 'alpha.41', + 'alpha.46', ) version_object = semver.VersionInfo( diff --git a/apps/cic-eth/crypto_dev_signer_config/config.ini b/apps/cic-eth/crypto_dev_signer_config/config.ini index f87759df..c88377ab 100644 --- a/apps/cic-eth/crypto_dev_signer_config/config.ini +++ b/apps/cic-eth/crypto_dev_signer_config/config.ini @@ -1,4 +1,4 @@ [signer] secret = deadbeef #database = crypto-dev-signer -socket_path = /run/crypto-dev-signer/jsonrpc.ipc +socket_path = ipc:///run/crypto-dev-signer/jsonrpc.ipc diff --git a/apps/cic-eth/docker/start_tasker.sh b/apps/cic-eth/docker/start_tasker.sh index 02c36fa0..4494ac21 100644 --- a/apps/cic-eth/docker/start_tasker.sh +++ b/apps/cic-eth/docker/start_tasker.sh @@ -6,7 +6,7 @@ set -e # set CONFINI_ENV_PREFIX to override the env prefix to override env vars echo "!!! starting signer" -python /usr/local/bin/crypto-dev-daemon -c /usr/local/etc/crypto-dev-signer & +python /usr/local/bin/crypto-dev-daemon -c /usr/local/etc/crypto-dev-signer -vv 2> /tmp/signer.log & echo "!!! starting tracker" /usr/local/bin/cic-eth-taskerd $@ diff --git a/apps/cic-eth/requirements.txt b/apps/cic-eth/requirements.txt index 39592245..3db12ba4 100644 --- a/apps/cic-eth/requirements.txt +++ b/apps/cic-eth/requirements.txt @@ -1,7 +1,7 @@ -cic-base~=0.1.1a24 +cic-base~=0.1.1a30 web3==5.12.2 celery==4.4.7 -crypto-dev-signer~=0.4.13rc4 +crypto-dev-signer~=0.4.13rc6 confini~=0.3.6rc3 cic-registry~=0.5.3a22 cic-bancor~=0.0.6 @@ -19,6 +19,7 @@ eth-gas-proxy==0.0.1a4 websocket-client==0.57.0 moolb~=0.1.1b2 eth-address-index~=0.1.0a8 -chainlib~=0.0.1a21 +chainlib~=0.0.1a25 hexathon~=0.0.1a3 chainsyncer~=0.0.1a19 +pysha3==1.0.2 diff --git a/apps/contract-migration/docker/Dockerfile b/apps/contract-migration/docker/Dockerfile index 3a77f0d6..16e11051 100644 --- a/apps/contract-migration/docker/Dockerfile +++ b/apps/contract-migration/docker/Dockerfile @@ -107,7 +107,7 @@ RUN cd cic-bancor/python && \ RUN apt-get install -y cargo -ARG cic_base_version=0.1.1a24 +ARG cic_base_version=0.1.1a30 RUN pip install --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version ARG cic_registry_version=0.5.3a24 diff --git a/apps/contract-migration/scripts/requirements.txt b/apps/contract-migration/scripts/requirements.txt index 657948b1..0d593f66 100644 --- a/apps/contract-migration/scripts/requirements.txt +++ b/apps/contract-migration/scripts/requirements.txt @@ -1,3 +1,3 @@ -cic-base[full_graph]==0.1.1a25 -cic-eth==0.10.0a42 +cic-base[full_graph]==0.1.1a28 +cic-eth==0.10.0a46 cic-types==0.1.0a8 diff --git a/apps/contract-migration/seed_cic_eth.sh b/apps/contract-migration/seed_cic_eth.sh index d59efefa..227e759f 100644 --- a/apps/contract-migration/seed_cic_eth.sh +++ b/apps/contract-migration/seed_cic_eth.sh @@ -31,7 +31,7 @@ set -e set -a # We need to not install these here... -pip install --extra-index-url $DEV_PIP_EXTRA_INDEX_URL cic-eth==0.10.0a41 chainlib==0.0.1a21 cic-contracts==0.0.2a2 +pip install --extra-index-url $DEV_PIP_EXTRA_INDEX_URL cic-eth==0.10.0a46 chainlib==0.0.1a25 cic-contracts==0.0.2a2 >&2 echo "create account for gas gifter" old_gas_provider=$DEV_ETH_ACCOUNT_GAS_PROVIDER diff --git a/apps/requirements.txt b/apps/requirements.txt index 619ba109..59dccdae 100644 --- a/apps/requirements.txt +++ b/apps/requirements.txt @@ -3,7 +3,7 @@ alembic==1.4.2 bcrypt==3.2.0 celery==4.4.7 confini==0.3.6rc3 -crypto-dev-signer==0.4.13rc4 +crypto-dev-signer==0.4.13rc6 cryptography==3.2.1 ecuth==0.4.5a1 eth-accounts-index==0.0.10a10 @@ -42,6 +42,6 @@ rlp==2.0.1 cryptocurrency-cli-tools==0.0.4 giftable-erc20-token==0.0.7b12 hexathon==0.0.1a3 -chainlib==0.0.1a21 +chainlib==0.0.1a25 chainsyncer==0.0.1a19 cic-registry==0.5.3.a22 diff --git a/docker-compose.yml b/docker-compose.yml index 86e72ca7..3588eb06 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -219,7 +219,7 @@ services: BANCOR_DIR: ${BANCOR_DIR:-/usr/local/share/cic/bancor} CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis} CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis} - SIGNER_SOCKET_PATH: ${SIGNER_SOCKET_PATH:-/tmp/cic/signer/jsonrpc.ipc} + SIGNER_SOCKET_PATH: ${SIGNER_SOCKET_PATH:-ipc:///tmp/cic/signer/jsonrpc.ipc} SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef} ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER: ${DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER:-0xACB0BC74E1686D62dE7DC6414C999EA60C09F0eA} TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1}