2nd update of 2022 on BlockTrades work on Hive software
![blocktrades update.png](https://images.hive.blog/DQmSihw8Kz4U7TuCQa98DDdCzqbqPFRumuVWAbareiYZW1Z/blocktrades%20update.png)
Below is a list of some of the Hive-related programming issues worked on by the BlockTrades team during the past two weeks.
# HAF account history app (aka hafah)
We briefly deployed hafah (the HAF-based account history app) to our production node as a replacement for our hived-based account history node, but we discovered that many apps are still using the legacy “condenser_api” form of the account history calls (which hafah didn’t support). This left us with two options: get apps to move from the legacy condenser_api calls to the account_history_api calls or implement support for the legacy calls inside hafah itself.
After carefully considering both options, it seemed best to add support for the legacy calls inside hafah. This was relatively quick to do, it didn’t require coordination with other dev teams, and HAF may lead to a new programming paradigm that will deprecate the use of both the old and the new account_history_api calls (so no point in forcing Hive apps to upgrade once, then shortly thereafter change again).
We’re still working on an alternate version of hafah that uses postgREST as the api server instead of the python-based one. Benchmarks of hived account history plugin vs python-based hafah led me to believe that the python server was impacting the potential performance of the very fast api calls such as find_transaction (hived was actually performing better than hafah for these very fast calls). The results from the postgresT server seem to confirm this issue we’re seeing about 4x better peformance with postgresT vs the python server on those calls (4.8ms vs 22ms).
So I think it is very likely that we will switch to using postgresT unless we find some compelling reason to stay with the python implementation for hafah. If do make this switch, we'll likely modify the HAF setup scripts to optionally install a postgREST server if this becomes the default recommended server for HAF apps.
# Hived (blockchain node software) work
During our testing of Hafah we uncovered a problem with recent changes to hived’s account history plugin, so, after a few bumps along the way, we fixed that issue. We’ve tested the changes with a replay of hived and we’re currently using that replayed hived to re-index a hivemind server as a final test. The test has already progressed to the point that we’re confident in the fix, so the changes have been merged to the develop branch of hived, and we’re using that version of hived now to power our HAF and hafah tests.
We also finished testing and merged code that enables a HF26 feature which allow apps to refer to assets (e.g. hive and hbd) using either legacy-style strings or the new numeric asset identifiers (NAIs). This is to allow apps to gradually update to the new NAI syntax.
We created more unit tests, regression tests, and performance tests for various parts of hived.
# Hive Application Framework: framework for building robust and scalable Hive apps
Last week I published an introductory post for HAF to Hive app developers. Those instructions are slightly out-of-date as it is now possible to directly grab and run the setup_haf_instance.sh script without needing to checkout the HAF repo first. The benefit of this new approach is you don’t end up with two copies of the HAF repo on your development system. To directly download the install script from gitlab, type:
`wget https://gitlab.syncad.com/hive/haf/-/raw/develop/scripts/setup_haf_instance.sh`
We also added new stored procedures in HAF to simplify implementation of Hive
API calls that return “legacy-style” json results (i.e. where results are returned as an array rather than a dictionary). These procedures were used to ease implementation of the condenser_api calls for hafah and they may be useful for supporting other legacy API calls in the future.
# Condenser wallet (source code for https://wallet.hive.blog)
We added support for filtering transactions displayed in a user’s wallet. We also added a feature to display the top voters on a DHF proposal (a small bug was found in this latter feature which is being fixed now).
# What’s next?
* Modify one-step script for installing HAF to optionally download a trusted block_log and block_log.index file
* Create CI scripts to auto-deploy docker-based hived and HAF instances
* Add support for filtering of operations by sql_serializer to allow for smaller HAF server databases
* Collect benchmarks for hafah operating in irreversible block mode
* Test hafah on production servers (api.hive.blog)
* Finish conversion of hivemind to a HAF-based app
* Fix locking/task incompatibility issue between blockchain and p2p threads and see if this fixes block time offset increase under heavy transaction loading.
* Complete work on resource credit rationalization after block time offset issue is resolved.
See: 2nd update of 2022 on BlockTrades work on Hive software by @blocktrades