Compare commits

..
Author SHA1 Message Date
nolash d3240a5063 replace requirements base for cache, notify 2021-03-29 15:17:32 +02:00
nolash 309392511a Downgrade correct cic-eth increment version 2021-03-29 14:37:35 +02:00
nolash 7684cd6aa1 Update cic-eth deps 2021-03-29 14:36:27 +02:00
nolash 059191346e Rehabilitate migration scripts 2021-03-29 14:35:02 +02:00
nolash 1047a1a487 Node atomicity rehabilitated 2021-03-29 11:35:41 +02:00
nolash bd9070ae44 Parse receipt value correctly 2021-03-29 09:55:57 +02:00
nolash 02d23112cd Bump faucet version 2021-03-29 02:21:07 +02:00
nolash 792715ca8c Upgrade facucet 2021-03-28 22:54:14 +02:00
nolash e3846809a6 WIP add writer registration to seed script 2021-03-28 21:29:05 +02:00
nolash 1322ebc8b6 WIP rehabilitate admin api runnables 2021-03-28 18:32:37 +02:00
nolash f35bbc84e4 Complete rehabilitation of RPC signing 2021-03-27 16:35:18 +01:00
nolash 47c9f16806 Add dedicated rpc signer connection 2021-03-27 15:49:22 +01:00
nolash da9d27606e Sighhhhhhhh 2021-03-26 18:07:58 +01:00
nolash e72fe5d61b Absolutely fucking sigh 2021-03-26 17:34:29 +01:00
nolash 4edf7d1e82 Sighsighsighsighsighsigh 2021-03-26 16:16:12 +01:00
nolash 80c76f2f2e sigh sigh sigh 2021-03-26 15:33:51 +01:00
nolash 5cc1526c7c Sigh 2021-03-26 15:27:46 +01:00
nolash e2913dd37d Upgrade base 2021-03-26 15:13:01 +01:00
nolash 9542b0544b Bump faucet version 2021-03-26 15:02:02 +01:00
nolash 44c1ca9573 Upgrade faucet, base without faucet 2021-03-26 14:02:49 +01:00
nolash 11f86d6409 Correct tag for account registry 2021-03-26 13:38:46 +01:00
nolash 35ca98c65b Correct role name in create account
Signed-off-by: nolash <dev@holbrook.no>
2021-03-26 10:00:34 +01:00
nolash 3a17647107 Rehabilitate tracker daemon frontend 2021-03-26 08:39:33 +01:00
nolash 101a1eb050 WIP rehabilitate sync tx 2021-03-26 07:57:35 +01:00
nolash e166f3d101 Add basic send test 2021-03-25 20:03:29 +01:00
nolash 7d5d7f67c6 Update cic-eth version in contract migration dockerfile 2021-03-25 19:24:46 +01:00
nolash 21f71043c9 WIP rehabilitate view cli 2021-03-25 19:23:41 +01:00
nolash 4ad2f18fb1 Rehabilitate lock cli 2021-03-25 16:46:46 +01:00
nolash a903d12bf0 Rehabilitate admin api tests (except nonce manip) 2021-03-25 16:40:33 +01:00
nolash 72eb61b1c2 Seed script rehabilitated with chainlib 2021-03-25 10:34:53 +01:00
nolash 5bf30afb07 WIP Rehabilitate seed scrip 2021-03-25 09:34:57 +01:00
nolash 8675b1a215 Add chain spec to tag invocations 2021-03-24 19:51:01 +01:00
nolash b93aa82bf7 Make account setter use celery 2021-03-24 17:57:18 +01:00
nolash e64b1bf984 Rehabilitate cic-eth-create step 2021-03-24 15:52:52 +01:00
nolash 585ad07c6e Merge remote-tracking branch 'origin/master' into lash/migration-last-gasp 2021-03-24 13:12:56 +01:00
nolash e138a0005a Rehabilitate reset script after chainlib refactors 2021-03-24 13:08:54 +01:00
nolash 97ecce96a8 Bump deps and version 2021-03-24 10:21:25 +01:00
nolash b441abb004 Update reset to use new deploy scripts 2021-03-23 17:15:48 +01:00
nolash 353abaa151 Merge upstream contract migration 2021-03-23 17:15:27 +01:00
nolash d892caa288 Add rpc disconnect 2021-03-23 00:13:57 +01:00
nolash 1bc08295ef WIP rehabilitate tracker daemon 2021-03-22 23:36:34 +01:00
nolash 0d67f6efba WIP rehabilitate cic tasker daemon 2021-03-22 22:57:36 +01:00
nolash 305a1f760b WIP Rehabilitate runnables 2021-03-22 22:10:52 +01:00
nolash 05f7b3c9c3 Rehabilitate bloom filter tx list test 2021-03-22 20:31:03 +01:00
nolash 431ee11f4f Rehabilitate address translate test 2021-03-22 20:10:20 +01:00
nolash 0ab8675d19 Rehabilitate transaction list api and test 2021-03-21 21:10:56 +01:00
nolash 267ce84caa Rehabilitate balance api 2021-03-21 19:39:38 +01:00
nolash 333d410b1c Bump version 2021-03-21 14:04:54 +01:00
nolash e5223e6195 Rename token registration fixture 2021-03-21 14:04:14 +01:00
nolash 453dd47091 Rehabilitate api tests 2021-03-21 12:18:15 +01:00
nolash 65bb4cf66f Reinstate api callback test 2021-03-20 23:00:15 +01:00
nolash 06ddfb4fe8 Reinstate basic tx test 2021-03-20 22:58:48 +01:00
nolash 2eaaedb0f0 Rehabilitate db unit tests 2021-03-20 22:40:06 +01:00
nolash 964952e904 Rehabilitate queue tests 2021-03-20 21:10:19 +01:00
nolash 788aa9d7b9 WIP Rehabilitate queue tests 2021-03-20 16:44:07 +01:00
nolash bf832afb87 Rehabilitate list tx and balances test 2021-03-20 14:35:35 +01:00
nolash 3f61a2007e Rehabilitate transfer, approve
Signed-off-by: nolash <dev@holbrook.no>
2021-03-20 13:58:45 +01:00
nolash c245a29a6b Rehabilitate erc20 balance task 2021-03-19 19:51:30 +01:00
nolash 871cbdcaeb Account register test passes 2021-03-18 19:36:52 +01:00
nolash 2f07ea1395 WIP refactor send, checkgas, refillgas to use chainlib 2021-03-18 11:57:26 +01:00
nolash 9f2773e948 Change from rlp to simple-rlp 2021-03-17 17:22:17 +01:00
nolash 41731b5e96 WIP Add role fixture, rehabilitate account register task, test 2021-03-17 11:24:55 +01:00
nolash 318615751c WIP rehabilitate register account test and task 2021-03-16 17:16:06 +01:00
nolash 6a6b6b59d8 Assimilate agnostic rpc in base tests 2021-03-16 15:35:22 +01:00
nolash be3a2e7b2d Port new fixtures, registry setup in tests 2021-03-15 19:46:37 +01:00
nolash a6fd20124c WIP receive new registry 2021-03-13 21:31:37 +01:00
nolash e20a099570 WIP Remove web3 from tests 2021-03-12 18:44:29 +01:00
nolash 958bd9af96 Move signer from middleware to dedicated connection 2021-03-12 09:36:57 +01:00
nolash 10835979bc Use chainlib directly for signing 2021-03-11 11:40:30 +01:00
nolash 94c8fd6cd6 Revert back to subsession handling of nonce 2021-03-09 07:43:31 +01:00
nolash 2fe205b1e8 Provide web3 constructor to tracker rpc client 2021-03-08 15:51:45 +01:00
nolash b37c7f3cc2 Provide thread safe registry solution 2021-03-08 10:11:04 +01:00
nolash abc9877726 Merge branch 'master' into lash/migration-last-gasp 2021-03-07 20:35:43 +01:00
nolash 6d6e2a29b4 Fix refill gas task typo, include missing eth error symbol 2021-03-07 20:10:49 +01:00
nolash b9d7cc20f7 Merge remote-tracking branch 'origin/master' into lash/cli-rehabilitations 2021-03-07 19:54:32 +01:00
nolash cf468fc4c7 Add custom eth error 2021-03-07 19:01:16 +01:00
nolash 69a13235ba Handle occasional incompatible phone number 2021-03-07 15:42:09 +01:00
nolash 84a20a6743 Merge remote-tracking branch 'origin/master' into lash/cli-rehabilitations 2021-03-07 14:52:11 +01:00
nolash 67330b2ad5 Make lock tasks critical db tasks 2021-03-07 13:33:26 +01:00
nolash 16ea3f3db8 Bump version 2021-03-07 12:53:09 +01:00
nolash 2b354a1029 Add role tag option to reserve nonce 2021-03-07 12:52:48 +01:00
nolash 5f0822598f Bump cic base 2021-03-07 10:37:27 +01:00
nolash 05479a6576 WIP remove lower layer deps in ussd, correct create account api task graph 2021-03-07 10:33:11 +01:00
nolash 1c0732d983 Upgrade notify 2021-03-07 07:45:13 +01:00
nolash fd263e7648 Merge remote-tracking branch 'origin/master' into lash/browser-emulator-ussd 2021-03-07 07:24:42 +01:00
nolash 2e09b69e36 Add configurable host, port, ssl scheme to ussd browser emulator 2021-03-06 23:50:43 +01:00
16 changed files with 107 additions and 398 deletions
+16 -45
View File
@@ -31,10 +31,7 @@ from cic_eth.db.models.tx import TxCache
from cic_eth.db.models.nonce import Nonce
from cic_eth.db.enum import (
StatusEnum,
StatusBits,
is_alive,
is_error_status,
status_str,
)
from cic_eth.error import InitializationError
from cic_eth.db.error import TxStateChangeError
@@ -45,8 +42,6 @@ app = celery.current_app
#logg = logging.getLogger(__file__)
logg = logging.getLogger()
local_fail = StatusBits.LOCAL_ERROR | StatusBits.NODE_ERROR | StatusBits.UNKNOWN_ERROR
class AdminApi:
"""Provides an interface to view and manipulate existing transaction tasks and system runtime settings.
@@ -200,7 +195,6 @@ class AdminApi:
blocking_tx = None
blocking_nonce = None
nonce_otx = 0
last_nonce = -1
for k in txs.keys():
s_get_tx = celery.signature(
'cic_eth.queue.tx.get_tx',
@@ -211,25 +205,18 @@ class AdminApi:
)
tx = s_get_tx.apply_async().get()
#tx = get_tx(k)
logg.debug('checking nonce {} (previous {})'.format(tx['nonce'], last_nonce))
logg.debug('checking nonce {}'.format(tx['nonce']))
if tx['status'] in [StatusEnum.REJECTED, StatusEnum.FUBAR]:
blocking_tx = k
blocking_nonce = tx['nonce']
nonce_otx = tx['nonce']
if not is_alive(tx['status']) and tx['status'] & local_fail > 0:
logg.info('permanently errored {} nonce {} status {}'.format(k, nonce_otx, status_str(tx['status'])))
blocking_tx = k
blocking_nonce = nonce_otx
elif nonce_otx - last_nonce > 1:
logg.error('nonce gap; {} followed {}'.format(nonce_otx, last_nonce))
blocking_tx = k
blocking_nonce = nonce_otx
break
last_nonce = nonce_otx
#nonce_cache = Nonce.get(address)
nonce_cache = Nonce.get(address)
#nonce_w3 = self.w3.eth.getTransactionCount(address, 'pending')
return {
'nonce': {
#'network': nonce_cache,
'network': nonce_cache,
'queue': nonce_otx,
#'cache': nonce_cache,
'blocking': blocking_nonce,
@@ -283,15 +270,16 @@ class AdminApi:
# self.w3.eth.sign(addr, text='666f6f')
def account(self, chain_spec, address, include_sender=True, include_recipient=True, renderer=None, w=sys.stdout):
def account(self, chain_spec, address, cols=['tx_hash', 'sender', 'recipient', 'nonce', 'block', 'tx_index', 'status', 'network_status', 'date_created'], include_sender=True, include_recipient=True):
"""Lists locally originated transactions for the given Ethereum address.
Performs a synchronous call to the Celery task responsible for performing the query.
:param address: Ethereum address to return transactions for
:type address: str, 0x-hex
:param cols: Data columns to include
:type cols: list of str
"""
last_nonce = -1
s = celery.signature(
'cic_eth.queue.tx.get_account_tx',
[
@@ -303,45 +291,33 @@ class AdminApi:
tx_dict_list = []
for tx_hash in txs.keys():
errors = []
s = celery.signature(
'cic_eth.queue.tx.get_tx_cache',
[tx_hash],
queue=self.queue,
)
tx_dict = s.apply_async().get()
if tx_dict['sender'] == address:
if tx_dict['nonce'] - last_nonce > 1:
logg.error('nonce gap; {} followed {} for tx {}'.format(tx_dict['nonce'], last_nonce, tx_dict['hash']))
errors.append('nonce')
elif tx_dict['nonce'] == last_nonce:
logg.warning('nonce {} duplicate in tx {}'.format(tx_dict['nonce'], tx_dict['hash']))
last_nonce = tx_dict['nonce']
if not include_sender:
logg.debug('skipping sender tx {}'.format(tx_dict['tx_hash']))
continue
if tx_dict['sender'] == address and not include_sender:
logg.debug('skipping sender tx {}'.format(tx_dict['tx_hash']))
continue
elif tx_dict['recipient'] == address and not include_recipient:
logg.debug('skipping recipient tx {}'.format(tx_dict['tx_hash']))
continue
logg.debug(tx_dict)
o = {
'nonce': tx_dict['nonce'],
'tx_hash': tx_dict['tx_hash'],
'status': tx_dict['status'],
'date_updated': tx_dict['date_updated'],
'errors': errors,
}
if renderer != None:
r = renderer(o)
w.write(r + '\n')
else:
tx_dict_list.append(o)
tx_dict_list.append(o)
return tx_dict_list
# TODO: Add exception upon non-existent tx aswell as invalid tx data to docstring
def tx(self, chain_spec, tx_hash=None, tx_raw=None, registry=None, renderer=None, w=sys.stdout):
def tx(self, chain_spec, tx_hash=None, tx_raw=None, registry=None):
"""Output local and network details about a given transaction with local origin.
If the transaction hash is given, the raw trasnaction data will be retrieved from the local transaction queue backend. Otherwise the raw transaction data must be provided directly. Only one of transaction hash and transaction data can be passed.
@@ -535,9 +511,4 @@ class AdminApi:
for p in problems:
sys.stderr.write('!!!{}\n'.format(p))
if renderer == None:
return tx
r = renderer(tx)
w.write(r + '\n')
return None
return tx
-1
View File
@@ -281,7 +281,6 @@ def send(self, txs, chain_spec_dict):
o = raw(tx_hex)
conn = RPCConnection.connect(chain_spec, 'default')
conn.do(o)
s_set_sent.apply_async()
tx_tail = txs[1:]
-33
View File
@@ -1,33 +0,0 @@
# standard imports
import logging
# external imports
from cic_eth_registry import CICRegistry
from cic_eth_registry.lookup.declarator import AddressDeclaratorLookup
from cic_eth_registry.lookup.tokenindex import TokenIndexLookup
logg = logging.getLogger()
def connect_token_registry(rpc, chain_spec):
registry = CICRegistry(chain_spec, rpc)
token_registry_address = registry.by_name('TokenRegistry')
logg.debug('using token registry address {}'.format(token_registry_address))
lookup = TokenIndexLookup(token_registry_address)
CICRegistry.add_lookup(lookup)
def connect_declarator(rpc, chain_spec, trusted_addresses):
registry = CICRegistry(chain_spec, rpc)
declarator_address = registry.by_name('AddressDeclarator')
logg.debug('using declarator address {}'.format(declarator_address))
lookup = AddressDeclaratorLookup(declarator_address, trusted_addresses)
CICRegistry.add_lookup(lookup)
def connect(rpc, chain_spec, registry_address):
CICRegistry.address = registry_address
registry = CICRegistry(chain_spec, rpc)
registry_address = registry.by_name('ContractRegistry')
return registry
@@ -16,6 +16,8 @@ from chainlib.eth.connection import EthUnixSignerConnection
from chainlib.chain import ChainSpec
# local imports
from cic_eth_registry import CICRegistry
from cic_eth.eth import erc20
from cic_eth.eth import tx
from cic_eth.eth import account
@@ -31,11 +33,6 @@ from cic_eth.db.models.base import SessionBase
from cic_eth.db.models.otx import Otx
from cic_eth.db import dsn_from_config
from cic_eth.ext import tx
from cic_eth.registry import (
connect as connect_registry,
connect_declarator,
connect_token_registry,
)
logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger()
@@ -124,6 +121,8 @@ RPCConnection.register_location(config.get('SIGNER_SOCKET_PATH'), chain_spec, 's
Otx.tracing = config.true('TASKS_TRACE_QUEUE_STATUS')
CICRegistry.address = config.get('CIC_REGISTRY_ADDRESS')
def main():
argv = ['worker']
@@ -146,8 +145,8 @@ def main():
# Callback.ssl_ca_file = config.get('SSL_CA_FILE')
rpc = RPCConnection.connect(chain_spec, 'default')
connect_registry(rpc, chain_spec, config.get('CIC_REGISTRY_ADDRESS'))
registry = CICRegistry(chain_spec, rpc)
registry_address = registry.by_name('ContractRegistry')
trusted_addresses_src = config.get('CIC_TRUST_ADDRESS')
if trusted_addresses_src == None:
@@ -156,8 +155,6 @@ def main():
trusted_addresses = trusted_addresses_src.split(',')
for address in trusted_addresses:
logg.info('using trusted address {}'.format(address))
connect_declarator(rpc, chain_spec, trusted_addresses)
connect_token_registry(rpc, chain_spec)
current_app.worker_main(argv)
-100
View File
@@ -1,100 +0,0 @@
#!/usr/bin/python
import sys
import os
import logging
import uuid
import json
import argparse
# external imports
import celery
import confini
import redis
from xdg.BaseDirectory import xdg_config_home
from chainlib.eth.address import to_checksum_address
# local imports
from cic_eth.api import Api
logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger('create_account_script')
logging.getLogger('confini').setLevel(logging.WARNING)
logging.getLogger('gnupg').setLevel(logging.WARNING)
default_config_dir = os.environ.get('CONFINI_DIR', '/usr/local/etc/cic')
argparser = argparse.ArgumentParser()
argparser.add_argument('--no-register', dest='no_register', action='store_true', help='Do not register new account in on-chain accounts index')
argparser.add_argument('-c', type=str, default=default_config_dir, help='config file')
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, help='chain spec')
argparser.add_argument('--token-symbol', dest='token_symbol', type=str, help='Symbol of token to transfer')
argparser.add_argument('--redis-host', dest='redis_host', type=str, help='redis host to use for task submission')
argparser.add_argument('--redis-port', dest='redis_port', type=int, help='redis host to use for task submission')
argparser.add_argument('--redis-db', dest='redis_db', type=int, help='redis db to use for task submission and callback')
argparser.add_argument('--redis-host-callback', dest='redis_host_callback', default='localhost', type=str, help='redis host to use for callback')
argparser.add_argument('--redis-port-callback', dest='redis_port_callback', default=6379, type=int, help='redis port to use for callback')
argparser.add_argument('--timeout', default=20.0, type=float, help='Callback timeout')
argparser.add_argument('-q', type=str, default='cic-eth', help='Task queue')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
argparser.add_argument('sender', type=str, help='Transaction sender')
argparser.add_argument('recipient', type=str, help='Transaction recipient')
argparser.add_argument('value', type=int, help='Transaction value with decimals')
args = argparser.parse_args()
if args.vv:
logg.setLevel(logging.DEBUG)
if args.v:
logg.setLevel(logging.INFO)
config_dir = args.c
config = confini.Config(config_dir, os.environ.get('CONFINI_ENV_PREFIX'))
config.process()
args_override = {
'CIC_CHAIN_SPEC': getattr(args, 'i'),
'REDIS_HOST': getattr(args, 'redis_host'),
'REDIS_PORT': getattr(args, 'redis_port'),
'REDIS_DB': getattr(args, 'redis_db'),
}
config.dict_override(args_override, 'cli')
config.add(to_checksum_address(args.sender), '_SENDER', True)
config.add(to_checksum_address(args.recipient), '_RECIPIENT', True)
config.add(args.value, '_VALUE', True)
config.add(args.token_symbol, '_SYMBOL', True)
if config.get('_SYMBOL') == None:
raise ValueError('gas transfers not yet supported; token symbol required')
celery_app = celery.Celery(broker=config.get('CELERY_BROKER_URL'), backend=config.get('CELERY_RESULT_URL'))
def main():
redis_host = config.get('REDIS_HOST')
redis_port = config.get('REDIS_PORT')
redis_db = config.get('REDIS_DB')
redis_channel = str(uuid.uuid4())
r = redis.Redis(redis_host, redis_port, redis_db)
ps = r.pubsub()
ps.subscribe(redis_channel)
ps.get_message()
api = Api(
config.get('CIC_CHAIN_SPEC'),
queue=args.q,
callback_param='{}:{}:{}:{}'.format(args.redis_host_callback, args.redis_port_callback, redis_db, redis_channel),
callback_task='cic_eth.callbacks.redis.redis',
callback_queue=args.q,
)
#register = not args.no_register
#logg.debug('register {}'.format(register))
#t = api.create_account(register=register)
t = api.transfer(config.get('_SENDER'), config.get('_RECIPIENT'), config.get('_VALUE'), config.get('_SYMBOL'))
ps.get_message()
o = ps.get_message(timeout=args.timeout)
m = json.loads(o['data'])
print(m['result'])
if __name__ == '__main__':
main()
+27 -17
View File
@@ -14,6 +14,8 @@ import datetime
# external imports
import confini
import celery
from cic_eth_registry import CICRegistry
from cic_eth_registry.lookup.declarator import AddressDeclaratorLookup
from chainlib.chain import ChainSpec
from chainlib.eth.connection import EthHTTPConnection
from hexathon import add_0x
@@ -25,7 +27,6 @@ from cic_eth.db.enum import (
status_str,
LockEnum,
)
from cic_eth.registry import connect as connect_registry
logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger()
@@ -115,16 +116,12 @@ def render_tx(o, **kwargs):
return content
def render_account(o, **kwargs):
s = '{} {} {} {}'.format(
return '{} {} {} {}'.format(
o['date_updated'],
o['nonce'],
o['tx_hash'],
o['status'],
)
if len(o['errors']) > 0:
s += ' !{}'.format(','.join(o['errors']))
return s
def render_lock(o, **kwargs):
@@ -146,31 +143,44 @@ def render_lock(o, **kwargs):
return s
def connect_registry(registry_address, chain_spec, rpc):
CICRegistry.address = registry_address
registry = CICRegistry(chain_spec, rpc)
declarator_address = registry.by_name('AddressDeclarator')
lookup = AddressDeclaratorLookup(declarator_address, trusted_addresses)
registry.add_lookup(lookup)
return registry
# TODO: move each command to submodule
def main():
txs = []
renderer = render_tx
if len(config.get('_QUERY')) > 66:
registry = connect_registry(rpc, chain_spec, registry_address)
admin_api.tx(chain_spec, tx_raw=config.get('_QUERY'), registry=registry, renderer=renderer)
registry = connect_registry(registry_address, chain_spec, rpc)
txs = [admin_api.tx(chain_spec, tx_raw=config.get('_QUERY'), registry=registry)]
elif len(config.get('_QUERY')) > 42:
registry = connect_registry(rpc, chain_spec, registry_address)
admin_api.tx(chain_spec, tx_hash=config.get('_QUERY'), registry=registry, renderer=renderer)
registry = connect_registry(registry_address, chain_spec, rpc)
txs = [admin_api.tx(chain_spec, tx_hash=config.get('_QUERY'), registry=registry)]
elif len(config.get('_QUERY')) == 42:
registry = connect_registry(rpc, chain_spec, registry_address)
txs = admin_api.account(chain_spec, config.get('_QUERY'), include_recipient=False, renderer=render_account)
registry = connect_registry(registry_address, chain_spec, rpc)
txs = admin_api.account(chain_spec, config.get('_QUERY'), include_recipient=False)
renderer = render_account
elif len(config.get('_QUERY')) >= 4 and config.get('_QUERY')[:4] == 'lock':
t = admin_api.get_lock()
txs = t.get()
renderer = render_lock
for tx in txs:
r = renderer(txs)
sys.stdout.write(r + '\n')
else:
raise ValueError('cannot parse argument {}'.format(config.get('_QUERY')))
if len(txs) == 0:
logg.info('no matches found')
else:
if fmt == 'json':
sys.stdout.write(json.dumps(txs))
else:
m = map(renderer, txs)
print(*m, sep="\n")
if __name__ == '__main__':
main()
+1 -1
View File
@@ -10,7 +10,7 @@ version = (
0,
10,
1,
'beta.2',
'beta.1',
)
version_object = semver.VersionInfo(
-1
View File
@@ -54,4 +54,3 @@ console_scripts =
# TODO: Merge this with ctl when subcmds sorted to submodules
cic-eth-tag = cic_eth.runnable.tag:main
cic-eth-resend = cic_eth.runnable.resend:main
cic-eth-transfer = cic_eth.runnable.transfer:main
@@ -1,50 +0,0 @@
# external imports
from chainlib.eth.nonce import RPCNonceOracle
from chainlib.eth.tx import (
receipt,
)
from eth_address_declarator import AddressDeclarator
from hexathon import add_0x
# local imports
from cic_eth.ext.address import translate_tx_addresses
def test_translate(
default_chain_spec,
address_declarator,
eth_signer,
eth_rpc,
contract_roles,
agent_roles,
cic_registry,
init_celery_tasks,
):
nonce_oracle = RPCNonceOracle(contract_roles['CONTRACT_DEPLOYER'], eth_rpc)
c = AddressDeclarator(signer=eth_signer, nonce_oracle=nonce_oracle, chain_id=default_chain_spec.chain_id())
description = 'alice'.encode('utf-8').ljust(32, b'\x00').hex()
(tx_hash_hex, o) = c.add_declaration(address_declarator, contract_roles['CONTRACT_DEPLOYER'], agent_roles['ALICE'], add_0x(description))
eth_rpc.do(o)
o = receipt(tx_hash_hex)
r = eth_rpc.do(o)
assert r['status'] == 1
description = 'bob'.encode('utf-8').ljust(32, b'\x00').hex()
(tx_hash_hex, o) = c.add_declaration(address_declarator, contract_roles['CONTRACT_DEPLOYER'], agent_roles['BOB'], add_0x(description))
eth_rpc.do(o)
o = receipt(tx_hash_hex)
r = eth_rpc.do(o)
assert r['status'] == 1
tx = {
'sender': agent_roles['ALICE'],
'sender_label': None,
'recipient': agent_roles['BOB'],
'recipient_label': None,
}
tx = translate_tx_addresses(tx, [contract_roles['CONTRACT_DEPLOYER']], default_chain_spec.asdict())
assert tx['sender_label'] == 'alice'
assert tx['recipient_label'] == 'bob'
@@ -1,96 +0,0 @@
# standard imports
import logging
# external imports
import celery
import moolb
from chainlib.eth.tx import (
count,
receipt,
)
from chainlib.eth.erc20 import ERC20
from chainlib.eth.nonce import RPCNonceOracle
# local imports
from cic_eth.db.models.nonce import (
NonceReservation,
Nonce,
)
logg = logging.getLogger()
# TODO: This test fails when not run alone. Identify which fixture leaves a dirty state
def test_filter_process(
init_database,
default_chain_spec,
init_eth_tester,
eth_rpc,
eth_signer,
agent_roles,
init_custodial,
cic_registry,
foo_token,
celery_session_worker,
):
b = moolb.Bloom(1024, 3)
t = moolb.Bloom(1024, 3)
tx_hashes = []
# external tx
nonce_oracle = RPCNonceOracle(agent_roles['ALICE'], eth_rpc)
init_eth_tester.mine_blocks(13)
c = ERC20(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)
r = eth_rpc.do(o)
a = r['block_number']
b.add(a.to_bytes(4, 'big'))
a = r['block_number'] + r['transaction_index']
t.add(a.to_bytes(4, 'big'))
tx_hashes.append(tx_hash_hex)
# external tx
init_eth_tester.mine_blocks(28)
c = ERC20(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)
r = eth_rpc.do(o)
a = r['block_number']
b.add(a.to_bytes(4, 'big'))
a = r['block_number'] + r['transaction_index']
t.add(a.to_bytes(4, 'big'))
tx_hashes.append(tx_hash_hex)
init_eth_tester.mine_blocks(10)
o = {
'alg': 'sha256',
'filter_rounds': 3,
'low': 0,
'high': 50,
'block_filter': b.to_bytes().hex(),
'blocktx_filter': t.to_bytes().hex(),
}
s = celery.signature(
'cic_eth.ext.tx.list_tx_by_bloom',
[
o,
agent_roles['BOB'],
default_chain_spec.asdict(),
],
queue=None
)
t = s.apply_async()
r = t.get()
assert len(r) == 2
for tx_hash in r.keys():
tx_hashes.remove(tx_hash)
assert len(tx_hashes) == 0
+5 -1
View File
@@ -1 +1,5 @@
cic_base[full_graph]~=0.1.2a46
alembic~=1.4.2
celery~=4.4.7
confini~=0.3.6rc3
redis~=3.5.3
semver==2.13.0
+1 -1
View File
@@ -1,7 +1,7 @@
# standard imports
import semver
version = (0, 3, 0, 'alpha.7')
version = (0, 3, 0, 'alpha.5')
version_object = semver.VersionInfo(
major=version[0],
+47 -2
View File
@@ -1,4 +1,49 @@
cic_base[full_graph]~=0.1.2a46
#cic_base[full_graph]~=0.1.1a24
africastalking==1.2.3
alembic==1.4.2
amqp==2.6.1
attrs==20.2.0
bcrypt==3.2.0
betterpath==0.2.2
billiard==3.6.3.0
celery==4.4.7
cffi==1.14.3
cic-eth~=0.10.1b1
cic-notify~=0.4.0a3
cic-types~=0.1.0a8
cic-types~=0.1.0a8
click==7.1.2
confini~=0.3.6rc3
cryptography==3.2.1
faker==4.17.1
iniconfig==1.1.1
kombu==4.6.11
Mako==1.1.3
MarkupSafe==1.1.1
mirakuru==2.3.0
more-itertools==8.5.0
packaging==20.4
phonenumbers==8.12.12
pluggy==0.13.1
port-for==0.4
psutil==5.7.3
psycopg2==2.8.6
py==1.9.0
pycparser==2.20
pyparsing==2.4.7
python-dateutil==2.8.1
python-editor==1.0.4
python-gnupg==0.4.6
python-i18n==0.3.9
pytz==2020.1
PyYAML==5.3.1
redis==3.5.3
semver==2.13.0
six==1.15.0
SQLAlchemy==1.3.20
tinydb==4.2.0
toml==0.10.1
transitions==0.8.4
uWSGI==2.0.19.1
vcversioner==2.16.0.0
vine==1.3.0
zope.interface==5.1.2
+3 -39
View File
@@ -32,10 +32,7 @@ from chainlib.eth.block import (
from chainlib.eth.hash import keccak256_string_to_hex
from chainlib.eth.address import to_checksum_address
from chainlib.eth.erc20 import ERC20
from chainlib.eth.gas import (
OverrideGasOracle,
balance,
)
from chainlib.eth.gas import OverrideGasOracle
from chainlib.eth.tx import TxFactory
from chainlib.eth.rpc import jsonrpc_template
from chainlib.eth.error import EthException
@@ -44,7 +41,6 @@ from cic_types.models.person import (
Person,
generate_metadata_pointer,
)
from erc20_single_shot_faucet import SingleShotFaucet
logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger()
@@ -131,19 +127,17 @@ class VerifierError(Exception):
class Verifier:
# TODO: what an awful function signature
def __init__(self, conn, cic_eth_api, gas_oracle, chain_spec, index_address, token_address, faucet_address, data_dir, exit_on_error=False):
def __init__(self, conn, cic_eth_api, gas_oracle, chain_spec, index_address, token_address, data_dir, exit_on_error=False):
self.conn = conn
self.gas_oracle = gas_oracle
self.chain_spec = chain_spec
self.index_address = index_address
self.token_address = token_address
self.faucet_address = faucet_address
self.erc20_tx_factory = ERC20(chain_id=chain_spec.chain_id(), gas_oracle=gas_oracle)
self.tx_factory = TxFactory(chain_id=chain_spec.chain_id(), gas_oracle=gas_oracle)
self.api = cic_eth_api
self.data_dir = data_dir
self.exit_on_error = exit_on_error
self.faucet_tx_factory = SingleShotFaucet(chain_id=chain_spec.chain_id(), gas_oracle=gas_oracle)
verifymethods = []
for k in dir(self):
@@ -188,21 +182,6 @@ class Verifier:
raise VerifierError((address, r), 'local key')
def verify_gas(self, address, balance_token=None):
o = balance(address)
r = self.conn.do(o)
actual_balance = int(strip_0x(r), 16)
if actual_balance == 0:
raise VerifierError((address, actual_balance), 'gas')
def verify_faucet(self, address, balance_token=None):
o = self.faucet_tx_factory.usable_for(self.faucet_address, address)
r = self.conn.do(o)
if self.faucet_tx_factory.parse_usable_for(r):
raise VerifierError((address, r), 'faucet')
def verify_metadata(self, address, balance=None):
k = generate_metadata_pointer(bytes.fromhex(strip_0x(address)), ':cic.person')
url = os.path.join(meta_url, k)
@@ -241,8 +220,6 @@ class Verifier:
'accounts_index',
'balance',
'metadata',
'gas',
'faucet',
]
for k in methods:
@@ -280,7 +257,6 @@ def main():
txf = TxFactory(signer=None, gas_oracle=gas_oracle, nonce_oracle=None, chain_id=chain_spec.chain_id())
tx = txf.template(ZERO_ADDRESS, config.get('CIC_REGISTRY_ADDRESS'))
# TODO: replace with cic-eth-registry
registry_addressof_method = keccak256_string_to_hex('addressOf(bytes32)')[:8]
data = add_0x(registry_addressof_method)
data += eth_abi.encode_single('bytes32', b'TokenRegistry').hex()
@@ -307,18 +283,6 @@ def main():
account_index_address = to_checksum_address(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
logg.info('found account index address {}'.format(account_index_address))
data = add_0x(registry_addressof_method)
data += eth_abi.encode_single('bytes32', b'Faucet').hex()
txf.set_code(tx, data)
o = jsonrpc_template()
o['method'] = 'eth_call'
o['params'].append(txf.normalize(tx))
o['params'].append('latest')
r = conn.do(o)
faucet_address = to_checksum_address(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
logg.info('found faucet {}'.format(faucet_address))
# Get Sarafu token address
tx = txf.template(ZERO_ADDRESS, token_index_address)
@@ -359,7 +323,7 @@ def main():
api = AdminApi(MockClient())
verifier = Verifier(conn, api, gas_oracle, chain_spec, account_index_address, sarafu_token_address, faucet_address, user_dir, exit_on_error)
verifier = Verifier(conn, api, gas_oracle, chain_spec, account_index_address, sarafu_token_address, user_dir, exit_on_error)
user_new_dir = os.path.join(user_dir, 'new')
for x in os.walk(user_new_dir):
+1 -1
View File
@@ -22,7 +22,7 @@ abi_dir=${ETH_ABI_DIR:-/usr/local/share/cic/solidity/abi}
gas_amount=100000000000000000000000
token_amount=${gas_amount}
#faucet_amount=1000000000
faucet_amount=${DEV_FAUCET_AMOUNT:-0}
faucet_amount=0
env_out_file=${CIC_DATA_DIR}/.env_seed
init_level_file=${CIC_DATA_DIR}/.init
truncate $env_out_file -s 0
-1
View File
@@ -102,7 +102,6 @@ services:
CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis:6379}
DEV_PIP_EXTRA_INDEX_URL: ${DEV_PIP_EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
RUN_MASK: ${RUN_MASK:-0} # bit flags; 1: contract migrations 2: seed data
DEV_FAUCET_AMOUNT: ${DEV_FAUCET_AMOUNT:-0}
command: ["./run_job.sh"]
#command: ["./reset.sh"]
depends_on: