-
Notifications
You must be signed in to change notification settings - Fork 2.2k
slashing: add proof account functionality #7394
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Slashing Program | ||
|
||
A program that validates a proof of a slashable event on chain for logging purposes. | ||
Users can create a proof buffer for the flavor of slashable infraction, populate it, | ||
and submit for verification. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "spl-slashing" | ||
version = "0.1.0" | ||
description = "Solana Program Library Slashing" | ||
authors = ["Solana Labs Maintainers <[email protected]>"] | ||
repository = "https://github.com/solana-labs/solana-program-library" | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
|
||
[features] | ||
no-entrypoint = [] | ||
test-sbf = [] | ||
|
||
[dependencies] | ||
bytemuck = { version = "1.19.0", features = ["derive"] } | ||
num-derive = "0.4" | ||
num-traits = "0.2" | ||
solana-program = "2.0.3" | ||
thiserror = "1.0" | ||
spl-pod = { version = "0.4.0", path = "../../libraries/pod" } | ||
|
||
[dev-dependencies] | ||
solana-program-test = "2.0.3" | ||
solana-sdk = "2.0.3" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "lib"] | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.bpfel-unknown-unknown.dependencies.std] | ||
features = [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8sT74BE7sanh4iT84EyVUL8b77cVruLHXGjvTyJ4GwCe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just used the default key when from when I deployed to testnet, can update once we decide how this is going to be deployed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem. Since this will be an "enshrined" program we could even add it a non-random address with a feature-gate, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, let me know if I have this correct for the deployment scheme:
I did see that some of the other spl programs were deployed with a squads multi sig as the upgrade authority. Curious about your thoughts about that deployment schema. It seems that would allow us more freedom in upgrading or disabling the slashing program should there be any vulnerabilities. But optically is it worse if the keys are held by anza & FD? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that would be the process. Anza / FD really can't hold the upgrade keys to something so sensitive -- we'll need to leave it up to the validators. We can start off with feature gates, and then eventually move to a validator DAO, if that ever materializes. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//! Program entrypoint | ||
|
||
#![cfg(all(target_os = "solana", not(feature = "no-entrypoint")))] | ||
|
||
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey}; | ||
|
||
solana_program::entrypoint!(process_instruction); | ||
fn process_instruction( | ||
program_id: &Pubkey, | ||
accounts: &[AccountInfo], | ||
instruction_data: &[u8], | ||
) -> ProgramResult { | ||
crate::processor::process_instruction(program_id, accounts, instruction_data) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! Error types | ||
|
||
use { | ||
num_derive::FromPrimitive, | ||
solana_program::{decode_error::DecodeError, program_error::ProgramError}, | ||
thiserror::Error, | ||
}; | ||
|
||
/// Errors that may be returned by the program. | ||
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] | ||
pub enum SlashingError { | ||
/// Incorrect authority provided on write or close | ||
#[error("Incorrect authority provided on write or close")] | ||
IncorrectAuthority, | ||
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we could use |
||
|
||
/// Invalid proof type | ||
#[error("Invalid proof type")] | ||
InvalidProofType, | ||
|
||
/// Calculation overflow | ||
#[error("Calculation overflow")] | ||
Overflow, | ||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we could use |
||
} | ||
|
||
impl From<SlashingError> for ProgramError { | ||
fn from(e: SlashingError) -> Self { | ||
ProgramError::Custom(e as u32) | ||
} | ||
} | ||
|
||
impl<T> DecodeError<T> for SlashingError { | ||
fn type_of() -> &'static str { | ||
"Slashing Error" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this file hasn't been needed for a long time, so we can remove it