Add raw tx to error logging when tx send fails

This commit is contained in:
nolash
2021-01-27 13:33:52 +01:00
parent e6072da8e4
commit c8ce2659a3
5 changed files with 20 additions and 7 deletions

View File

@@ -4,3 +4,7 @@ class UnknownAccountError(Exception):
class TransactionRevertError(Exception):
pass
class NetworkError(Exception):
pass

View File

@@ -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):

View File

@@ -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)