Skip to content

Commit

Permalink
dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
pipermerriam committed Sep 30, 2016
1 parent 2ec9ee1 commit f35028c
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 40 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ Testing for Alarm is done with [populus](https://github.com/pipermerriam/populus
$ pip install populus
```

You must first compile the Alarm contracts prior to running tests.

```shell
$ populus compile --optimize
```

Then you can run the test suite using `pytest` which is installed along with
populus.

Expand Down
15 changes: 14 additions & 1 deletion alarm_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def request_create(ctx,
while True:
try:
click.echo("Waiting for transaction to be mined...", nl=False)
create_txn_receipt = config.wait.for_receipt(create_txn_hash)
create_txn_receipt = config.wait.for_receipt(create_txn_hash, poll_interval=3)
click.echo("MINED via block #{0}".format(
create_txn_receipt['blockNumber']
))
Expand Down Expand Up @@ -323,6 +323,13 @@ def client_run(ctx):
claimed_event_filter = TransactionRequestFactory.on('Claimed')
created_event_filter = factory.on('RequestCreated')

new_block_filter.poll_interval = 2
executed_event_filter.poll_interval = 17
aborted_event_filter.poll_interval = 17
cancelled_event_filter.poll_interval = 17
claimed_event_filter.poll_interval = 17
created_event_filter.poll_interval = 17

click.echo("Starting client")

new_block_filter.watch(functools.partial(new_block_callback, config))
Expand Down Expand Up @@ -380,6 +387,12 @@ def client_monitor(ctx):
claimed_event_filter = TransactionRequestFactory.on('Claimed')
created_event_filter = factory.on('RequestCreated')

executed_event_filter.poll_interval = 17
aborted_event_filter.poll_interval = 17
cancelled_event_filter.poll_interval = 17
claimed_event_filter.poll_interval = 17
created_event_filter.poll_interval = 17

click.echo("Watching for events")

executed_event_filter.watch(functools.partial(executed_event_callback, config))
Expand Down
6 changes: 3 additions & 3 deletions alarm_client/client/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def claim_txn_request(config, txn_request):
claim_txn_hash = txn_request.transact({'value': claim_deposit}).claim()
logger.info("Sent claim transaction. Txn Hash: %s", claim_txn_hash)
try:
wait.for_receipt(claim_txn_hash)
wait.for_receipt(claim_txn_hash, poll_interval=5)
except gevent.Timeout:
logger.error(
"Timed out waiting for claim transaction receipt. Txn Hash: %s",
Expand Down Expand Up @@ -195,7 +195,7 @@ def execute_txn_request(config, txn_request):

try:
logger.info("Waiting for transaction to be mined...")
wait.for_receipt(execute_txn_hash)
wait.for_receipt(execute_txn_hash, poll_interval=5)
logger.info("Execution transaction mined.")
except gevent.Timeout:
logger.error(
Expand Down Expand Up @@ -245,7 +245,7 @@ def cleanup_txn_request(config, txn_request):

try:
logger.info("Waiting for transaction to be mined...")
wait.for_receipt(cancel_txn_hash)
wait.for_receipt(cancel_txn_hash, poll_interval=5)
logger.info("Cancellation transaction mined.")
except gevent.Timeout:
logger.error(
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Changelog
=========

1.0.0 (unreleased)
0.8.0 (unreleased)
-----

- Full rewrite of all contracts.
Expand Down
208 changes: 208 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
CLI Interface
=============

.. contents:: :local:

The alarm service ships with a command line interface that can be used to
interact with the service in various ways.


Requirements
------------

The ``ethereum-alarm-clock-client`` python package requires some system
dependencies to install. Please see the `pyethereum documentation`_ for more
information on how to install these.

This package is only tested against Python 3.5. It may work on other versions
but they are explicitely not supported.

This package is only tested on unix based platforms (OSX and Linux). It may
work on other platforms but they are explicitely not supported.


Installation
------------

The ``ethereum-alarm-clock-client`` package can be installed using ``pip`` like this.

.. code-block:: bash
$ pip install ethereum-alarm-clock-client
Or directly from source like this.

.. code-block:: bash
$ python setup.py install
If you are planning on modifying the code or developing a new feature you
should instead install like this.

.. code-block:: bash
$ python setup.py develop
The ``eth_alarm`` executable
----------------------------

Once you've installed the package you should have the ``eth_alarm`` executable
available on your command line.


.. code-block:: bash
TODO: `help` output from the main command
Setting up an





.. _pyethereum documentation: https://github.com/ethereum/pyethereum/wiki/Developer-Notes


Running a server
----------------

TODO: update this.

The scheduler runs nicely on the smallest AWS EC2 instance size. The following
steps should get an EC2 instance provisioned with the scheduler running.

1. Setup an EC2 Instance
^^^^^^^^^^^^^^^^^^^^^^^^

* Setup an EC2 instance running Ubuntu. The smallest instance size works fine.
* Add an extra volume to store your blockchain data. 16GB should be sufficient
for the near term future.
* Optionally mark this volume to persist past termination of the instance so
that you can reuse your blockchain data.
* Make sure that the security policy leaves `30303` open to connections from
the outside world.


2. Provision the Server
^^^^^^^^^^^^^^^^^^^^^^^

* ``sudo apt-get update --fix-missing``
* ``sudo apt-get install -y supervisor``
* ``sudo apt-get install -y python-dev python build-essential libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev python-virtualenv``

3. Mount the extra volume
^^^^^^^^^^^^^^^^^^^^^^^^^

The following comes from the `AWS Documentation`_ and will only work verbatim
if your additional volume is ``/dev/xvdb``.


* ``sudo mkfs -t ext4 /dev/xvdb``
* ``sudo mkdir -p /data``
* ``sudo mount /dev/xvdb /data``
* ``sudo mkdir -p /data/ethereum``
* ``sudo chown ubuntu /data/ethereum``

Modify `/etc/fstab` to look like the following. This ensures the extra volume
will persist through restarts.

.. code-block:: shell
#/etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0
/dev/xvdb /data ext4 defaults,nofail 0 2
Run ``sudo mount -a`` If you don't get any errors then you haven't borked your
``etc/fstab``

4. Install Geth
^^^^^^^^^^^^^^^

Install the go-ethereum client.

* ``sudo apt-get install -y software-properties-common``
* ``sudo add-apt-repository -y ppa:ethereum/ethereum``
* ``sudo apt-get update``
* ``sudo apt-get install -y ethereum``

5. Install the Alarm Client
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Install the Alarm client.

* ``mkdir -p ~/alarm-0.6.0``
* ``cd ~/alarm-0.6.0``
* ``virtualenv env && source env/bin/activate``
* ``pip install ethereum-alarm-clock-client``

6. Configure Supervisord
^^^^^^^^^^^^^^^^^^^^^^^^

Supervisord will be used to manage both ``geth`` and ``eth_alarm``.

Put the following in ``/etc/supervisord/conf.d/geth.conf``

.. code-block:: shell
[program:geth]
command=geth --datadir /data/ethereum --unlock 0 --password /home/ubuntu/geth_password --rpc --fast
user=ubuntu
stdout_logfile=/var/log/supervisor/geth-stdout.log
stderr_logfile=/var/log/supervisor/geth-stderr.log
Put the following in ``/etc/supervisord/conf.d/scheduler-v6.conf``

.. code-block:: shell
[program:scheduler-v6]
user=ubuntu
command=/home/ubuntu/alarm-0.6.0/env/bin/eth_alarm scheduler --client rpc --address 0xe109ecb193841af9da3110c80fdd365d1c23be2a
directory=/home/ubuntu/alarm-0.6.0/
environment=PATH="/home/ubuntu/alarm-0.6.0/env/bin"
stdout_logfile=/var/log/supervisor/scheduler-v6-stdout.log
stderr_logfile=/var/log/supervisor/scheduler-v6-stderr.log
autorestart=true
autostart=false
7. Generate geth account
^^^^^^^^^^^^^^^^^^^^^^^^

Use the following command to generate an account. The ``--datadir`` argument
is important, otherwise the generated account won't be found by our geth
process being run by supervisord.

* ``$ geth --datadir /data/ethereum account new``

Place the password for that account in ``/home/ubuntu/geth_password``.

You will also need to send this account a few ether. Twice the maximum
transaction cost should be sufficient.

8. Turn it on
^^^^^^^^^^^^^

Reload supervisord so that it finds the two new config files.

* ``sudo supervisord reload``

You'll want to wait for ``geth`` to fully sync with the network before you
start the ``scheduler-v6`` process.

9. Monitoring
^^^^^^^^^^^^^

You can monitor these two processes with ``tail``

* ``tail -f /var/log/supervisor/geth*.log``
* ``tail -f /var/log/supervisor/scheduler-v6*.log``



.. _Ethereum Alarm Clock Client: https://github.com/pipermerriam/ethereum-alarm-client
.. _pip: https://pip.pypa.io/en/stable/
.. _issue 1: https://github.com/pipermerriam/ethereum-alarm-client/issues/1
.. _AWS Documentation: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Contents:
request_factory
request_tracker
scheduler
cli
changelog
:maxdepth: 1

Expand Down
24 changes: 0 additions & 24 deletions docs/what.rst

This file was deleted.

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sphinx>=1.3.1
sphinx-better-theme>=0.1.4
populus>=1.1.0
web3>=2.9.0
populus>=1.2.0
web3>=3.0.0
eth-testrpc>=0.8.4
ethereum-tester-client>=1.2.2
click>=6.6
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
DIR = os.path.dirname(os.path.abspath(__file__))


version = '7.0.0'
version = '8.0.0'

setup(
name='ethereum-alarm-clock',
name='ethereum-alarm-clock-client',
version=version,
description="""Ethereum Alarm Clock""",
long_description="Ethereum Alarm Clock service",
Expand All @@ -21,7 +21,8 @@
include_package_data=True,
py_modules=['eth_alarm_client'],
install_requires=[
"populus>=1.1.0",
"populus>=1.2.0",
"web3>=3.0.0",
"pylru>=1.0.9",
],
license="MIT",
Expand Down

0 comments on commit f35028c

Please sign in to comment.