funga

Signer and keystore daemon and library for cryptocurrency software development
Log | Files | Refs | README | LICENSE

commit c8ce2659a3efd92a1006fc0887a5499cf12fd94a
parent e6072da8e409ef16d32d3ab25aa655437536efaa
Author: nolash <dev@holbrook.no>
Date:   Wed, 27 Jan 2021 13:33:52 +0100

Add raw tx to error logging when tx send fails

Diffstat:
Mcrypto_dev_signer/error.py | 4++++
Mcrypto_dev_signer/eth/helper/tx.py | 10+++++++++-
Mcrypto_dev_signer/runnable/signer.py | 9+++++----
Msetup.py | 2+-
Mtest/test_helper.py | 2+-
5 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/crypto_dev_signer/error.py b/crypto_dev_signer/error.py @@ -4,3 +4,7 @@ class UnknownAccountError(Exception): class TransactionRevertError(Exception): pass + + +class NetworkError(Exception): + pass diff --git a/crypto_dev_signer/eth/helper/tx.py b/crypto_dev_signer/eth/helper/tx.py @@ -3,6 +3,7 @@ import logging # local imports from crypto_dev_signer.helper import TxExecutor +from crypto_dev_signer.error import NetworkError logg = logging.getLogger() logging.getLogger('web3').setLevel(logging.CRITICAL) @@ -30,7 +31,14 @@ class EthTxExecutor(TxExecutor): def dispatcher(self, tx): - return self.w3.eth.sendRawTransaction(tx) + error_object = None + try: + tx_hash = self.w3.eth.sendRawTransaction(tx) + except ValueError as e: + error_object = e.args[0] + logg.error('node could not intepret rlp {}'.format(tx)) + if error_object != None: + raise NetworkError(error_object) def reporter(self, tx): diff --git a/crypto_dev_signer/runnable/signer.py b/crypto_dev_signer/runnable/signer.py @@ -165,14 +165,14 @@ def process_input(j): return (rpc_id, methods[m](p)) -def start_server_lo(spec): +def start_server_tcp(spec): s = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM) s.bind(spec) logg.debug('created tcp socket {}'.format(spec)) start_server(s) -def start_server_ipc(socket_path): +def start_server_unix(socket_path): socket_dir = os.path.dirname(socket_path) try: fi = os.stat(socket_dir) @@ -190,6 +190,7 @@ def start_server_ipc(socket_path): logg.debug('created unix ipc socket {}'.format(socket_path)) start_server(s) + def start_server(s): s.listen(10) logg.debug('server started') @@ -251,9 +252,9 @@ def main(): if len(socket_spec) == 2: host = socket_spec[0] port = int(socket_spec[1]) - start_server_lo((host, port)) + start_server_tcp((host, port)) else: - start_server_ipc(socket_path) + start_server_unix(socket_path) sys.exit(0) (rpc_id, response) = process_input(arg) diff --git a/setup.py b/setup.py @@ -24,7 +24,7 @@ f.close() setup( name="crypto-dev-signer", - version="0.4.13b11", + version="0.4.13b12", description="A signer and keystore daemon and library for cryptocurrency software development", author="Louis Holbrook", author_email="dev@holbrook.no", diff --git a/test/test_helper.py b/test/test_helper.py @@ -81,7 +81,7 @@ class TestHelper(unittest.TestCase): def test_eth_helper(self): backend = MockEthTxBackend() w3 = web3.Web3(web3.Web3.HTTPProvider('http://localhost:8545')) - executor = EthTxExecutor(w3, self.address_hex, self.signer, 8996) + executor = EthTxExecutor(w3, self.address_hex, self.signer, 1337) tx_ish = {'from': self.address_hex} #executor.sign_and_send([backend.builder, backend.builder_two])