Merge branch 'master' into lash/refactor-syncer

This commit is contained in:
nolash 2021-02-22 21:00:52 +01:00
commit 9d6bfef73d
14 changed files with 32 additions and 25 deletions

View File

@ -178,8 +178,10 @@ def register(self, account_address, chain_str, writer_address=None):
""" """
chain_spec = ChainSpec.from_chain_str(chain_str) chain_spec = ChainSpec.from_chain_str(chain_str)
session = SessionBase.create_session()
if writer_address == None: if writer_address == None:
writer_address = AccountRole.get_address('ACCOUNTS_INDEX_WRITER') writer_address = AccountRole.get_address('ACCOUNTS_INDEX_WRITER', session)
session.close()
if writer_address == zero_address: if writer_address == zero_address:
raise RoleMissingError(account_address) raise RoleMissingError(account_address)

View File

@ -3,11 +3,8 @@ FROM node:15.3.0-alpine3.10
WORKDIR /tmp/src/cic-meta WORKDIR /tmp/src/cic-meta
COPY cic-meta/package.json \ COPY cic-meta/package.json \
cic-meta/package-lock.json \
./ ./
RUN npm install
COPY cic-meta/src/ src/ COPY cic-meta/src/ src/
COPY cic-meta/tests/ tests/ COPY cic-meta/tests/ tests/
COPY cic-meta/scripts/ scripts/ COPY cic-meta/scripts/ scripts/
@ -15,6 +12,8 @@ COPY cic-meta/scripts/ scripts/
RUN alias tsc=node_modules/typescript/bin/tsc RUN alias tsc=node_modules/typescript/bin/tsc
RUN npm install
COPY cic-meta/.config/ /usr/local/etc/cic-meta/ COPY cic-meta/.config/ /usr/local/etc/cic-meta/
# COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql # COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql

View File

