Below are a few highlights of the Hive-related programming issues worked on by the BlockTrades team since my last post.
Hived (blockchain node software) work
Mirrornet (testnet that mirrors traffic from mainnet)
We continued to make updates to the mirrornet code to fix some issues related to transaction expiration and duplicate transactions and we’re now launching a new mirrornet network to resume testing.
Further optimization of OBI (one-block irreversibility) protocol
The optimizations to the OBI protocol are mostly done, but the dev for this work is currently tied up with another Hive-related coding task, so it still needs to be fully tested.
Switching from legacy assets to NAI assets is going to delay the hardfork
As I mentioned in my last post, one of the last planned changes to hived was to support assets using “network asset identifiers” instead of strings. When we originally planned this change, it looked fairly simple: when the node received a transaction, it would first try to decode it with NAI assets, then if that failed, fallback to processing the transaction as if the assets were in string format.
Unfortunately, we found that internally the binary form of the transaction is discarded in favor of a decoded form as a C++ object and then only much later packed back into a binary form. And to support the two formats, there were now going to be several places in the code where we would need to pack with both formats to see which one matched the original format it was signed in and this would add some significant CPU overhead.
Fortunately, there is a better solution to this problem, and it fits well with one of the optimization changes that I mentioned in my last post that we were planning to make after the hardfork related to the new “compressed block” feature we recently added.
Currently, hived compresses blocks when it writes them to the blocklog (the file that stores all the blockchain blocks), but it can only share blocks over the p2p network in uncompressed form. This leads to some amount of unnecessary compression/decompression of blocks during normal operation and it also means that more data has to be exchanged over the p2p network (because the blocks aren’t shared in compressed form).
So we were already planning to introduce a change after the HF to allow nodes to exchange blocks in either uncompressed or compressed form (the nodes would negotiate during their connection whether or not they understand each other’s compression formats or if they will need to exchange blocks uncompressed). To do this efficiently, we planned to retain the binary form of the block received from a node (as well as the unpacked object that exists today).
But we decided to implement this optimization now instead of after the HF, because it will yield substantial performance benefits by eliminating a lot of object copying, packing, unpacking, compression, decompression done by the current code; plus it will help with the change to NAI serialization (which can only be done via a HF).
Preliminary analysis shows that the performance benefits of this change are quite large and should dramatically increase the amount of transactions that can be processed in a block by a hived node.
But it does require reasonably large changes to both the p2p and the block processing code, so I think it is only prudent to allow more time to not only implement the changes, but also perform extensive testing of those changes. My best guess right now is that this will push the HF out to late July.
Hive Application Framework (HAF)
HAF development is still quite active and a lot of the current work is focused on creating docker images for the HAF server and associated HAF apps to simplify deployment and management .
We’ve also added some additional information from the blockchain to the “default” HAF tables based on needs found when developing the HAF-based block explorer.
HAF account history app (aka hafah)
We found and fixed a few more issues and annoyances with the HAF account history application, plus added some minor features (e.g. get_version API to report the current version of the account history app).
We also updated the benchmarking code to test various aspects of hafah operation. These benchmarks can now test just the internal SQL calls (to analyze the SQL time without the overhead from the web servers), the python-based web server, and the postgREST server (including testing both the legacy API and the new higher-performance “direct URL” API).
We also did more benchmarking to firmly convince ourselves that the postgREST web server performs better than the python-based one (one of our devs had benchmarks that suggested otherwise, but this appears to have been a fluke). In the end we found that postgREST, as expected, did much better (on average, the response times were about 3x better). We also double-checked that both servers responded the same, to be sure that there wasn’t some functional difference that was responsible for the improved performance.
At this point, there are no known issues with hafah functionality or performance, so I expect we’ll resume real world testing in a production environment this upcoming week.
One further issue I’ve been thinking about lately is that I think we should be able to use hafah to implement the get_block API as well, which would further lower the API processing load on hived nodes AND allow for faster response times I think, but I haven’t had a chance to look at this closely yet.
HAF-based hivemind (social media middleware server used by web sites)
We completed the work to store hivemind’s tables directly into a hivemind-specific schema in a HAF database (i.e. the same method used by other HAF apps) and we’ve been testing this new version with full syncs to the headblock (i.e. to live sync mode).
During this testing process, we’ve found and fixed several bugs along the way, but the testing is time-consuming (it takes almost 54 hours to reach live sync, which performance-wise is pretty good for processing of 6 years of blockchain history, but is a long time when you just want to find out if there’s a bug that regular testing didn’t expose).
Anyways, despite the long test times, I think we’re close to completion of this task; at least to the point where it should be a more-than-adequate replacement for the current production version of hivemind (we may be able to make further optimizations later based on the HAF-based design approach).
HAF-based Hive block explorer
We have a preliminary version of the HAF-based Hive block explorer completed, and I’ll share some screenshots and technical description of it in a separate post later this week. One of the ideas behind this design is to really decentralize the tech behind Hive block explorers so that any HAF server operator can easily run one.
Some upcoming tasks
- Modify hived to process transactions containing either NAI-based assets or legacy assets. As mentioned in the hived section of this post, this task has morphed into the wrapping of existing block and transaction objects with smarter objects that retain the binary form of these objects (and other meta data which is costly to recompute). This task is currently in progress and I think we’ll have a preliminary version ready for testing next week.
- Merge in new RC cost rationalization code.
- Finish dockerization and CI improvements for HAF and HAF apps.
- Collect benchmarks for a hafah app operating in “irreversible block mode” and compare to a hafah app operating in “normal” mode.
- Test postgREST-based hafah running inside a docker on a production server (api.hive.blog).
- Complete and benchmark HAF-based hivemind, then deploy and test on our API node.
- Test enhancements to one-block irreversibility (OBI) algorithm.
- Continue testing using updated blockchain converter for mirrornet.
When hardfork 26?
Due to the unexpected decision to optimize hived p2p and block processing before the hardfork rather than after, the hardfork date has been shifted to late July to ensure we have adequate time to test these changes.
On the positive side, I’ve pretty certain this will be the last update we make to the hardfork timing, as this should be the last changes we need for the hardfork.
As a side note, several times there have been requests for a summary of the changes made as part of the hardfork and I'll try to put together a list of the changes soon (including non-hardfork changes, since many of those are actually the most significant changes).
I agree with these comments. We might as well just keep adding to this HF. There isn’t a rush that I am aware of to push this one through.
When you say, “Preliminary analysis shows that the performance benefits of this change are quite large and should dramatically increase the amount of transactions that can be processed in a block by a hived node”, what ballpark are you thinking? 2X? 3X? 100X?
Tagging in @geekgirl who was just talking about this.
2x for sure, hard to say more until we have hard numbers.
Thanks! That’s pretty exciting.
this upcoming HF is such a tease : P
my dude xD
may the crypto gods hear your prayer :)
Thanks for the update. As Hive is working pretty well right now I don't think people are that impatient for the next hardfork. Take your time to get it as good as possible.
Thanks.
Agreed! Slow and steady wins the race.
Hmm, how long will it take 10-20 years from now to replay the blockchain history?
Very hard to predict such things because it depends on growth rate of the blockchain, software improvements, and hardware advancements.
not that long as the speed of processors and capacities of computers are doubling faster than the db is doubling
Yeah, that's a good point. Software improvements, as blocktrades pointed out in his answer can make a difference as well.
It's nice to see the Hive Application Framework (HAF) shaping up. I'm sure it will be instrumental to the new generation of DApps on the Hive Blockchain. Good work!
it's better not to rush it, thanks!
Thanks for the update!
Great job 😎👋🏻
Interesting to read about what is happening behind the curtain.
And good to know that api.hive.blog will run some tests in the next time. So I can exclude it from my default api node settings which I have to update regularly to keep acceptable response times for my peakd UI.
Good
great job !
Congratulations @blocktrades! Your post has been a top performer on the Hive blockchain and you have been rewarded with the following badge:
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out the last post from @hivebuzz:
Support the HiveBuzz project. Vote for our proposal!
The rewards earned on this comment will go directly to the people(@seckorama) sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.
Let me see this new update?
Proper preparation is essential for lasting success. We can build on the shifting sands of hurry, or we can take our time and build on the solid rock of adequate preparation.
So, in my mind, you can even extend the time if necessary.
@blocktrades I just asked Andarchy from Koinos about what he thinks about the state of the Hive blockchain and I just thought his answer was interesting so I'll forward it here:
Continued
Any thoughts? :)
Hive's new architecture will be mainly layer 2 after this hardfork, so this is really a non-issue. I'm afraid that Andrarchy may be in a bit in "sales-pitch" mode, which is understandable I guess. But IMO, the upcoming Hive architecture will easily outscale Koinos for realworld applications.
thanks for the response!
is this because of layer 2? What makes you so confident? I guess I am just realizing that I know too little about "Hive's new architecture" to fully comprehend this. I should read up on your posts 😅
I'll just leave the reply from Andrew here (not having wanted to start an argument):
I'm not really interested in spending time debating this topic with Andrachy because he is not a dev who understand the details about these systems. Nothing he's said since changes my mind on this subject. I just felt compelled to respond briefly because you directly asked me to.
I've written about the reasons for our approach from early on and my reasons why I think that layer 1 smart contracts are bad. From his latest response referencing this as a "missing feature", it is clear that he's never bothered to read that even. This doesn't surprise me, but I think it's a mistake to attack our architecture without even reading the design ideas that led to it.
Finally, I do think he's biased on this subject, and I think it is fair game to mention it. And yes, he can point out that I'm a large stakeholder in Hive, but that is ultimately because I believe in the design, not vice-versa. So a more accurate description of my bias would be "it's my design".
I am biased as well, but it seems to me that with the implementation of HAF, Hive's layer 1 seems very close to "complete". You will have removed the need for developers to even know how to interact with the blockchain and they can now just code in the language that is familiar to them. This is only going to lead to an explosion of layer 2 development.
And layer 2 development can happen so much faster than layer 1 development. We are going to really kick it up a notch in terms of development speed. It is going to be fun to watch.
I am excited for the work you plan to do after the hardfork and am curious to see how fast things are able to move on layer 2.
here is a really stupid question, but what exactly is layer 2? 😅 It's obviously not layer 1 (so it's code not running on the main chain), but where is it stored then? I guess on a side chain, but how does that operate; who validates the blocks, who runs the nodes? And how does layer 1 and 2 interact?
Can you clear that up?
I will start by saying I am not a developer or even remotely close so assume part of what I am about to say is wrong. I have been listening and reading for the last 5 years though, so part of it will be correct.
The short answer to your question is it depends on the layer 2 application. All layer 2 applications will utilize layer 1 in some form (otherwise it would just be a stand alone application like current web 2 apps). The layer 2 app can be centralized or decentralize. It can be open sourced or it can be close sourced. Hive-Engine is a layer 2 application. Splinterlands is a layer 2 application. Peakd is a layer 2 application.
The goal is to keep layer 1 as lightweight as possible so the blockchain as a whole is easiest, fastest, and cheapest to run, and most importantly, scalable.
Having everything on layer 1 would bloat the chain. This is one reason some chains have high gas fees. By being lightweight, Hive is able to have no fees (except replenishable RCs). This allows for economical gaming and micro-transactions.
Having more on layer 2 also ensures there are less hardforks, which in addition to keeping the network secure and up-and-running, this should be a nice and marketable feature to exchanges, who probably don’t appreciate needing to constantly upgrade things on their end. I haven’t seen this discussed, but I think this would be a huge selling point for the likes of coinbase, etc.
Since layer 2 doesn’t require hardforks, development can also be faster.
thanks for clearing that up and taking time to respond. I was just curious as to some of the arguments that were put forth on either side to understand the issue better (since I am myself not a dev). I really appreciate all the work you and your team is doing (and the many other devs on the chain), and see a bright future for Hive :)
This is incredibly great. I see that the original idea for decentralization is in Hive's future. Keep it cool and steady.
Great work. So many under the hood changes seem to be coming to the next Hardfork. I am happy you are not trying to rush it out. Take all the time you need. The testing tools are really coming together.
Hi PostREST mentioned is https://postgrest.org right ?
Yes. It's a great fit for HAF-based applications, both from a development standpoint (which was the original driver for investigating the technology) and from a performance perspective (which we found when we started benchmarking against the python-based web server used by hivemind).
Great to hear. I had heard good things about this magical API creator and glad that finally seeing it in action. This will give a chance to learn one more cool piece of tech to me and many of our fellow Hivers. Thanks for the response.