Add role tag option to reserve nonce

This commit is contained in:
nolash 2021-03-07 12:52:48 +01:00
parent 5f0822598f
commit 2b354a1029
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
8 changed files with 33 additions and 18 deletions

View File

@ -82,6 +82,7 @@ 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',
[
@ -143,6 +144,7 @@ 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',
[
@ -340,11 +342,6 @@ 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',
[
@ -357,6 +354,13 @@ class Api:
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',
[
@ -390,7 +394,9 @@ class Api:
)
s_nonce = celery.signature(
'cic_eth.eth.tx.reserve_nonce',
[],
[
'GAS_GIFTER',
],
queue=self.queue,
)
s_refill = celery.signature(

View File

@ -588,13 +588,23 @@ 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, address=None):
def reserve_nonce(self, chained_input, signer=None):
session = SessionBase.create_session()
if address == None:
address = None
if signer == 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 address {}'.format(address))
raise ValueError('invalid result when resolving address for nonce {}'.format(address))
root_id = self.request.root_id
nonce = NonceReservation.next(address, root_id)

View File

@ -1,4 +1,4 @@
cic-base~=0.1.1a19
cic-base~=0.1.1a20
web3==5.12.2
celery==4.4.7
crypto-dev-signer~=0.4.13rc4

View File

@ -1,7 +1,7 @@
# standard imports
import semver
version = (0, 3, 0, 'alpha.4')
version = (0, 3, 0, 'alpha.5')
version_object = semver.VersionInfo(
major=version[0],

View File

@ -3,7 +3,7 @@ alembic==1.4.2
bcrypt==3.2.0
celery==4.4.7
chainlib~=0.0.1a20
cic-eth==0.10.0a39
cic-eth~=0.10.0a40
cic-notify~=0.4.0a2
cic-types==0.1.0a8
confini~=0.3.6rc3

View File

@ -107,10 +107,10 @@ RUN cd cic-bancor/python && \
RUN apt-get install -y cargo
ARG cic_base_version=0.1.1a10
ARG cic_base_version=0.1.1a23
RUN pip install --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version
ARG cic_registry_version=0.5.3a22
ARG cic_registry_version=0.5.3a24
RUN pip install --extra-index-url $pip_extra_index_url cic-registry==$cic_registry_version
WORKDIR /root

View File

@ -1,3 +1,3 @@
cic-base[full_graph]==0.1.1a12
cic-eth==0.10.0a38
cic-base[full_graph]==0.1.1a23
cic-eth==0.10.0a40
cic-types==0.1.0a8

View File

@ -31,8 +31,7 @@ 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.0a39 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
pip install --extra-index-url $DEV_PIP_EXTRA_INDEX_URL cic-eth==0.10.0a40 chainlib==0.0.1a21 cic-contracts==0.0.2a2
>&2 echo "create account for gas gifter"
old_gas_provider=$DEV_ETH_ACCOUNT_GAS_PROVIDER