Skip to main content

Crate blvm_protocol

Crate blvm_protocol 

Source
Expand description

Bitcoin Protocol Engine

This crate provides a Bitcoin protocol abstraction layer that enables:

  • Multiple Bitcoin variants (mainnet, testnet, regtest, educational)
  • Protocol evolution support (Bitcoin V1, V2, etc.)
  • Economic model abstraction (PoW, future variants)
  • Educational and research-friendly interfaces

This is Tier 3 of the 5-tier BTCDecoded architecture:

  1. Orange Paper (mathematical foundation)
  2. blvm-consensus (pure math implementation)
  3. blvm-protocol (Bitcoin abstraction) ← THIS CRATE
  4. blvm-node (full Bitcoin node)
  5. blvm-sdk (ergonomic API)

Re-exports§

pub use error::ProtocolError;
pub use error::Result;
pub use node_tcp::ProtocolMessage;
pub use node_tcp::TcpFramedParser;
pub use commons::BanListMessage;
pub use commons::FilterPreferences;
pub use commons::FilteredBlockMessage;
pub use commons::GetBanListMessage;
pub use commons::GetFilteredBlockMessage;
pub use commons::GetUTXOProofMessage;
pub use commons::GetUTXOSetMessage;
pub use commons::UTXOCommitment;
pub use commons::UTXOProofMessage;
pub use commons::UTXOSetMessage;
pub use config::ProtocolConfig;
pub use config::ProtocolFeaturesConfig;
pub use config::ProtocolValidationConfig;
pub use config::ServiceFlagsConfig;
pub use network::BlockMessage;
pub use network::CompactBlockMessage;
pub use network::TxMessage;
pub use service_flags::commons as service_flags_commons;
pub use service_flags::standard as service_flags_standard;
pub use economic::EconomicParameters;
pub use features::ActivationMethod;
pub use features::FeatureActivation;
pub use features::FeatureContext;
pub use features::FeatureRegistry;
pub use smallvec;
pub use lru;
pub use rayon;

Modules§

activation
address
BIP350/351: Bech32m Address Encoding
bip113
bip119
bip152
BIP152 high-level compact block types (wire / serde).
bip157
BIP157: Client-Side Block Filtering Network Protocol
bip158
BIP158: Compact Block Filters for Light Client Discovery
bip_validation
block
commons
Commons-specific protocol extensions
config
Configuration for blvm-protocol
consensus_config
Consensus runtime configuration from blvm-consensus (distinct from this crate’s config module).
constants
Consensus constants (blvm-primitives / Orange Paper symbols) — same as blvm_consensus::constants.
crypto
economic
Economic Model Parameters
error
Protocol-specific error types
features
Feature Activation Tracking
genesis
Genesis Blocks
mempool
mining
network
Bitcoin P2P Network Protocol (Orange Paper Section 10)
network_params
Network parameters for different Bitcoin variants
node_tcp
Framed TCP P2P (mainnet magic, command allowlist supplied by the node). Not BIP324 v2 transport. Bitcoin TCP v1 framed messages: standard header (magic, command, length, checksum) plus payload.
opcodes
Script opcodes (re-exported from consensus / primitives) for callers that should not name blvm-consensus directly. Bitcoin Script Opcode Constants
optimizations
Production-only batch hashing, preallocation, and related optimization helpers from consensus.
p2p_commands
Bitcoin P2P command names (payload type tags; 12-byte null-padded on the wire).
p2p_frame
Bitcoin P2P message framing: magic, 12-byte command, LE length, 4-byte checksum, payload.
p2p_framing
Bitcoin P2P framing constants: magic bytes, max message size, and common count limits.
payment
BIP70: Payment Protocol (P2P Variant)
pow
script
Script interpreter (consensus). Exposed so benches/node avoid a direct blvm-consensus dep where possible.
segwit
serialization
service_flags
Service flags for Bitcoin P2P protocol
sigop
spam_filter
Spam Filtering for UTXO Commitments
test_utils
time
Safe time utilities for fault tolerance
transaction
transaction_hash
Transaction sighash / txid helpers from consensus.
types
utxo_commitments
UTXO Commitments Module
utxo_overlay
v2_transport
BIP324: Version 2 P2P Encrypted Transport Protocol
validation
Protocol validation interface
variants
Protocol variants implementation
varint
Variable-length integer encoding (Bitcoin protocol)
version_bits
wire
Bitcoin P2P wire format serialization
witness

Macros§

profile_log
Forwards to blvm_consensus::profile_log! so upper layers avoid naming blvm-consensus directly. When the profile feature is off on consensus, the inner macro expands to a no-op.
tx_inputs
Helper macro to create Transaction inputs/outputs that works with both Vec and SmallVec
tx_outputs

Structs§

BitcoinProtocolEngine
Bitcoin Protocol Engine
Block
Block: ℬ = ℋ × 𝒯𝒳*
BlockHeader
Block Header: ℋ = ℤ × ℍ × ℍ × ℕ × ℕ × ℕ
ConsensusProof
Consensus Proof - wrapper struct for consensus validation functions
NetworkMessageLimits
Network message size limits configuration
NetworkParameters
Network parameters for different Bitcoin variants
OutPoint
OutPoint: 𝒪 = ℍ × ℕ
Transaction
Transaction: 𝒯𝒳 = ℕ × ℐ* × 𝒯* × ℕ
TransactionInput
Transaction Input: ℐ = 𝒪 × 𝕊 × ℕ
TransactionOutput
Transaction Output: 𝒯 = ℤ × 𝕊
UTXO
UTXO: 𝒰 = ℤ × 𝕊 × ℕ

Enums§

ConsensusError
ProtocolVersion
Bitcoin protocol versions
ValidationResult
Validation result

Constants§

BIP112_CSV_ACTIVATION_MAINNET
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. BIP112/BIP113: CHECKSEQUENCEVERIFY (CSV) - Mainnet activation height
BIP112_CSV_ACTIVATION_REGTEST
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. BIP112/BIP113: CSV - Regtest (active from genesis for typical regtest chains)
BIP112_CSV_ACTIVATION_TESTNET
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. BIP112/BIP113: CSV - Testnet activation height (Bitcoin Core testnet3)
GENESIS_BLOCK_HASH_INTERNAL
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. Genesis block hash in internal / wire byte order.
SEGWIT_ACTIVATION_MAINNET
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. SegWit (BIP141) - Mainnet activation height
SEGWIT_ACTIVATION_TESTNET
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. SegWit (BIP141) - Testnet activation height (Bitcoin Core testnet3 consensus.SegwitHeight)
TAPROOT_ACTIVATION_MAINNET
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. Taproot (BIP341) - Mainnet activation height
TAPROOT_ACTIVATION_TESTNET
Buried deployment heights (Core chainparams) for RPC / tooling without a direct blvm-consensus dep. Taproot (BIP341) - Testnet activation height (Bitcoin Core testnet3)

Functions§

reset_assume_valid_height
Reset assume-valid override (benchmarking).
set_assume_valid_height
Set assume-valid height for benchmarking (overrides config).

Type Aliases§

ByteString
Byte string type
ConsensusResult
Hash
Hash type: 256-bit hash
Integer
Integer type
Natural
Natural number type
UtxoSet
UTXO Set: 𝒰𝒮 = 𝒪 → 𝒰
Witness
Witness data: stack of witness elements (SegWit/Taproot)