ChainSwarm Analyzers Baseline
Baseline analytics algorithms for blockchain pattern detection and feature engineering.
This package provides the official baseline implementation for the ChainSwarm Analytics Tournament.
Overview
chainswarm-analyzers-baseline extracts core analytical algorithms from analytics-pipeline/packages/analyzers/ and provides:
- Feature Computation - 70+ features per address including volume, graph, temporal, and behavioral metrics
- Pattern Detection - 7 pattern types: cycles, layering paths, smurfing networks, motifs, proximity risk, temporal bursts, and threshold evasion
Installation
pip install chainswarm-analyzers-baseline
From Source
cd analyzers-baseline
pip install -e .
Quick Start
Production Usage (ClickHouse)
from chainswarm_core.db import ClientFactory, get_connection_params
from chainswarm_analyzers_baseline import BaselineAnalyzersPipeline
from chainswarm_analyzers_baseline.adapters import ClickHouseAdapter
# Get connection params from environment (uses CLICKHOUSE_* env vars)
connection_params = get_connection_params(
network="torus",
database_prefix="analytics"
)
# Create client using chainswarm-core
factory = ClientFactory(connection_params)
client = factory.create_client()
# Create adapter with ClickHouse client
adapter = ClickHouseAdapter(client=client, network="torus")
# Run pipeline
pipeline = BaselineAnalyzersPipeline(adapter=adapter)
result = pipeline.run(
start_timestamp_ms=1700000000000,
end_timestamp_ms=1702600000000,
window_days=30,
processing_date="2025-01-15",
network="torus"
)
Tournament Testing (Parquet)
from chainswarm_analyzers_baseline import BaselineAnalyzersPipeline
from chainswarm_analyzers_baseline.adapters import ParquetAdapter
# Create adapter with file paths
adapter = ParquetAdapter(
input_path="./input",
output_path="./output"
)
# Run pipeline
pipeline = BaselineAnalyzersPipeline(adapter=adapter)
result = pipeline.run(
start_timestamp_ms=1700000000000,
end_timestamp_ms=1702600000000,
window_days=30,
processing_date="2025-01-15",
network="torus"
)
CLI Usage
The CLI auto-extracts metadata (network, date, window) from the input path structure:
data/input/{network}/{processing_date}/{window_days}/
# Run full pipeline - metadata auto-extracted from path
run-pipeline --input data/input/torus/2025-01-15/30
# Output auto-constructed as data/output/torus/2025-01-15/30/
# Override extracted values if needed
run-pipeline \
--input data/input/torus/2025-01-15/30 \
--output ./custom-output \
--network bittensor # Override network
# Run full pipeline (ClickHouse mode - uses CLICKHOUSE_* env vars)
run-pipeline \
--clickhouse \
--network torus \
--window-days 30 \
--processing-date 2025-01-15
# Run features only
run-features --input data/input/torus/2025-01-15/30
# Run patterns only
run-patterns --input data/input/torus/2025-01-15/30
Package Structure
chainswarm_analyzers_baseline/
├── protocols/ # Abstract interfaces (Python Protocols)
├── features/ # Feature computation implementations
├── patterns/ # Pattern detection implementations
├── adapters/ # I/O adapters (Parquet, ClickHouse)
├── graph/ # Graph building utilities
├── pipeline/ # Production pipeline
├── config/ # Configuration management
└── scripts/ # Script entry points
Data Directory Structure
For Parquet mode, the path structure encodes metadata:
data/
├── input/{network}/{processing_date}/{window_days}/
│ ├── transfers.parquet # Required for pattern detection
│ ├── money_flows.parquet # Required (pre-aggregated edge data)
│ ├── assets.parquet # Optional
│ ├── asset_prices.parquet # Optional
│ └── address_labels.parquet # Optional
└── output/{network}/{processing_date}/{window_days}/
├── features.parquet
├── patterns_cycle.parquet
├── patterns_layering.parquet
└── ...
Note: Both ParquetAdapter and ClickHouseAdapter support full pattern detection including temporal burst analysis (added in v0.2.2).
Data Schemas
All data schemas match data-pipeline core tables for compatibility.
Input Files (Parquet Mode)
transfers.parquet
Balance transfer data matching core_transfers schema:
| Column | Type | Description |
|---|---|---|
tx_id |
String | Transaction hash (EVM/Substrate/UTXO) |
event_index |
String | Event index within transaction |
edge_index |
String | Edge disambiguator (UTXO) |
block_height |
UInt32 | Block number |
block_timestamp |
UInt64 | Milliseconds since epoch |
from_address |
String | Source address |
to_address |
String | Destination address |
asset_symbol |
String | Asset symbol (TAO, USDT, etc.) |
asset_contract |
String | Contract address or 'native' |
amount |
Decimal128(18) | Native token amount |
amount_usd |
Decimal128(18) | USD value at transaction time |
fee |
Decimal128(18) | Transaction fee |
Output Files
| File | Description |
|---|---|
features.parquet |
70+ computed features per address |
patterns_cycle.parquet |
Cycle patterns |
patterns_layering.parquet |
Layering path patterns |
patterns_network.parquet |
Smurfing network patterns |
patterns_proximity.parquet |
Proximity risk patterns |
patterns_motif.parquet |
Fan-in/fan-out motif patterns |
patterns_burst.parquet |
Temporal burst patterns |
patterns_threshold.parquet |
Threshold evasion patterns |
Pattern Types
Pattern types use lowercase values from chainswarm_core.constants.PatternTypes:
| Pattern Type | Value | Description |
|---|---|---|
| Cycle | cycle |
Circular transaction patterns |
| Layering Path | layering_path |
Long transaction chains |
| Smurfing Network | smurfing_network |
Fragmented value transfers |
| Motif Fan-In | motif_fanin |
Many-to-one patterns |
| Motif Fan-Out | motif_fanout |
One-to-many patterns |
| Proximity Risk | proximity_risk |
Distance to risky addresses |
| Temporal Burst | temporal_burst |
High-frequency activity |
| Threshold Evasion | threshold_evasion |
Structuring below limits |
Requirements
- Python >= 3.13
- chainswarm-core >= 0.1.13 (provides clickhouse-connect, loguru, pydantic)
- networkx >= 3.0
- numpy >= 1.24
- pandas >= 2.0
- pyarrow >= 14.0
- click >= 8.0
License
Apache-2.0
Metadata
Release files for chainswarm-analyzers-baseline 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chainswarm_analyzers_baseline-0.3.1.tar.gz | 8.0 MB | Without provenance | Details for chainswarm_analyzers_baseline-0.3.1.tar.gz |
Built distributions (wheels)
Total release size: 19.5 MB
Release files / chainswarm_analyzers_baseline-0.3.1.tar.gz
| Download URL | chainswarm_analyzers_baseline-0.3.1.tar.gz |
|---|---|
| Size | 8.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64ea95262dcf4d4fe5de657f36ea27b9eb754586340cfd3ee1d5a0a8c5551a14
|
|
BLAKE2b-256 checksum How to use checksums |
8659f19ecd875dda66eb2377de9283d3e78c37872d449f30508ac9f6a6833305
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / chainswarm_analyzers_baseline-0.3.1-cp312-abi3-win_amd64.whl
| Download URL | chainswarm_analyzers_baseline-0.3.1-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1e175f4342426e70265f57aea52a435d9cd781ccb0a8bbf085e18801e47f02be
|
|
BLAKE2b-256 checksum How to use checksums |
1eb1fc7479e01490911461732af7b57c2a128d7437d1238b7057ef33fd06bb2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / chainswarm_analyzers_baseline-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | chainswarm_analyzers_baseline-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
6d71bee06b13893c60810581bec48429a91875dc556186e96845503f9166f1dd
|
|
BLAKE2b-256 checksum How to use checksums |
7a7a0e4e8c982393689040b0cbd4a160e60f3fc53797038a4114a4a0af2a3a7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / chainswarm_analyzers_baseline-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | chainswarm_analyzers_baseline-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ce1342ecf079590af2445b11f54883d8876e06653102e6ceb4a8e27e7aa85215
|
|
BLAKE2b-256 checksum How to use checksums |
9650db1b4deb52f0caba066781656e7a8182b5bdcf66ed9850018f80bfb9bbfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / chainswarm_analyzers_baseline-0.3.1-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | chainswarm_analyzers_baseline-0.3.1-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3296495fcfbf1170c26570be22ea8df52e61e0ec6639c36e775c546783f22d7a
|
|
BLAKE2b-256 checksum How to use checksums |
8a569f4cd09c6fe5e845dab31ddc8adcbaf03190ce3dc97d90431fd5207d1ad2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / chainswarm_analyzers_baseline-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | chainswarm_analyzers_baseline-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
81605d81b467d5afa8be41fe10bad6156fa89ad2210c336e8ccfb403679f1d56
|
|
BLAKE2b-256 checksum How to use checksums |
1126e528b3eb4a158ea59cb5e5bdd7ad0432b7fb5275002eee24a286b6a034c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Security for chainswarm-analyzers-baseline 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.