Skip to content

Commit 318b642

Browse files
committed
[wip] Add stake interface
1 parent d37ebc0 commit 318b642

File tree

8 files changed

+2706
-3
lines changed

8 files changed

+2706
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
[workspace]
22
resolver = "2"
3-
members = ["clients/rust", "program"]
3+
members = ["clients/rust", "interface", "program"]
44

55
[workspace.metadata.cli]
66
solana = "edge"
77

8-
# Specify Rust toolchains for rustfmt, clippy, and build.
9-
# Any unprovided toolchains default to stable.
108
[workspace.metadata.toolchains]
119
format = "nightly-2023-10-05"
1210
lint = "nightly-2023-10-05"

interface/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "solana-stake-interface"
3+
version = "0.1.0"
4+
description = "Instructions and constructors for the Stake program"
5+
repository = "https://github.com/solana-program/stake"
6+
edition = "2021"
7+
readme = "README.md"
8+
license-file = "../LICENSE"
9+
10+
[dependencies]
11+
borsh = { version = "1.5.1", features = ["derive", "unstable__schema"] }
12+
borsh0-10 = { package = "borsh", version = "0.10.3" }
13+
num-derive = "0.4"
14+
num-traits = "0.2"
15+
serde = { version="1.0.210" }
16+
solana-decode-error = { version="2.1.0", git="https://github.com/anza-xyz/agave.git" }
17+
serde_derive = { version="1.0.210" }
18+
solana-clock = { version="2.1.0", features=["serde"], git="https://github.com/anza-xyz/agave.git" }
19+
solana-instruction = { version="2.1.0", features=["bincode"], git="https://github.com/anza-xyz/agave.git" }
20+
solana-program = { version="2.1.0", git="https://github.com/anza-xyz/agave.git" }
21+
solana-program-error = { version="2.1.0", features=["serde"], git="https://github.com/anza-xyz/agave.git" }
22+
solana-pubkey = { version="2.1.0", features=["serde"], git="https://github.com/anza-xyz/agave.git" }
23+
24+
[dev-dependencies]
25+
assert_matches = "1.5.0"
26+
bincode = "1.3.3"
27+
static_assertions = "1.1.0"

interface/src/config.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! config for staking
2+
//! carries variables that the stake program cares about
3+
4+
#[deprecated(
5+
since = "1.16.7",
6+
note = "Please use `solana_sdk::stake::state::{DEFAULT_SLASH_PENALTY, DEFAULT_WARMUP_COOLDOWN_RATE}` instead"
7+
)]
8+
pub use super::state::{DEFAULT_SLASH_PENALTY, DEFAULT_WARMUP_COOLDOWN_RATE};
9+
use serde_derive::{Deserialize, Serialize};
10+
use solana_pubkey::declare_deprecated_id;
11+
12+
// stake config ID
13+
declare_deprecated_id!("StakeConfig11111111111111111111111111111111");
14+
15+
#[deprecated(
16+
since = "1.16.7",
17+
note = "Please use `solana_sdk::stake::state::warmup_cooldown_rate()` instead"
18+
)]
19+
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Copy)]
20+
pub struct Config {
21+
/// how much stake we can activate/deactivate per-epoch as a fraction of currently effective stake
22+
pub warmup_cooldown_rate: f64,
23+
/// percentage of stake lost when slash, expressed as a portion of u8::MAX
24+
pub slash_penalty: u8,
25+
}
26+
27+
impl Default for Config {
28+
fn default() -> Self {
29+
Self {
30+
warmup_cooldown_rate: DEFAULT_WARMUP_COOLDOWN_RATE,
31+
slash_penalty: DEFAULT_SLASH_PENALTY,
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)