From 93c6ed78772651a9005e67b15f603bec3f403893 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 20 Jul 2021 16:58:03 +0200 Subject: [PATCH] Add inline config files --- MANIFEST.in | 2 +- README.md | 135 +++++++++++++++++++++++ chaind_eth/data/config/syncer/config.ini | 4 + requirements.txt | 3 +- setup.cfg | 1 + 5 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 README.md create mode 100644 chaind_eth/data/config/syncer/config.ini diff --git a/MANIFEST.in b/MANIFEST.in index 829a7e6..4731f39 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include *requirements.txt LICENSE +include *requirements.txt LICENSE chaind_eth/data/config/* chaind_eth/data/config/syncer/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec2e6b7 --- /dev/null +++ b/README.md @@ -0,0 +1,135 @@ +# chaind-eth development tester recipe + +chaind-eth is a socket server that acts as a automated transaction handler for an EVM network. + +It capabilities are (unchecked box means feature not yet completed): + +- [x] unix socket server to accept raw, signed RLP evm transactions +- [x] stateful queueing system following full local and remote lifecycle of the transaction +- [x] transaction dispatcher unit +- [ ] transaction retry unit (for errored or suspended transactions) +- [x] blockchain listener that updates state of transactions in queue +- [x] CLI transaction listing tool, filterable by: + * [x] transaction range with lower and/or upper bound + * [x] only show transaction with errors + * [x] only show transaction that have not yet completed +- [x] systemd unit / socket service + +## prerequisites + +For these examples you need: + +- python 3.9.x +- pip +- virtualenv +- socat +- sqlite +- an EVM RPC endpoint + +For any python command / executable use: + +* `-v` or `-vv` to get more information about what is going on +* `--help` for information on how to use and parameters that can be passed + + +## usage example + + +### set up database + +In terminal window A + +Currently there is no more practical way of setting up the database backend :/ + +``` +git clone https://gitlab.com/chaintool/chaind +cd chaind +python -m venv .venv +. .venv/bin/activate +pip install --extra-index-url https://pip.grassrootseconomics.net:8433 -r requirements.txt +# the following will set up your database in ~/.local/share/chaind/eth/chaind.sqlite +PYTHONPATH=. CHAIND_DOMAIN=eth DATABASE_ENGINE=sqlite python scripts/migrate.py +``` + +### create an empty working directory + +``` +d=$(mktemp -d) && cd $d +``` + +### create a chaind-eth sandbox + +``` +python -m venv .venv +. .venv/bin/activate +pip install --extra-index-url https://pip.grassrootseconomics.net:8433 "chaind-eth>=0.0.1a2" +``` + +### start the services + +In terminal window B + +``` +cd +. .venv/bin/activate +export DATABASE_ENGINE=sqlite +export RPC_HTTP_PROVIDER= +export CHAIN_SPEC= +chaind-eth-server --session-id testsession +``` + +In terminal window C + +``` +cd +. .venv/bin/activate +export DATABASE_ENGINE=sqlite +export RPC_HTTP_PROVIDER= +export CHAIN_SPEC= +chaind-eth-syncer +``` + +### prepare test transactions + +Create two transactions from sender in keyfile (which needs to have gas balance) to a newly created account + +``` +export WALLET_KEY_FILE= +export WALLET_PASSWORD= +export RPC_HTTP_PROVIDER= +export CHAIN_SPEC= + +# create new account and store address in variable +eth-keyfile -z > testkey.json +recipient=$(eth-keyfile -z -d testkey.json) + +# create transactions +eth-gas --raw -a $recipient 1024 > tx1.txt +eth-gas --raw -a $recipient 2048 > tx2.txt +eth-gas --raw -a $recipient 4096 > tx3.txt +``` + +### send test transactions to queue + +``` +cat tx1.txt | socat UNIX-CLIENT=/run/user/$UID/testsession/chaind.sock +cat tx2.txt | socat UNIX-CLIENT=/run/user/$UID/testsession/chaind.sock +cat tx3.txt | socat UNIX-CLIENT=/run/user/$UID/testsession/chaind.sock +``` + +### check status of transactions + +``` +export DATABASE_ENGINE=sqlite +sender=$(eth-keyfile -d $WALLET_KEY_FILE) +DATABASE_NAME=$HOME/.local/share/chaind/eth/chaind.sqlite chainqueue-list $sender +# to show a summary only instead all transactions +DATABASE_NAME=$HOME/.local/share/chaind/eth/chaind.sqlite chainqueue-list --summary $sender +``` + +The `chainqueue-list` tool provides some basic filtering. Use `chainqueue-list --help` to see what they are. + + +## systemd + +TBC diff --git a/chaind_eth/data/config/syncer/config.ini b/chaind_eth/data/config/syncer/config.ini new file mode 100644 index 0000000..92f2023 --- /dev/null +++ b/chaind_eth/data/config/syncer/config.ini @@ -0,0 +1,4 @@ +[syncer] +history_start = 0 +skip_history = 0 +loop_interval = 1 diff --git a/requirements.txt b/requirements.txt index 854c8bf..3371ec3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ chaind<=0.0.1,>=0.0.1a5 hexathon~=0.0.1a7 -chainlib-eth<=0.0.6,>0.0.6a1 -#chainlib-eth~=0.0.5a4 +chainlib-eth<=0.0.6,>=0.0.6a1 diff --git a/setup.cfg b/setup.cfg index 02b14da..412551b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,7 @@ licence_files = [options] python_requires = >= 3.6 +include_package_data = True packages = chaind_eth chaind_eth.runnable