How to Use Substrate Archive: A Guide to Blockchain Indexing

Jun 17, 2023 | Blockchain

Welcome to your comprehensive guide on using the Substrate Archive! This indexing engine allows you to maintain and analyze data from a substrate-backed blockchain effectively. With this guide, you’ll be able to navigate the setup and usage like a pro.

What is Substrate Archive?

The Substrate Archive is designed to index all Blocks, State, and Extrinsic data into PostgreSQL, allowing for efficient management and access to blockchain data. Here, you will learn how to set up the CLI, prerequisite installations, and how to troubleshoot any issues that may arise.

Installation Steps

To begin your journey, follow these steps to install and configure the CLI:

1. Prerequisites

  • Ensure you have about ~60GB of free space.
  • PostgreSQL installed and ready for new data.
  • A Substrate-based Blockchain running with RocksDB as the backend.
  • The blockchain should be running under --pruning=archive.

2. Install The CLI

The CLI is your friendly assistant, allowing you to get started without having to dabble in Rust code:

  • Clone the repository: bash
  • git clone https://github.com/paritytech/substrate-archive.git
  • Set up the database: source .substrate-archive/scripts/up.sh
  • Run the drop command if needed: ./scripts/down.sh
  • Navigate to the repository: cd substrate-archive/bin
  • Start the polkadot node with pruning set to archive: polkadot --chain=polkadot --pruning=archive
  • Launch the substrate-archive node: cargo run --release -- -c test_conf.toml --chain=polkadot

Access help by running: cargo run --release -- --help.

3. Usage

The schema for the PostgreSQL database is detailed in the PDF file at the root of the directory. You can find examples of usage in the examples directory.

Troubleshooting Common Issues

Even the best systems can encounter bumps in the road. Here are some solutions for common issues:

Issue: “Too Many Open Files” Error

This typically arises due to the limitations placed on the number of files that can be opened. To resolve this, you can:

  • Adjust the limit for Docker containers by running: $ docker run --ulimit nofile=90000:90000 image-tag
  • Set the limit for the current shell session: ulimit -a 90000
  • Make changes permanently for a user by editing /etc/security/limits.conf, adding lines to increase hard and soft limits.

Note: A warning will be raised on macOS and Linux if the file descriptor limit is low. Windows users may not encounter this issue.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

With this guide, you’re now equipped to successfully set up and utilize the Substrate Archive for your blockchain projects. Happy indexing!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox