OpenPay (1 crate, 1801 LOC, 57 tests)
op-bin BIN/IIN database + range matching + card-network
classification. 8-digit normalized prefix Bin +
BinRange. Sorted-vec interval tree with O(log N) point
lookup + overlap rejection. CardNetwork classify()
with structural rules (Visa 4, MC 51-55/2221-2720,
Amex 34/37, Discover, JCB, Diners, UnionPay, RuPay,
Mir, Troy, Maestro, Elo). Static prefix tables +
build_default_tree(). ISO/IEC 7812-1 Annex B Luhn
(validate / is_valid / check_digit). Card-type +
issuer-country + Durbin regulated-debit. PCI-safe:
8-digit cap, no full-PAN APIs.
Smart Byte (1 crate, ~1500 LOC, 20 tests)
smart-byte-tendermint BFT consensus. Step enum + Round + propose/prevote/
precommit/commit FSM with voting-power tallies.
ValidatorSet with 2/3+1 quorum, 1/3+1 trust
threshold, round-robin proposer. Block / Header /
Commit / CommitSig with Blake3 hashing. Light client
(sequential + skipping). ABCI Application trait +
EchoApp. DuplicateVoteEvidence + LightClientAttackEvidence.
IBC ClientState + ConsensusState + light-client
update.
EOC (1 crate, 2084 LOC, 23 tests)
eoc-safety AI safety primitives. RegexSet over 16 prompt-injection
signatures. 13-family jailbreak detector (DAN/DUDE/
Grandma/STAN/AIM/dev-mode/etc.). Presidio-style PII
redactor with Luhn-validated CC. Toxicity / bias /
NSFW classifier traits + heuristic baselines (5-axis
bias, 4-category NSFW with hard-reject for minors).
Constitutional AI critique→revise loop. Composable
InputGuard / OutputGuard pipelines. JSON-Schema-subset
output validator. Token-bucket rate limiter +
abuse-window detection. Red-team replay harness.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
//! Error types for the Tendermint adapter.
|
|
|
|
use thiserror::Error;
|
|
|
|
/// Errors produced by Tendermint consensus, light-client, and evidence logic.
|
|
#[derive(Debug, Error)]
|
|
pub enum Error {
|
|
/// A validator id was referenced but not present in the active set.
|
|
#[error("unknown validator")]
|
|
UnknownValidator,
|
|
|
|
/// The voting-power total overflowed a `u64`.
|
|
#[error("voting power overflow")]
|
|
VotingPowerOverflow,
|
|
|
|
/// A vote could not be applied (wrong height, wrong round, duplicate, etc.).
|
|
#[error("invalid vote: {0}")]
|
|
InvalidVote(&'static str),
|
|
|
|
/// A proposal was rejected (wrong proposer, wrong round, etc.).
|
|
#[error("invalid proposal: {0}")]
|
|
InvalidProposal(&'static str),
|
|
|
|
/// A block failed structural validation.
|
|
#[error("invalid block: {0}")]
|
|
InvalidBlock(&'static str),
|
|
|
|
/// A light-client verification step failed.
|
|
#[error("light client: {0}")]
|
|
LightClient(&'static str),
|
|
|
|
/// Evidence could not be validated.
|
|
#[error("invalid evidence: {0}")]
|
|
InvalidEvidence(&'static str),
|
|
|
|
/// A signature could not be verified.
|
|
#[error("signature verification failed")]
|
|
BadSignature,
|
|
|
|
/// An ABCI application returned an error.
|
|
#[error("abci: {0}")]
|
|
Abci(&'static str),
|
|
}
|
|
|
|
/// Convenience `Result` alias.
|
|
pub type Result<T> = core::result::Result<T, Error>;
|