2021-10-19 19:40:31 +02:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
# standard imports
|
|
|
|
import io
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import urllib
|
|
|
|
|
|
|
|
# external imports
|
2022-05-12 20:05:13 +02:00
|
|
|
from chainlib.settings import ChainSettings
|
2021-10-19 19:40:31 +02:00
|
|
|
from funga.eth.signer import EIP155Signer
|
|
|
|
from funga.eth.keystore.dict import DictKeystore
|
2022-05-12 20:05:13 +02:00
|
|
|
from chainlib.chain import ChainSpec
|
|
|
|
from chainlib.jsonrpc import (
|
|
|
|
JSONRPCRequest,
|
|
|
|
IntSequenceGenerator,
|
|
|
|
)
|
2021-10-19 19:40:31 +02:00
|
|
|
from hexathon import (
|
|
|
|
add_0x,
|
|
|
|
strip_0x,
|
|
|
|
uniform as hex_uniform,
|
|
|
|
)
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from chainlib.eth.address import to_checksum
|
|
|
|
from chainlib.eth.connection import EthHTTPConnection
|
|
|
|
from chainlib.eth.nonce import (
|
|
|
|
RPCNonceOracle,
|
|
|
|
OverrideNonceOracle,
|
|
|
|
)
|
|
|
|
from chainlib.eth.gas import (
|
|
|
|
RPCGasOracle,
|
|
|
|
OverrideGasOracle,
|
|
|
|
)
|
|
|
|
from chainlib.eth.tx import (
|
|
|
|
TxFactory,
|
|
|
|
raw,
|
|
|
|
)
|
|
|
|
from chainlib.eth.error import RevertEthException
|
|
|
|
from chainlib.eth.runnable.util import decode_for_puny_humans
|
|
|
|
from chainlib.eth.jsonrpc import to_blockheight_param
|
2022-05-12 15:05:02 +02:00
|
|
|
import chainlib.eth.cli
|
|
|
|
from chainlib.eth.cli.arg import (
|
|
|
|
Arg,
|
|
|
|
ArgFlag,
|
|
|
|
process_args,
|
|
|
|
)
|
|
|
|
from chainlib.eth.cli.config import (
|
|
|
|
Config,
|
|
|
|
process_config,
|
|
|
|
)
|
|
|
|
from chainlib.eth.cli.log import process_log
|
2022-05-12 20:05:13 +02:00
|
|
|
from chainlib.eth.settings import process_settings
|
2021-10-19 19:40:31 +02:00
|
|
|
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
|
|
|
|
2022-05-12 15:05:02 +02:00
|
|
|
|
|
|
|
def process_config_local(config, arg, args, flags):
|
|
|
|
config.add(args.ignore, '_IGNORE', False)
|
|
|
|
config.add(args.ignore_all, '_IGNORE_ALL', False)
|
2022-05-12 20:20:52 +02:00
|
|
|
config.add(args.hashes, '_HASH', False)
|
2022-05-12 15:05:02 +02:00
|
|
|
return config
|
|
|
|
|
2022-05-12 20:20:52 +02:00
|
|
|
|
|
|
|
def process_settings_local(settings, config):
|
|
|
|
settings.set('HASH', config.get('_HASH'))
|
|
|
|
return settings
|
|
|
|
|
|
|
|
|
2022-05-12 15:05:02 +02:00
|
|
|
arg_flags = ArgFlag()
|
|
|
|
arg = Arg(arg_flags)
|
|
|
|
flags = arg_flags.STD_READ
|
|
|
|
|
|
|
|
argparser = chainlib.eth.cli.ArgumentParser()
|
|
|
|
argparser = process_args(argparser, arg, flags)
|
2021-10-19 19:40:31 +02:00
|
|
|
argparser.add_argument('--ignore', type=str, action='append', default=[], help='Ignore error from the given transaction')
|
|
|
|
argparser.add_argument('--ignore-all', action='store_true', dest='ignore_all', help='Ignore errors from all transactions')
|
2022-05-12 15:05:02 +02:00
|
|
|
argparser.add_argument('hashes', nargs='*', type=str, help='Transaction hashes to wait for')
|
2021-10-19 19:40:31 +02:00
|
|
|
args = argparser.parse_args()
|
2022-05-12 15:05:02 +02:00
|
|
|
|
|
|
|
logg = process_log(args, logg)
|
|
|
|
|
|
|
|
config = Config()
|
|
|
|
config = process_config(config, arg, args, flags)
|
|
|
|
config = process_config_local(config, arg, args, flags)
|
|
|
|
logg.debug('config loaded:\n{}'.format(config))
|
2021-10-19 19:40:31 +02:00
|
|
|
|
2022-05-12 18:13:02 +02:00
|
|
|
settings = ChainSettings()
|
|
|
|
settings = process_settings(settings, config)
|
|
|
|
logg.debug('settings loaded:\n{}'.format(settings))
|
2021-10-19 19:40:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
hashes_ready = []
|
|
|
|
hashes_ignore = []
|
|
|
|
|
|
|
|
for hsh in config.get('_IGNORE'):
|
|
|
|
hashes_ignore.append(add_0x(hex_uniform(strip_0x(hsh))))
|
|
|
|
|
2022-05-12 20:20:52 +02:00
|
|
|
if len(settings.get('HASH')) == 1:
|
|
|
|
hsh = settings.get('HASH')[0]
|
2021-10-19 19:40:31 +02:00
|
|
|
try:
|
|
|
|
hashes_ready = [hsh]
|
|
|
|
except ValueError:
|
|
|
|
logg.debug('hash argument not a hash, will try it as a file name')
|
2022-05-12 20:20:52 +02:00
|
|
|
f = open(hsh)
|
2021-10-19 19:40:31 +02:00
|
|
|
for hsh in f:
|
2022-05-12 20:20:52 +02:00
|
|
|
hashes_ready.append(hsh)
|
2021-10-19 19:40:31 +02:00
|
|
|
f.close()
|
|
|
|
else:
|
2022-05-12 20:20:52 +02:00
|
|
|
for hsh in settings.get('HASH'):
|
|
|
|
if hsh in hashes_ready:
|
|
|
|
logg.debug('skipping duplicate hash {}'.format(hsh))
|
|
|
|
continue
|
|
|
|
hashes_ready.append(hsh)
|
2021-10-19 19:40:31 +02:00
|
|
|
|
|
|
|
for hsh in hashes_ready:
|
2022-05-12 20:20:52 +02:00
|
|
|
logg.info('processing transaction hash {}'.format(hsh))
|
2021-10-19 19:40:31 +02:00
|
|
|
try:
|
2022-05-12 18:13:25 +02:00
|
|
|
r = settings.get('CONN').wait(hsh)
|
2021-10-19 19:40:31 +02:00
|
|
|
except RevertEthException:
|
|
|
|
if config.get('_IGNORE_ALL') or hsh in hashes_ignore:
|
2022-05-12 20:20:52 +02:00
|
|
|
logg.debug('ignoring revert in transaction hash {}'.format(hsh))
|
2021-10-19 19:40:31 +02:00
|
|
|
continue
|
|
|
|
sys.stderr.write('revert in transaction hash {}\n'.format(hsh))
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|