Skip to content

Commit 834f255

Browse files
committed
Backport enhanced analytics support and comprehensive documentation from v3.0
1 parent 6b38fbe commit 834f255

File tree

3 files changed

+334
-4
lines changed

3 files changed

+334
-4
lines changed

README.md

Lines changed: 247 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22

33
Kafka publisher for use with Solana's [plugin framework](https://docs.solana.com/developing/plugins/geyser-plugins).
44

5+
## What This Plugin Does
6+
7+
Streams **three types** of Solana data to Kafka:
8+
- **Account Updates**: Balance changes, data modifications, owner changes
9+
- **Transactions**: Complete transaction details, instructions, fees, success/failure
10+
- **Slot Status**: Network progress, confirmation status, health metrics
11+
12+
## Quick Start
13+
14+
**Want to see data flowing immediately?** Use this minimal config:
15+
16+
```json
17+
{
18+
"libpath": "target/release/libsolana_accountsdb_plugin_kafka.so",
19+
"kafka": {
20+
"bootstrap.servers": "localhost:9092"
21+
},
22+
"filters": [{
23+
"update_account_topic": "solana.testnet.account_updates",
24+
"slot_status_topic": "solana.testnet.slot_status",
25+
"transaction_topic": "solana.testnet.transactions",
26+
"publish_all_accounts": true
27+
}]
28+
}
29+
```
30+
31+
This will publish **all** account updates, transactions, and slot status to Kafka. Perfect for testing and development.
32+
533
## Installation
634

735
### Binary releases
@@ -40,6 +68,10 @@ Config is specified via the plugin's JSON config file.
4068

4169
### Example Config
4270

71+
**⚠️ WARNING: This example config will NOT publish most data by default!**
72+
73+
The following config is a minimal example that demonstrates the structure, but with `publish_all_accounts: false` and no `program_filters`, you'll only see slot status updates. For testing, consider using the scenarios below.
74+
4375
```json
4476
{
4577
"libpath": "target/release/libsolana_accountsdb_plugin_kafka.so",
@@ -64,12 +96,31 @@ Config is specified via the plugin's JSON config file.
6496
"wrap_messages": false
6597
}]
6698
}
99+
100+
**For Testing/Development (Recommended):**
101+
```json
102+
{
103+
"libpath": "target/release/libsolana_accountsdb_plugin_kafka.so",
104+
"kafka": {
105+
"bootstrap.servers": "localhost:9092"
106+
},
107+
"filters": [{
108+
"update_account_topic": "solana.testnet.account_updates",
109+
"slot_status_topic": "solana.testnet.slot_status",
110+
"transaction_topic": "solana.testnet.transactions",
111+
"publish_all_accounts": true
112+
}]
113+
}
114+
```
67115
```
68116
69117
### Reference
70118
71119
- `libpath`: Path to Kafka plugin
72-
- `kafka`: [`librdkafka` config options](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md).
120+
- `kafka`: [`librdkafka` config options](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). Common options include:
121+
- `statistics.interval.ms`: Enables Prometheus metrics collection (set to 1000ms or higher)
122+
- `queue.buffering.max.messages`: Controls producer buffer size
123+
- `queue.buffering.max.kbytes`: Controls producer buffer size in KB
73124
- `shutdown_timeout_ms`: Time the plugin is given to flush out all messages to Kafka upon exit request.
74125
- `prometheus`: Optional port to provide metrics in Prometheus format.
75126
- `filters`: Vec of filters with next fields:
@@ -94,9 +145,57 @@ The message types are keyed as follows:
94145
95146
### Filtering
96147
97-
If `program_ignores` are specified, then these addresses will be filtered out of the account updates
98-
and transaction notifications. More specifically, account update messages for these accounts will not be emitted,
99-
and transaction notifications for any transaction involving these accounts will not be emitted.
148+
**⚠️ IMPORTANT: Understanding how filtering works is crucial for getting data flowing to Kafka!**
149+
150+
The plugin uses a **whitelist approach** for filtering. By default, most events are filtered out unless you explicitly configure what you want to see.
151+
152+
#### How Filtering Works
153+
154+
1. **Account Updates**: Only published if the account's owner program is in `program_filters` OR the account address is in `account_filters`
155+
2. **Transactions**: Only published if they involve accounts from programs in `program_filters` OR specific accounts in `account_filters`
156+
3. **Slot Status**: Always published (not affected by filters)
157+
4. **Program Ignores**: Blacklist of programs/accounts to exclude (applied after whitelist filtering)
158+
159+
#### Common Filtering Scenarios
160+
161+
**Scenario 1: See Everything (Recommended for testing)**
162+
```json
163+
{
164+
"publish_all_accounts": true,
165+
"program_filters": [],
166+
"account_filters": []
167+
}
168+
```
169+
170+
**Scenario 2: See Specific Programs Only**
171+
```json
172+
{
173+
"publish_all_accounts": false,
174+
"program_filters": [
175+
"11111111111111111111111111111111", // System Program
176+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" // Token Program
177+
]
178+
}
179+
```
180+
181+
**Scenario 3: See Specific Accounts Only**
182+
```json
183+
{
184+
"publish_all_accounts": false,
185+
"account_filters": [
186+
"YourAccountAddressHere111111111111111111111111"
187+
]
188+
}
189+
```
190+
191+
#### Troubleshooting: No Data in Kafka?
192+
193+
If you're not seeing messages in Kafka despite successful slot processing:
194+
195+
1. **Check your filters**: Make sure you have either `publish_all_accounts: true` or specific `program_filters`/`account_filters`
196+
2. **Verify topics**: Ensure your topic names are correct and Kafka is running
197+
3. **Check program ignores**: Make sure you're not accidentally filtering out everything with overly restrictive `program_ignores`
198+
4. **Test with minimal config**: Start with `publish_all_accounts: true` to verify the plugin is working
100199

