Crates.io | aptos-sf-stream |
lib.rs | aptos-sf-stream |
version | 0.2.7 |
source | src |
created_at | 2022-08-14 08:08:30.677906 |
updated_at | 2022-08-16 07:53:57.681226 |
description | Aptos StreamingFast Stream |
homepage | https://aptoslabs.com |
repository | https://github.com/aptos-labs/aptos-core |
max_upload_size | |
id | 645281 |
size | 126,828 |
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.
All internal errors should be converted into anyhow::Error
first.
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
.
Run integration/smoke tests in testsuite/smoke-test
cargo test --test "forge" "api::"
The Aptos node generates the following default SF-Stream configuration:
sf_stream:
enabled: false
When sf_stream.enabled
is set to true
, the SF-Stream will be enabled, and transactions will be streamed to stdout.
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.
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 aboutcmake
not defined, this is a fallback whenprotoc
is not found.
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.
cargo build
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