Compare commits
2 Commits
fix-cache-
...
lash/retry
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec45ce6db4
|
||
|
|
9de522f9d9
|
@@ -25,7 +25,6 @@ licence_files =
|
||||
python_requires = >= 3.6
|
||||
packages =
|
||||
cic_cache
|
||||
cic_cache.tasks
|
||||
cic_cache.db
|
||||
cic_cache.db.models
|
||||
cic_cache.runnable
|
||||
@@ -34,6 +33,5 @@ scripts =
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
cic-cache-trackerd = cic_cache.runnable.tracker:main
|
||||
cic-cache-serverd = cic_cache.runnable.server:main
|
||||
cic-cache-taskerd = cic_cache.runnable.tasker:main
|
||||
cic-cache-tracker = cic_cache.runnable.tracker:main
|
||||
cic-cache-server = cic_cache.runnable.server:main
|
||||
|
||||
@@ -10,15 +10,12 @@ from cic_registry import zero_address
|
||||
from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.task import (
|
||||
CriticalSQLAlchemyTask,
|
||||
)
|
||||
from cic_eth.error import LockedError
|
||||
|
||||
celery_app = celery.current_app
|
||||
logg = logging.getLogger()
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
@celery_app.task()
|
||||
def lock(chained_input, chain_str, address=zero_address, flags=LockEnum.ALL, tx_hash=None):
|
||||
"""Task wrapper to set arbitrary locks
|
||||
|
||||
@@ -36,7 +33,7 @@ def lock(chained_input, chain_str, address=zero_address, flags=LockEnum.ALL, tx_
|
||||
return chained_input
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
@celery_app.task()
|
||||
def unlock(chained_input, chain_str, address=zero_address, flags=LockEnum.ALL):
|
||||
"""Task wrapper to reset arbitrary locks
|
||||
|
||||
@@ -54,7 +51,7 @@ def unlock(chained_input, chain_str, address=zero_address, flags=LockEnum.ALL):
|
||||
return chained_input
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
@celery_app.task()
|
||||
def lock_send(chained_input, chain_str, address=zero_address, tx_hash=None):
|
||||
"""Task wrapper to set send lock
|
||||
|
||||
@@ -70,7 +67,7 @@ def lock_send(chained_input, chain_str, address=zero_address, tx_hash=None):
|
||||
return chained_input
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
@celery_app.task()
|
||||
def unlock_send(chained_input, chain_str, address=zero_address):
|
||||
"""Task wrapper to reset send lock
|
||||
|
||||
@@ -86,7 +83,7 @@ def unlock_send(chained_input, chain_str, address=zero_address):
|
||||
return chained_input
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
@celery_app.task()
|
||||
def lock_queue(chained_input, chain_str, address=zero_address, tx_hash=None):
|
||||
"""Task wrapper to set queue direct lock
|
||||
|
||||
@@ -102,7 +99,7 @@ def lock_queue(chained_input, chain_str, address=zero_address, tx_hash=None):
|
||||
return chained_input
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
@celery_app.task()
|
||||
def unlock_queue(chained_input, chain_str, address=zero_address):
|
||||
"""Task wrapper to reset queue direct lock
|
||||
|
||||
@@ -118,7 +115,7 @@ def unlock_queue(chained_input, chain_str, address=zero_address):
|
||||
return chained_input
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
@celery_app.task()
|
||||
def check_lock(chained_input, chain_str, lock_flags, address=None):
|
||||
session = SessionBase.create_session()
|
||||
r = Lock.check(chain_str, lock_flags, address=zero_address, session=session)
|
||||
|
||||
@@ -82,7 +82,6 @@ class Api:
|
||||
:returns: uuid of root task
|
||||
:rtype: celery.Task
|
||||
"""
|
||||
raise NotImplementedError('out of service until new DEX migration is done')
|
||||
s_check = celery.signature(
|
||||
'cic_eth.admin.ctrl.check_lock',
|
||||
[
|
||||
@@ -144,7 +143,6 @@ class Api:
|
||||
:returns: uuid of root task
|
||||
:rtype: celery.Task
|
||||
"""
|
||||
raise NotImplementedError('out of service until new DEX migration is done')
|
||||
s_check = celery.signature(
|
||||
'cic_eth.admin.ctrl.check_lock',
|
||||
[
|
||||
@@ -342,6 +340,11 @@ class Api:
|
||||
],
|
||||
queue=self.queue,
|
||||
)
|
||||
s_nonce = celery.signature(
|
||||
'cic_eth.eth.tx.reserve_nonce',
|
||||
[],
|
||||
queue=self.queue,
|
||||
)
|
||||
s_account = celery.signature(
|
||||
'cic_eth.eth.account.create',
|
||||
[
|
||||
@@ -349,18 +352,12 @@ class Api:
|
||||
],
|
||||
queue=self.queue,
|
||||
)
|
||||
s_check.link(s_account)
|
||||
s_nonce.link(s_account)
|
||||
s_check.link(s_nonce)
|
||||
if self.callback_param != None:
|
||||
s_account.link(self.callback_success)
|
||||
|
||||
if register:
|
||||
s_nonce = celery.signature(
|
||||
'cic_eth.eth.tx.reserve_nonce',
|
||||
[
|
||||
'ACCOUNTS_INDEX_WRITER',
|
||||
],
|
||||
queue=self.queue,
|
||||
)
|
||||
s_register = celery.signature(
|
||||
'cic_eth.eth.account.register',
|
||||
[
|
||||
@@ -368,8 +365,7 @@ class Api:
|
||||
],
|
||||
queue=self.queue,
|
||||
)
|
||||
s_nonce.link(s_register)
|
||||
s_account.link(s_nonce)
|
||||
s_account.link(s_register)
|
||||
|
||||
t = s_check.apply_async(queue=self.queue)
|
||||
return t
|
||||
@@ -394,9 +390,7 @@ class Api:
|
||||
)
|
||||
s_nonce = celery.signature(
|
||||
'cic_eth.eth.tx.reserve_nonce',
|
||||
[
|
||||
'GAS_GIFTER',
|
||||
],
|
||||
[],
|
||||
queue=self.queue,
|
||||
)
|
||||
s_refill = celery.signature(
|
||||
|
||||
@@ -73,10 +73,3 @@ class SignerError(Exception):
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class EthError(Exception):
|
||||
"""Exception raised when unspecified error from evm node is encountered
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -54,7 +54,6 @@ class GasOracle():
|
||||
"""
|
||||
session = SessionBase.create_session()
|
||||
a = AccountRole.get_address('GAS_GIFTER', session)
|
||||
logg.debug('gasgifter {}'.format(a))
|
||||
session.close()
|
||||
return a
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ from cic_eth.db import Otx, SessionBase
|
||||
from cic_eth.db.models.tx import TxCache
|
||||
from cic_eth.db.models.nonce import NonceReservation
|
||||
from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.db.models.role import AccountRole
|
||||
from cic_eth.db.enum import (
|
||||
LockEnum,
|
||||
StatusBits,
|
||||
@@ -39,7 +38,6 @@ from cic_eth.task import (
|
||||
CriticalWeb3Task,
|
||||
CriticalWeb3AndSignerTask,
|
||||
CriticalSQLAlchemyAndSignerTask,
|
||||
CriticalSQLAlchemyAndWeb3Task,
|
||||
)
|
||||
|
||||
celery_app = celery.current_app
|
||||
@@ -49,7 +47,7 @@ MAX_NONCE_ATTEMPTS = 3
|
||||
|
||||
|
||||
# TODO this function is too long
|
||||
@celery_app.task(bind=True, throws=(OutOfGasError), base=CriticalSQLAlchemyAndWeb3Task)
|
||||
@celery_app.task(bind=True, throws=(OutOfGasError), base=CriticalSQLAlchemyTask)
|
||||
def check_gas(self, tx_hashes, chain_str, txs=[], address=None, gas_required=None):
|
||||
"""Check the gas level of the sender address of a transaction.
|
||||
|
||||
@@ -77,9 +75,6 @@ def check_gas(self, tx_hashes, chain_str, txs=[], address=None, gas_required=Non
|
||||
if address == None:
|
||||
address = o['address']
|
||||
|
||||
if not web3.Web3.isChecksumAddress(address):
|
||||
raise ValueError('invalid address {}'.format(address))
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(chain_str)
|
||||
|
||||
queue = self.request.delivery_info['routing_key']
|
||||
@@ -88,12 +83,7 @@ def check_gas(self, tx_hashes, chain_str, txs=[], address=None, gas_required=Non
|
||||
c = RpcClient(chain_spec)
|
||||
|
||||
# TODO: it should not be necessary to pass address explicitly, if not passed should be derived from the tx
|
||||
balance = 0
|
||||
try:
|
||||
balance = c.w3.eth.getBalance(address)
|
||||
except ValueError as e:
|
||||
raise EthError('balance call for {}'.format())
|
||||
|
||||
balance = c.w3.eth.getBalance(address)
|
||||
logg.debug('address {} has gas {} needs {}'.format(address, balance, gas_required))
|
||||
|
||||
if gas_required > balance:
|
||||
@@ -600,23 +590,11 @@ def resend_with_higher_gas(self, txold_hash_hex, chain_str, gas=None, default_fa
|
||||
|
||||
|
||||
@celery_app.task(bind=True, base=CriticalSQLAlchemyTask)
|
||||
def reserve_nonce(self, chained_input, signer=None):
|
||||
def reserve_nonce(self, chained_input, address=None):
|
||||
session = SessionBase.create_session()
|
||||
|
||||
address = None
|
||||
if signer == None:
|
||||
if address == None:
|
||||
address = chained_input
|
||||
logg.debug('non-explicit address for reserve nonce, using arg head {}'.format(chained_input))
|
||||
else:
|
||||
if web3.Web3.isChecksumAddress(signer):
|
||||
address = signer
|
||||
logg.debug('explicit address for reserve nonce {}'.format(signer))
|
||||
else:
|
||||
address = AccountRole.get_address(signer, session=session)
|
||||
logg.debug('role for reserve nonce {} -> {}'.format(signer, address))
|
||||
|
||||
if not web3.Web3.isChecksumAddress(address):
|
||||
raise ValueError('invalid result when resolving address for nonce {}'.format(address))
|
||||
|
||||
root_id = self.request.root_id
|
||||
nonce = NonceReservation.next(address, root_id)
|
||||
|
||||
@@ -5,7 +5,6 @@ import os
|
||||
import logging
|
||||
import uuid
|
||||
import json
|
||||
from xdg.BaseDirectory import xdg_config_home
|
||||
|
||||
import celery
|
||||
from cic_eth.api import Api
|
||||
|
||||
@@ -25,7 +25,7 @@ logging.getLogger('urllib3').setLevel(logging.WARNING)
|
||||
|
||||
|
||||
default_abi_dir = '/usr/share/local/cic/solidity/abi'
|
||||
default_config_dir = os.environ.get('CONFINI_DIR', '/usr/local/etc/cic')
|
||||
default_config_dir = os.path.join('/usr/local/etc/cic-eth')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)')
|
||||
|
||||
@@ -22,7 +22,7 @@ logg = logging.getLogger()
|
||||
logging.getLogger('web3').setLevel(logging.WARNING)
|
||||
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
||||
|
||||
default_config_dir = os.environ.get('CONFINI_DIR', '/usr/local/etc/cic')
|
||||
default_config_dir = os.path.join('/usr/local/etc/cic-eth')
|
||||
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
|
||||
@@ -37,7 +37,7 @@ logging.getLogger('urllib3').setLevel(logging.WARNING)
|
||||
|
||||
|
||||
default_abi_dir = '/usr/share/local/cic/solidity/abi'
|
||||
default_config_dir = os.environ.get('CONFINI_DIR', '/usr/local/etc/cic')
|
||||
default_config_dir = os.path.join('/usr/local/etc/cic-eth')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', type=str, help='Web3 provider url (http only)')
|
||||
|
||||
@@ -6,10 +6,7 @@ import celery
|
||||
import sqlalchemy
|
||||
|
||||
# local imports
|
||||
from cic_eth.error import (
|
||||
SignerError,
|
||||
EthError,
|
||||
)
|
||||
from cic_eth.error import SignerError
|
||||
|
||||
|
||||
class CriticalTask(celery.Task):
|
||||
@@ -36,7 +33,6 @@ class CriticalSQLAlchemyAndWeb3Task(CriticalTask):
|
||||
sqlalchemy.exc.DatabaseError,
|
||||
sqlalchemy.exc.TimeoutError,
|
||||
requests.exceptions.ConnectionError,
|
||||
EthError,
|
||||
)
|
||||
|
||||
class CriticalSQLAlchemyAndSignerTask(CriticalTask):
|
||||
|
||||
@@ -10,7 +10,7 @@ version = (
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
'alpha.41',
|
||||
'alpha.38',
|
||||
)
|
||||
|
||||
version_object = semver.VersionInfo(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cic-base~=0.1.1a20
|
||||
cic-base~=0.1.1a10
|
||||
web3==5.12.2
|
||||
celery==4.4.7
|
||||
crypto-dev-signer~=0.4.13rc4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = cic-notify
|
||||
version= 0.4.0a2
|
||||
version= attr: cic_notify.version.__version_string__
|
||||
description = CIC notifications service
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
[app]
|
||||
service_code = *483*46#
|
||||
@@ -1,4 +0,0 @@
|
||||
[client]
|
||||
host =
|
||||
port =
|
||||
ssl =
|
||||
@@ -1,3 +0,0 @@
|
||||
[ussd]
|
||||
user =
|
||||
pass =
|
||||
@@ -1,107 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Author: Louis Holbrook <dev@holbrook.no> (https://holbrook.no)
|
||||
# Description: interactive console for Sempo USSD session
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
import os
|
||||
import sys
|
||||
import uuid
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
import urllib
|
||||
from xdg.BaseDirectory import xdg_config_home
|
||||
from urllib import request
|
||||
|
||||
# third-party imports
|
||||
from confini import Config
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_config_dir = os.environ.get('CONFINI_DIR', '/usr/local/etc/cic')
|
||||
|
||||
argparser = argparse.ArgumentParser(description='CLI tool to interface a Sempo USSD session')
|
||||
argparser.add_argument('-c', type=str, default=default_config_dir, help='config root to use')
|
||||
#argparser.add_argument('-d', type=str, default='local', help='deployment name to interface (config root subdirectory)')
|
||||
argparser.add_argument('--host', type=str, default='localhost')
|
||||
argparser.add_argument('--port', type=int, default=9000)
|
||||
argparser.add_argument('--nossl', help='do not use ssl (careful)', action='store_true')
|
||||
argparser.add_argument('phone', help='phone number for USSD session')
|
||||
argparser.add_argument('-v', help='be verbose', action='store_true')
|
||||
argparser.add_argument('-vv', help='be more verbose', action='store_true')
|
||||
|
||||
args = argparser.parse_args(sys.argv[1:])
|
||||
|
||||
if args.v == True:
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
elif args.vv == True:
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
#config_dir = os.path.join(args.c, args.d)
|
||||
config_dir = os.path.join(args.c)
|
||||
os.makedirs(config_dir, 0o777, True)
|
||||
|
||||
config = Config(config_dir)
|
||||
config.process()
|
||||
logg.debug('config loaded from {}'.format(config_dir))
|
||||
|
||||
host = config.get('CLIENT_HOST')
|
||||
port = config.get('CLIENT_PORT')
|
||||
ssl = config.get('CLIENT_SSL')
|
||||
|
||||
if host == None:
|
||||
host = args.host
|
||||
if port == None:
|
||||
port = args.port
|
||||
if ssl == None:
|
||||
ssl = not args.nossl
|
||||
elif ssl == 0:
|
||||
ssl = False
|
||||
else:
|
||||
ssl = True
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
# TODO: improve url building
|
||||
url = 'http'
|
||||
if ssl:
|
||||
url += 's'
|
||||
url += '://{}:{}'.format(host, port)
|
||||
url += '/?username={}&password={}'.format(config.get('USSD_USER'), config.get('USSD_PASS'))
|
||||
|
||||
logg.info('service url {}'.format(url))
|
||||
logg.info('phone {}'.format(args.phone))
|
||||
|
||||
session = uuid.uuid4().hex
|
||||
data = {
|
||||
'sessionId': session,
|
||||
'serviceCode': config.get('APP_SERVICE_CODE'),
|
||||
'phoneNumber': args.phone,
|
||||
'text': config.get('APP_SERVICE_CODE'),
|
||||
}
|
||||
|
||||
state = "_BEGIN"
|
||||
while state != "END":
|
||||
|
||||
if state != "_BEGIN":
|
||||
user_input = input('next> ')
|
||||
data['text'] = user_input
|
||||
|
||||
req = urllib.request.Request(url)
|
||||
data_str = json.dumps(data)
|
||||
data_bytes = data_str.encode('utf-8')
|
||||
req.add_header('Content-Type', 'application/json')
|
||||
req.data = data_bytes
|
||||
response = urllib.request.urlopen(req)
|
||||
response_data = response.read().decode('utf-8')
|
||||
state = response_data[:3]
|
||||
out = response_data[4:]
|
||||
print(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,7 +1,7 @@
|
||||
# standard imports
|
||||
import semver
|
||||
|
||||
version = (0, 3, 0, 'alpha.5')
|
||||
version = (0, 3, 0, 'alpha.1')
|
||||
|
||||
version_object = semver.VersionInfo(
|
||||
major=version[0],
|
||||
|
||||
@@ -16,16 +16,9 @@ div#session {
|
||||
<textarea id="monitor" disabled="1"></textarea>
|
||||
<div id="login">
|
||||
<label for="user">API username</label>
|
||||
<input type="text" id="user" name="user" />
|
||||
<input type="text" id="user" name="user" type="text" /><br/>
|
||||
<label for="user">API password</label>
|
||||
<input type="text" id="pass" name="pass" /> <br/>
|
||||
|
||||
<label for="host">API host</label>
|
||||
<input type="text" id="host" name="host" />
|
||||
<label for="host">API port</label>
|
||||
<input type="text" id="port" name="port" />
|
||||
<label for="host">SSL</label>
|
||||
<input type="checkbox" id="ssl" name="ssl" checked="1"/> <br/>
|
||||
<input type="text" id="pass" name="pass" type="text" /><br/>
|
||||
<hr/>
|
||||
<input type="text" id="phone" /> <button onclick="setPhone(document.getElementById('phone').value);" id="send_phone">set phone number</button>
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
var ssl = false;
|
||||
var host = 'localhost';
|
||||
var port = 9000;
|
||||
//var proto = 'http';
|
||||
//var host = 'localhost:9000';
|
||||
var proto = 'https';
|
||||
var host = 'staging.sarafu.network';
|
||||
var user = 'foo';
|
||||
var pass = 'bar';
|
||||
var path = '/';
|
||||
var serviceCode = '*483*46#';
|
||||
var user = 'admin_bert_token_inc.';
|
||||
var pass = '197781ed60bf16d5dc12d84e3df37e35';
|
||||
var serviceCode = '*483*061#';
|
||||
|
||||
// cheekily stolen from https://www.tutorialspoint.com/how-to-create-guid-uuid-in-javascript
|
||||
function createUUID() {
|
||||
@@ -25,17 +23,9 @@ function send(s) {
|
||||
document.getElementById('send_input').disabled = true;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'text';
|
||||
const current_user = document.getElementById('user').value;
|
||||
const current_pass = document.getElementById('pass').value;
|
||||
const current_host = document.getElementById('host').value;
|
||||
const current_port = document.getElementById('port').value;
|
||||
let current_scheme = 'http';
|
||||
if (document.getElementById('ssl').checked) {
|
||||
current_scheme += 's';
|
||||
}
|
||||
const url = current_scheme + '://' + current_host + ':' + current_port + '?username=' + current_user + '&password=' + current_pass
|
||||
console.debug('connecting to', url);
|
||||
xhr.open('POST', url, true);
|
||||
current_user = document.getElementById('user').value;
|
||||
current_pass = document.getElementById('pass').value;
|
||||
xhr.open('POST', proto + '://' + host + '/api/v1/ussd/kenya?username=' + current_user + '&password=' + current_pass, true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
data = {
|
||||
sessionId: uuid,
|
||||
@@ -116,8 +106,6 @@ function abort() {
|
||||
window.addEventListener('load', () => {
|
||||
document.getElementById('user').value = user;
|
||||
document.getElementById('pass').value = pass;
|
||||
document.getElementById('host').value = host;
|
||||
document.getElementById('port').value = port;
|
||||
document.getElementById('phone').addEventListener('keyup', (e) => {
|
||||
if (e.keyCode == '13') {
|
||||
document.getElementById('input').value = '';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
cic-types==0.1.0a8
|
||||
alembic==1.4.2
|
||||
amqp==2.6.1
|
||||
attrs==20.2.0
|
||||
@@ -7,10 +6,12 @@ betterpath==0.2.2
|
||||
billiard==3.6.3.0
|
||||
celery==4.4.7
|
||||
cffi==1.14.3
|
||||
cic-eth~=0.10.0a22
|
||||
chainlib~=0.0.1a15
|
||||
cic-eth==0.10.0a38
|
||||
cic-notify==0.3.1
|
||||
cic-types==0.1.0a8
|
||||
click==7.1.2
|
||||
confini~=0.3.6a1
|
||||
confini==0.3.5
|
||||
cryptography==3.2.1
|
||||
faker==4.17.1
|
||||
iniconfig==1.1.1
|
||||
@@ -35,6 +36,7 @@ python-i18n==0.3.9
|
||||
pytz==2020.1
|
||||
PyYAML==5.3.1
|
||||
redis==3.5.3
|
||||
requests==2.24.0
|
||||
semver==2.13.0
|
||||
six==1.15.0
|
||||
SQLAlchemy==1.3.20
|
||||
|
||||
@@ -44,5 +44,4 @@ scripts =
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
cic-ussd-tasker = cic_ussd.runnable.tasker:main
|
||||
cic-ussd-client = cic_ussd.runnable.client:main
|
||||
cic-ussd-tasker = cic_ussd.runnable.tasker:main
|
||||
@@ -107,10 +107,10 @@ RUN cd cic-bancor/python && \
|
||||
|
||||
|
||||
RUN apt-get install -y cargo
|
||||
ARG cic_base_version=0.1.1a23
|
||||
ARG cic_base_version=0.1.1a10
|
||||
RUN pip install --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version
|
||||
|
||||
ARG cic_registry_version=0.5.3a24
|
||||
ARG cic_registry_version=0.5.3a22
|
||||
RUN pip install --extra-index-url $pip_extra_index_url cic-registry==$cic_registry_version
|
||||
|
||||
WORKDIR /root
|
||||
@@ -127,6 +127,5 @@ COPY contract-migration/from_env.sh from_env.sh
|
||||
COPY contract-migration/seed_cic_eth.sh seed_cic_eth.sh
|
||||
COPY contract-migration/sarafu_declaration.json sarafu_declaration.json
|
||||
COPY contract-migration/keystore keystore
|
||||
COPY contract-migration/envlist .
|
||||
|
||||
# ENTRYPOINT [ "/bin/bash" ]
|
||||
ENTRYPOINT [ "/bin/bash" ]
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
SYNCER_LOOP_INTERVAL
|
||||
SSL_ENABLE_CLIENT
|
||||
SSL_CERT_FILE
|
||||
SSL_KEY_FILE
|
||||
SSL_PASSWORD
|
||||
SSL_CA_FILE
|
||||
BANCOR_DIR
|
||||
REDIS_HOST
|
||||
REDIS_PORT
|
||||
REDIS_DB
|
||||
PGP_EXPORTS_DIR
|
||||
PGP_PRIVATEKEY_FILE
|
||||
PGP_PASSPHRASE
|
||||
DATABASE_USER
|
||||
DATABASE_PASSWORD
|
||||
DATABASE_NAME
|
||||
DATABASE_HOST
|
||||
DATABASE_PORT
|
||||
DATABASE_ENGINE
|
||||
DATABASE_DRIVER
|
||||
DATABASE_DEBUG
|
||||
TASKS_AFRICASTALKING
|
||||
TASKS_SMS_DB
|
||||
TASKS_LOG
|
||||
TASKS_TRACE_QUEUE_STATUS
|
||||
TASKS_TRANSFER_CALLBACKS
|
||||
DEV_MNEMONIC
|
||||
DEV_ETH_RESERVE_ADDRESS
|
||||
DEV_ETH_ACCOUNTS_INDEX_ADDRESS
|
||||
DEV_ETH_RESERVE_AMOUNT
|
||||
DEV_ETH_ACCOUNT_BANCOR_DEPLOYER
|
||||
DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER
|
||||
DEV_ETH_ACCOUNT_GAS_PROVIDER
|
||||
DEV_ETH_ACCOUNT_RESERVE_OWNER
|
||||
DEV_ETH_ACCOUNT_RESERVE_MINTER
|
||||
DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_OWNER
|
||||
DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER
|
||||
DEV_ETH_ACCOUNT_SARAFU_OWNER
|
||||
DEV_ETH_ACCOUNT_SARAFU_GIFTER
|
||||
DEV_ETH_ACCOUNT_APPROVAL_ESCROW_OWNER
|
||||
DEV_ETH_ACCOUNT_SINGLE_SHOT_FAUCET_OWNER
|
||||
DEV_ETH_SARAFU_TOKEN_NAME
|
||||
DEV_ETH_SARAFU_TOKEN_SYMBOL
|
||||
DEV_ETH_SARAFU_TOKEN_DECIMALS
|
||||
DEV_ETH_SARAFU_TOKEN_ADDRESS
|
||||
DEV_PGP_PUBLICKEYS_ACTIVE_FILE
|
||||
DEV_PGP_PUBLICKEYS_TRUSTED_FILE
|
||||
DEV_PGP_PUBLICKEYS_ENCRYPT_FILE
|
||||
CIC_REGISTRY_ADDRESS
|
||||
CIC_APPROVAL_ESCROW_ADDRESS
|
||||
CIC_TOKEN_INDEX_ADDRESS
|
||||
CIC_ACCOUNTS_INDEX_ADDRESS
|
||||
CIC_DECLARATOR_ADDRESS
|
||||
CIC_CHAIN_SPEC
|
||||
ETH_PROVIDER
|
||||
ETH_ABI_DIR
|
||||
SIGNER_SOCKET_PATH
|
||||
SIGNER_SECRET
|
||||
CELERY_BROKER_URL
|
||||
CELERY_RESULT_URL
|
||||
META_PROVIDER
|
||||
@@ -64,7 +64,7 @@ export CIC_TRUST_ADDRESS=$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER
|
||||
|
||||
EOF
|
||||
|
||||
cat ./envlist | bash from_env.sh > $CIC_DATA_DIR/.env_all
|
||||
cat $CIC_DATA_DIR/envlist | bash from_env.sh > $CIC_DATA_DIR/.env_all
|
||||
# popd
|
||||
|
||||
set +a
|
||||
|
||||
@@ -191,16 +191,9 @@ if __name__ == '__main__':
|
||||
|
||||
fa = open(os.path.join(user_dir, 'balances.csv'), 'w')
|
||||
|
||||
i = 0
|
||||
while i < user_count:
|
||||
eth = None
|
||||
phone = None
|
||||
o = None
|
||||
try:
|
||||
(eth, phone, o) = gen()
|
||||
except Exception as e:
|
||||
logg.warning('generate failed, trying anew: {}'.format(e))
|
||||
continue
|
||||
for i in range(user_count):
|
||||
|
||||
(eth, phone, o) = gen()
|
||||
uid = eth[2:].upper()
|
||||
|
||||
print(o)
|
||||
@@ -219,7 +212,5 @@ if __name__ == '__main__':
|
||||
amount = genAmount()
|
||||
fa.write('{},{}\n'.format(eth,amount))
|
||||
logg.debug('pidx {}, uid {}, eth {}, amount {}'.format(pidx, uid, eth, amount))
|
||||
|
||||
i += 1
|
||||
|
||||
fa.close()
|
||||
|
||||
@@ -74,7 +74,7 @@ new cic.PGPKeyStore(
|
||||
importMeta,
|
||||
);
|
||||
|
||||
const batchSize = 16;
|
||||
const batchSize = 50;
|
||||
const batchDelay = 1000;
|
||||
const total = parseInt(process.argv[3]);
|
||||
const workDir = path.join(process.argv[2], 'meta');
|
||||
|
||||
@@ -38,7 +38,7 @@ argparser.add_argument('--redis-host-callback', dest='redis_host_callback', defa
|
||||
argparser.add_argument('--redis-port-callback', dest='redis_port_callback', default=6379, type=int, help='redis port to use for callback')
|
||||
argparser.add_argument('--batch-size', dest='batch_size', default=50, type=int, help='burst size of sending transactions to node')
|
||||
argparser.add_argument('--batch-delay', dest='batch_delay', default=2, type=int, help='seconds delay between batches')
|
||||
argparser.add_argument('--timeout', default=60.0, type=float, help='Callback timeout')
|
||||
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')
|
||||
@@ -97,7 +97,6 @@ def register_eth(i, u):
|
||||
callback_queue=args.q,
|
||||
)
|
||||
t = api.create_account(register=True)
|
||||
logg.debug('register {} -> {}'.format(u, t))
|
||||
|
||||
while True:
|
||||
ps.get_message()
|
||||
@@ -113,11 +112,11 @@ def register_eth(i, u):
|
||||
r = json.loads(m['data'])
|
||||
address = r['result']
|
||||
break
|
||||
except Exception as e:
|
||||
except TypeError as e:
|
||||
if m == None:
|
||||
logg.critical('empty response from redis callback (did the service crash?) {}'.format(e))
|
||||
logg.critical('empty response from redis callback (did the service crash?)')
|
||||
else:
|
||||
logg.critical('unexpected response from redis callback: {} {}'.format(m, e))
|
||||
logg.critical('unexpected response from redis callback: {}'.format(m))
|
||||
sys.exit(1)
|
||||
logg.debug('[{}] register eth {} {}'.format(i, u, address))
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
cic-base[full_graph]==0.1.1a23
|
||||
cic-eth==0.10.0a41
|
||||
cic-base[full_graph]==0.1.1a12
|
||||
cic-eth==0.10.0a38
|
||||
cic-types==0.1.0a8
|
||||
|
||||
@@ -31,7 +31,8 @@ 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.0a41 chainlib==0.0.1a21 cic-contracts==0.0.2a2
|
||||
pip install --extra-index-url $DEV_PIP_EXTRA_INDEX_URL cic-eth==0.10.0a38 chainlib==0.0.1a19 cic-contracts==0.0.2a2
|
||||
pip install --extra-index-url $DEV_PIP_EXTRA_INDEX_URL --force-reinstall erc20-transfer-authorization==0.3.0a10
|
||||
|
||||
>&2 echo "create account for gas gifter"
|
||||
old_gas_provider=$DEV_ETH_ACCOUNT_GAS_PROVIDER
|
||||
|
||||
@@ -1,35 +1,54 @@
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:debug
|
||||
entrypoint: [""]
|
||||
image: docker:19.03.13
|
||||
|
||||
variables:
|
||||
KANIKO_CACHE_ARGS: "--cache=true --cache-copy-layers=true --cache-ttl=24h"
|
||||
CONTEXT: $CI_PROJECT_DIR/apps/
|
||||
# docker host
|
||||
DOCKER_HOST: tcp://docker:2376
|
||||
# container, thanks to volume mount from config.toml
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
# These are usually specified by the entrypoint, however the
|
||||
# Kubernetes executor doesn't run entrypoints
|
||||
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4125
|
||||
DOCKER_TLS_VERIFY: 1
|
||||
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
|
||||
# We are building these from the apps dir to easily share the requirements file there.
|
||||
# It would be nicer to build from the app dir context. TODO figure out a nice way to do this in local DOCKER_TLS_VERIFY
|
||||
CONTEXT: apps/
|
||||
|
||||
services:
|
||||
- docker:19.03.13-dind
|
||||
|
||||
before_script:
|
||||
- docker info
|
||||
|
||||
.py_build_merge_request:
|
||||
stage: build
|
||||
before_script:
|
||||
- cd $CONTEXT
|
||||
variables:
|
||||
- CI_DEBUG_TRACE: "true"
|
||||
CI_DEBUG_TRACE: "true"
|
||||
IMAGE_TAG: $APP_NAME:$CI_COMMIT_SHORT_SHA
|
||||
script:
|
||||
- mkdir -p /kaniko/.docker
|
||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > "/kaniko/.docker/config.json"
|
||||
- /kaniko/executor --context $CONTEXT --dockerfile $DOCKERFILE_PATH $KANIKO_CACHE_ARGS --cache-repo $CI_REGISTRY_IMAGE --no-push
|
||||
- docker build -t $IMAGE_TAG -f $DOCKERFILE_PATH .
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
when: always
|
||||
|
||||
.py_build_push:
|
||||
stage: build
|
||||
variables:
|
||||
IMAGE_TAG_BASE: $CI_REGISTRY_IMAGE/$APP_NAME:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
|
||||
LATEST_TAG: $CI_REGISTRY_IMAGE/$APP_NAME:latest
|
||||
script:
|
||||
- export IMAGE_TAG="$IMAGE_TAG_BASE-$(date +%F.%H%M%S)"
|
||||
- mkdir -p /kaniko/.docker
|
||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > "/kaniko/.docker/config.json"
|
||||
- /kaniko/executor --context $CONTEXT --dockerfile $DOCKERFILE_PATH $KANIKO_CACHE_ARGS --destination $IMAGE_TAG
|
||||
- /kaniko/executor --context $CONTEXT --dockerfile $DOCKERFILE_PATH $KANIKO_CACHE_ARGS --destination $CI_REGISTRY_IMAGE/$APP_NAME:latest
|
||||
rules:
|
||||
stage: build
|
||||
before_script:
|
||||
- cd $CONTEXT
|
||||
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" $CI_REGISTRY --password-stdin
|
||||
variables:
|
||||
CI_DEBUG_TRACE: "true"
|
||||
IMAGE_TAG_BASE: $CI_REGISTRY_IMAGE/$APP_NAME:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
|
||||
LATEST_TAG: $CI_REGISTRY_IMAGE/$APP_NAME:latest
|
||||
script:
|
||||
- export IMAGE_TAG="$IMAGE_TAG_BASE-$(date +%F.%H%M%S)"
|
||||
- docker build -t $IMAGE_TAG -f $DOCKERFILE_PATH .
|
||||
- docker push $IMAGE_TAG
|
||||
- docker tag $IMAGE_TAG $LATEST_TAG
|
||||
- docker push $LATEST_TAG
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "master"
|
||||
when: always
|
||||
|
||||
|
||||
@@ -162,43 +162,7 @@ services:
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/.env ]]; then source /tmp/cic/config/.env; fi
|
||||
/usr/local/bin/cic-cache-trackerd -vv
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
|
||||
cic-cache-tasker:
|
||||
build:
|
||||
context: apps
|
||||
dockerfile: cic-cache/docker/Dockerfile
|
||||
environment:
|
||||
CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS # supplied at contract-config after contract provisioning
|
||||
ETH_PROVIDER: ${ETH_PROVIDER:-http://eth:8545}
|
||||
DATABASE_USER: ${DATABASE_USER:-grassroots}
|
||||
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala} # this is is set at initdb see: postgres/initdb/create_db.sql
|
||||
DATABASE_HOST: ${DATABASE_HOST:-postgres}
|
||||
DATABASE_PORT: ${DATABASE_PORT:-5432}
|
||||
DATABASE_NAME: ${DATABASE_NAME_CIC_CACHE:-cic_cache}
|
||||
DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
|
||||
DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
|
||||
DATABASE_DEBUG: 1
|
||||
ETH_ABI_DIR: ${ETH_ABI_DIR:-/usr/local/share/cic/solidity/abi}
|
||||
CIC_TRUST_ADDRESS: ${DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER:-0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C}
|
||||
CIC_CHAIN_SPEC: ${CIC_CHAIN_SPEC:-evm:bloxberg:8996}
|
||||
CELERY_BROKER_URL: redis://redis:6379
|
||||
CELERY_RESULT_URL: redis://redis:6379
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
depends_on:
|
||||
- redis
|
||||
- postgres
|
||||
- eth
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/.env ]]; then source /tmp/cic/config/.env; fi
|
||||
/usr/local/bin/cic-cache-taskerd -vv
|
||||
/usr/local/bin/cic-cache-tracker -vv
|
||||
volumes:
|
||||
- contract-config:/tmp/cic/config/:ro
|
||||
|
||||
@@ -228,7 +192,7 @@ services:
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/.env ]]; then source /tmp/cic/config/.env; fi
|
||||
"/usr/local/bin/uwsgi" \
|
||||
--wsgi-file /usr/src/cic-cache/cic_cache/runnable/serverd.py \
|
||||
--wsgi-file /usr/src/cic-cache/cic_cache/runnable/server.py \
|
||||
--http :8000 \
|
||||
--pyargv -vv
|
||||
|
||||
@@ -274,7 +238,7 @@ services:
|
||||
- -c
|
||||
- |
|
||||
if [[ -f /tmp/cic/config/.env ]]; then source /tmp/cic/config/.env; fi
|
||||
./start_tasker.sh -q cic-eth -vv
|
||||
./start_tasker.sh -q cic-eth
|
||||
# command: [/bin/sh, "./start_tasker.sh", -q, cic-eth, -vv ]
|
||||
|
||||
cic-eth-tracker:
|
||||
|
||||
Reference in New Issue
Block a user