Indexer Fullnode
This document describes how to run an indexer fullnode on the Aptos network. See Indexing guide that describes the basic indexing concept and the available options for indexing service on the Aptos blockchain.
The below installation steps are verified only on macOS with Apple silicon.
Summary
To run an indexer fullnode, these are the steps in summary:
- Make sure that you have all the required tools and packages described below in this document.
- Follow the guide Fullnode Using Aptos Source or Docker and prepare the setup, but do not run the
cargo run -p aptos-node --release -- -f ./fullnode.yaml
command yet. - Edit the
fullnode.yaml
as described below in this document. - Run the indexer fullnode by executing the command described below in this document.
Required tools and packages
- Install Brew.
- Install Cargo and Rust via Install Rust.
- Install libpq. This is a Postgres C API library. Make sure to perform all export commands after the installation.
- macOS:
brew install libpq
- Linux:
apt install libpq
- macOS:
- Install PostgreSQL:
- macOS:
brew install postgres
- Linux:
apt install postgres
- macOS:
- Install Diesel:
cargo install diesel_cli --no-default-features --features postgres
.
Setup
Start the PostgreSQL server:
- macOS:
brew services start postgresql
- Linux:
pg_ctl -D /opt/homebrew/var/postgres start
- macOS:
Run the following command to create a PostgreSQL user
postgres
(macOS commmand example below):/opt/homebrew/bin/createuser -s postgres
Ensure you are able to do:
psql postgres
.Install the Diesel CLI:
cargo install diesel_cli --no-default-features --features postgres
Clone
aptos-core
repo:git clone https://github.com/aptos-labs/aptos-core.git
cd
intoaptos-core/crates/indexer
directory.Run the command:
diesel migration run --database-url postgresql://localhost/postgres
This will create a database schema with the subdirectory
migrations
located in thisaptos-core/crates/indexer
directory.- If for some reason this database is already being used, try a different database. For example:
DATABASE_URL=postgres://postgres@localhost:5432/indexer_v2 diesel database reset
- If for some reason this database is already being used, try a different database. For example:
Follow the guide Fullnode Using Aptos Source or Docker and prepare the setup, but do not run the
cargo run -p aptos-node --release -- -f ./fullnode.yaml
command yet.Edit the
./fullnode.yaml
and add the following configuration:storage:
enable_indexer: true
# This is to avoid the node being pruned
storage_pruner_config:
ledger_pruner_config:
enable: false
indexer:
enabled: true
postgres_uri: "postgres://postgres@localhost:5432/postgres"
processor: "default_processor"
check_chain_id: true
emit_every: 500Run the indexer fullnode with:
cargo run --bin aptos-node --features "indexer" -- --config </path/to/fullnode.yaml>`