Merge branch 'lash/4k' into 'master'

Make 40k import pass

See merge request grassrootseconomics/cic-internal-integration!86
This commit is contained in:
Louis Holbrook 2021-04-06 15:14:04 +00:00
commit 7728f38f14
18 changed files with 31 additions and 31 deletions

View File

@ -61,8 +61,8 @@ def balance(tokens, holder_address, chain_spec_dict):
for t in tokens: for t in tokens:
address = t['address'] address = t['address']
token = ERC20Token(rpc, address) token = ERC20Token(chain_spec, rpc, address)
c = ERC20() c = ERC20(chain_spec)
o = c.balance_of(address, holder_address, sender_address=caller_address) o = c.balance_of(address, holder_address, sender_address=caller_address)
r = rpc.do(o) r = rpc.do(o)
t['balance_network'] = c.parse_balance(r) t['balance_network'] = c.parse_balance(r)

View File

@ -171,6 +171,7 @@ def sync_tx(self, tx_hash_hex, chain_spec_dict):
except NotFoundEthException as e: except NotFoundEthException as e:
pass pass
# TODO: apply receipt in tx object to validate and normalize input
if rcpt != None: if rcpt != None:
success = rcpt['status'] == 1 success = rcpt['status'] == 1
logg.debug('sync tx {} mined block {} success {}'.format(tx_hash_hex, rcpt['blockNumber'], success)) 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, tx_hash_hex,
rcpt['blockNumber'], rcpt['blockNumber'],
rcpt['transactionIndex'],
not success, not success,
], ],
queue=queue, queue=queue,

View File

@ -23,7 +23,7 @@ def translate_address(address, trusted_addresses, chain_spec, sender_address=ZER
registry = CICRegistry(chain_spec, rpc) registry = CICRegistry(chain_spec, rpc)
declarator_address = registry.by_name('AddressDeclarator', sender_address=sender_address) declarator_address = registry.by_name('AddressDeclarator', sender_address=sender_address)
c = AddressDeclarator() c = AddressDeclarator(chain_spec)
for trusted_address in trusted_addresses: for trusted_address in trusted_addresses:
o = c.declaration(declarator_address, trusted_address, address, sender_address=sender_address) o = c.declaration(declarator_address, trusted_address, address, sender_address=sender_address)

View File

@ -20,10 +20,10 @@ def set_sent(chain_spec_dict, tx_hash, fail=False):
@celery_app.task(base=CriticalSQLAlchemyTask) @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) chain_spec = ChainSpec.from_dict(chain_spec_dict)
session = SessionBase.create_session() 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() session.close()
return r return r

View File

@ -39,6 +39,7 @@ class TxFilter(SyncFilter):
self.chain_spec.asdict(), self.chain_spec.asdict(),
add_0x(tx_hash_hex), add_0x(tx_hash_hex),
tx.block.number, tx.block.number,
tx.index,
tx.status == Status.ERROR, tx.status == Status.ERROR,
], ],
queue=self.queue, queue=self.queue,

View File

@ -80,7 +80,7 @@ straggler_delay = int(config.get('CIC_TX_RETRY_DELAY'))
# logg.debug('submitting tx {} for retry'.format(tx_hash)) # logg.debug('submitting tx {} for retry'.format(tx_hash))
# s_check = celery.signature( # s_check = celery.signature(
# 'cic_eth.admin.ctrl.check_lock', # 'cic_eth.admin.ctrl.check_lock',
[ # [
# tx_hash, # tx_hash,
# chain_str, # chain_str,
# LockEnum.QUEUE, # LockEnum.QUEUE,

View File

@ -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') #RPCConnection.register_location(config.get('ETH_PROVIDER'), chain_spec, 'default')
cic_base.rpc.setup(chain_spec, config.get('ETH_PROVIDER')) cic_base.rpc.setup(chain_spec, config.get('ETH_PROVIDER'))
def main(): def main():
# connect to celery # connect to celery
celery.Celery(broker=config.get('CELERY_BROKER_URL'), backend=config.get('CELERY_RESULT_URL')) celery.Celery(broker=config.get('CELERY_BROKER_URL'), backend=config.get('CELERY_RESULT_URL'))
@ -76,7 +75,10 @@ def main():
o = block_latest() o = block_latest()
r = rpc.do(o) 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)) logg.debug('starting at block {}'.format(block_offset))

View File

