solana geyser plugin with redis and grpc stream
heimdall
solana geyser plugin with redis, grpc, and postgres for real-time blockchain data streaming, analytics, and client updates
installation
building from source
prerequisites
- rust (latest stable version)
- docker and docker compose
- diesel cli for database migrations
build
cargo build --release
builds:
- linux:
./target/release/libgeyser.so - macos:
./target/release/libgeyser.dylib
this includes the solana version and rust compiler version. loading a plugin targeting wrong versions will result in memory corruption and crashes.
configuration
configuration is specified via json config file.
example config
{
"libpath": "target/release/libgeyser.dylib",
"redis": {
"url": "redis://localhost:6379",
"max_connections": 10,
"connectiontimeoutms": 5000,
"database": 0
},
"shutdowntimeoutms": 30000,
"filters": [{
"updateaccountstream": "heimdall:accounts",
"slotstatusstream": "heimdall:slots",
"transaction_stream": "heimdall:transactions",
"program_ignores": [
"Sysvar1111111111111111111111111111111111111",
"Vote111111111111111111111111111111111111111"
],
"program_filters": [],
"account_filters": [],
"publishallaccounts": false,
"includevotetransactions": true,
"includefailedtransactions": true,
"wrap_messages": false
}],
"prometheus": "127.0.0.1:9090"
}
reference
libpath: path to geyser pluginredis: redis connection configuration
url: redis connection url
- max_connections: maximum number of connections in pool
- connectiontimeoutms: connection timeout in milliseconds
- database: redis database number
shutdowntimeoutms: time the plugin is given to flush out all messages upon exitprometheus: optional address to provide metrics in prometheus formatfilters: array of filters with the following fields:
updateaccountstream: redis stream name for account updates
- slotstatusstream: redis stream name for slot status updates
- transaction_stream: redis stream name for transaction updates
- program_ignores: account addresses to ignore
- program_filters: solana program ids to include
- account_filters: solana accounts to include
- publishallaccounts: publish all accounts on startup
- includevotetransactions: include vote transactions
- includefailedtransactions: include failed transactions
- wrap_messages: wrap all messages in unified wrapper object
setup
infrastructure setup
- start docker services
docker compose up -d
this starts postgresql and redis containers with the following default configuration:
- postgresql:
postgresql://heimdall:heimdall@localhost:5432/heimdall_db - redis:
redis://localhost:6379
- install diesel cli
cargo install diesel_cli --no-default-features --features postgres
- configure environment variables
export DATABASEURL="postgresql://heimdall:heimdall@localhost:5432/heimdalldb"
- run database migrations
pnpm run migrate
running services
start services in separate terminals:
- start api server
pnpm run start:api
- start stream server
pnpm run start:stream
- start database processor
pnpm run start:db-processor
- test stream client
pnpm run start:client
development
available scripts:
pnpm run build- build in release modepnpm run build:dev- build in debug modepnpm run build:geyser- build geyser plugin specificallypnpm run test- run testspnpm run check- check code without buildingpnpm run clean- clean build artifactspnpm run migrate- run database migrationspnpm run migrate:reset- reset and rerun migrations
buffering
the redis publisher acts strictly non-blocking to allow the solana validator to sync without induced lag. this means incoming events from the solana validator get buffered and published asynchronously.
when the publishing buffer is exhausted, additional events will get dropped. this can happen when redis is slow or the connection fails. therefore it is crucial to choose sufficiently large buffer sizes.
buffer size can be controlled using redis configuration options and connection pool settings.
license
licensed under the apache license, version 2.0