Holochain
Published in

Holochain

Dev Tools in the Works

Holochain Dev Pulse 92

Summary

Mostly we’re working on performance, bugfixes, and features (proxy server, storage code, sharding, and validation receipts), but we’re also working on a few developer tools: the hc command (yes, it's coming back), a mock HDK, and a nearly finalised hApp bundle spec.

Highlights

  • The hc developer command returns!
  • Mock HDK: Test your DNA without firing up Holochain
  • hApp bundle spec ready for basic use

The hc developer command returns!

Veteran Holochain developers will remember the hc command, a sort of Swiss army knife tool that let you scaffold, compile, test, and run your hApps. It's here again and (almost) ready for you to start using in your daily development.

Subcommands already implemented:

  • hc dna replaces the existing dna-util command.
  • hc dna init creates an empty directory and manifest file for a DNA.
  • hc dna pack packs a collection of compiled WASM zomes and a DNA manifest file into a DNA file. It replaces dna-util -c.
  • hc dna unpack unpacks a DNA file into its component manifest and compiled WASM zomes. It replaces dna-util -e.
  • hc app has the same subcommands as hc dna, but works at the level of a hApp bundle - that is, a collection of DNAs. (See below for more info on bundles.)
  • hc sandbox is still a work-in-progress, but will let you generate and run conductor 'sandboxes' - temporary conductor configurations (including multiple instances on multiple conductors) that let you test-run your application.

This tool isn’t available in mainline Holonix quite just yet, but you can try it out with this command:

nix-shell https://github.com/holochain/holonix/archive/pr/bump-holo-nixpkgs-add-hc.tar.gz

Once it’s finished its work and you find yourself in the development shell, you should have the hc tool available:

hc --version holochain_cli 0.1.0

We’re still working out what scaffolding should look like beyond the simple hc dna init and hc app init commands. If you have an idea of what you need from a scaffolding tool, please create a GitHub feature request and tag it with 'enhancement'.

What about scaffolding and testing? Testing is already well-covered by the tools native to each language:

  • You can use npm test to run scenario/end-to-end tests written with Tryorama
  • You can use cargo test to run unit tests with the new mock HDK (see below)

Mock HDK: Test your DNA without firing up Holochain

Unit testing — tests for the smallest executable pieces of your code — should be the foundation of your testing plan. Up until now, though, we haven’t had any great tools for unit testing a DNA.

Tryorama, our scenario testing framework, has been great for doing integration testing. It loads up an entire conductor (or multiple conductors) to host your DNAs. But this isn’t what you want for unit tests, which are meant to test a specific piece in isolation. It also doesn’t support a lot of edge cases — unexpected conductor shutdowns are easy to model, but other situations like hardware errors and malicious peers are impossible.

So the core devs have introduced a mock HDK that lets you simulate host call responses and introduce all the edge cases you like. You can find examples throughout the WASM test suite; here’s one that mocks the CRUD host functions.

hApp bundle spec ready for basic use

We expect a common pattern for hApp development will be mixing-and-matching existing DNAs in new configurations, sort of like an ecosystem of microservices. In fact, we explicitly want to see that happening. We think Holochain will get adopted more quickly if developers can lean on each other’s good work; it saves work and time for developers, and leads to a better user experience when new apps can connect to existing apps and take advantage of users’ existing data.

To that end, we’ve long held an intention to let developers easily specify a ‘bundle’ of DNAs that make up a full application. There are different needs; here are a few:

  • Connect to an existing DNA, such as a core app (like DeepKey) or other popular app (like chat or social media)
  • Make a new copy of an existing DNA so users can enjoy a private space using the same code
  • Clone a DNA multiple times for separate, small spaces — such as team chat rooms within an organisation

hApp bundles existed in Holochain Redux; now they’re coming to RSM. A few of the above scenarios (e.g., cloning, DNA versioning) aren’t supported yet, and the bundle spec format isn’t officially stable. But it’s already in use in the admin API (and soon Tryorama and the ), and the parts that hApp devs are already using look pretty robust and probably won’t change much. Here’s what works and what’s changed:

  • The admin API endpoint InstallAppBundle is meant to replace InstallApp, which will be deprecated. It supports all the features of InstallApp already and will support more in the future.
  • DNA manifests, which already exist and can override properties and UUID in the DNA bundle. DNA manifests have only had a minor tweak to allow referencing DNA bundle files by URL as well as file path.
  • An app bundle has ‘slots’, which give a human-readable ID to existing or new DNAs in a bundle. In the future, these slots will also be used for cloned DNAs.
  • In contrast to Redux’s bundle spec, DNAs don’t explicitly depend on each other via bridge specs. The cell can simply make a bridge call to any other cell it has a handle for. Access is granted or denied via capability-based security. (This means you have to be careful about circular dependencies.)

Bonus: signs of ecosystem growth

I’ve noticed some things lately that signal to me that Holochain is gaining awareness and support in the open-source developer community.

  • hApp developers are creating pull requests that add features — both ones that meet their own needs, like being able to specify header timestamps, as well as ones that everyone can enjoy, like mDNS peer discovery for local networks.
  • People from outside the Holochain dev community are offering their own gifts, such as in this forum post introducing a low-code development toolkit (soon to be open-sourced) and inviting collaboration to make it work with Holochain, as well as this post investigating Holochain’s usefulness for a popular Kenyan community currency.
  • Engagement on the developers’ forum has seen a steady climb in the past two months. If I could guess, I’d say this is partly due to the fact that people can now actually see Holochain in action, thanks to Elemental Chat landing on HoloPorts, and partly due to the work we’ve been doing to increase awareness at events like the FOSDEM 2021 and Hello Decentralization conferences.

Connect with us!

If you’re a developer and you’re just learning about Holochain, I encourage you to join the developer forum and talk to the other friendly community members. If you’ve got an application (or an idea for an application) and are wondering how it would work with Holochain as a back end, I love talking about the nitty-gritty details of implementation (my username is @pauldaoust). The community also runs courses; there’s an application architecture course currently running and it’s likely to be offered again in the future.

Originally published at https://blog.holochain.org on March 13, 2021.

--

--

--

Holochain enables a distributed web with user autonomy built directly into its architecture and protocols. Data is about remembering our lived and shared experiences. Distributing the storage and processing of that data can change how we coordinate and interact. www.holochain.org

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Holochain Design

Holochain Design

Creating an ecosystem of decentralized applications with distributed, user-controlled storage. Cheaper, faster, better than #Blockchain @metacurrency @H_O_L_O_

More from Medium

Autonomous Cars

Open Source and Interporality in the Metaverse

DeepSquare & Openfabric On A Mission To Democratize Artificial Intelligence

1.What is Next.js?