From a305aafc86df27bb52660e61ae23eaaf31bc0efa Mon Sep 17 00:00:00 2001 From: Louis Holbrook Date: Tue, 6 Apr 2021 15:14:04 +0000 Subject: [PATCH] Make 40k import pass --- apps/cic-eth/cic_eth/eth/erc20.py | 4 ++-- apps/cic-eth/cic_eth/eth/tx.py | 2 ++ apps/cic-eth/cic_eth/ext/address.py | 2 +- apps/cic-eth/cic_eth/queue/state.py | 4 ++-- apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py | 1 + apps/cic-eth/cic_eth/runnable/daemons/retry.py | 2 +- apps/cic-eth/cic_eth/runnable/daemons/tracker.py | 6 ++++-- apps/cic-eth/cic_eth/version.py | 2 +- apps/cic-eth/docker/Dockerfile | 2 +- apps/cic-eth/requirements.txt | 6 +++--- .../filters/{straggler.py => test_straggler_filter.py} | 2 +- apps/cic-eth/tests/filters/{tx.py => test_tx_filter.py} | 2 +- apps/cic-eth/tests/task/api/test_app.py | 3 ++- apps/cic-eth/tests/task/test_task_account.py | 2 +- apps/cic-eth/tests/unit/ext/test_ext_tx.py | 4 ++-- apps/contract-migration/docker/Dockerfile | 6 +++--- apps/contract-migration/scripts/import_users.py | 6 ------ apps/contract-migration/scripts/requirements.txt | 6 +++--- 18 files changed, 31 insertions(+), 31 deletions(-) rename apps/cic-eth/tests/filters/{straggler.py => test_straggler_filter.py} (98%) rename apps/cic-eth/tests/filters/{tx.py => test_tx_filter.py} (99%) diff --git a/apps/cic-eth/cic_eth/eth/erc20.py b/apps/cic-eth/cic_eth/eth/erc20.py index 845ec0ea..5bde32b9 100644 --- a/apps/cic-eth/cic_eth/eth/erc20.py +++ b/apps/cic-eth/cic_eth/eth/erc20.py @@ -61,8 +61,8 @@ def balance(tokens, holder_address, chain_spec_dict): for t in tokens: address = t['address'] - token = ERC20Token(rpc, address) - c = ERC20() + token = ERC20Token(chain_spec, rpc, address) + c = ERC20(chain_spec) o = c.balance_of(address, holder_address, sender_address=caller_address) r = rpc.do(o) t['balance_network'] = c.parse_balance(r) diff --git a/apps/cic-eth/cic_eth/eth/tx.py b/apps/cic-eth/cic_eth/eth/tx.py index 05bef05d..4883e872 100644 --- a/apps/cic-eth/cic_eth/eth/tx.py +++ b/apps/cic-eth/cic_eth/eth/tx.py @@ -171,6 +171,7 @@ def sync_tx(self, tx_hash_hex, chain_spec_dict): except NotFoundEthException as e: pass + # TODO: apply receipt in tx object to validate and normalize input if rcpt != None: success = rcpt['status'] == 1 logg.debug('sync tx {} mined block {} success {}'.format(tx_hash_hex, rcpt['blockNumber'], success)) @@ -180,6 +181,7 @@ def sync_tx(self, tx_hash_hex, chain_spec_dict): [ tx_hash_hex, rcpt['blockNumber'], + rcpt['transactionIndex'], not success, ], queue=queue, diff --git a/apps/cic-eth/cic_eth/ext/address.py b/apps/cic-eth/cic_eth/ext/address.py index 449a5f3c..3db76925 100644 --- a/apps/cic-eth/cic_eth/ext/address.py +++ b/apps/cic-eth/cic_eth/ext/address.py @@ -23,7 +23,7 @@ def translate_address(address, trusted_addresses, chain_spec, sender_address=ZER registry = CICRegistry(chain_spec, rpc) declarator_address = registry.by_name('AddressDeclarator', sender_address=sender_address) - c = AddressDeclarator() + c = AddressDeclarator(chain_spec) for trusted_address in trusted_addresses: o = c.declaration(declarator_address, trusted_address, address, sender_address=sender_address) diff --git a/apps/cic-eth/cic_eth/queue/state.py b/apps/cic-eth/cic_eth/queue/state.py index 5c86233f..89d5ce40 100644 --- a/apps/cic-eth/cic_eth/queue/state.py +++ b/apps/cic-eth/cic_eth/queue/state.py @@ -20,10 +20,10 @@ def set_sent(chain_spec_dict, tx_hash, fail=False): @celery_app.task(base=CriticalSQLAlchemyTask) -def set_final(chain_spec_dict, tx_hash, block=None, fail=False): +def set_final(chain_spec_dict, tx_hash, block=None, tx_index=None, fail=False): chain_spec = ChainSpec.from_dict(chain_spec_dict) session = SessionBase.create_session() - r = chainqueue.state.set_final(chain_spec, tx_hash, block, fail, session=session) + r = chainqueue.state.set_final(chain_spec, tx_hash, block=block, tx_index=tx_index, fail=fail, session=session) session.close() return r diff --git a/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py b/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py index d226c263..4e06e4d8 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py @@ -39,6 +39,7 @@ class TxFilter(SyncFilter): self.chain_spec.asdict(), add_0x(tx_hash_hex), tx.block.number, + tx.index, tx.status == Status.ERROR, ], queue=self.queue, diff --git a/apps/cic-eth/cic_eth/runnable/daemons/retry.py b/apps/cic-eth/cic_eth/runnable/daemons/retry.py index 6fefc94d..1044101b 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/retry.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/retry.py @@ -80,7 +80,7 @@ straggler_delay = int(config.get('CIC_TX_RETRY_DELAY')) # logg.debug('submitting tx {} for retry'.format(tx_hash)) # s_check = celery.signature( # 'cic_eth.admin.ctrl.check_lock', - [ +# [ # tx_hash, # chain_str, # LockEnum.QUEUE, diff --git a/apps/cic-eth/cic_eth/runnable/daemons/tracker.py b/apps/cic-eth/cic_eth/runnable/daemons/tracker.py index f9f91629..5cc7f7e7 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/tracker.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/tracker.py @@ -66,7 +66,6 @@ chain_spec = ChainSpec.from_chain_str(config.get('CIC_CHAIN_SPEC')) #RPCConnection.register_location(config.get('ETH_PROVIDER'), chain_spec, 'default') cic_base.rpc.setup(chain_spec, config.get('ETH_PROVIDER')) - def main(): # connect to celery celery.Celery(broker=config.get('CELERY_BROKER_URL'), backend=config.get('CELERY_RESULT_URL')) @@ -76,7 +75,10 @@ def main(): o = block_latest() r = rpc.do(o) - block_offset = int(strip_0x(r), 16) + 1 + block_current = int(r, 16) + block_offset = block_current + 1 + + stat = init_chain_stat(rpc, block_current) logg.debug('starting at block {}'.format(block_offset)) diff --git a/apps/cic-eth/cic_eth/version.py b/apps/cic-eth/cic_eth/version.py index 01bc68bb..c7572135 100644 --- a/apps/cic-eth/cic_eth/version.py +++ b/apps/cic-eth/cic_eth/version.py @@ -10,7 +10,7 @@ version = ( 0, 11, 0, - 'alpha.4', + 'beta.1', ) version_object = semver.VersionInfo( diff --git a/apps/cic-eth/docker/Dockerfile b/apps/cic-eth/docker/Dockerfile index ee48c23d..d60dac16 100644 --- a/apps/cic-eth/docker/Dockerfile +++ b/apps/cic-eth/docker/Dockerfile @@ -29,7 +29,7 @@ RUN /usr/local/bin/python -m pip install --upgrade pip # python merge_requirements.py | tee merged_requirements.txt #RUN cd cic-base && \ # pip install $pip_extra_index_url_flag -r ./merged_requirements.txt -RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2a60 +RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2a61 COPY cic-eth/scripts/ scripts/ COPY cic-eth/setup.cfg cic-eth/setup.py ./ diff --git a/apps/cic-eth/requirements.txt b/apps/cic-eth/requirements.txt index 7efa8df2..a4cf6a36 100644 --- a/apps/cic-eth/requirements.txt +++ b/apps/cic-eth/requirements.txt @@ -2,7 +2,7 @@ cic-base~=0.1.2a60 celery==4.4.7 crypto-dev-signer~=0.4.14a17 confini~=0.3.6rc3 -cic-eth-registry~=0.5.4a11 +cic-eth-registry~=0.5.4a12 #cic-bancor~=0.0.6 redis==3.5.3 alembic==1.4.2 @@ -19,7 +19,7 @@ eth-address-index~=0.1.1a7 chainlib~=0.0.2a4 hexathon~=0.0.1a7 chainsyncer~=0.0.1a21 -chainqueue~=0.0.1a5 +chainqueue~=0.0.1a7 pysha3==1.0.2 coincurve==15.0.0 -sarafu-faucet~=0.0.2a16 +sarafu-faucet~=0.0.2a19 diff --git a/apps/cic-eth/tests/filters/straggler.py b/apps/cic-eth/tests/filters/test_straggler_filter.py similarity index 98% rename from apps/cic-eth/tests/filters/straggler.py rename to apps/cic-eth/tests/filters/test_straggler_filter.py index 9342ded6..27dc0b75 100644 --- a/apps/cic-eth/tests/filters/straggler.py +++ b/apps/cic-eth/tests/filters/test_straggler_filter.py @@ -37,7 +37,7 @@ def test_tx( eth_rpc, eth_signer, agent_roles, - celery_worker, + celery_session_worker, ): rpc = RPCConnection.connect(default_chain_spec, 'default') diff --git a/apps/cic-eth/tests/filters/tx.py b/apps/cic-eth/tests/filters/test_tx_filter.py similarity index 99% rename from apps/cic-eth/tests/filters/tx.py rename to apps/cic-eth/tests/filters/test_tx_filter.py index 2cb4c3fd..7515401e 100644 --- a/apps/cic-eth/tests/filters/tx.py +++ b/apps/cic-eth/tests/filters/test_tx_filter.py @@ -37,7 +37,7 @@ def test_tx( eth_rpc, eth_signer, agent_roles, - celery_worker, + celery_session_worker, ): rpc = RPCConnection.connect(default_chain_spec, 'default') diff --git a/apps/cic-eth/tests/task/api/test_app.py b/apps/cic-eth/tests/task/api/test_app.py index 5e1733a2..1d3e64aa 100644 --- a/apps/cic-eth/tests/task/api/test_app.py +++ b/apps/cic-eth/tests/task/api/test_app.py @@ -38,11 +38,12 @@ def test_transfer_api( agent_roles, cic_registry, register_tokens, + register_lookups, celery_session_worker, ): #token = CICRegistry.get_address(default_chain_spec, bancor_tokens[0]) - foo_token_cache = ERC20Token(eth_rpc, foo_token) + foo_token_cache = ERC20Token(default_chain_spec, eth_rpc, foo_token) api = Api(str(default_chain_spec), callback_param='transfer', callback_task='cic_eth.callbacks.noop.noop', queue=None) t = api.transfer(custodial_roles['FOO_TOKEN_GIFTER'], agent_roles['ALICE'], 1024, foo_token_cache.symbol) diff --git a/apps/cic-eth/tests/task/test_task_account.py b/apps/cic-eth/tests/task/test_task_account.py index 412e1f07..010f0e51 100644 --- a/apps/cic-eth/tests/task/test_task_account.py +++ b/apps/cic-eth/tests/task/test_task_account.py @@ -116,7 +116,7 @@ def test_register_account( init_eth_tester.mine_block() - c = AccountRegistry() + c = AccountRegistry(default_chain_spec) o = c.have(account_registry, eth_empty_accounts[0], sender_address=call_sender) r = eth_rpc.do(o) assert int(strip_0x(r), 16) == 1 diff --git a/apps/cic-eth/tests/unit/ext/test_ext_tx.py b/apps/cic-eth/tests/unit/ext/test_ext_tx.py index d942c4ac..2fadca4b 100644 --- a/apps/cic-eth/tests/unit/ext/test_ext_tx.py +++ b/apps/cic-eth/tests/unit/ext/test_ext_tx.py @@ -43,7 +43,7 @@ def test_filter_process( nonce_oracle = RPCNonceOracle(agent_roles['ALICE'], eth_rpc) init_eth_tester.mine_blocks(13) - c = ERC20(signer=eth_signer, nonce_oracle=nonce_oracle) + c = ERC20(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) (tx_hash_hex, o) = c.transfer(foo_token, agent_roles['ALICE'], agent_roles['BOB'], 1024) eth_rpc.do(o) o = receipt(tx_hash_hex) @@ -56,7 +56,7 @@ def test_filter_process( # external tx init_eth_tester.mine_blocks(28) - c = ERC20(signer=eth_signer, nonce_oracle=nonce_oracle) + c = ERC20(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) (tx_hash_hex, o) = c.transfer(foo_token, agent_roles['ALICE'], agent_roles['BOB'], 512) eth_rpc.do(o) o = receipt(tx_hash_hex) diff --git a/apps/contract-migration/docker/Dockerfile b/apps/contract-migration/docker/Dockerfile index bfdfe4e2..b2282e2b 100644 --- a/apps/contract-migration/docker/Dockerfile +++ b/apps/contract-migration/docker/Dockerfile @@ -57,9 +57,9 @@ WORKDIR /home/grassroots USER grassroots ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433 -ARG cic_base_version=0.1.2a60 -ARG cic_eth_version=0.11.0a4 -ARG sarafu_faucet_version=0.0.2a16 +ARG cic_base_version=0.1.2a61 +ARG cic_eth_version=0.11.0b1 +ARG sarafu_faucet_version=0.0.2a19 ARG cic_contracts_version=0.0.2a2 RUN pip install --user --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version \ cic-eth==$cic_eth_version \ diff --git a/apps/contract-migration/scripts/import_users.py b/apps/contract-migration/scripts/import_users.py index d7a8e6e0..acba257f 100644 --- a/apps/contract-migration/scripts/import_users.py +++ b/apps/contract-migration/scripts/import_users.py @@ -124,10 +124,6 @@ def register_eth(i, u): return address -def register_ussd(u): - pass - - if __name__ == '__main__': #fi = open(os.path.join(user_out_dir, 'addresses.csv'), 'a') @@ -155,8 +151,6 @@ if __name__ == '__main__': sub_chain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id()) u.identities['evm'][sub_chain_str] = [new_address] - register_ussd(u) - new_address_clean = strip_0x(new_address) filepath = os.path.join( user_new_dir, diff --git a/apps/contract-migration/scripts/requirements.txt b/apps/contract-migration/scripts/requirements.txt index 7a06dd35..5a62a439 100644 --- a/apps/contract-migration/scripts/requirements.txt +++ b/apps/contract-migration/scripts/requirements.txt @@ -1,5 +1,5 @@ -cic-base[full_graph]==0.1.2a60 -sarafu-faucet==0.0.2a16 -cic-eth==0.11.0a4 +cic-base[full_graph]==0.1.2a61 +sarafu-faucet==0.0.2a17 +cic-eth==0.11.0b1 cic-types==0.1.0a10 crypto-dev-signer==0.4.14a17