City of Zion has released a new update to the neo-python project, a NEO node and SDK written in the Python language. Version 0.8.3 includes a complete refactoring of neo-python’s CLI alongside various improvements designed to improve stability and usability. The latest version can be downloaded here and the full changelog may be viewed here.

CLI Refactor

Due to the ever-increasing complexity of prompt.py, which handles all commands, several issues and inconsistencies were plaguing the user experience of neo-python. Project maintainer @ixje outlined some of these issues in his rationale for the refactor:

  • Commands present but missing from the help output
  • Commands present but not part of the auto-completer
  • Some commands have been extracted to live under /neo/Prompt/Commands/ yet still are dependent on proper integration in prompt.py
  • Most commands are suboptimally covered in automated testing and/or poorly testable
  • Custom commands require patching after every update

To address these issues and support future extensibility, with support from key contributors @jseagrave21 and @LysanderGG, he began the task of moving console commands to a plugin-based system, based on an initial structure by @LysanderGG. This will allow commands to be easily added or tested without running the prompt itself, once dynamic loading has been added.

The overhaul changed 9,740 lines of code and is expected to provide a much more user-friendly experience when using neo-python. Commands may now be easily located under /neo/Prompt/Commands/.

Additional Features

The latest update includes support for GET requests, allowing RPC nodes to be easily queried for information from any browser via URL. To accompany the change, OPTIONS requests will also be supported, allowing easy differentiation between RPC servers that use default RPC commands, and those with Extended-RPC support.

The v0.8.3 release also included a gettransactionheight RPC method, improved getpeers functionality with tracking of bad peers, and an –to-addr option when claiming GAS, allowing users to claim GAS to a different address.

The team also added a new approach for loading plugins, inspired by the popular Django framework for Python. The changes apply to both REST and RPC servers, with new documentation provided here.

Bug Fixes

Several bug fixes were also included in the update. Pull requests #714, #746, and #751 were created to fix the JSON output from various RPC commands so that they match the outputs received when using the same commands in neo-cli.

The cannot join current thread issue when using np-bootstrap on Ubuntu systems has been resolved. Using np-bootstrap will now also remove the need for users to update their protocol config files whenever bootstrap files are updated. MainNet bootstrap files have been updated to block height 3210xxx, and an unnecessary default bootstrap warning has been removed.

An issue where a transaction that has been confirmed on the blockchain but is not purged from the mempool has been resolved. Various issues signing transactions for multi-signature accounts have also been fixed, alongside an edge case issue where using the sendmany function with alternating assets could calculate an incorrect asset change value, resulting in the transaction being rejected by the network.

General Changes

As noted in NEO News Today’s community development report for November, improving network stability has been a priority for the neo-python project.

Pull request #723 includes various updates to the network code and adds health checking of peers based on requests and responses within a given timeframe. The changes also add monitoring of connected peers. If zero peers are connected, the process resets and searches for fresh nodes to connect to. Extensive logging support has been added to improve inspection.

Two changes aimed at improving the user experience were also included in the latest version. The show nodes output has been updated to be more readable, along with a useful error message being produced as opposed to a list of exceptions when NEP-5 balance queries fail. This would occasionally confuse developers who use wallet to view a custom token balance on a network where the token has not been deployed.

The getassetstate RPC method has been updated to allow ‘neo’ or ‘gas’ to be searched by name. The pull request also added a showallassets LevelDBBlockchain function, which returns a list of all asset hashes.