@ -10,7 +10,7 @@ version = (
0, 0,
11, 11,
0, 0,
'alpha.4', 'beta.1',
) )
version_object = semver.VersionInfo( version_object = semver.VersionInfo(

View File

@ -29,7 +29,7 @@ RUN /usr/local/bin/python -m pip install --upgrade pip
# python merge_requirements.py | tee merged_requirements.txt # python merge_requirements.py | tee merged_requirements.txt
#RUN cd cic-base && \ #RUN cd cic-base && \
# pip install $pip_extra_index_url_flag -r ./merged_requirements.txt # 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/scripts/ scripts/
COPY cic-eth/setup.cfg cic-eth/setup.py ./ COPY cic-eth/setup.cfg cic-eth/setup.py ./

View File

@ -2,7 +2,7 @@ cic-base~=0.1.2a60
celery==4.4.7 celery==4.4.7
crypto-dev-signer~=0.4.14a17 crypto-dev-signer~=0.4.14a17
confini~=0.3.6rc3 confini~=0.3.6rc3
cic-eth-registry~=0.5.4a11 cic-eth-registry~=0.5.4a12
#cic-bancor~=0.0.6 #cic-bancor~=0.0.6
redis==3.5.3 redis==3.5.3
alembic==1.4.2 alembic==1.4.2
@ -19,7 +19,7 @@ eth-address-index~=0.1.1a7
chainlib~=0.0.2a4 chainlib~=0.0.2a4
hexathon~=0.0.1a7 hexathon~=0.0.1a7
chainsyncer~=0.0.1a21 chainsyncer~=0.0.1a21
chainqueue~=0.0.1a5 chainqueue~=0.0.1a7
pysha3==1.0.2 pysha3==1.0.2
coincurve==15.0.0 coincurve==15.0.0
sarafu-faucet~=0.0.2a16 sarafu-faucet~=0.0.2a19

View File

@ -37,7 +37,7 @@ def test_tx(
eth_rpc, eth_rpc,
eth_signer, eth_signer,
agent_roles, agent_roles,
celery_worker, celery_session_worker,
): ):
rpc = RPCConnection.connect(default_chain_spec, 'default') rpc = RPCConnection.connect(default_chain_spec, 'default')

View File

@ -37,7 +37,7 @@ def test_tx(
eth_rpc, eth_rpc,
eth_signer, eth_signer,
agent_roles, agent_roles,
celery_worker, celery_session_worker,
): ):
rpc = RPCConnection.connect(default_chain_spec, 'default') rpc = RPCConnection.connect(default_chain_spec, 'default')

View File

@ -38,11 +38,12 @@ def test_transfer_api(
agent_roles, agent_roles,
cic_registry, cic_registry,
register_tokens, register_tokens,
register_lookups,
celery_session_worker, celery_session_worker,
): ):
#token = CICRegistry.get_address(default_chain_spec, bancor_tokens[0]) #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) 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) t = api.transfer(custodial_roles['FOO_TOKEN_GIFTER'], agent_roles['ALICE'], 1024, foo_token_cache.symbol)

View File

@ -116,7 +116,7 @@ def test_register_account(
init_eth_tester.mine_block() 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) o = c.have(account_registry, eth_empty_accounts[0], sender_address=call_sender)
r = eth_rpc.do(o) r = eth_rpc.do(o)
assert int(strip_0x(r), 16) == 1 assert int(strip_0x(r), 16) == 1

View File

@ -43,7 +43,7 @@ def test_filter_process(
nonce_oracle = RPCNonceOracle(agent_roles['ALICE'], eth_rpc) nonce_oracle = RPCNonceOracle(agent_roles['ALICE'], eth_rpc)
init_eth_tester.mine_blocks(13) 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) (tx_hash_hex, o) = c.transfer(foo_token, agent_roles['ALICE'], agent_roles['BOB'], 1024)
eth_rpc.do(o) eth_rpc.do(o)
o = receipt(tx_hash_hex) o = receipt(tx_hash_hex)
@ -56,7 +56,7 @@ def test_filter_process(
# external tx # external tx
init_eth_tester.mine_blocks(28) 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) (tx_hash_hex, o) = c.transfer(foo_token, agent_roles['ALICE'], agent_roles['BOB'], 512)
eth_rpc.do(o) eth_rpc.do(o)
o = receipt(tx_hash_hex) o = receipt(tx_hash_hex)

View File

@ -57,9 +57,9 @@ WORKDIR /home/grassroots
USER grassroots USER grassroots
ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433 ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433
ARG cic_base_version=0.1.2a60 ARG cic_base_version=0.1.2a61
ARG cic_eth_version=0.11.0a4 ARG cic_eth_version=0.11.0b1
ARG sarafu_faucet_version=0.0.2a16 ARG sarafu_faucet_version=0.0.2a19
ARG cic_contracts_version=0.0.2a2 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 \ RUN pip install --user --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version \
cic-eth==$cic_eth_version \ cic-eth==$cic_eth_version \

View File

@ -124,10 +124,6 @@ def register_eth(i, u):
return address return address
def register_ussd(u):
pass
if __name__ == '__main__': if __name__ == '__main__':
#fi = open(os.path.join(user_out_dir, 'addresses.csv'), 'a') #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()) sub_chain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id())
u.identities['evm'][sub_chain_str] = [new_address] u.identities['evm'][sub_chain_str] = [new_address]
register_ussd(u)
new_address_clean = strip_0x(new_address) new_address_clean = strip_0x(new_address)
filepath = os.path.join( filepath = os.path.join(
user_new_dir, user_new_dir,

View File

@ -1,5 +1,5 @@
cic-base[full_graph]==0.1.2a60 cic-base[full_graph]==0.1.2a61
sarafu-faucet==0.0.2a16 sarafu-faucet==0.0.2a17
cic-eth==0.11.0a4 cic-eth==0.11.0b1
cic-types==0.1.0a10 cic-types==0.1.0a10
crypto-dev-signer==0.4.14a17 crypto-dev-signer==0.4.14a17