solana geyser plugin with redis, grpc, and postgres for real-time blockchain data streaming, analytics, and client updates

- rust (latest stable version)
- docker and docker compose
- diesel cli for database migrations
cargo build --releasebuilds:
- linux:
./target/release/libgeyser.so - macos:
./target/release/libgeyser.dylib
important: solana's plugin interface requires the build environment of the solana validator and this plugin to be identical.
this includes the solana version and rust compiler version. loading a plugin targeting wrong versions will result in memory corruption and crashes.
configuration is specified via json config file.
{
"libpath": "target/release/libgeyser.dylib",
"redis": {
"url": "redis://localhost:6379",
"max_connections": 10,
"connection_timeout_ms": 5000,
"database": 0
},
"shutdown_timeout_ms": 30000,
"filters": [{
"update_account_stream": "heimdall:accounts",
"slot_status_stream": "heimdall:slots",
"transaction_stream": "heimdall:transactions",
"program_ignores": [
"Sysvar1111111111111111111111111111111111111",
"Vote111111111111111111111111111111111111111"
],
"program_filters": [],
"account_filters": [],
"publish_all_accounts": false,
"include_vote_transactions": true,
"include_failed_transactions": true,
"wrap_messages": false
}],
"prometheus": "127.0.0.1:9090"
}libpath: path to geyser pluginredis: redis connection configurationurl: redis connection urlmax_connections: maximum number of connections in poolconnection_timeout_ms: connection timeout in millisecondsdatabase: redis database number
shutdown_timeout_ms: 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:update_account_stream: redis stream name for account updatesslot_status_stream: redis stream name for slot status updatestransaction_stream: redis stream name for transaction updatesprogram_ignores: account addresses to ignoreprogram_filters: solana program ids to includeaccount_filters: solana accounts to includepublish_all_accounts: publish all accounts on startupinclude_vote_transactions: include vote transactionsinclude_failed_transactions: include failed transactionswrap_messages: wrap all messages in unified wrapper object
- start docker services
docker compose up -dthis 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 DATABASE_URL="postgresql://heimdall:heimdall@localhost:5432/heimdall_db"- run database migrations
pnpm run migratestart 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:clientavailable 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
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.
licensed under the apache license, version 2.0