eth-monitor

Monitor and cache ethereum transactions with match filters
git clone git://git.defalsify.org/eth-monitor.git
Log | Files | Refs | README | LICENSE

commit 8016cc7c9f135dbe5b5189f1950e7a27f9f0344e
parent 5f7b23fa009d74d4b51f2da1c0d67e76a0a9dc91
Author: lash <dev@holbrook.no>
Date:   Thu,  3 Mar 2022 17:27:19 +0000

Add man pages for import, list

Diffstat:
Meth_monitor/runnable/import.py | 22++++++++++++++++++++--
Meth_monitor/runnable/list.py | 8+++-----
Aman/eth-monitor-import.head.groff | 23+++++++++++++++++++++++
Aman/eth-monitor-import.overrides | 6++++++
Aman/eth-monitor-import.seealso.groff | 3+++
Aman/eth-monitor-list.head.groff | 22++++++++++++++++++++++
Aman/eth-monitor-list.overrides | 4++++
Aman/eth-monitor-list.seealso.groff | 3+++
Mman/eth-monitor.head.groff | 5++---
Mman/eth-monitor.overrides | 2++
10 files changed, 88 insertions(+), 10 deletions(-)

diff --git a/eth_monitor/runnable/import.py b/eth_monitor/runnable/import.py @@ -24,6 +24,9 @@ logg = logging.getLogger() normalize_address = TxHexNormalizer().wallet_address +services = [ + 'etherscan', + ] argparser = argparse.ArgumentParser('master eth events monitor') argparser.add_argument('--api-key-file', dest='api_key_file', type=str, help='File to read API key from') @@ -31,7 +34,8 @@ argparser.add_argument('--cache-dir', dest='cache_dir', type=str, help='Director argparser.add_argument('--store-tx-data', dest='store_tx_data', action='store_true', help='Include all transaction data objects by default') argparser.add_argument('--store-block-data', dest='store_block_data', action='store_true', help='Include all block data objects by default') argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string') -argparser.add_argument('-f', '--address-file', dest='address_file', default=[], type=str, action='append', help='Add addresses from file') +argparser.add_argument('--address-file', dest='address_file', default=[], type=str, action='append', help='Add addresses from file') +argparser.add_argument('--list-services', dest='list', action='store_true', help='List all supported services') argparser.add_argument('-a', '--address', default=[], type=str, action='append', help='Add address') argparser.add_argument('--socks-host', dest='socks_host', type=str, help='Conect through socks host') argparser.add_argument('--socks-port', dest='socks_port', type=int, help='Conect through socks port') @@ -39,8 +43,18 @@ argparser.add_argument('--delay', type=float, default=0.2, help='Seconds to wait argparser.add_argument('-v', action='store_true', help='Be verbose') argparser.add_argument('-vv', action='store_true', help='Be more verbose') argparser.add_argument('-p', type=str, help='RPC provider') +argparser.add_argument('service', nargs='?', type=str, help='Index service to import from') args = argparser.parse_args(sys.argv[1:]) +if args.list: + for s in services: + sys.stdout.write('{}\n'.format(s)) + sys.exit(0) + +if not args.service: + argparser.error('the following arguments are required: service') + sys.exit(1) + if args.vv: logg.setLevel(logging.DEBUG) elif args.v: @@ -140,7 +154,11 @@ def main(): cache_filter, ] - importer = EtherscanImporter(rpc, api_key, filters=filters, block_callback=RuledFilter.block_callback) + importer = [] + if args.service == 'etherscan': + importer = EtherscanImporter(rpc, api_key, filters=filters, block_callback=RuledFilter.block_callback) + else: + raise ValueError('invalid service: {}'.format(args.service)) for a in addresses: importer.get(a) time.sleep(args.delay) diff --git a/eth_monitor/runnable/list.py b/eth_monitor/runnable/list.py @@ -29,9 +29,7 @@ from eth_monitor.rules import AddressRules logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() -default_eth_provider = os.environ.get('RPC_PROVIDER') -if default_eth_provider == None: - default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545') +default_eth_provider = os.environ.get('RPC_PROVIDER', 'http://localhost:8545') script_dir = os.path.realpath(os.path.dirname(__file__)) exec_dir = os.path.realpath(os.getcwd()) @@ -44,7 +42,7 @@ argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provide argparser.add_argument('-c', type=str, help='config file') argparser.add_argument('-i', '--chain-spec', dest='i', type=str, help='Chain specification string') argparser.add_argument('--seq', action='store_true', help='Use sequential rpc ids') -argparser.add_argument('--output', default=[], action='append', type=str, help='Add output (sender) addresses to includes list') +argparser.add_argument('-a', '--address', dest='a', default=[], action='append', type=str, help='Add address to includes list') argparser.add_argument('--filter', type=str, action='append', help='Add python module filter path') argparser.add_argument('-v', action='store_true', help='Be verbose') argparser.add_argument('-vv', action='store_true', help='Be more verbose') @@ -95,7 +93,7 @@ def main(): idx = AddressIndex(rpc, store) - for address in args.output: + for address in args.a: idx.load_address_tx(address) OutFilter.init(store) diff --git a/man/eth-monitor-import.head.groff b/man/eth-monitor-import.head.groff @@ -0,0 +1,23 @@ +.TH eth-monitor-import 1 + + +.SH NAME +eth-monitor-import \- Import transaction data from an indexing service + + +.SH SYNOPSIS +.SY eth-monitor-import +[ -i \fIchain_spec\fP] [ --api-key-file \fIfile\fp ] [ --address-file \fIfile\fP ] [ -a \fIaddress\fP ... ] [ --cache-dir \fIdirectory\fP ] \fIservice\fP + + +.SH DESCRIPTION +Use an indexing service to retrieve transaction hashes for one or more addresses. Supported services may be listed using the \fB--list-services\fP option. +.P +Which addresses to retrieve data for may be defined by the \fB-a\fP \fIaddress\fP option. Alternatively, the \fB--address-file\fP \fIfile\fP option may be used, where addresses are supplied from the given file as a comma-separated list. The address matching mechanism used in transaction processing is the same as for \fBeth-monitor(1)\fP. +.P +Only block and transaction hashes are used from the indexing service. The RPC endpoint will be used to retrieve the block and transaction data. +.P +If \fB--cache-dir\fP \fIdirectory\fP is defined, data will be cached to the given path using the same caching filter as \fBeth-monitor(1)\fP. \fB--store-tx-data\fP and \fB--store-block-data-\fP define whether also transaction and block data is stored to cache, respectively. + + +.SS OPTIONS diff --git a/man/eth-monitor-import.overrides b/man/eth-monitor-import.overrides @@ -0,0 +1,6 @@ +addressfile Load address include matching rules from file. Addresses must be given as a comma-separated list. --address-file file +storetx Store transaction data in cache for matching transactions. Requires \fB--cache-dir\fP. --store-tx-data +storeblock Store block data in cache for matching transactions. Requires \fB--cache-dir\fP. --store-block-data +list List all supported services. --list-services +sockshost Connect through the specified socks4a host (e.g. tor) --socks-host host +socksport Connect through the specified socks4a host port (e.g. tor) --socks-port port diff --git a/man/eth-monitor-import.seealso.groff b/man/eth-monitor-import.seealso.groff @@ -0,0 +1,3 @@ +.SH SEE ALSO + +eth-monitor (1) diff --git a/man/eth-monitor-list.head.groff b/man/eth-monitor-list.head.groff @@ -0,0 +1,22 @@ +.TH eth-monitor-list 1 + + +.SH NAME +eth-monitor-list \- Query transactions cache + + +.SH SYNOPSIS +.SY eth-monitor-list +[ -i \fIchain_spec\fP ] [ p \fIeth_provider\fP ] [ -a \fIaddress\fP ... ] \fIcache_dir\fP +.YS + + +.SH DESCRIPTION +List transactions stored in cache matching the given address. +.P +Any block data and/or transaction data matchin the relevant hashes returned by the query will be used to create the output. The \fB--fresh\fP option may be defined to force all block and transaction data from the RPC provider endpoint instead. +.P +For details on rendering and filtering, please refer to to \fBeth-monitor (1)\fP man page. + + +.SS OPTIONS diff --git a/man/eth-monitor-list.overrides b/man/eth-monitor-list.overrides @@ -0,0 +1,4 @@ +fresh Only use hashes from cache, and retrieve all block and transaction data from RPC endpoint. --fresh +address Add an address of interest to match any role. Complements \fB--address-file\fP. --address address +filter Add code execution filter to all matching transactions. The argument must be a python module path. Several filters may be added by supplying the option multiple times. Filters will be executed in the order the options are given. See \fBDEFINING FILTERS\fP section of \fBeth-monitor (1)\fP for more details. --filter module +renderer Add output renderer filter to all matching transactions. The argument must be a python module path. Several renderers may be added by supplying the option multiple times. See \fBRENDERERS\fP section of \fBeth-monitor (1)\fP for more details. --renderer module diff --git a/man/eth-monitor-list.seealso.groff b/man/eth-monitor-list.seealso.groff @@ -0,0 +1,3 @@ +.SH SEE ALSO + +eth-monitor (1) diff --git a/man/eth-monitor.head.groff b/man/eth-monitor.head.groff @@ -5,15 +5,14 @@ eth-monitor \- Cache, index and monitor transactions with an EVM node rpc .SH SYNOPSIS .SY eth-monitor -[ --skip-history ] [ --single ] [ p \fIeth_provider\fP ] [ --includes-file \fIfile\fP ] +[ --skip-history ] [ --single ] [ p \fIeth_provider\fP ] [ --includes-file \fIfile\fP ] [ -i chain_spec ] .YS .SY eth-monitor -[ --skip-history ] [ --single ] [ p \fIeth_provider\fP ] [ --excludes-file \fIfile\fP ] [ --include-default ] +[ --skip-history ] [ --single ] [ p \fIeth_provider\fP ] [ --excludes-file \fIfile\fP ] [ --include-default ] [ -i chain_spec ]  .YS .SH DESCRIPTION -.P The \fBeth-monitor\fP has fulfills three distinct but related functions: .IP 1. A customizable view of on transactions of interest. diff --git a/man/eth-monitor.overrides b/man/eth-monitor.overrides @@ -11,3 +11,5 @@ includesfile Load address include matching rules from file. See \fBMATCHING ADDR excludesfile Load address exclude matching rules from file. See \fBMATCHING ADDRESSES\fP. --excludes-file file storetx Store transaction data in cache for matching transactions. Requires \fB--cache-dir\fP. --store-tx-data storeblock Store block data in cache for matching transactions. Requires \fB--cache-dir\fP. --store-block-data +renderer Add output renderer filter to all matched transactions. The argument must be a python module path. Several renderers may be added by supplying the option multiple times. See \fBRENDERERS\fP section of \fBeth-monitor (1)\fP for more details. --renderer module +filter Add code execution filter to all matched transactions. The argument must be a python module path. Several filters may be added by supplying the option multiple times. Filters will be executed in the order the options are given. See \fBDEFINING FILTERS\fP section of \fBeth-monitor (1)\fP for more details. --filter module