Skip to content

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

Latest
Compare
Choose a tag to compare
@Someguy123 Someguy123 released this 05 Jun 16:42

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