GithubHelp home page GithubHelp logo

sentinel's Introduction

Dash Sentinel (DEPRECATED)

Test Status

An automated governance helper for Dash Masternodes.

Note: Sentinel was deprecated by Dash Core 20.0 which migrated all functionality directly into Dash Core.

Sentinel is an autonomous agent for persisting, processing and automating Dash governance objects and tasks. It is a Python application which runs alongside the DashCore instance on each Dash Masternode.

Table of Contents

Install

These instructions cover installing Sentinel on Ubuntu 18.04 / 20.04.

Dependencies

Update system package list and install dependencies:

$ sudo apt-get update
$ sudo apt-get -y install git python3 virtualenv

Make sure Python version 3.6.x or above is installed:

python3 --version

Make sure the local DashCore daemon running is at least version 0.15.0.

$ dashd --version | head -n1

Install Sentinel

Clone the Sentinel repo and install Python dependencies.

$ git clone https://github.com/dashpay/sentinel.git && cd sentinel
$ virtualenv -p $(which python3) ./venv
$ ./venv/bin/pip install -r requirements.txt

Usage

Sentinel is "used" as a script called from cron every minute.

Set up Cron

Set up a crontab entry to call Sentinel every minute:

$ crontab -e

In the crontab editor, add the lines below, replacing '/path/to/sentinel' to the path where you cloned sentinel to:

* * * * * cd /path/to/sentinel && ./venv/bin/python bin/sentinel.py >/dev/null 2>&1

Test Configuration

Test the config by running tests:

$ ./venv/bin/py.test ./test

With all tests passing and crontab setup, Sentinel will stay in sync with dashd and the installation is complete

Configuration

Configuration is done via environment variables. Example:

$ RPCUSER=dash RPCPASSWORD=password RPCHOST=127.0.0.1 RPCPORT=19998 ./venv/bin/python bin/sentinel.py

A path to a dash.conf file can be specified in sentinel.conf:

# warning: deprecated
dash_conf=/path/to/dash.conf

This is now deprecated and will be removed in a future version. Users are encouraged to update their configurations to use environment variables instead.

Troubleshooting

To view debug output, set the SENTINEL_DEBUG environment variable to anything non-zero, then run the script manually:

$ SENTINEL_DEBUG=1 ./venv/bin/python bin/sentinel.py

Maintainer

@nmarley

Contributing

Please follow the DashCore guidelines for contributing.

Specifically:

  • Contributor Workflow

    To contribute a patch, the workflow is as follows:

    • Fork repository
    • Create topic branch
    • Commit patches

    In general commits should be atomic and diffs should be easy to read. For this reason do not mix any formatting fixes or code moves with actual code changes.

    Commit messages should be verbose by default, consisting of a short subject line (50 chars max), a blank line and detailed explanatory text as separate paragraph(s); unless the title alone is self-explanatory (like "Corrected typo in main.cpp") then a single title line is sufficient. Commit messages should be helpful to people reading your code in the future, so explain the reasoning for your decisions. Further explanation here.

Code Style

Please use black to format code automatically before opening a PR:

./venv/bin/black .

License

Released under the MIT license, under the same terms as DashCore itself. See LICENSE for more info.

sentinel's People

Contributors

andyfreer avatar chaeplin avatar codablock avatar dependabot[bot] avatar eduffield222 avatar fireice-uk avatar moocowmoo avatar nmarley avatar pastapastapasta avatar rex4539 avatar schinzelh avatar strophy avatar taw00 avatar the-schnibble avatar thelazier avatar thephez avatar udjinm6 avatar xdustinface avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentinel's Issues

For 12.2 (branch core-v0.12.2.x) Fails to Parse Numbers with Comma

I have two 12.2 TestNet masternodes that are failing to run sentinel (I think). It's definitely failing when i run it manually but it looks as if it's running enough to keep my nodes ENABLED.

I am running the last version of the core-v0.12.2.x branch.

When I run Sentinel manually, I receive the following output on one of my nodes.

ubuntu@ip-10-0-4-117:~$ cd /home/ubuntu/.dashcore/sentinel && venv/bin/python bin/sentinel.py
Traceback (most recent call last):
  File "bin/sentinel.py", line 265, in <module>
    main()
  File "bin/sentinel.py", line 218, in main
    prune_expired_proposals(dashd)
  File "bin/sentinel.py", line 65, in prune_expired_proposals
    for proposal in Proposal.expired(dashd.superblockcycle()):
  File "lib/models.py", line 383, in expired
    for proposal in self.select():
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2193, in next
    obj = self.qrw.iterate()
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2253, in iterate
    return self.process_row(row)
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2331, in process_row
    setattr(instance, column, func(row[i]))
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 1072, in python_value
    return decimal.Decimal(str(value))
  File "/usr/lib/python2.7/decimal.py", line 548, in __new__
    "Invalid literal for Decimal: %r" % value)
  File "/usr/lib/python2.7/decimal.py", line 3872, in _raise_error
    raise error(explanation)
