From 4af7592212ccf405542f7bd00dfcd48f2af3ef94 Mon Sep 17 00:00:00 2001 From: nolash Date: Sun, 28 Feb 2021 11:02:30 +0100 Subject: [PATCH] Rehabilitate import scripts and builds after syncer changes --- .../cic_eth/runnable/daemons/tracker.py | 5 ++- apps/cic-eth/cic_eth/version.py | 2 +- apps/cic-eth/requirements.txt | 8 ++--- apps/contract-migration/docker/Dockerfile | 4 +-- .../scripts/import_balance.py | 5 +-- .../scripts/import_users.py | 32 +++++++++++-------- .../scripts/requirements.txt | 4 +-- apps/contract-migration/scripts/verify.py | 1 + apps/contract-migration/seed_cic_eth.sh | 2 +- apps/requirements.txt | 4 +-- 10 files changed, 39 insertions(+), 28 deletions(-) diff --git a/apps/cic-eth/cic_eth/runnable/daemons/tracker.py b/apps/cic-eth/cic_eth/runnable/daemons/tracker.py index 47bbc1f7..3bb58b74 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/tracker.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/tracker.py @@ -13,7 +13,10 @@ import celery import rlp import web3 from web3 import HTTPProvider, WebsocketProvider -import cic_base +import cic_base.config +import cic_base.log +import cic_base.argparse +import cic_base.rpc from cic_registry import CICRegistry from chainlib.chain import ChainSpec from cic_registry import zero_address diff --git a/apps/cic-eth/cic_eth/version.py b/apps/cic-eth/cic_eth/version.py index 98ee59d8..9d9fc7f4 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.33', + 'alpha.34', ) version_object = semver.VersionInfo( diff --git a/apps/cic-eth/requirements.txt b/apps/cic-eth/requirements.txt index 7b52306e..a72fc0fd 100644 --- a/apps/cic-eth/requirements.txt +++ b/apps/cic-eth/requirements.txt @@ -1,8 +1,8 @@ web3==5.12.2 celery==4.4.7 -crypto-dev-signer~=0.4.13rc2 +crypto-dev-signer~=0.4.13rc3 confini~=0.3.6b1 -cic-registry~=0.5.3a20 +cic-registry~=0.5.3a22 cic-bancor~=0.0.6 redis==3.5.3 alembic==1.4.2 @@ -18,7 +18,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.1a18 +chainlib~=0.0.1a19 hexathon~=0.0.1a3 chainsyncer~=0.0.1a18 -cic-base==0.1.1a5 +cic-base==0.1.1a8 diff --git a/apps/contract-migration/docker/Dockerfile b/apps/contract-migration/docker/Dockerfile index 69d876f2..6759c904 100644 --- a/apps/contract-migration/docker/Dockerfile +++ b/apps/contract-migration/docker/Dockerfile @@ -107,10 +107,10 @@ RUN cd cic-bancor/python && \ RUN apt-get install -y cargo -ARG cic_base_version=0.1.1a7 +ARG cic_base_version=0.1.1a8 RUN pip install --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version -ARG cic_registry_version=0.5.3a21 +ARG cic_registry_version=0.5.3a22 RUN pip install --extra-index-url $pip_extra_index_url cic-registry==$cic_registry_version WORKDIR /root diff --git a/apps/contract-migration/scripts/import_balance.py b/apps/contract-migration/scripts/import_balance.py index 305d6da9..658ab0d6 100644 --- a/apps/contract-migration/scripts/import_balance.py +++ b/apps/contract-migration/scripts/import_balance.py @@ -48,7 +48,7 @@ argparser = argparse.ArgumentParser(description='daemon that monitors transactio argparser.add_argument('-p', '--provider', dest='p', type=str, help='chain rpc provider address') argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing') argparser.add_argument('-c', type=str, default=config_dir, help='config root to use') -argparser.add_argument('--old-chain-spec', type=str, dest='old_chain_spec', default='oldchain:1', help='chain spec') +argparser.add_argument('--old-chain-spec', type=str, dest='old_chain_spec', default='evm:oldchain:1', help='chain spec') argparser.add_argument('-i', '--chain-spec', type=str, dest='i', help='chain spec') argparser.add_argument('-r', '--registry-address', type=str, dest='r', help='CIC Registry address') argparser.add_argument('--token-symbol', default='SRF', type=str, dest='token_symbol', help='Token symbol to use for trnsactions') @@ -101,6 +101,7 @@ else: chain_spec = ChainSpec.from_chain_str(chain_str) old_chain_spec_str = args.old_chain_spec +old_chain_spec = ChainSpec.from_chain_str(old_chain_spec_str) user_dir = args.user_dir # user_out_dir from import_users.py @@ -146,7 +147,7 @@ class Handler: logg.error('no import record of address {}'.format(recipient)) return u = Person.deserialize(o) - original_address = u.identities['evm'][old_chain_spec_str][0] + original_address = u.identities[old_chain_spec.engine()]['{}:{}'.format(old_chain_spec.common_name(), old_chain_spec.network_id())][0] balance = self.balances[original_address] # TODO: store token object in handler ,get decimals from there diff --git a/apps/contract-migration/scripts/import_users.py b/apps/contract-migration/scripts/import_users.py index 74d791c2..a0cc3c8f 100644 --- a/apps/contract-migration/scripts/import_users.py +++ b/apps/contract-migration/scripts/import_users.py @@ -88,7 +88,7 @@ batch_delay = args.batch_delay def register_eth(i, u): redis_channel = str(uuid.uuid4()) ps.subscribe(redis_channel) - ps.get_message() + #ps.get_message() api = Api( config.get('CIC_CHAIN_SPEC'), queue=args.q, @@ -98,18 +98,24 @@ def register_eth(i, u): ) t = api.create_account(register=True) - ps.get_message() - m = ps.get_message(timeout=args.timeout) - try: - r = json.loads(m['data']) - address = r['result'] - except TypeError as e: - if m == None: - logg.critical('empty response from redis callback (did the service crash?)') - else: - logg.critical('unexpected response from redis callback: {}'.format(m)) - sys.exit(1) - logg.debug('[{}] register eth {} {}'.format(i, u, address)) + while True: + ps.get_message() + m = ps.get_message(timeout=args.timeout) + address = None + if m['type'] == 'subscribe': + logg.debug('skipping subscribe message') + continue + try: + r = json.loads(m['data']) + address = r['result'] + break + except TypeError as e: + if m == None: + logg.critical('empty response from redis callback (did the service crash?)') + else: + logg.critical('unexpected response from redis callback: {}'.format(m)) + sys.exit(1) + logg.debug('[{}] register eth {} {}'.format(i, u, address)) return address diff --git a/apps/contract-migration/scripts/requirements.txt b/apps/contract-migration/scripts/requirements.txt index 561c877c..307ade0d 100644 --- a/apps/contract-migration/scripts/requirements.txt +++ b/apps/contract-migration/scripts/requirements.txt @@ -1,3 +1,3 @@ -cic-base[full]==0.1.1a5 -cic-eth==0.10.0a33 +cic-base[full_graph]==0.1.1a8 +cic-eth==0.10.0a34 cic-types==0.1.0a8 diff --git a/apps/contract-migration/scripts/verify.py b/apps/contract-migration/scripts/verify.py index ff6a032e..ef3ee2b4 100644 --- a/apps/contract-migration/scripts/verify.py +++ b/apps/contract-migration/scripts/verify.py @@ -139,6 +139,7 @@ class Verifier: o = self.erc20_tx_factory.erc20_balance(self.token_address, address) r = self.conn.do(o) actual_balance = int(strip_0x(r), 16) + balance = int(balance / 1000000) * 1000000 logg.debug('balance for {}: {}'.format(address, balance)) if balance != actual_balance: raise VerifierError((actual_balance, balance), 'balance') diff --git a/apps/contract-migration/seed_cic_eth.sh b/apps/contract-migration/seed_cic_eth.sh index 488088e5..fdba8973 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.0a33 chainlib==0.0.1a18 cic-contracts==0.0.2a2 +pip install --extra-index-url $DEV_PIP_EXTRA_INDEX_URL cic-eth==0.10.0a34 chainlib==0.0.1a19 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 e70f9c2a..00b23fe4 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.13rc2 +crypto-dev-signer==0.4.13rc3 cryptography==3.2.1 ecuth==0.4.5a1 eth-accounts-index==0.0.10a10 @@ -44,4 +44,4 @@ giftable-erc20-token==0.0.7b12 hexathon==0.0.1a3 chainlib==0.0.1a19 chainsyncer==0.0.1a18 -cic-registry==0.5.3.a21 +cic-registry==0.5.3.a22