-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
slashing: add proof account functionality
- Loading branch information
1 parent
b4a73a3
commit 9be74cb
Showing
13 changed files
with
993 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.bpfel-unknown-unknown.dependencies.std] | ||
features = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8sT74BE7sanh4iT84EyVUL8b77cVruLHXGjvTyJ4GwCe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
|
||
/// Invalid proof type | ||
#[error("Invalid proof type")] | ||
InvalidProofType, | ||
|
||
/// Calculation overflow | ||
#[error("Calculation overflow")] | ||
Overflow, | ||
} | ||
|
||
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" | ||
} | ||
} |
Oops, something went wrong.