Skip to content

Module hb.erl

Hyperbeam is a decentralized node implementing the AO-Core protocol on top of Arweave.

Description

This protocol offers a computation layer for executing arbitrary logic on top of the network's data.

Arweave is built to offer a robust, permanent storage layer for static data over time. It can be seen as a globally distributed key-value store that allows users to lookup IDs to retrieve data at any point in time:

Arweave(ID) => Message

Hyperbeam adds another layer of functionality on top of Arweave's protocol: Allowing users to store and retrieve not only arbitrary bytes, but also to perform execution of computation upon that data:

Hyperbeam(Message1, Message2) => Message3

When Hyperbeam executes a message, it will return a new message containing the result of that execution, as well as signed commitments of its correctness. If the computation that is executed is deterministic, recipients of the new message are able to verify that the computation was performed correctly. The new message may be stored back to Arweave if desired, forming a permanent, verifiable, and decentralized log of computation.

The mechanisms described above form the basis of a decentralized and verifiable compute engine without any relevant protocol-enforced scalability limits. It is an implementation of a global, shared supercomputer.

Hyperbeam can be used for an extremely large variety of applications, from serving static Arweave data with signed commitments of correctness, to executing smart contracts that have built-in HTTP APIs. The Hyperbeam node implementation implements AO, an Actor-Oriented process-based environment for orchestrating computation over Arweave messages in order to facilitate the execution of more traditional, consensus-based smart contracts.

The core abstractions of the Hyperbeam node are broadly as follows:

  1. The hb and hb_opts modules manage the node's configuration, environment variables, and debugging tools.

  2. The hb_http and hb_http_server modules manage all HTTP-related functionality. hb_http_server handles turning received HTTP requests into messages and applying those messages with the appropriate devices. hb_http handles making requests and responding with messages. cowboy is used to implement the underlying HTTP server.

  3. hb_ao implements the computation logic of the node: A mechanism for resolving messages to other messages, via the application of logic implemented in devices. hb_ao also manages the loading of Erlang modules for each device into the node's environment. There are many different default devices implemented in the hyperbeam node, using the namespace dev_*. Some of the critical components are:

  4. dev_message: The default handler for all messages that do not specify their own device. The message device is also used to resolve keys that are not implemented by the device specified in a message, unless otherwise signalled.

  5. dev_stack: The device responsible for creating and executing stacks of other devices on messages that request it. There are many uses for this device, one of which is the resolution of AO processes.

  6. dev_p4: The device responsible for managing payments for the services provided by the node.

  7. hb_store, hb_cache and the store implementations forms a layered system for managing the node's access to persistent storage. hb_cache is used as a resolution mechanism for reading and writing messages, while hb_store provides an abstraction over the underlying persistent key-value byte storage mechanisms. Example hb_store mechanisms can be found in hb_store_fs and hb_store_remote_node.

  8. ar_* modules implement functionality related to the base-layer Arweave protocol and are largely unchanged from their counterparts in the Arweave node codebase presently maintained by the Digital History Association (@dha-team/Arweave).

You can find documentation of a similar form to this note in each of the core modules of the hyperbeam node.

Function Index

address/0Get the address of a wallet.
address/1*
benchmark/2Run a function as many times as possible in a given amount of time.
benchmark/3Run multiple instances of a function in parallel for a given amount of time.
build/0Utility function to hot-recompile and load the hyperbeam environment.
debug_wait/4Utility function to wait for a given amount of time, printing a debug message to the console first.
deploy_scripts/0Upload all scripts from the scripts directory to the node to Arweave, printing their IDs.
deploy_scripts/1*
do_start_simple_pay/1*
init/0Initialize system-wide settings for the hyperbeam node.
no_prod/3Utility function to throw an error if the current mode is prod and non-prod ready code is being executed.
now/0Utility function to get the current time in milliseconds.
profile/1Utility function to start a profiling session and run a function, then analyze the results.
read/1Debugging function to read a message from the cache.
read/2
start_mainnet/0Start a mainnet server without payments.
start_mainnet/1
start_simple_pay/0Start a server with a simple-pay@1.0 pre-processor.
start_simple_pay/1
start_simple_pay/2
topup/3Helper for topping up a user's balance on a simple-pay node.
topup/4
wallet/0
wallet/1
wallet/2*

Function Details

address/0

address() -> any()

Get the address of a wallet. Defaults to the address of the wallet specified by the priv_key_location configuration key. It can also take a wallet tuple as an argument.

address/1 *

address(Wallet) -> any()

benchmark/2

benchmark(Fun, TLen) -> any()

Run a function as many times as possible in a given amount of time.

benchmark/3

benchmark(Fun, TLen, Procs) -> any()

Run multiple instances of a function in parallel for a given amount of time.

build/0

build() -> any()

Utility function to hot-recompile and load the hyperbeam environment.

debug_wait/4

debug_wait(T, Mod, Func, Line) -> any()

Utility function to wait for a given amount of time, printing a debug message to the console first.

deploy_scripts/0

deploy_scripts() -> any()

Upload all scripts from the scripts directory to the node to Arweave, printing their IDs.

deploy_scripts/1 *

deploy_scripts(Dir) -> any()

do_start_simple_pay/1 *

do_start_simple_pay(Opts) -> any()

init/0

init() -> any()

Initialize system-wide settings for the hyperbeam node.

no_prod/3

no_prod(X, Mod, Line) -> any()

Utility function to throw an error if the current mode is prod and non-prod ready code is being executed. You can find these in the codebase by looking for ?NO_PROD calls.

now/0

now() -> any()

Utility function to get the current time in milliseconds.

profile/1

profile(Fun) -> any()

Utility function to start a profiling session and run a function, then analyze the results. Obviously -- do not use in production.

read/1

read(ID) -> any()

Debugging function to read a message from the cache. Specify either a scope atom (local or remote) or a store tuple as the second argument.

read/2

read(ID, ScopeAtom) -> any()

start_mainnet/0

start_mainnet() -> any()

Start a mainnet server without payments.

start_mainnet/1

start_mainnet(Port) -> any()

start_simple_pay/0

start_simple_pay() -> any()

Start a server with a simple-pay@1.0 pre-processor.

start_simple_pay/1

start_simple_pay(Addr) -> any()

start_simple_pay/2

start_simple_pay(Addr, Port) -> any()

topup/3

topup(Node, Amount, Recipient) -> any()

Helper for topping up a user's balance on a simple-pay node.

topup/4

topup(Node, Amount, Recipient, Wallet) -> any()

wallet/0

wallet() -> any()

wallet/1

wallet(Location) -> any()

wallet/2 *

wallet(Location, Opts) -> any()