Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.formatOnSave": true,
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
"rust-analyzer.checkOnSave.command": "clippy"
}
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
resolver = "2"

members = [
"polkadot-metadata",
"kusama-metadata",
"rococo-metadata",
"westend-metadata",
"ideal-network-local-metadata",
"ideal-metadata",
"indexer",
]
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ Event indexer for the Ideal Network.

IDN Indexer uses the [Hybrid Indexer](https://github.com/hybrid-explorer/hybrid-indexer) Rust library. It can be accessed using [Hybrid Dapp](https://github.com/hybrid-explorer/hybrid-dapp).

## Configuration

The indexer requires two key configuration values that can be set via environment variables:

- `IDN_GENESIS_HASH`: The genesis hash of your Ideal Network chain (hex format without 0x prefix)
- `IDN_WS_URL`: WebSocket URL of your Ideal Network node

Example configuration:
```sh
export IDN_GENESIS_HASH="af97825bf72091072a08b9dbff88d6664e2061bcb4e28a90f17bd85572d8f8ae"
export IDN_WS_URL="ws://127.0.0.1:1234"
```

If not set, the indexer will use default values suitable for local development.

## Building

Ideal Network Indexer can be built using `cargo build`, however it is necessary to use the nightly `rustc`.
Expand All @@ -25,11 +40,14 @@ Compiling `metadata` can take a very long time.
Usage: ideal-indexer [OPTIONS]

Options:
-c, --chain <CHAIN> Chain to index [default: ideal] [possible values: ideal,polkadot, kusama, rococo, westend]
-c, --chain <CHAIN> Chain to index [default: ideal]
-d, --db-path <DB_PATH> Database path
-u, --url <URL> URL of Substrate node to connect to
-b, --block-number <BLOCK_NUMBER> Block number to start indexing from
--db-mode <DB_MODE> Database mode [default: lowspace] [possible values: lowspace, highthroughput]
--db-cache-capacity <SIZE> Maximum size in bytes for the system page cache [default: 1024.00 MiB]
--queue-depth <QUEUE_DEPTH> Maximum number of concurrent requests to the chain [default: 64]
-i, --index-variant Index event variants
-p, --port <PORT> Port to open for WebSocket queries [default: 8172]
-v, --verbose... More output per occurrence
-q, --quiet... Less output per occurrence
Expand All @@ -45,24 +63,10 @@ First build the docker image:
docker build .
```

Run the docker image for each chain in a separate tab (replace `[image_hash]` with the hash of the docker image displayed at the end of the build):

```sh
docker run --rm -p 8172:8172 [image_hash] -c ideal -b 16730000 -p 8172
```

```sh
docker run --rm -p 8172:8172 [image_hash] -c polkadot -b 16730000 -p 8172
```
Run the docker image:

```sh
docker run --rm -p 8172:8172 [image_hash] -c kusama -b 16730000 -p 8172
```

```sh
docker run --rm -p 8174:8174 [image_hash] -c rococo -b 6550000 -p 8174
```

```sh
docker run --rm -p 8175:8175 [image_hash] -c westend -b 16940000 -p 8175
```
docker run --rm -p 8172:8172 \
-e IDN_GENESIS_HASH="your_genesis_hash_here" \
-e IDN_WS_URL="ws://your.node.url:port" \
[image_hash] -p 8172
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ideal-network-local-metadata"
name = "ideal-metadata"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[subxt::subxt(runtime_metadata_path = "ideal.scale")]
pub mod ideal_network_local_metadata {}
pub mod ideal_metadata {}
32 changes: 16 additions & 16 deletions indexer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
name = "acuity-index-polkadot"
version = "0.2.2"
name = "acuity-index-ideal"
version = "0.1.0"
edition = "2021"

[dependencies]
polkadot-metadata = { path = "../polkadot-metadata" }
kusama-metadata = { path = "../kusama-metadata" }
rococo-metadata = { path = "../rococo-metadata" }
westend-metadata = { path = "../westend-metadata" }
ideal-network-local-metadata = { path = "../ideal-network-local-metadata" }
tokio = { version = "1.28.2", features = ["macros", "rt", "rt-multi-thread"] }
subxt = "0.35.3"
clap = { version = "4.3.19", features = ["derive"] }
hex-literal = "0.4.1"
clap-verbosity-flag = "2.0.1"
sled = { version = "0.34.7", default-features = false }
ideal-metadata = { path = "../ideal-metadata" }
acuity-index-substrate = { git = "https://github.com/ideal-lab5/idn-acuity-index-substrate", version = "=0.6.2" }
byte-unit = "4.0.19"
serde = { version = "1.0.162", features = ["derive"] }
zerocopy = "0.7.8"
clap = { version = "4.5.1", features = ["derive"] }
clap-verbosity-flag = "2.2.0"
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.68"
sled = "0.34.7"
subxt = "0.35.3"
tokio = { version = "1.35.1", features = ["full"] }
tracing = "0.1.40"
tracing-log = "0.2.0"
acuity-index-substrate = { git = "https://github.com/ideal-lab5/idn-acuity-index-substrate", version = "=0.6.2" }
zerocopy = "0.7.32"
hex = "0.4.3"
hex-literal = "0.4.1"
lazy_static = "1.4.0"
16 changes: 16 additions & 0 deletions indexer/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use lazy_static::lazy_static;
use std::env;

lazy_static! {
pub static ref GENESIS_HASH: [u8; 32] = {
let hash = env::var("IDN_GENESIS_HASH").unwrap_or_else(|_| {
"af97825bf72091072a08b9dbff88d6664e2061bcb4e28a90f17bd85572d8f8ae".to_string()
});
let mut bytes = [0u8; 32];
hex::decode_to_slice(hash, &mut bytes)
.expect("Invalid genesis hash format in IDN_GENESIS_HASH");
bytes
};
pub static ref DEFAULT_URL: String =
env::var("IDN_WS_URL").unwrap_or_else(|_| "ws://127.0.0.1:1234".to_string());
}
13 changes: 7 additions & 6 deletions indexer/src/ideal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ideal_network_local_metadata::ideal_network_local_metadata::{
use ideal_metadata::ideal_metadata::{
runtime_types::{
frame_system::pallet::Event as SystemEvent,
pallet_balances::pallet::Event as BalancesEvent,
Expand All @@ -7,9 +7,11 @@ use ideal_network_local_metadata::ideal_network_local_metadata::{
Event,
};

use crate::*;
use crate::{
config::{DEFAULT_URL, GENESIS_HASH},
*,
};
use acuity_index_substrate::*;
use hex_literal::hex;

pub struct IdealIndexer;

Expand All @@ -22,16 +24,15 @@ impl acuity_index_substrate::shared::RuntimeIndexer for IdealIndexer {
}

fn get_genesis_hash() -> <Self::RuntimeConfig as subxt::Config>::Hash {
// Replace with your chain's genesis hash
hex!["af97825bf72091072a08b9dbff88d6664e2061bcb4e28a90f17bd85572d8f8ae"].into() // Temporary placeholder
(*GENESIS_HASH).into()
}

fn get_versions() -> &'static [u32] {
&[0]
}

fn get_default_url() -> &'static str {
"ws://127.0.0.1:1234" // Replace with your actual endpoint
&DEFAULT_URL
}

fn process_event(
Expand Down
188 changes: 0 additions & 188 deletions indexer/src/kusama.rs

This file was deleted.

Loading
Loading