0.2.7 Aug 16, 2022
0.2.1 Aug 14, 2022

#7 in #streamer

Used in 11 crates (via aptos-node)


56K SLoC


This module provides a StreamingFast Streamer for pushing protobuf data from the Aptos Blockchain



Models or types are defined in the aptos-api-types package (in the directory /api/types).

These types handle deserialization between internal data types and API response JSON types. These are then used to construct the Protobuf messages.

Error Handling

All internal errors should be converted into anyhow::Error first.

Unit Test

Handler tests should cover all aspects of features and functions.

A TestContext is implemented to create components' stubs that API handlers are connected to. These stubs are more close to real production components, instead of mocks, so that tests can ensure the handlers are working well with other components in the systems. For example, we use real AptosDB implementation in tests for API layers to interact with the database.

Most of the utility functions are provided by the TestContext.

Integration/Smoke Test

Run integration/smoke tests in testsuite/smoke-test

cargo test --test "forge" "api::"

Aptos Node Operation

The Aptos node generates the following default SF-Stream configuration:

  enabled: false

When sf_stream.enabled is set to true, the SF-Stream will be enabled, and transactions will be streamed to stdout.

Installing Protobuf Compiler

Install protoc

protoc is a Protocol Buffer compiler. It is needed to generate code for Rust and other languages, out of the protobuf definitions you will create or get through third-party Substreams packages.

There are multiple ways on how to do it. Here is the official documentation of protocol buffer compiler.

Install protoc-gen-prost

This tool helps you render Rust structures out of protobuf definitions, for use in your Substreams modules. It is called by protoc following their plugin system. Install it with:

  cargo install protoc-gen-prost

If you forget to install protoc, when generating the definitions, you might see error about cmake not defined, this is a fallback when protoc is not found.

Install buf

https://buf.build is a tool used to simplify the generation of typed structures in any language. It invokes protoc and simplifies a good number of things. Substreams packages are compatible with buf Images.

See the installation instructions here.

Build proto

cargo build


Connect to Firehose

To test with firehose, we need to build aptos-node

cd ../aptos-node
cargo install --path .

If necessary, set path to aptos-node

export PATH={path to directory containing aptos-core repo}:$PATH

Then follow instructions in https://github.com/streamingfast/firehose-aptos


~2M SLoC