101200
### Message Wrapping
102201

@@ -109,6 +208,92 @@ Note that if `wrap_messages` is true, in order to avoid key collision, the messa
109208
which is dependent on the type of the message being wrapped. Account update message keys are prefixed with
110209
65 (A), slot status keys with 83 (S), and transaction keys with 84 (T).
111210

211+
## Enhanced Analytics Support
212+
213+
The plugin now provides significantly richer analytics data for blockchain monitoring and analysis, enhancing all supported Solana transaction formats.
214+
215+
### Transaction Types
216+
217+
The plugin supports multiple Solana transaction formats:
218+
219+
- **Legacy Transactions**: Traditional Solana message format
220+
- **V0 Transactions**: Versioned transactions with address lookup tables (LUTs)
221+
222+
All transaction types are enhanced with comprehensive analytics metadata.
223+
224+
### Enhanced Analytics Features
225+
226+
All transactions provide additional analytics data that can be used for:
227+
228+
#### Performance Monitoring
229+
- **Compute Units**: Actual compute units consumed by transactions
230+
- **Pricing Information**: Compute unit pricing from ComputeBudget instructions
231+
- **Cost Analysis**: Transaction fees and compute costs
232+
233+
#### Error Analysis & Debugging
234+
- **Error Detection**: Reliable error status from transaction metadata
235+
- **Success Tracking**: Transaction success/failure status
236+
- **Error Details**: Structured error information without log parsing
237+
238+
#### Address Intelligence
239+
- **Address Lookup Tables**: Support for V0 LUT transactions
240+
- **Loaded Address Details**: Index and writable status for loaded addresses
241+
- **Account Metadata**: Enhanced account information and versioning
242+
243+
#### Slot & Network Analytics
244+
- **Confirmation Status**: Smart confirmation counting based on slot status
245+
- **Status Descriptions**: Human-readable slot status descriptions
246+
- **Progress Tracking**: Slot progression monitoring
247+
248+
### Message Schema Enhancements
249+
250+
The protobuf schema has been enhanced with analytics fields:
251+
252+
#### UpdateAccountEvent
253+
- `data_version`: Account data version for change tracking
254+
- `is_startup`: Whether this is a startup account update
255+
- `account_age`: Approximate account age in slots
256+
257+
#### SlotStatusEvent
258+
- `is_confirmed`: Whether slot is confirmed by supermajority
259+
- `confirmation_count`: Confirmation level (0-2 based on status)
260+
- `status_description`: Human-readable status description
261+
262+
#### TransactionEvent
263+
- `compute_units_consumed`: Actual compute units used
264+
- `compute_units_price`: Compute unit pricing in micro-lamports
265+
- `total_cost`: Total transaction cost (fee + compute)
266+
- `instruction_count`: Number of instructions in transaction
267+
- `account_count`: Number of accounts involved
268+
- `execution_time_ns`: Execution time in nanoseconds
269+
- `is_successful`: Transaction success status
270+
- `execution_logs`: Detailed execution logs
271+
- `error_details`: Detailed error information
272+
- `confirmation_count`: Number of confirmations
273+
274+
#### LoadedAddresses
275+
- `writable_info`: Detailed writable address information
276+
- `readonly_info`: Detailed readonly address information
277+
278+
### Configuration for Analytics Features
279+
280+
Analytics features are enabled by default and require no additional configuration. The plugin automatically:
281+
282+
- Detects transaction format (Legacy or V0)
283+
- Extracts available metadata fields
284+
- Provides enhanced analytics where data is available
285+
- Maintains backwards compatibility with existing consumers
286+
287+
### Use Cases
288+
289+
Analytics enhancements enable new use cases:
290+
291+
- **Performance Monitoring**: Track compute unit usage and costs
292+
- **Error Analysis**: Monitor transaction failures and success rates
293+
- **Network Analytics**: Analyze slot confirmation patterns
294+
- **Address Intelligence**: Monitor address lookup table usage
295+
- **Cost Optimization**: Analyze transaction pricing and efficiency
296+
112297
## Buffering
113298

114299
The Kafka producer acts strictly non-blocking to allow the Solana validator to sync without much induced lag.
@@ -122,3 +307,61 @@ The buffer size can be controlled using `librdkafka` config options, including:
122307

