Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
12 changes: 9 additions & 3 deletions .github/workflows/build-container-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ on:
workflow_dispatch:
inputs:
service_config:
description: 'Service configuration'
description: "Service configuration"
required: true
default: 'api'
default: "api"
type: choice
options:
- api
- cranker
- writer-service
- steward-writer-service
- bam-writer-service

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -57,6 +58,11 @@ jobs:
echo "service=steward-writer-service" >> $GITHUB_OUTPUT
echo "image_name=${{ github.repository }}/kobe-steward-writer-service" >> $GITHUB_OUTPUT
;;
"bam-writer-service")
echo "target=bam-writer-service" >> $GITHUB_OUTPUT
echo "service=bam-writer-service" >> $GITHUB_OUTPUT
echo "image_name=${{ github.repository }}/kobe-bam-writer-service" >> $GITHUB_OUTPUT
;;
esac

- name: Extract metadata
Expand All @@ -79,4 +85,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ jobs:
with:
command: test
args: --lib

41 changes: 33 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"
members = [
"api",
"bam-writer-service",
"core",
"cranker",
"cranker/cli",
Expand Down Expand Up @@ -39,9 +40,10 @@ http = { version = "0.2.1" }
itertools = "0.5.9"
jito-priority-fee-distribution = { features = ["no-entrypoint"], git = "https://github.com/jito-foundation/jito-programs", branch = "master" }
jito-priority-fee-distribution-sdk = { git = "https://github.com/jito-foundation/jito-programs", branch = "master" }
jito-steward = { features = ["no-entrypoint"], git = "https://github.com/jito-foundation/stakenet", rev = "d724a42b49c0cd32791afbd2a362dd63364a7a9a" }
jito-steward = { package = "jito-steward", git = "https://github.com/jito-foundation/stakenet", rev = "6d35e58013cf7442dce287a1f45013085cb24967", features = ["no-entrypoint"] }
jito-tip-distribution = { features = ["no-entrypoint"], git = "https://github.com/jito-foundation/jito-programs", branch = "master" }
jito-tip-distribution-sdk = { git = "https://github.com/jito-foundation/jito-programs", branch = "master" }
kobe-api = { path = "api", version = "1.0.0" }
kobe-core = { path = "core", version = "1.0.0" }
log = "0.4.18"
mongodb = { version = "2.2.2", features = ["bson-chrono-0_4"] }
Expand Down Expand Up @@ -83,7 +85,7 @@ spl-pod = "0.5.1"
spl-stake-pool = { features = ["no-entrypoint"], version = "2.0.2" }
spl-stake-pool-cli = { path = "cranker/cli", version = "1.0.0" }
spl-token = { version = "4.0", features = ["no-entrypoint"] }
stakenet-sdk = { package = "stakenet-sdk", git = "https://github.com/jito-foundation/stakenet", rev = "d724a42b49c0cd32791afbd2a362dd63364a7a9a" }
stakenet-sdk = { package = "stakenet-sdk", git = "https://github.com/jito-foundation/stakenet", rev = "6d35e58013cf7442dce287a1f45013085cb24967" }
thiserror = "1.0.37"
tokio = { version = "1.36.0", features = ["full"] }
tokio-retry = "0.3.0"
Expand All @@ -92,4 +94,4 @@ tower-http = { version = "0.4.0", features = ["cors", "trace"] }
tracing = { version = "0.1.37" }
tracing-core = "0.1.32"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
validator-history = { package = "validator-history", git = "https://github.com/jito-foundation/stakenet", rev = "d724a42b49c0cd32791afbd2a362dd63364a7a9a", features = ["no-entrypoint"] }
validator-history = { package = "validator-history", git = "https://github.com/jito-foundation/stakenet", rev = "6d35e58013cf7442dce287a1f45013085cb24967", features = ["no-entrypoint"] }
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ ENV APP="kobe-steward-writer-service"
WORKDIR /app
COPY --from=builder /home/root/app/${APP} ./
ENTRYPOINT ./$APP listen

FROM debian:bookworm-slim as bam-writer-service
RUN apt-get update && apt-get install -y libssl3 ca-certificates procps && rm -rf /var/lib/apt/lists/*
ENV APP="kobe-bam-writer-service"
WORKDIR /app
COPY --from=builder /home/root/app/${APP} ./
ENTRYPOINT ./$APP run
93 changes: 66 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,32 @@ Named after both the premium grade of Kobe beef and in honor of basketball legen
## Architecture Overview

```
┌───────────────────────────────────────────────────────┐
│ Solana Network │
│ (Blockchain) │
└───────────────────────────────────────────────────────┘
▲ │ │
│ │ (read on-chain data) │
│ ▼ ▼
(write │ ┌──────────────────┐ ┌──────────────────┐
transactions) │ │ Kobe Writer │ │ Steward Writer │
│ │ Service │ │ Service │
│ │ (Data Collection)│ │ (Steward Events) │
│ └──────────────────┘ └──────────────────┘
│ │ │
│ ▼ (write to db) ▼ (write to db)
┌──────────────────┐ ┌─────────────────────────────────────────────┐
│ Kobe Cranker │ │ MongoDB │
│ (Pool Management)│ │ (Database) │
└──────────────────┘ └─────────────────────────────────────────────┘
│ (read from db + on-chain)
┌─────────────────┐
│ Kobe API │
│ (Data Access) │
└─────────────────┘
┌────────────────────────────────────────────────────────────────────────────────────────┐ ┌─────────────┐
│ Solana Network │ │ BAM API │
│ (Blockchain) │ │ │
└────────────────────────────────────────────────────────────────────────────────────────┘ └─────────────┘
▲ │ │ │ │
│ │ (read on-chain data) │ (read on-chain data) │ │ (read bam data)
│ ▼ ▼ ▼ ▼
(write │ ┌──────────────────┐ ┌──────────────────┐ ┌────────────────────────────────────┐
transactions) │ │ Kobe Writer │ │ Steward Writer │ │ BAM Writer │
│ │ Service │ │ Service │ │ Service │
│ │ (Data Collection)│ │ (Steward Events) │ │ │
│ └──────────────────┘ └──────────────────┘ └────────────────────────────────────┘
│ │ │ │ ▲
│ ▼ (write to db) ▼ (write to db) ▼ (write to db) │
┌──────────────────┐ ┌──────────────────────────────────────────────────────────────────────┐ │
│ Kobe Cranker │ │ MongoDB │ │
│ (Pool Management)│ │ (Database) │ │
└──────────────────┘ └──────────────────────────────────────────────────────────────────────┘ │ (read validators data)
│ │
│ (read from db + on-chain) │
▼ │
┌─────────────────┐ │
│ Kobe API │ │
│ (Data Access) │ ──────────────────────────────────────────────────
│ │
└─────────────────┘
```

## JitoSOL APY Calculation
Expand Down Expand Up @@ -253,7 +254,24 @@ Therefore, users may see different APY values between real-time calculations and
- Risk management actions
- Stake rebalancing operations

**Use Cases:** Steward transparency, audit trails, performance analysis, regulatory compliance
---

### [Kobe BAM Writer Service](./bam-writer-service/README.md)
**Specialized monitoring** service for Block Assembly Marketplace (BAM) delegation calculations, tracking network-wide BAM validator participation and computing available JitoSOL delegation based on JIP-28 specifications.

**Capabilities:**
- Real-time BAM validator stake tracking
- JIP-28 tier-based delegation calculations
- Network stakeweight monitoring
- Epoch-based metrics collection and storage

**Key Features:**
- Automated epoch threshold detection (default: 90% epoch progress)
- Integration with BAM API for validator discovery
- Dynamic delegation allocation based on network participation tiers
- Historical BAM metrics persistence in MongoDB

**Use Cases:** Powers BAM delegation strategy, provides transparency into automated stake allocation decisions, enables historical analysis of BAM adoption trends

## Quick Start

Expand Down Expand Up @@ -308,7 +326,14 @@ RUST_LOG=info cargo r -p kobe-cranker -- \
#### Start Data Collection

```bash
cargo r --bin kobe-writer-service -- live
RUST_LOG=info cargo r --bin kobe-writer-service -- \
--rpc-url "" \
--mongo-connection-uri "mongodb://localhost:27017/kobe" \
--mongo-db-name "validators" \
--solana-cluster "testnet" \
--jito-steward-program-id "Stewardf95sJbmtcZsyagb2dg4Mo8eVQho8gpECvLx8" \
--steward-config-pubkey "5pZmpk3ktweGZW9xFknpEHhQoWeAKTzSGwnCUyVdiye" \
live
```

#### Start Steward Monitoring
Expand All @@ -323,6 +348,20 @@ RUST_LOG=info cargo r -p kobe-steward-writer-service -- \
listen
```

#### Run BAM writer service

```bash
RUST_LOG=info cargo r -p kobe-bam-writer-service -- \
--mongo-connection-uri "mongodb://localhost:27017/kobe" \
--mongo-db-name "validators" \
--rpc-url "https://api.mainnet-beta.solana.com/" \
--bam-api-base-url "" \
--kobe-api-base-url "https://kobe.mainnet.jito.network" \
--epoch-progress-threshold "0.8" \
--poll-interval-secs "60" \
run
```

## Contributing

1. Fork the repository
Expand Down
22 changes: 15 additions & 7 deletions api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ use env_logger::{Builder, Target};
use kobe_api::{
error::{handle_error, ApiError},
resolvers::query_resolver::{
daily_mev_rewards_cacheable_wrapper, get_validator_histories_wrapper,
jito_stake_over_time_ratio_cacheable_wrapper, jitosol_ratio_cacheable_wrapper,
jitosol_validators_cacheable_wrapper, mev_commission_average_over_time_cacheable_wrapper,
mev_rewards_cacheable_wrapper, stake_pool_stats_cacheable_wrapper,
staker_rewards_cacheable_wrapper, steward_events_cacheable_wrapper,
validator_by_vote_account_cacheable_wrapper, validator_rewards_cacheable_wrapper,
validators_cacheable_wrapper, QueryResolver,
daily_mev_rewards_cacheable_wrapper, get_bam_epoch_metric_wrapper,
get_validator_histories_wrapper, jito_stake_over_time_ratio_cacheable_wrapper,
jitosol_ratio_cacheable_wrapper, jitosol_validators_cacheable_wrapper,
mev_commission_average_over_time_cacheable_wrapper, mev_rewards_cacheable_wrapper,
stake_pool_stats_cacheable_wrapper, staker_rewards_cacheable_wrapper,
steward_events_cacheable_wrapper, validator_by_vote_account_cacheable_wrapper,
validator_rewards_cacheable_wrapper, validators_cacheable_wrapper, QueryResolver,
},
schemas::{
jitosol_ratio::JitoSolRatioRequest,
Expand Down Expand Up @@ -194,6 +194,13 @@ async fn get_validator_histories(
get_validator_histories_wrapper(resolver, vote_account, epoch_query).await
}

async fn get_bam_epoch_metric(
resolver: Extension<QueryResolver>,
Query(epoch_query): Query<EpochQuery>,
) -> impl IntoResponse {
get_bam_epoch_metric_wrapper(resolver, epoch_query.epoch).await
}

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
Expand Down Expand Up @@ -334,6 +341,7 @@ async fn run_server(args: &Args) {
"/api/v1/validator_history/:vote_account",
get(get_validator_histories),
)
.route("/api/v1/bam_epoch_metric", get(get_bam_epoch_metric))
.layer(Extension(query_resolver))
.layer(middleware)
.layer(cors);
Expand Down
Loading
Loading