@ -1,6 +1,6 @@
{ {
"name": "cic-client-meta", "name": "cic-client-meta",
"version": "0.0.6", "version": "0.0.7-alpha.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -6,7 +6,7 @@
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "mocha -r node_modules/node-localstorage/register -r ts-node/register tests/*.ts", "test": "mocha -r node_modules/node-localstorage/register -r ts-node/register tests/*.ts",
"build": "node_modules/typescript/bin/tsc -d --outDir dist && npm run build-server", "build": "node_modules/typescript/bin/tsc -d --outDir dist src/index.ts",
"build-server": "tsc -d --outDir dist-server scripts/server/*.ts", "build-server": "tsc -d --outDir dist-server scripts/server/*.ts",
"pack": "node_modules/typescript/bin/tsc -d --outDir dist && webpack", "pack": "node_modules/typescript/bin/tsc -d --outDir dist && webpack",
"clean": "rm -rf dist", "clean": "rm -rf dist",

View File

@ -46,3 +46,5 @@ RUN cd cic-ussd && \
# copy config and migration files to definitive file so they can be referenced in path definitions for running scripts # copy config and migration files to definitive file so they can be referenced in path definitions for running scripts
COPY cic-ussd/.config/ /usr/local/etc/cic-ussd/ COPY cic-ussd/.config/ /usr/local/etc/cic-ussd/
COPY cic-ussd/cic_ussd/db/migrations/ /usr/local/share/cic-ussd/alembic COPY cic-ussd/cic_ussd/db/migrations/ /usr/local/share/cic-ussd/alembic
WORKDIR /root

0
apps/contract-migration/reset.sh Normal file → Executable file
View File

View File

@ -49,7 +49,7 @@ This will monitor new mined blocks and send balances to the newly created accoun
Without any modifications to the cluster and config files: Without any modifications to the cluster and config files:
`python -c config --redis-host-callback redis <datadir>` `python import_users.py -c config --redis-host-callback redis <datadir>`
** A note on the The callback**: The script uses a redis callback to retrieve the newly generated custodial address. This is the redis server _from the perspective of the cic-eth component_. ** A note on the The callback**: The script uses a redis callback to retrieve the newly generated custodial address. This is the redis server _from the perspective of the cic-eth component_.

View File

@ -191,7 +191,7 @@ class BlockGetter:
def progress_callback(block_number, tx_index, s): def progress_callback(block_number, tx_index, s):
sys.stdout.write(s.ljust(200) + "\n") sys.stdout.write(str(s).ljust(200) + "\n")

View File

@ -20,7 +20,7 @@ from hexathon import (
from chainlib.eth.address import to_checksum from chainlib.eth.address import to_checksum
from cic_types.models.person import Person from cic_types.models.person import Person
from cic_eth.api.api_task import Api from cic_eth.api.api_task import Api
from cic_registry.chain import ChainSpec from chainlib.chain import ChainSpec
from cic_types.processor import generate_metadata_pointer from cic_types.processor import generate_metadata_pointer
logging.basicConfig(level=logging.WARNING) logging.basicConfig(level=logging.WARNING)
@ -142,7 +142,8 @@ if __name__ == '__main__':
new_address = register_eth(i, u) new_address = register_eth(i, u)
if u.identities.get('evm') == None: if u.identities.get('evm') == None:
u.identities['evm'] = {} u.identities['evm'] = {}
u.identities['evm'][chain_str] = [new_address] sub_chain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id())
u.identities['evm'][sub_chain_str] = [new_address]
register_ussd(u) register_ussd(u)

View File

@ -2,7 +2,7 @@ psycopg2==2.8.6
chainlib~=0.0.1a15 chainlib~=0.0.1a15
chainsyncer~=0.0.1a10 chainsyncer~=0.0.1a10
cic-eth==0.10.0a30+build.fdb16130 cic-eth==0.10.0a30+build.fdb16130
cic-registry~=0.5.3a19 cic-registry~=0.5.3a21
confini~=0.3.6rc3 confini~=0.3.6rc3
celery==4.4.7 celery==4.4.7
redis==3.5.3 redis==3.5.3

View File

@ -11,7 +11,7 @@ import csv
import json import json
import urllib import urllib
# external impotts # external imports
import celery import celery
import eth_abi import eth_abi
import confini import confini
@ -19,9 +19,9 @@ from hexathon import (
strip_0x, strip_0x,
add_0x, add_0x,
) )
from cic_registry.chain import ChainSpec
from chainsyncer.backend import MemBackend from chainsyncer.backend import MemBackend
from chainsyncer.driver import HeadSyncer from chainsyncer.driver import HeadSyncer
from chainlib.chain import ChainSpec
from chainlib.eth.connection import HTTPConnection from chainlib.eth.connection import HTTPConnection
from chainlib.eth.constant import ZERO_ADDRESS from chainlib.eth.constant import ZERO_ADDRESS
from chainlib.eth.block import ( from chainlib.eth.block import (
@ -53,7 +53,7 @@ config_dir = '/usr/local/etc/cic-syncer'
argparser = argparse.ArgumentParser(description='daemon that monitors transactions in new blocks') argparser = argparse.ArgumentParser(description='daemon that monitors transactions in new blocks')
argparser.add_argument('-p', '--provider', dest='p', type=str, help='chain rpc provider address') argparser.add_argument('-p', '--provider', dest='p', type=str, help='chain rpc provider address')
argparser.add_argument('-c', type=str, default=config_dir, help='config root to use') 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('-i', '--chain-spec', type=str, dest='i', help='chain spec')
argparser.add_argument('--meta-provider', type=str, dest='meta_provider', default='http://localhost:63380', help='cic-meta url') argparser.add_argument('--meta-provider', type=str, dest='meta_provider', default='http://localhost:63380', help='cic-meta url')
argparser.add_argument('-r', '--registry-address', type=str, dest='r', help='CIC Registry address') argparser.add_argument('-r', '--registry-address', type=str, dest='r', help='CIC Registry address')
@ -254,7 +254,6 @@ def main():
balances = {} balances = {}
f = open('{}/balances.csv'.format(user_dir, 'r')) f = open('{}/balances.csv'.format(user_dir, 'r'))
remove_zeros = 10**12
i = 0 i = 0
while True: while True:
l = f.readline() l = f.readline()
@ -266,7 +265,7 @@ def main():
sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r") sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r")
except ValueError: except ValueError:
break break
balance = int(int(r[1].rstrip()) / remove_zeros) balance = int(r[1].rstrip())
balances[address] = balance balances[address] = balance
i += 1 i += 1
@ -294,8 +293,10 @@ def main():
u = Person.deserialize(o) u = Person.deserialize(o)
logg.debug('data {}'.format(u.identities['evm'])) logg.debug('data {}'.format(u.identities['evm']))
new_address = u.identities['evm'][chain_str][0] subchain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id())
old_address = u.identities['evm'][old_chain_str][0] new_address = u.identities['evm'][subchain_str][0]
subchain_str = '{}:{}'.format(old_chain_spec.common_name(), old_chain_spec.network_id())
old_address = u.identities['evm'][subchain_str][0]
balance = balances[old_address] balance = balances[old_address]
logg.debug('checking {} -> {} = {}'.format(old_address, new_address, balance)) logg.debug('checking {} -> {} = {}'.format(old_address, new_address, balance))

0
apps/contract-migration/wait-for-it.sh Normal file → Executable file
View File

View File

@ -2,18 +2,18 @@ africastalking==1.2.3
alembic==1.4.2 alembic==1.4.2
bcrypt==3.2.0 bcrypt==3.2.0
celery==4.4.7 celery==4.4.7
confini==0.3.6a1 confini==0.3.6rc3
crypto-dev-signer==0.4.13rc2 crypto-dev-signer==0.4.13rc2
cryptography==3.2.1 cryptography==3.2.1
ecuth==0.4.5a1 ecuth==0.4.5a1
eth-accounts-index==0.0.10a7 eth-accounts-index==0.0.10a10
eth-address-index==0.1.0a7 eth-address-index==0.1.0a10
eth-tester==0.5.0b3 eth-tester==0.5.0b3
erc20-approval-escrow==0.3.0a5 erc20-transfer-authorization==0.3.0a9
erc20-single-shot-faucet==0.2.0a6 erc20-single-shot-faucet==0.2.0a6
faker==4.17.1 faker==4.17.1
http-hoba-auth==0.2.0 http-hoba-auth==0.2.0
moolb==0.1.0 moolb==0.1.1.b2
phonenumbers==8.12.12 phonenumbers==8.12.12
psycopg2==2.8.6 psycopg2==2.8.6
py-eth==0.1.1 py-eth==0.1.1
@ -40,6 +40,8 @@ websockets==8.1
yaml-acl==0.0.1 yaml-acl==0.0.1
rlp==2.0.1 rlp==2.0.1
cryptocurrency-cli-tools==0.0.4 cryptocurrency-cli-tools==0.0.4
giftable-erc20-token==0.0.7b7 giftable-erc20-token==0.0.7b12
hexathon==0.0.1a3 hexathon==0.0.1a3
chainlib==0.0.1a12 chainlib==0.0.1a16
chainsyncer==0.0.1a10
cic-registry==0.5.3.a21