Merge remote-tracking branch 'origin/master' into lash/improve-cache

This commit is contained in:
nolash 2021-12-22 20:09:54 +00:00
commit 03b06ca8c1
9 changed files with 35 additions and 19 deletions

View File

@ -515,7 +515,7 @@ class Api(ApiBase):
:param password: Password to encode the password with in the backend (careful, you will have to remember it) :param password: Password to encode the password with in the backend (careful, you will have to remember it)
:type password: str :type password: str
:param register: Register the new account in accounts index backend :param register: Register the new account in accounts index backend
:type password: bool :type register: bool
:returns: uuid of root task :returns: uuid of root task
:rtype: celery.Task :rtype: celery.Task
""" """

View File

@ -73,6 +73,7 @@ class Config(BaseConfig):
db, db,
) )
celery_config_url = urllib.parse.urlsplit(config.get('CELERY_BROKER_URL')) celery_config_url = urllib.parse.urlsplit(config.get('CELERY_BROKER_URL'))
hostport = urlhostmerge( hostport = urlhostmerge(
celery_config_url[1], celery_config_url[1],

View File

@ -397,6 +397,8 @@ def cache_transfer_data(
sender_address = tx_normalize.wallet_address(tx['from']) sender_address = tx_normalize.wallet_address(tx['from'])
recipient_address = tx_normalize.wallet_address(tx_data[0]) recipient_address = tx_normalize.wallet_address(tx_data[0])
token_value = tx_data[1] token_value = tx_data[1]
source_token_address = tx_normalize.executable_address(tx['to'])
destination_token_address = source_token_address
session = SessionBase.create_session() session = SessionBase.create_session()
@ -404,8 +406,8 @@ def cache_transfer_data(
'hash': tx_hash_hex, 'hash': tx_hash_hex,
'from': sender_address, 'from': sender_address,
'to': recipient_address, 'to': recipient_address,
'source_token': tx['to'], 'source_token': source_token_address,
'destination_token': tx['to'], 'destination_token': destination_token_address,
'from_value': token_value, 'from_value': token_value,
'to_value': token_value, 'to_value': token_value,
} }
@ -437,14 +439,16 @@ def cache_transfer_from_data(
spender_address = tx_data[0] spender_address = tx_data[0]
recipient_address = tx_data[1] recipient_address = tx_data[1]
token_value = tx_data[2] token_value = tx_data[2]
source_token_address = tx_normalize.executable_address(tx['to'])
destination_token_address = source_token_address
session = SessionBase.create_session() session = SessionBase.create_session()
tx_dict = { tx_dict = {
'hash': tx_hash_hex, 'hash': tx_hash_hex,
'from': tx['from'], 'from': tx['from'],
'to': recipient_address, 'to': recipient_address,
'source_token': tx['to'], 'source_token': source_token_address,
'destination_token': tx['to'], 'destination_token': destination_token_address,
'from_value': token_value, 'from_value': token_value,
'to_value': token_value, 'to_value': token_value,
} }
@ -476,14 +480,16 @@ def cache_approve_data(
sender_address = tx_normalize.wallet_address(tx['from']) sender_address = tx_normalize.wallet_address(tx['from'])
recipient_address = tx_normalize.wallet_address(tx_data[0]) recipient_address = tx_normalize.wallet_address(tx_data[0])
token_value = tx_data[1] token_value = tx_data[1]
source_token_address = tx_normalize.executable_address(tx['to'])
destination_token_address = source_token_address
session = SessionBase.create_session() session = SessionBase.create_session()
tx_dict = { tx_dict = {
'hash': tx_hash_hex, 'hash': tx_hash_hex,
'from': sender_address, 'from': sender_address,
'to': recipient_address, 'to': recipient_address,
'source_token': tx['to'], 'source_token': source_token_address,
'destination_token': tx['to'], 'destination_token': destination_token_address,
'from_value': token_value, 'from_value': token_value,
'to_value': token_value, 'to_value': token_value,
} }

View File

@ -72,7 +72,7 @@ def __balance_incoming_compatible(token_address, receiver_address):
status_compare = dead() status_compare = dead()
q = q.filter(Otx.status.op('&')(status_compare)==0) q = q.filter(Otx.status.op('&')(status_compare)==0)
# TODO: this can change the result for the recipient if tx is later obsoleted and resubmission is delayed. # TODO: this can change the result for the recipient if tx is later obsoleted and resubmission is delayed.
q = q.filter(Otx.status.op('&')(StatusBits.IN_NETWORK)==StatusBits.IN_NETWORK) #q = q.filter(Otx.status.op('&')(StatusBits.IN_NETWORK)==StatusBits.IN_NETWORK)
q = q.filter(TxCache.destination_token_address==token_address) q = q.filter(TxCache.destination_token_address==token_address)
delta = 0 delta = 0
for r in q.all(): for r in q.all():

View File

@ -1,6 +1,6 @@
celery==4.4.7 celery==4.4.7
semver==2.13.0 semver==2.13.0
chainlib-eth~=0.0.14 chainlib-eth~=0.0.15
urlybird~=0.0.1 urlybird~=0.0.1
cic-eth-registry~=0.6.5 cic-eth-registry~=0.6.5
cic-types~=0.2.1a8 cic-types~=0.2.1a8

View File

@ -41,8 +41,7 @@ def test_filter_gas(
token_registry, token_registry,
register_lookups, register_lookups,
register_tokens, register_tokens,
#celery_session_worker, celery_session_worker,
celery_worker,
cic_registry, cic_registry,
): ):

View File

@ -4,7 +4,7 @@ chainlib-eth~=0.0.15
eth-erc20~=0.1.5 eth-erc20~=0.1.5
erc20-demurrage-token~=0.0.7 erc20-demurrage-token~=0.0.7
eth-address-index~=0.2.4 eth-address-index~=0.2.4
cic-eth-registry~=0.6.4 cic-eth-registry~=0.6.5
erc20-faucet==0.3.2 erc20-faucet==0.3.2
sarafu-faucet==0.0.7 sarafu-faucet==0.0.7
confini~=0.5.3 confini~=0.5.3

View File

@ -1,16 +1,25 @@
# syntax = docker/dockerfile:1.2 ARG DOCKER_REGISTRY="registry.gitlab.com/grassrootseconomics"
FROM registry.gitlab.com/grassrootseconomics/cic-base-images:python-3.8.6-dev-5ab8bf45
FROM $DOCKER_REGISTRY/cic-base-images:python-3.8.6-dev-e8eb2ee2
WORKDIR /root WORKDIR /root
RUN mkdir -vp /usr/local/etc/cic RUN mkdir -vp /usr/local/etc/cic
COPY package.json \ ARG NPM_REPOSITORY=${NPM_REPOSITORY:-https://registry.npmjs.org}
package-lock.json \ RUN npm config set snyk=false
./ #RUN npm config set registry={NPM_REPOSITORY}
RUN npm config set registry=${NPM_REPOSITORY}
# copy the dependencies
COPY package.json package-lock.json ./
RUN --mount=type=cache,mode=0755,target=/root/.npm \
npm set cache /root/.npm && \
npm cache verify && \
npm ci --verbose
RUN npm ci --production #RUN npm ci --production --verbose
#RUN --mount=type=cache,mode=0755,target=/root/node_modules npm install #RUN --mount=type=cache,mode=0755,target=/root/node_modules npm install
COPY common/ cic_ussd/common/ COPY common/ cic_ussd/common/
@ -22,6 +31,7 @@ ARG EXTRA_PIP_ARGS=""
ARG PIP_INDEX_URL=https://pypi.org/simple ARG PIP_INDEX_URL=https://pypi.org/simple
RUN pip install --index-url $PIP_INDEX_URL \ RUN pip install --index-url $PIP_INDEX_URL \
--pre \
--extra-index-url $EXTRA_PIP_INDEX_URL $EXTRA_PIP_ARGS \ --extra-index-url $EXTRA_PIP_INDEX_URL $EXTRA_PIP_ARGS \
-r requirements.txt -r requirements.txt

View File

@ -4,7 +4,7 @@ cic-types~=0.2.1a8
funga>=0.5.1 funga>=0.5.1
faker==4.17.1 faker==4.17.1
chainsyncer~=0.0.7a3 chainsyncer~=0.0.7a3
chainlib-eth~=0.0.14 chainlib-eth~=0.0.15
eth-address-index~=0.2.4a1 eth-address-index~=0.2.4a1
eth-contract-registry~=0.6.3a3 eth-contract-registry~=0.6.3a3
eth-accounts-index~=0.1.2a3 eth-accounts-index~=0.1.2a3