decimal.InvalidOperation: Invalid literal for Decimal: '2,12345678'

When I run it manually on the other node, I receive something similar.

ubuntu@ip-10-0-3-18:~/.dashcore/sentinel$ cd /home/ubuntu/.dashcore/sentinel && venv/bin/python bin/sentinel.py
Traceback (most recent call last):
  File "bin/sentinel.py", line 265, in <module>
    main()
  File "bin/sentinel.py", line 218, in main
    prune_expired_proposals(dashd)
  File "bin/sentinel.py", line 65, in prune_expired_proposals
    for proposal in Proposal.expired(dashd.superblockcycle()):
  File "lib/models.py", line 383, in expired
    for proposal in self.select():
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2193, in next
    obj = self.qrw.iterate()
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2253, in iterate
    return self.process_row(row)
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2331, in process_row
    setattr(instance, column, func(row[i]))
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 1072, in python_value
    return decimal.Decimal(str(value))
  File "/usr/lib/python2.7/decimal.py", line 548, in __new__
    "Invalid literal for Decimal: %r" % value)
  File "/usr/lib/python2.7/decimal.py", line 3872, in _raise_error
    raise error(explanation)
decimal.InvalidOperation: Invalid literal for Decimal: '2,4'

sentinel runs error

Traceback (most recent call last):
  File "bin/sentinel.py", line 5, in <module>
    import init
  File "/root/dash-sentinel-6/lib/init.py", line 112, in <module>
    main()
  File "/root/dash-sentinel-6/lib/init.py", line 99, in main
    if not is_database_correctly_configured():
  File "/root/dash-sentinel-6/lib/init.py", line 48, in is_database_correctly_configured
    db.connect(reuse_if_open=True)
TypeError: connect() got an unexpected keyword argument 'reuse_if_open'

Feature request: Adding timestamps to the output?

Hi,

it would be nice to have some timestamps on the output generated by sentinel. I'm writing output to a local log file for automated analysis and rotation, therfore it would be nice to have a date/time stamp. Even better, configurable ones using a customizable time format string.

Use the RPC connect IP from dash.conf

Sentinel is using only 127.0.0.1 when trying to connect to dashd. It needs to also use the 'rpcconnect' value if it was set in dash.conf.

Just a few lines needs to be changed in dash_config.py:

    # Changed the following line
    #match = re.findall(r'rpc(user|password|port)=(.*?)$', data, re.MULTILINE)
    match = re.findall(r'rpc(user|password|port|connect)=(.*?)$', data, re.MULTILINE)

    # Added the following before
    #    return creds
    # set the host from config file
    if ('connect' in creds):
        creds[u'host'] = creds[u'connect']

Any interest in obsoleting this repo?

This project never ended up being what it was envisioned as. Currently it just votes on the superblock for DashCore and votes to remove expired proposals, and that functionality could be absorbed into the C++ codebase. It would be less work for MNOs to set this up and it would ensure the superblock votes are coming in (hasn't been an enforced requirement to run Sentinel in a couple years).

I do believe it would take a hard fork cycle or 2 and require changes to the gobject format, using strings instead of numbers for example, but would get rid of this. Not sure if it's worth the effort or not, but wanted to float the idea.

@UdjinM6 @PastaPastaPasta @QuantumExplorer

Issue when installing

Hi,

When installing on Ubuntu 16 LTS I get the following errors:
$ virtualenv venv
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home//.dashcore/sentinel/venv/bin/python2
Not overwriting existing python script /home//.dashcore/sentinel/venv/bin/python (you must use /home//.dashcore/sentinel/venv/bin/python2)
Installing setuptools, pkg_resources, pip, wheel...
Complete output from command /home//.dash...nel/venv/bin/python2 - setuptools pkg_resources pip wheel:
Traceback (most recent call last):
File "", line 24, in
File "/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/init.py", line 215, in main
File "/home//.dashcore/sentinel/venv/lib/python2.7/locale.py", line 581, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

...Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/virtualenv.py", line 2363, in
main()
File "/usr/lib/python3/dist-packages/virtualenv.py", line 719, in main
symlink=options.symlink)
File "/usr/lib/python3/dist-packages/virtualenv.py", line 988, in create_environment
download=download,
File "/usr/lib/python3/dist-packages/virtualenv.py", line 918, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/usr/lib/python3/dist-packages/virtualenv.py", line 812, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home//.dash...nel/venv/bin/python2 - setuptools pkg_resources pip wheel failed with error code 1

Any ideas why?

Travis-CI is still required on PRs into develop

The .travis.yml file was removed a couple PRs ago but still shows as required. I'm assuming someone w/owner privileges on dashpay GitHub will have to go into Travis-CI and switch off this repo. Or all repos, would be fine too. ;)

