From 101a1eb050ec7aedd4f494b7b97d98768d3bdb48 Mon Sep 17 00:00:00 2001 From: nolash Date: Fri, 26 Mar 2021 07:57:35 +0100 Subject: [PATCH] WIP rehabilitate sync tx --- apps/cic-eth/cic_eth/eth/tx.py | 11 +++++------ apps/cic-eth/cic_eth/runnable/daemons/tracker.py | 3 ++- apps/cic-eth/requirements.txt | 5 ++--- .../task/{test_task_send.py => test_task_tx.py} | 12 +++++++++++- 4 files changed, 20 insertions(+), 11 deletions(-) rename apps/cic-eth/tests/task/{test_task_send.py => test_task_tx.py} (91%) diff --git a/apps/cic-eth/cic_eth/eth/tx.py b/apps/cic-eth/cic_eth/eth/tx.py index 66dd94c9..5586e02e 100644 --- a/apps/cic-eth/cic_eth/eth/tx.py +++ b/apps/cic-eth/cic_eth/eth/tx.py @@ -474,7 +474,7 @@ def reserve_nonce(self, chained_input, signer_address=None): @celery_app.task(bind=True, throws=(NotFoundEthException,), base=CriticalWeb3Task) -def sync_tx(self, tx_hash_hex, chain_str): +def sync_tx(self, tx_hash_hex, chain_spec_dict): """Force update of network status of a simgle transaction :param tx_hash_hex: Transaction hash @@ -483,11 +483,11 @@ def sync_tx(self, tx_hash_hex, chain_str): :type chain_str: str """ - queue = self.request.delivery_info['routing_key'] + queue = self.request.delivery_info.get('routing_key') - chain_spec = ChainSpec.from_chain_str(chain_str) + chain_spec = ChainSpec.from_dict(chain_spec_dict) - conn = RPCConnection.connect() + conn = RPCConnection.connect(chain_spec, 'default') o = transaction(tx_hash_hex) tx = conn.do(o) @@ -495,8 +495,7 @@ def sync_tx(self, tx_hash_hex, chain_str): try: o = receipt(tx_hash_hex) rcpt = conn.do(o) - #rcpt = c.w3.eth.getTransactionReceipt(tx_hash_hex) - except NotFoundEthException as e: #web3.exceptions.TransactionNotFound as e: + except NotFoundEthException as e: pass if rcpt != None: diff --git a/apps/cic-eth/cic_eth/runnable/daemons/tracker.py b/apps/cic-eth/cic_eth/runnable/daemons/tracker.py index 4fe598f1..f9f91629 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/tracker.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/tracker.py @@ -63,7 +63,8 @@ SessionBase.connect(dsn, pool_size=16, debug=config.true('DATABASE_DEBUG')) chain_spec = ChainSpec.from_chain_str(config.get('CIC_CHAIN_SPEC')) -RPCConnection.register_location(config.get('ETH_PROVIDER'), chain_spec, 'default') +#RPCConnection.register_location(config.get('ETH_PROVIDER'), chain_spec, 'default') +cic_base.rpc.setup(chain_spec, config.get('ETH_PROVIDER')) def main(): diff --git a/apps/cic-eth/requirements.txt b/apps/cic-eth/requirements.txt index 48e64243..45915cc8 100644 --- a/apps/cic-eth/requirements.txt +++ b/apps/cic-eth/requirements.txt @@ -1,9 +1,8 @@ -cic-base~=0.1.2a22 -web3==5.12.2 +cic-base~=0.1.2a23 celery==4.4.7 crypto-dev-signer~=0.4.14a8 confini~=0.3.6rc3 -cic-eth-registry~=0.5.4a4 +cic-eth-registry~=0.5.4a5 #cic-bancor~=0.0.6 redis==3.5.3 alembic==1.4.2 diff --git a/apps/cic-eth/tests/task/test_task_send.py b/apps/cic-eth/tests/task/test_task_tx.py similarity index 91% rename from apps/cic-eth/tests/task/test_task_send.py rename to apps/cic-eth/tests/task/test_task_tx.py index 48c9fbb2..9251e3b7 100644 --- a/apps/cic-eth/tests/task/test_task_send.py +++ b/apps/cic-eth/tests/task/test_task_tx.py @@ -19,6 +19,7 @@ from cic_eth.eth.tx import cache_gas_data logg = logging.getLogger() +@pytest.mark.skip() def test_tx_send( init_database, default_chain_spec, @@ -26,7 +27,7 @@ def test_tx_send( eth_signer, agent_roles, contract_roles, - celery_worker, + celery_session_worker, ): chain_id = default_chain_spec.chain_id() @@ -56,3 +57,12 @@ def test_tx_send( o = receipt(tx_hash_hex) rcpt = eth_rpc.do(o) assert rcpt['status'] == 1 + + +def test_sync_tx( + default_chain_spec, + eth_rpc, + eth_signer, + celery_worker, + ): + pass