123308
- `queue.buffering.max.messages`: Maximum number of messages allowed on the producer queue.
124309
- `queue.buffering.max.kbytes`: Maximum total message size sum allowed on the producer queue.
310+
311+
## Troubleshooting
312+
313+
### Common Issues
314+
315+
#### 1. No Data in Kafka Topics
316+
317+
**Symptoms**: Solana validator shows slot processing but no messages appear in Kafka topics.
318+
319+
**Causes & Solutions**:
320+
- **Filtering too restrictive**: Set `publish_all_accounts: true` or add specific `program_filters`
321+
- **Wrong topic names**: Verify your topic names match exactly
322+
- **Kafka connection issues**: Check if Kafka is running and accessible
323+
- **Plugin not loaded**: Verify the plugin path in `libpath` is correct
324+
325+
**Quick Test**: Use the Quick Start config above to verify the plugin works.
326+
327+
#### 2. Only Slot Status Messages Appear
328+
329+
**Cause**: This is expected behavior with the default example config! Slot status is always published, but account updates and transactions require explicit filter configuration.
330+
331+
**Solution**: Add `publish_all_accounts: true` or configure `program_filters`.
332+
333+
#### 3. Plugin Fails to Load
334+
335+
**Common Causes**:
336+
- **Version mismatch**: Ensure Solana and plugin are built with identical Rust/Solana versions
337+
- **Library path**: Check `libpath` points to the correct `.so` or `.dylib` file
338+
- **Permissions**: Ensure the plugin file is readable by the Solana process
339+
340+
#### 4. High Memory Usage
341+
342+
**Cause**: Large Kafka producer buffers can consume significant memory.
343+
344+
**Solution**: Adjust buffer settings:
345+
```json
346+
{
347+
"kafka": {
348+
"queue.buffering.max.messages": "10000",
349+
"queue.buffering.max.kbytes": "1048576"
350+
}
351+
}
352+
```
353+
354+
### Debugging Tips
355+
356+
1. **Start Simple**: Begin with `publish_all_accounts: true` to verify basic functionality
357+
2. **Check Topics**: Use Kafdrop or `kafka-console-consumer` to verify topics exist
358+
3. **Monitor Metrics**: Enable Prometheus metrics to see message counts and errors
359+
4. **Verify Filters**: Double-check your filter configuration matches your expectations
360+
361+
### Getting Help
362+
363+
If you're still having issues:
364+
1. Check this troubleshooting section
365+
2. Review the filtering documentation above
366+
3. Try the Quick Start configuration
367+
4. Open an issue with your config and error details

proto/event.proto

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ message UpdateAccountEvent {
3535

3636
// First signature of the transaction caused this account modification
3737
optional bytes txn_signature = 9;
38+
39+
// Additional analytics fields
40+
uint32 data_version = 10; // Account data version for change tracking
41+
bool is_startup = 11; // Whether this is a startup account update
42+
uint64 account_age = 12; // Account age in slots since creation
3843
}
3944

4045
message SlotStatusEvent {
@@ -43,6 +48,11 @@ message SlotStatusEvent {
4348
uint64 parent = 2;
4449

4550
SlotStatus status = 3;
51+
52+
// Additional analytics fields
53+
bool is_confirmed = 4; // Whether slot is confirmed
54+
uint32 confirmation_count = 5; // Number of confirmations
55+
string status_description = 6; // Human-readable status description
4656
}
4757

4858
enum SlotStatus {
@@ -174,6 +184,9 @@ message TransactionStatusMeta {
174184
repeated TransactionTokenBalance pre_token_balances = 8;
175185
repeated TransactionTokenBalance post_token_balances = 9;
176186
repeated Reward rewards = 10;
187+
uint32 compute_units_consumed = 11; // Compute units used by transaction
188+
repeated string error_logs = 13; // Detailed error logs for debugging
189+
bool is_successful = 14; // Transaction success status (inverse of is_status_err)
177190
}
178191

179192
// based on solana_accountsdb_plugin_interface::accountsdb_plugin_interface::ReplicaTransactionInfo
@@ -184,6 +197,17 @@ message TransactionEvent {
184197
TransactionStatusMeta transaction_status_meta = 4;
185198
uint64 slot = 5;
186199
uint64 index = 6;
200+
201+
// Enhanced analytics fields
202+
uint32 compute_units_consumed = 7; // Compute units used by transaction
203+
uint64 total_cost = 8; // Total transaction cost (fee + compute)
204+
uint32 instruction_count = 9; // Number of instructions in transaction
205+
uint32 account_count = 10; // Number of accounts involved
206+
uint64 execution_time_ns = 11; // Execution time in nanoseconds
207+
bool is_successful = 12; // Transaction success status
208+
repeated string execution_logs = 13; // Detailed execution logs
209+
repeated string error_details = 14; // Detailed error information
210+
uint32 confirmation_count = 15; // Number of confirmations
187211
}
188212

189213
message MessageWrapper {

0 commit comments

Comments
 (0)