venv/bin/py.test test fails since April superblock

It seems this failure started to appear today, after the superblock, but I'm not 100% sure.

sentinel git:(master) venv/bin/py.test test
==================================================================== test session starts =====================================================================
platform linux2 -- Python 2.7.12, pytest-3.0.1, py-1.4.31, pluggy-0.3.1
rootdir: /home/tom/.dashcore/sentinel, inifile:
collected 20 items

test/integration/test_jsonrpc.py .
test/unit/test_dash_config.py .
test/unit/test_dashd_data_shims.py ..
test/unit/test_dashy_things.py .....
test/unit/test_models.py ..
test/unit/test_submit_command.py .
test/unit/models/test_proposals.py ...
test/unit/models/test_superblocks.py ...F.

========================================================================== FAILURES ==========================================================================
___________________________________________________________ test_deterministic_superblock_creation ___________________________________________________________

go_list_proposals = [{'AbsoluteYesCount': 1000, 'AbstainCount': 7, 'CollateralHash': 'acb67ec3f3566c9b94a26b70b36c1f74a010a37c0950c22d683c...5223a20312c202275726c223a2022687474703a2f2f6461736863656e7472616c2e6f72672f6665726e616e64657a2d37363235227d5d5d', ...}]

    def test_deterministic_superblock_creation(go_list_proposals):
        import dashlib
        import misc
        from dashd import DashDaemon
        dashd = DashDaemon.from_dash_conf(config.dash_conf)
        for item in go_list_proposals:
            (go, subobj) = GovernanceObject.import_gobject_from_dashd(dashd, item)

        max_budget = 60
        prop_list = Proposal.approved_and_ranked(proposal_quorum=1, next_superblock_max_budget=max_budget)
        sb = dashlib.create_superblock(prop_list, 72000, budget_max=max_budget, sb_epoch_time=misc.now())

>       assert sb.event_block_height == 72000
E       AttributeError: 'NoneType' object has no attribute 'event_block_height'

test/unit/models/test_superblocks.py:225: AttributeError
============================================================ 1 failed, 19 passed in 0.50 seconds =============================================================

Sentinel cannot be installed on Ubuntu 22.04

The following error is reported during pip install -r requirements on Ubuntu 22.04. It appears that the issue is due to incompatibility with Python 3.10 as I was able to successfully run tests if I installed Python 3.9.

image

ERROR

From this day it doesn't work with error

Wed Nov 22 16:46:30 UTC 2023 Traceback (most recent call last): File "/home/ubuntu/.dashcore/sentinel/
bin/sentinel.py", line 230, in <module> main() File "/home/ubuntu/.dashcore/sentinel/bin/sentinel.py",
 line 176, in main attempt_superblock_creation(dashd) File "/home/ubuntu/.dashcore/sentinel/bin/sentin
el.py", line 66, in attempt_superblock_creation proposal_quorum=dashd.governance_quorum(), File "/home
/ubuntu/.dashcore/sentinel/lib/dashd.py", line 97, in governance_quorum hpmn_weight = masternode_count
["detailed"]["hpmn"]["enabled"] Dockerfile LICENSE README.md bin database lib requirements.txt 
sentinel-cron.log sentinel.conf share test venv 4 KeyError: 'hpmn'

Do i need Sentinel to work a masternode?

Crashes on 12.2 TestNet

I am running the latest version of Sentinel on 12.2 testnet and some of my nodes (at least 4) are failing with the following error. All 4 went WATCHDOG_EXPIRED at the same time. When i run with -b all four nodes fail after about 20-30 seconds.

ubuntu@ip-10-0-4-209:~/.dashcore/sentinel$ venv/bin/python bin/sentinel.py
Traceback (most recent call last):
  File "bin/sentinel.py", line 265, in <module>
    main()
  File "bin/sentinel.py", line 218, in main
    prune_expired_proposals(dashd)
  File "bin/sentinel.py", line 65, in prune_expired_proposals
    for proposal in Proposal.expired(dashd.superblockcycle()):
  File "lib/models.py", line 383, in expired
    for proposal in self.select():
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2193, in next
    obj = self.qrw.iterate()
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2253, in iterate
    return self.process_row(row)
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 2331, in process_row
    setattr(instance, column, func(row[i]))
  File "/home/ubuntu/.dashcore/sentinel/venv/local/lib/python2.7/site-packages/peewee.py", line 1072, in python_value
    return decimal.Decimal(str(value))
  File "/usr/lib/python2.7/decimal.py", line 548, in __new__
    "Invalid literal for Decimal: %r" % value)
  File "/usr/lib/python2.7/decimal.py", line 3872, in _raise_error
    raise error(explanation)
decimal.InvalidOperation: Invalid literal for Decimal: '47,5'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.