Skip to content

Releases: Someguy123/steem-rpc-scanner

v2.1.0 - Node ordering for `app.py`, method-only testing with `test_methods`, and other major improvements

05 Jun 16:42
Compare
Choose a tag to compare

New Features

Example usage of new features:

# Scan nodes.conf, including plugin tests - and sort the results placing nodes with the most successful API tests
# at the top, and least working tests at the bottom.
./app.py -q --plugins --sort tests
# Same again, but place nodes which have 'Hive' as their network at the top.
./app.py -q --plugins --sort hive

# Testing a mixture of supported and unsupported methods
./health.py test_methods https://hived.privex.io account_history_api.get_account_history condenser_api.get_blog condenser_api.get_version condenser_api.get_config
# Testing a supported method
./health.py test_method https://hived.privex.io condenser_api.get_blog
# Testing an unsupported method
./health.py test_method https://hived.privex.io condenser_api.get_config

# Same as above, but using run.sh pipenv wrapper instead of health.py
./run.sh health test_methods https://hived.privex.io account_history_api.get_account_history condenser_api.get_blog condenser_api.get_version condenser_api.get_config
./run.sh health test_method https://hived.privex.io condenser_api.get_blog
./run.sh health test_method https://hived.privex.io condenser_api.get_config

List of new features

  • Added support for ordering the scanner results outputted by app.py, along with reversing the results.

  • Improved health metrics for app.py output, such as support for Out-of-sync status.

  • Improved colour scale, instead of just red/yellow/green - rows/columns can go between red, light red,
    yellow, light yellow, and green, depending on how bad the node's health is.

  • Added new test_methods and test_method commands to health.py, which uses ONLY the plugin scanning from MethodTests

    • Much like health.py scan, both test_methods and test_method return a UNIX exit code based on whether or not the
      node is considered "good"

    • The test_methods command tests a list of API methods for a given RPC node against one or more nodes.

      • You can optionally specify a custom list of methods to test on the command line
      • If you don't specify any methods to test, then it will scan all supported methods, just like health.py scan
      • You can specify -l or --min-methods to control how many methods in total must pass their tests before
        a node is considered "good" (thus returnining a 0 exit code)
    • The test_method command works the same as test_methods, except it only tests a singular API method
      against an RPC node, and returns the appropriate exit code based on whether that individual method
      passed or not.

    • For both commands, you can also specify methods which aren't supported by the scanner. This means
      you can test methods that don't yet have a full method test implemented.

      However, be aware that the test for unsupported methods only checks that there were no errors
      returned in the JSON result, and that there was a non-empty results key. It cannot verify
      that the results returned are actually in the correct format that applications would expect.

    • If you want to test a method which requires certain JSON-RPC parameters to be specified for it to
      work at all, you can specify parameters that should be used for all unsupported methods being tested
      with --params (defaults to []).

      For newer appbase / Hivemind APIs, many of them don't work with a standard blank list [], but
      will work if you pass a blank dictionary {} as params.

