Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vendor/
*.toml
*.json
config.yaml
.env

# Coverage
coverage.*
Expand Down
115 changes: 115 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,118 @@ format:
clean:
rm -f tools-stamp ./build/**
.PHONY: clean

###############################################################################
### Config ###
###############################################################################

update-config:
@if [ -z "$(CONFIG)" ]; then \
echo "Error: CONFIG variable is not set."; \
echo "Please specify a config file using CONFIG=<path> or use one of:"; \
echo " make start-testnet (uses configs/testnet-config.yaml)"; \
echo " make start-mainnet (uses configs/mainnet-config.yaml)"; \
echo " make start CONFIG=<path> (uses your custom config)"; \
exit 1; \
fi
@if [ ! -f "$(CONFIG)" ]; then \
echo "Error: Config file '$(CONFIG)' does not exist."; \
exit 1; \
fi
@echo "Copying $(CONFIG) to ~/.callisto/config.yaml..."
@mkdir -p ~/.callisto
@cp $(CONFIG) ~/.callisto/config.yaml
@echo "Config updated successfully"
.PHONY: update-config

init-config:
@echo "Initializing callisto config..."
@./build/callisto init
.PHONY: init-config

###############################################################################
### Database ###
###############################################################################

DB_EXEC := docker compose exec -T database psql -U user -d database

db-schema-drop:
@echo "Dropping all tables..."
@$(DB_EXEC) -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
@echo "All tables dropped"
.PHONY: db-schema-drop

db-schema-apply:
@echo "Applying schema files..."
@for f in $(sort $(wildcard database/schema/*.sql)); do \
echo " Applying $$f..."; \
$(DB_EXEC) < $$f; \
done
@echo "Schema applied successfully"
.PHONY: db-schema-apply

db-schema-reset: db-schema-drop db-schema-apply
@echo "Schema reset complete"
.PHONY: db-schema-reset

db-shell:
@docker compose exec database psql -U user -d database
.PHONY: db-shell

db-tables:
@$(DB_EXEC) -c "\dt"
.PHONY: db-tables

db-size:
@$(DB_EXEC) -c "SELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname || '.' || tablename)) AS size FROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname || '.' || tablename) DESC;"
.PHONY: db-size

###############################################################################
### Local development ###
###############################################################################

setup-env:
@ARCH=$$(uname -m); \
if [ "$$ARCH" = "arm64" ] || [ "$$ARCH" = "aarch64" ]; then \
echo "HASURA_IMAGE_SUFFIX=.ubuntu.arm64" > .env; \
echo "Detected ARM architecture"; \
else \
echo "HASURA_IMAGE_SUFFIX=" > .env; \
echo "Detected x86 architecture"; \
fi
.PHONY: setup-env

start: setup-env update-config build
@echo "Starting database services..."
@docker compose up -d
@echo "Waiting for database to be ready..."
@sleep 3
@echo "Starting callisto..."
@./build/callisto start
.PHONY: start
Comment on lines +177 to +184
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The start/start-clean targets always invoke update-config, but update-config will fail with a cryptic cp error when CONFIG is not set (e.g., make start). Consider adding a guard that errors with a clear message when CONFIG is empty, or set a sensible default.

Copilot uses AI. Check for mistakes.

start-clean: setup-env update-config build
@echo "Starting database services..."
@docker compose up -d
@echo "Waiting for database to be ready..."
@sleep 3
@$(MAKE) db-schema-reset
@echo "Starting callisto..."
@./build/callisto start
.PHONY: start-clean

start-testnet: CONFIG=configs/testnet-config.yaml
start-testnet: start
.PHONY: start-testnet

start-testnet-clean: CONFIG=configs/testnet-config.yaml
start-testnet-clean: start-clean
.PHONY: start-testnet-clean

start-mainnet: CONFIG=configs/mainnet-config.yaml
start-mainnet: start
.PHONY: start-mainnet

start-mainnet-clean: CONFIG=configs/mainnet-config.yaml
start-mainnet-clean: start-clean
.PHONY: start-mainnet-clean
238 changes: 216 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,227 @@
# Callisto
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/forbole/bdjuno/Tests)](https://github.com/forbole/bdjuno/actions?query=workflow%3ATests)
[![Go Report Card](https://goreportcard.com/badge/github.com/forbole/bdjuno)](https://goreportcard.com/report/github.com/forbole/bdjuno)
![Codecov branch](https://img.shields.io/codecov/c/github/forbole/bdjuno/cosmos/v0.40.x)
# XRPL EVM Callisto - Blockchain Indexer

Callisto (formerly BDJuno) is the [Juno](https://github.com/forbole/juno) implementation
for [Big Dipper](https://github.com/forbole/big-dipper).
Callisto is a blockchain indexer (formerly BDJuno) built on the Juno framework designed to index and parse Cosmos blockchain data. It stores blockchain data in PostgreSQL and provides GraphQL APIs through Hasura.

It extends the custom Juno behavior by adding different handlers and custom operations to make it easier for Big Dipper
showing the data inside the UI.
## Requirements

All the chains' data that are queried from the RPC and gRPC endpoints are stored inside
a [PostgreSQL](https://www.postgresql.org/) database on top of which [GraphQL](https://graphql.org/) APIs can then be
created using [Hasura](https://hasura.io/).
- Go 1.23.8
- PostgreSQL 13+
- Docker & Docker Compose
- Hasura 2.6.1+ (included in docker-compose)

## Usage
To know how to setup and run Callisto, please refer to
the [docs website](https://docs.bigdipper.live/cosmos-based/parser/overview/).
## Quick Start

## Testing
If you want to test the code, you can do so by running
### 1. Install Go

```shell
$ make test-unit
Using GVM (Go Version Manager):

```bash
gvm install go1.23.8
gvm use go1.23.8
```

### 2. Build

```bash
make build
```

The binary will be created at `./build/callisto`. To install globally:

```bash
make install
```

### 3. Configuration

Running `callisto init` generates a default configuration file at `~/.callisto/config.yaml`:

```bash
./build/callisto init
```

Pre-configured network configs are provided in `configs/`:

- `configs/testnet-config.yaml` — XRPL EVM Sidechain testnet
- `configs/mainnet-config.yaml` — XRPL EVM Sidechain mainnet

Copy the desired config before starting:

```bash
mkdir -p ~/.callisto
cp configs/testnet-config.yaml ~/.callisto/config.yaml
```

### 4. Start Indexing

```bash
# 1. Start PostgreSQL and Hasura
docker compose up -d

# 2. Build and start the indexer
make build
./build/callisto start
```

### 5. Start with Make Targets

Alternatively, Make targets are available that automate the above steps (build, copy config, start services, and launch the indexer) in a single command:

```bash
# Testnet
make start-testnet

# Mainnet
make start-mainnet
```

For a clean start (drops and recreates the database schema):

```bash
make start-testnet-clean
make start-mainnet-clean
```

You can also pass a custom config:

```bash
make start CONFIG=path/to/config.yaml
```

### 6. Database Management

Commands to interact with the database without restarting Docker containers:

```bash
# Drop all tables and recreate empty schema
make db-schema-drop

# Apply all schema SQL files (database/schema/*.sql) in order
make db-schema-apply

# Full reset: drop + apply (wipes data, keeps containers running)
make db-schema-reset

# Open an interactive psql session
make db-shell

# List all tables
make db-tables

# Show size of each table
make db-size
```

Use `make db-schema-reset` when you need a fresh database without tearing down the Docker stack. The `start-*-clean` targets use this internally.

## Services

| Service | URL | Description |
|---------|-----|-------------|
| Hasura Console & GraphQL API | http://localhost:8080 | GraphQL management console and endpoint |
| Callisto Actions | http://localhost:3000 | HTTP server for Hasura actions |
| PostgreSQL | localhost:5432 | Database connection |

Default database credentials (from docker-compose.yml):
- User: `user`
- Password: `password`
- Database: `database`

## CLI Commands

| Command | Description |
|---------|-------------|
| `callisto init` | Generate default config at `~/.callisto/config.yaml` |
| `callisto start` | Start continuous block indexing |
| `callisto version` | Display version information |
| `callisto migrate` | Migrate database between versions |

## Database Schema

The database schema is located in `database/schema/` and consists of:

| File | Module | Purpose |
|------|--------|---------|
| 00-cosmos.sql | Core | Blocks, transactions, validators, messages |
| 01-auth.sql | x/auth | Vesting accounts and periods |
| 02-bank.sql | x/bank | Total supply tracking |
| 03-staking.sql | x/staking | Validators, delegations, staking pool |
| 04-consensus.sql | Consensus | Pre-commits and validator state |
| 05-mint.sql | x/mint | Inflation and minting parameters (excluded, not used in XRPL EVM Sidechain) |
| 06-distribution.sql | x/distribution | Community pool and distribution |
| 07-pricefeed.sql | x/pricefeed | Token prices and market data |
| 08-gov.sql | x/gov | Proposals, votes, deposits |
| 09-modules.sql | Modules | Module tracking |
| 10-slashing.sql | x/slashing | Slashing parameters and signing info |
| 11-feegrant.sql | x/feegrant | Fee grant allowances |
| 12-upgrade.sql | x/upgrade | Software upgrade plans |

## Development

### Run Tests

```bash
# Start test database
make start-docker-test

# Run unit tests
make test-unit

# Stop test database
make stop-docker-test
```

**Note**: Requires [Docker](https://docker.com).
### Linting and Formatting

```bash
# Run linter
make lint

# Auto-fix lint issues
make lint-fix

# Format code
make format
```

This will:
1. Create a Docker container running a PostgreSQL database.
2. Run all the tests using that database as support.
### Clean Build

```bash
make clean
```

## Troubleshooting

### Block height not available

```
ERR re-enqueueing failed block err="failed to get block from node: error in json rpc client, with http response metadata: (Status: 200 OK, Protocol HTTP/1.1). RPC error -32603 - Internal error: height 4 is not available, lowest height is 4133001" height=5
```

This error means the node you are connected to has pruned blocks below its lowest available height. To fix it, either:

1. **Connect to an archive/full node** that has all block heights available by updating the RPC/gRPC endpoints in your config.
2. **Update `start_height`** in your config (`parsing.start_height`) to the lowest height available on the node (e.g. `4133001` in the example above).

### Hasura image platform mismatch

```
The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
```

This happens when the Hasura image in `docker-compose.yml` is set to the ARM variant. Update the image from:

```yaml
image: hasura/graphql-engine:v2.6.1.cli-migrations-v3.ubuntu.arm64
```

to:

```yaml
image: hasura/graphql-engine:v2.6.1.cli-migrations-v3
```

## References

- [Official Documentation](https://docs.bigdipper.live/cosmos-based/parser/overview/)
- [GitHub Repository](https://github.com/forbole/callisto)
3 changes: 3 additions & 0 deletions cmd/callisto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/forbole/callisto/v4/utils"

"github.com/forbole/callisto/v4/types/config"
evmconfig "github.com/forbole/callisto/v4/types/evm_config"

"github.com/forbole/callisto/v4/database"
"github.com/forbole/callisto/v4/modules"
Expand All @@ -21,6 +22,8 @@ func main() {
initCfg := initcmd.NewConfig().
WithConfigCreator(config.Creator)

evmconfig.Cfg = evmconfig.ReadConfigFromFile()

cdc := utils.GetCodec()
parseCfg := parsetypes.NewConfig().
WithDBBuilder(database.Builder(cdc)).
Expand Down
Loading
Loading