Skip to content

Commit

Permalink
FEATURE: Adding keeper (#71)
Browse files Browse the repository at this point in the history
- Adding in the keeper bot
- Refactor into sdk
- Keeper quickstart guide

---------

Co-authored-by: Evan Batsell <ebatsell@gmail.com>
Co-authored-by: Christian <christian.krueger.health@gmail.com>
Co-authored-by: Christian  Krueger <coach@Christians-MacBook-Pro.local>
Co-authored-by: Christian  Krueger <coach@Christians-MBP.localdomain>
  • Loading branch information
5 people authored Aug 5, 2024
1 parent 8135f26 commit aa7b269
Show file tree
Hide file tree
Showing 83 changed files with 5,921 additions and 1,423 deletions.
49 changes: 31 additions & 18 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[workspace]
members = [
"keepers/*",
"programs/*",
"programs/*",
"sdk",
"tests",
"utils/*",
]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.71-slim-buster as builder
FROM rust:1.75-slim-buster as builder

RUN apt-get update && apt-get install -y libudev-dev clang pkg-config libssl-dev build-essential cmake protobuf-compiler

Expand Down
90 changes: 71 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Validator History Program
# Stakenet

## About

Jito StakeNet is a decentralized Solana stake pool manager, blending Validator History and Steward Programs for secure, transparent validator management and autonomous stake operations.

## Validator History Program

The Validator History Program, a component of Jito StakeNet, is an on-chain record of verified Solana validator data, storing up to 512 epochs of history per validator. It takes fields accessible to the solana runtime like validator performance history, validator commission, MEV commission, as well as Gossip data like validator IP, version, and client type, and stores them all in a single account. It also contains some fields that currently require permissioned upload but are easily verifiable with a getVoteAccounts call, like total active stake per validator, stake rank, and superminority status. All these fields are stored in a single account per validator, the ValidatorHistory account. This enables all these disparate fields to be easily composed with in on chain programs, with a long lookback period and ease of access through the single account.

## Structure
### Structure

The main Anchor program is in `programs/validator-history`.

Expand All @@ -22,43 +26,51 @@ Note that this is a `zero_copy` account, which allows us to initialize a lot of

`Config`: Tracks admin authorities as well as global program metadata.

## Test
## Steward Program

Tests are in `tests/` written with solana-program-test.
Harnessing on-chain validator metrics and network data, the Steward Program employs advanced algorithms to evaluate and rank validators. Automated keepers then execute a state machine to optimally allocate stake, maximizing network security and efficiency.

All tests can be run by running:
```shell
./run_tests.sh
```
On-chain Steward accounts for JitoSOL:

| Account | Address |
|-----------------|---------------------------------------------|
| Program | Stewardf95sJbmtcZsyagb2dg4Mo8eVQho8gpECvLx8 |
| Steward Config | jitoVjT9jRUyeXHzvCwzPgHj7yWNRhLcUoXtes4wtjv |
| Steward State | 9BAmGVLGxzqct6bkgjWmKSv3BFB6iKYXNBQp8GWG1LDY|
| Authority | 9eZbWiHsPRsxLSiHxzg2pkXsAuQMwAjQrda7C7e21Fw6|

## Build
## Build and Test

### Build

`anchor build --program-name validator_history` (regular anchor build)
`solana-verify build --library-name validator_history` (solana verified build)

## Verify
### Verify

Verify with [solana-verifiable-build](https://github.com/Ellipsis-Labs/solana-verifiable-build):

`solana-verify verify-from-repo -um --program-id HistoryJTGbKQD2mRgLZ3XhqHnN811Qpez8X9kCcGHoa https://github.com/jito-foundation/stakenet`

## Running Keeper
### Test

Run as binary:
Tests are in `tests/` written with solana-program-test.

Build: `cargo b -r --package validator-keeper`
All tests can be run by running ( root directory ):

Run: `./target/release/validator-keeper --json-rpc-url <YOUR RPC> --cluster mainnet --tip-distribution-program-id F2Zu7QZiTYUhPd7u9ukRVwxh7B71oA3NMJcHuCHc29P2 --program-id HistoryJTGbKQD2mRgLZ3XhqHnN811Qpez8X9kCcGHoa --interval 600 --keypair <YOUR KEYPAIR>`
```shell
./run_tests.sh
```

Run as docker container (need to set environment variables in config/.env file):
## Running Keeper

`docker compose --env-file config/.env up -d --build validator-keeper`
Check out the [Keeper Bot Quick Start](./keeper-bot-quick-start.md)

Metrics for running can be sent to your influx server if you set the SOLANA_METRICS_CONFIG env var.
## CLIs

## CLI
### Validator History

The CLI can be used to see the status of on-chain validator history data.
This CLI can be used to see the status of on-chain validator history data.

Build: `cargo b -r --package validator-history-cli`

Expand All @@ -69,3 +81,43 @@ To see the current epoch state of all validator history accounts:
To see the historical state of a single validator history account:

`./target/release/validator-history-cli --json-rpc-url <YOUR RPC URL> history <VOTE ACCOUNT>`

### Steward

This CLI can be used to see the status of on-chain steward data.

Build:

```bash
cargo b -r --package steward-cli
```

To view the config:

```bash
./target/release/steward-cli --program-id Stewardf95sJbmtcZsyagb2dg4Mo8eVQho8gpECvLx8 view-config --steward-config jitoVjT9jRUyeXHzvCwzPgHj7yWNRhLcUoXtes4wtjv
```

To view the state:
(Note: This fetches a lot of accounts, you may want to use your own RPC)

```bash
./target/release/steward-cli --json-rpc-url YOUR_RPC view-state --steward-config jitoVjT9jRUyeXHzvCwzPgHj7yWNRhLcUoXtes4wtjv
```

To see the state of each validator in the context of the steward add `--verbose`

```bash
./target/release/steward-cli --json-rpc-url YOUR_RPC view-state --steward-config jitoVjT9jRUyeXHzvCwzPgHj7yWNRhLcUoXtes4wtjv --verbose
```

> TIP: To use your own RPC configured in your solana config, use the following:
> `--json-rpc-url $(solana config get | grep "RPC URL" | awk '{print $3}')`
To see all of the available commands:

```bash
./target/release/steward-cli -h
```

To see more info on the Steward CLI check out the [CLI notes](./utils/steward-cli/steward_cli_notes.md)
38 changes: 38 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "3"
services:
validator-keeper:
build:
context: .
target: validator-history
container_name: validator-keeper
environment:
- RUST_LOG=${RUST_LOG:-info}
- SOLANA_METRICS_CONFIG=${SOLANA_METRICS_CONFIG}
- JSON_RPC_URL=${JSON_RPC_URL}
- KEYPAIR=${KEYPAIR}
- ORACLE_AUTHORITY_KEYPAIR=${ORACLE_AUTHORITY_KEYPAIR}
- CLUSTER=${CLUSTER}
- VALIDATOR_HISTORY_PROGRAM_ID=${VALIDATOR_HISTORY_PROGRAM_ID}
- TIP_DISTRIBUTION_PROGRAM_ID=${TIP_DISTRIBUTION_PROGRAM_ID}
- STEWARD_PROGRAM_ID=${STEWARD_PROGRAM_ID}
- STEWARD_CONFIG=${STEWARD_CONFIG}
- PRIORITY_FEES=${PRIORITY_FEES}
- RUN_CLUSTER_HISTORY=${RUN_CLUSTER_HISTORY}
- RUN_COPY_VOTE_ACCOUNTS=${RUN_COPY_VOTE_ACCOUNTS}
- RUN_MEV_COMMISSION=${RUN_MEV_COMMISSION}
- RUN_MEV_EARNED=${RUN_MEV_EARNED}
- RUN_STEWARD=${RUN_STEWARD}
- VALIDATOR_HISTORY_INTERVAL=${VALIDATOR_HISTORY_INTERVAL}
- STEWARD_INTERVAL=${STEWARD_INTERVAL}
- METRICS_INTERVAL=${METRICS_INTERVAL}
- RUN_STAKE_UPLOAD=${RUN_STAKE_UPLOAD}
- RUN_GOSSIP_UPLOAD=${RUN_GOSSIP_UPLOAD}
- RUN_EMIT_METRICS=${RUN_EMIT_METRICS}
- FULL_STARTUP=${FULL_STARTUP}
- NO_PACK=${NO_PACK}
- PAY_FOR_NEW_ACCOUNTS=${PAY_FOR_NEW_ACCOUNTS}
- COOL_DOWN_RANGE=${COOL_DOWN_RANGE}
- GOSSIP_ENTRYPOINT=${GOSSIP_ENTRYPOINT}
volumes:
- ./credentials:/credentials
restart: on-failure:5
Loading

0 comments on commit aa7b269

Please sign in to comment.