Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2f55f073e
|
@@ -1,11 +1,3 @@
|
|||||||
- 0.2.7
|
|
||||||
* Upgrade chainlib
|
|
||||||
- 0.2.6
|
|
||||||
* Deps upgrade
|
|
||||||
- 0.2.5
|
|
||||||
* Deps upgrade
|
|
||||||
- 0.2.4
|
|
||||||
* Allow omission of state store sync in queue store backend
|
|
||||||
- 0.2.2
|
- 0.2.2
|
||||||
* Fix missing symbol crashes related to race conditions
|
* Fix missing symbol crashes related to race conditions
|
||||||
- 0.2.1
|
- 0.2.1
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ logg = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class ChaindAdapter:
|
class ChaindAdapter:
|
||||||
|
|
||||||
def __init__(self, chain_spec, state_store, index_store, counter_store, cache_adapter, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0, store_sync=True):
|
def __init__(self, chain_spec, state_store, index_store, counter_store, cache_adapter, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0):
|
||||||
self.cache_adapter = cache_adapter
|
self.cache_adapter = cache_adapter
|
||||||
self.dispatcher = dispatcher
|
self.dispatcher = dispatcher
|
||||||
store_lock = StoreLock()
|
store_lock = StoreLock()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.store = QueueStore(chain_spec, state_store, index_store, counter_store, cache=cache, sync=store_sync)
|
self.store = QueueStore(chain_spec, state_store, index_store, counter_store, cache=cache)
|
||||||
break
|
break
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
logg.debug('queuestore instantiation failed, possible race condition (will try again): {}'.format(e))
|
logg.debug('queuestore instantiation failed, possible race condition (will try again): {}'.format(e))
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ logg = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class ChaindFsAdapter(ChaindAdapter):
|
class ChaindFsAdapter(ChaindAdapter):
|
||||||
|
|
||||||
def __init__(self, chain_spec, path, cache_adapter, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0, digest_bytes=32, event_callback=None, store_sync=True):
|
def __init__(self, chain_spec, path, cache_adapter, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0, digest_bytes=32, event_callback=None):
|
||||||
factory = SimpleFileStoreFactory(path, use_lock=True).add
|
factory = SimpleFileStoreFactory(path, use_lock=True).add
|
||||||
state_store = Status(factory, allow_invalid=True, event_callback=event_callback)
|
state_store = Status(factory, allow_invalid=True, event_callback=event_callback)
|
||||||
index_path = os.path.join(path, 'tx')
|
index_path = os.path.join(path, 'tx')
|
||||||
index_store = IndexStore(index_path, digest_bytes=digest_bytes)
|
index_store = IndexStore(index_path, digest_bytes=digest_bytes)
|
||||||
counter_store = CounterStore(path)
|
counter_store = CounterStore(path)
|
||||||
super(ChaindFsAdapter, self).__init__(chain_spec, state_store, index_store, counter_store, cache_adapter, dispatcher, cache=cache, pending_retry_threshold=pending_retry_threshold, error_retry_threshold=error_retry_threshold, store_sync=store_sync)
|
super(ChaindFsAdapter, self).__init__(chain_spec, state_store, index_store, counter_store, cache_adapter, dispatcher, cache=cache, pending_retry_threshold=pending_retry_threshold, error_retry_threshold=error_retry_threshold)
|
||||||
|
|
||||||
|
|
||||||
def put(self, signed_tx):
|
def put(self, signed_tx):
|
||||||
@@ -51,11 +51,11 @@ class ChaindFsAdapter(ChaindAdapter):
|
|||||||
logg.error('I am just a simple syncer and do not know how to handle the state which the tx {} is in: {}'.format(tx_hash, e))
|
logg.error('I am just a simple syncer and do not know how to handle the state which the tx {} is in: {}'.format(tx_hash, e))
|
||||||
return None
|
return None
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
logg.debug('queuestore get (file missing) {} failed, possible race condition (will try again): {}'.format(tx_hash, e))
|
logg.debug('queuestore get {} failed, possible race condition (will try again): {}'.format(tx_hash, e))
|
||||||
store_lock.again()
|
store_lock.again()
|
||||||
continue
|
continue
|
||||||
except StateLockedKey as e:
|
except StateLockedKey as e:
|
||||||
logg.debug('queuestore get (statelock) {} failed, possible race condition (will try again): {}'.format(tx_hash, e))
|
logg.debug('queuestore get {} failed, possible race condition (will try again): {}'.format(tx_hash, e))
|
||||||
store_lock.again()
|
store_lock.again()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -90,19 +90,12 @@ class ChaindFsAdapter(ChaindAdapter):
|
|||||||
def succeed(self, block, tx):
|
def succeed(self, block, tx):
|
||||||
if self.store.is_reserved(tx.hash):
|
if self.store.is_reserved(tx.hash):
|
||||||
raise QueueLockError(tx.hash)
|
raise QueueLockError(tx.hash)
|
||||||
r = self.store.final(tx.hash, block, tx, error=False)
|
|
||||||
(k, v) = self.store.get(tx.hash)
|
return self.store.final(tx.hash, block, tx, error=False)
|
||||||
self.store.purge(k)
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
def fail(self, block, tx):
|
def fail(self, block, tx):
|
||||||
if self.store.is_reserved(tx.hash):
|
return self.store.final(tx.hash, block, tx, error=True)
|
||||||
raise QueueLockError(tx.hash)
|
|
||||||
r = self.store.final(tx.hash, block, tx, error=True)
|
|
||||||
(k, v) = self.store.get(tx.hash)
|
|
||||||
self.store.purge(k)
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
def sendfail(self):
|
def sendfail(self):
|
||||||
@@ -135,8 +128,7 @@ class ChaindFsAdapter(ChaindAdapter):
|
|||||||
r = None
|
r = None
|
||||||
try:
|
try:
|
||||||
r = self.dispatcher.send(tx_wire)
|
r = self.dispatcher.send(tx_wire)
|
||||||
except RPCException as e:
|
except RPCException:
|
||||||
logg.error('dispatch send failed for {}: {}'.format(tx_hash, e))
|
|
||||||
self.store.fail(tx_hash)
|
self.store.fail(tx_hash)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
# standard imports
|
|
||||||
import logging
|
|
||||||
|
|
||||||
# local ipmorts
|
|
||||||
from chaind.adapters.fs import ChaindFsAdapter
|
|
||||||
from chaind.eth.cache import EthCacheTx
|
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class DispatchProcessor:
|
|
||||||
|
|
||||||
def __init__(self, chain_spec, queue_dir, dispatcher):
|
|
||||||
self.dispatcher = dispatcher
|
|
||||||
self.chain_spec = chain_spec,
|
|
||||||
self.queue_dir = queue_dir
|
|
||||||
|
|
||||||
|
|
||||||
def process(self, rpc, limit=50):
|
|
||||||
adapter = ChaindFsAdapter(
|
|
||||||
self.chain_spec,
|
|
||||||
self.queue_dir,
|
|
||||||
EthCacheTx,
|
|
||||||
self.dispatcher,
|
|
||||||
)
|
|
||||||
|
|
||||||
upcoming = adapter.upcoming(limit=limit)
|
|
||||||
logg.info('processor has {} candidates for {}, processing with limit {}'.format(len(upcoming), self.chain_spec, limit))
|
|
||||||
i = 0
|
|
||||||
for tx_hash in upcoming:
|
|
||||||
if adapter.dispatch(tx_hash):
|
|
||||||
i += 1
|
|
||||||
return i
|
|
||||||
@@ -54,7 +54,7 @@ class StateFilter(SyncFilter):
|
|||||||
logg.debug('skipping not local transaction {}'.format(tx.hash))
|
logg.debug('skipping not local transaction {}'.format(tx.hash))
|
||||||
return False
|
return False
|
||||||
except BackendError as e:
|
except BackendError as e:
|
||||||
logg.error('adapter get failed: {}, one more try'.format(e))
|
logg.error('adapter instantiation failed: {}, one more try'.format(e))
|
||||||
queue_adapter = None
|
queue_adapter = None
|
||||||
store_lock.again()
|
store_lock.again()
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import time
|
|||||||
from .error import BackendError
|
from .error import BackendError
|
||||||
|
|
||||||
BASE_DELAY = 0.01
|
BASE_DELAY = 0.01
|
||||||
BASE_DELAY_LIMIT = 10.0
|
BASE_DELAY_LIMIT = 3.0
|
||||||
|
|
||||||
|
|
||||||
class StoreLock:
|
class StoreLock:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ logg = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class SessionController:
|
class SessionController:
|
||||||
|
|
||||||
def __init__(self, config, processor):
|
def __init__(self, config, adapter, processor):
|
||||||
self.dead = False
|
self.dead = False
|
||||||
os.makedirs(os.path.dirname(config.get('SESSION_SOCKET_PATH')), exist_ok=True)
|
os.makedirs(os.path.dirname(config.get('SESSION_SOCKET_PATH')), exist_ok=True)
|
||||||
try:
|
try:
|
||||||
@@ -37,6 +37,7 @@ class SessionController:
|
|||||||
self.srv.settimeout(float(config.get('SESSION_DISPATCH_DELAY')))
|
self.srv.settimeout(float(config.get('SESSION_DISPATCH_DELAY')))
|
||||||
self.processor = processor
|
self.processor = processor
|
||||||
self.chain_spec = config.get('CHAIN_SPEC')
|
self.chain_spec = config.get('CHAIN_SPEC')
|
||||||
|
self.adapter = adapter
|
||||||
|
|
||||||
|
|
||||||
def shutdown(self, signo, frame):
|
def shutdown(self, signo, frame):
|
||||||
@@ -64,7 +65,7 @@ class SessionController:
|
|||||||
r = None
|
r = None
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
r = self.processor(conn)
|
r = self.processor(self.chain_spec, self.adapter, conn)
|
||||||
break
|
break
|
||||||
except BackendError as e:
|
except BackendError as e:
|
||||||
state_lock.again(e)
|
state_lock.again(e)
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class MockDispatcher:
|
|||||||
|
|
||||||
|
|
||||||
def send(self, v):
|
def send(self, v):
|
||||||
|
import sys
|
||||||
|
sys.stderr.write('susu v {} {}\n'.format(v, self.fails))
|
||||||
if v in self.fails:
|
if v in self.fails:
|
||||||
raise RPCException('{} is in fails'.format(v))
|
raise RPCException('{} is in fails'.format(v))
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
chainlib~=0.1.2
|
chainlib~=0.1.1
|
||||||
chainqueue~=0.1.11
|
chainqueue~=0.1.8
|
||||||
chainsyncer~=0.4.3
|
chainsyncer~=0.4.3
|
||||||
confini~=0.6.0
|
confini~=0.6.0
|
||||||
funga~=0.5.2
|
funga~=0.5.2
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = chaind
|
name = chaind
|
||||||
version = 0.2.7
|
version = 0.2.2
|
||||||
description = Base package for chain queue service
|
description = Base package for chain queue service
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
|||||||
Reference in New Issue
Block a user