General Developer Changelog

  • health.py

    • MAX_SCORE moved into settings
    • Added intro text to help epilog with source code link, license, repo link, and copyright etc.
    • Refactored various argparse arguments into arguments.py
    • Added new test_methods and test_method sub-commands / functions
    • score_node now appropriately compensates scoring when plugin testing is disabled.
    • Added logging
  • app.py

    • Moved argparse description into epilog, with much longer help text, and partially auto-generated help,
      such as which sorting options are reversed by default, and what sorting aliases are available
    • As with health.py, refactored various argparse arguments into arguments.py
    • Adjusted scan to read the CLI arguments, interpret them, and pass them to the completely overhauled print_nodes function,
      to support ordering of the results, along with reversing the order of the results.
  • RPCScanner.py

    • NodeStatus object

      • plugins attribute is no longer mandatory - now has a blank list factory
      • Added broken_plugins attribute
      • Added scanned_at attribute
      • Added new Unreliable status to _statuses
      • Added class properties server_type, server, head_block, ssl, avg_retries, res_time, and api_tests
      • Added get method, to improve compatibility with functions/methods which expect dictionaries.
      • Added magic methods __contains__, __getitem__, __str__ and __repr__
    • RPCScanner class

      • Cleaned up old .format() strings into modern python f-strings f"{x} {y:<20}"

      • plugin_test now appends to broken_plugins when plugin tests fail, so that they can be analyzed

      • Completely overhauled print_nodes with a new method written from the ground up (but should be mostly backwards compatible),
        which supports dynamic ordering / reversal of the rows.

        • Columns and row data are now independent objects NodeTableColumn and NodeTableRow, making it easier to add support for new
          node columns, as well as dynamically adjust column names, column padding, and row content padding.
        • Added enabled_columns static attribute, allowing for columns to be enabled/disabled without editing the code.
        • The new heart of print_nodes - the classmethod _node_table_row - makes use of modern NodeStatus objects, instead
          of relying on the dictionary compatibility layer of NodeStatus.
        • Nodes which are out-of-sync are now shown with the status Out-of-sync in red.
      • Various other small code quality and reliability improvements

  • MethodTests.py - only notable change is some adjustments to the whitelist/blacklist functionality of test_all, so
    that settings.SKIP_API_LIST is used appropriately.

  • rpc.py

    • Cleaned up old .format() strings into modern python f-strings f"{x} {y:<20}"
    • Removed a lot of old commented code lines
    • Refactored RPC error handling into new function handle_graphene_error
    • Improved RPC error handling with new customised RPCError exception, along with sub-exceptions to ease handling
      more common RPC errors.
    • Converted standard 3-item tuple output of the methods in NodePlug to use the new namedtuple - RPCBenchResult. Since
      it's a namedtuple, it should be backwards compatible with any old code that expects normal tuples.
  • settings.py / core.py

    • New helper functions find_parent, find_file, and scan_paths for more robust handling of user-specified file paths.
      These allow for relative paths to easily be resolved using some preset dynamic search paths.
    • LOG_DIR now uses the new find_parent function to resolve an absolute path to it's log folder, prevents issues if a
      user wants to specify a custom log folder.
    • Added CSV setting SKIP_API_LIST, which is designed to contain RPC API methods that should be skipped during scanning.
    • Moved MAX_SCORE from health.py into settings.py, and made it possible to specify it using an environment variable
      (however, it's not recommended to do that, since the scoring algorithm has been tested and tuned for a max of 50).
    • settings.node_file is resolved into an absolute path using find_file within core.py.
  • Various other small fixes, minor changes and improvements

v2.0.0 - Move from Twisted to native AsyncIO + major overhaul

29 May 00:50
Compare
Choose a tag to compare

All of the project has been migrated from Twisted Reactor to native Python AsyncIO, which affects
almost every single file in the project, so I'm not going to go into detail on the individual changes
for that.

This release is a major overhaul, with many new features, improvements, fixes and more. Not everything
is listed below, but most important changes are covered in great detail.

Key Changes

  • Many previously hardcoded settings have been changed so that they can be specified via either
    environment variables, CLI arguments, or both.

  • Various new environment variables and CLI arguments

  • Argument parsing in app.py and health.py have been re-formatted, and now respect
    the values in rpcscanner.settings as defaults.

  • Node list file

    • The default node list file has been changed from nodes.txt to nodes.conf - this
      allows for IDEs and text editors to apply some syntax highlighting, especially for comments,
      along with being able to use more assistive IDE features such as keyboard shortcuts to quickly
      comment / uncomment nodes.
    • core.py now uses regex to extract nodes from the node list, instead of a simple .readlines()
      and a .strip() loop. This means in-line comments next to listed RPC nodes are now possible,
      without causing a problem with the file parsing.
    • nodes.txt.example is now example.nodes.conf - which has had many RPC nodes added and removed,
      plus fancy comment blocks to separate sections of nodes in the file, and inline comments
      demarcating who runs each node (if known).
  • rpcscanner/MethodTests.py

    • The instance attribute MethodTests.METHOD_MAP has now been refactored into a module level
      attribute. This allows external RPC method testing functions/methods to be configured, alongside
      the ones built into the MethodTests class.
    • API Method testing functions now take a first argument host - this is to compensate for
      the newly added capability for adding external RPC method testing functions/methods, by
      making the pre-existing methods consistent with how an external method would receive the
      host URL being tested.
    • Added new test_all method, which works similarly to the original test method, but
      tests all supported API methods, or a subset if you specify a whitelist/blacklist.
  • rpcscanner/rpc.py

    • Classes and functions in this file which previously expected a reactor instance to be passed
      to them, no longer take a reactor argument. This is a breaking change, as the order of
      arguments for various functions/methods/constructors have changed.
    • General cleanup of NodePlug._ident_jussi, including refactoring the server type identification
      code into a static method which parses a dict/str response.
  • health.py

    • The default MAX_SCORE is now 50 instead of 20
    • The scoring algorithm used in score_node has been tweaked, and also has a new scoring metric based
      on whether a node is out of sync, applying a varying score penalty based on how badly out of sync
      the node is.
    • New fields Network and PassedStages have been added to the individual RPC health output
    • The Time field for individual RPC health has been adjusted to show how far behind the node is.
  • rpcscanner/RPCScanner.py

    • The server scanning stages have been adjusted to provide partial compatibility for older Steem-based networks
      such as Whaleshares, by using database_api instead of condenser_api, along with some other small adjustments.
    • The scanning stages now detect the network that a node is on, based on the native currency of the network
      returning within the dynamic global props. By network, I mean Steem, Hive, Whaleshares etc.
    • Various new methods such as add_tasks and rpc_tasks and others, which are helper methods for dealing with
      AsyncIO, reducing code duplication
    • filter_badnodes and identify_nodes have both been cleaned up, and have some new features added to them, related
      to the new network detection.
    • plugin_test now records the timing + retries for individual plugin testing.
  • App-wide changes

    • verbose and quiet have been refactored to behave differently. verbose is now more respected,
      while quiet is stricter on the log messages that it allows through
    • Various changes to the logging system, including the addition of log files, with automatic
      log folder creation to avoid issues.
    • Migrated from standard requirements.txt to pipenv, as pipenv handles both dependency management,
      and creation/maintenance of virtualenv's.
    • Added run.sh runner script, to make it easier to install, update, and run rpcscanner via pipenv.
    • Added a Dockerfile, so that rpc-scanner can be easily ran within a Docker container on any platform.
      Pre-built images coming soon.
    • General reliability and user experience improvements across the application

and various other fixes, changes and improvements...