Go to file
2021-09-08 16:18:19 +02:00
chaind_eth Add return hash on tx submit, return tx on hash submit 2021-09-08 16:18:19 +02:00
chainqueue/adapters Implement error parser to rpc instantation 2021-08-26 17:14:11 +02:00
systemd Add systemd setup 2021-06-03 22:23:21 +02:00
tests Fix bug in dispatch test failing on no gas balance in example tx 2021-07-19 14:49:34 +02:00
.coveragerc Add coverage check 2021-07-17 07:39:55 +02:00
.gitignore Add coverage check 2021-07-17 07:39:55 +02:00
LICENSE Add systemd setup 2021-06-03 22:23:21 +02:00
MANIFEST.in Add inline config files 2021-07-20 16:58:03 +02:00
README.md Upgrade chaind 2021-07-21 08:41:30 +02:00
requirements.txt Add token index to deps 2021-09-08 08:59:03 +02:00
run_coverage.sh Add coverage check 2021-07-17 07:39:55 +02:00
run_tests.sh Correct deps 2021-07-17 07:17:19 +02:00
setup.cfg Add return hash on tx submit, return tx on hash submit 2021-09-08 16:18:19 +02:00
setup.py Initial commit 2021-06-03 11:03:17 +02:00
test_requirements.txt Add coverage check 2021-07-17 07:39:55 +02:00

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

  • unix socket server to accept raw, signed RLP evm transactions
  • stateful queueing system following full local and remote lifecycle of the transaction
  • transaction dispatcher unit
  • transaction retry unit (for errored or suspended transactions)
  • blockchain listener that updates state of transactions in queue
  • CLI transaction listing tool, filterable by:
    • transaction range with lower and/or upper bound
    • only show transaction with errors
    • only show transaction that have not yet completed
  • systemd unit / socket service
  • sql storage backend
  • filesystem storage backend

prerequisites

For these examples you need:

  • linux (tested on 5.12.x, perhaps wsl/macos will work too, no guarantees, though)
  • python 3.9.x
  • pip
  • virtualenv
  • socat
  • sqlite
  • an EVM RPC endpoint

For any python command / executable used below:

  • add -v or -vv to get more information about what is going on
  • use with --help for information on how to use and parameters that can be passed

setting up the database backend

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

usage example

create an empty working directory

In terminal window A

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 <working directory>
. .venv/bin/activate
export DATABASE_ENGINE=sqlite
export RPC_HTTP_PROVIDER=<your_provider>
export CHAIN_SPEC=<chain_spec_of_provider>
chaind-eth-server --session-id testsession

In terminal window C

cd <working directory>
. .venv/bin/activate
export DATABASE_ENGINE=sqlite
export RPC_HTTP_PROVIDER=<your_provider>
export CHAIN_SPEC=<chain_spec_of_provider>
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=<path_to_keyfile>
export WALLET_PASSWORD=<keyfile_password_if_needed>
export RPC_HTTP_PROVIDER=<your_provider>
export CHAIN_SPEC=<chain_spec_of_provider>

# 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/chaind/eth/testsession/chaind.sock
cat tx2.txt | socat UNIX-CLIENT=/run/user/$UID/chaind/eth/testsession/chaind.sock
cat tx3.txt | socat UNIX-CLIENT=/run/user/$UID/chaind/eth/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