v0.3.14-pre.002-fix.002

This commit is contained in:
2026-09-11 20:55:53 +02:00
parent 5932250314
commit 7bf938c19f
7 changed files with 261 additions and 50 deletions

View File

@@ -1,16 +1,16 @@
// file: crates/ksp-worker-raw-transaction-ingest-lib/src/continuity.rs
// version: 2
// version: 3
/// Maximum number of simultaneously retained non-repaired run-local gaps.
pub(crate) const MAX_RAW_TRANSACTION_INGEST_OPEN_REPAIR_GAPS: usize = 64;
const MAX_RAW_TRANSACTION_INGEST_OPEN_REPAIR_GAPS: usize = 64;
/// Maximum number of run-local gaps that may actively repair at once.
pub(crate) const MAX_RAW_TRANSACTION_INGEST_REPAIR_ACTIVE_GAPS: usize = 1;
const MAX_RAW_TRANSACTION_INGEST_REPAIR_ACTIVE_GAPS: usize = 1;
/// Maximum number of logical block fetches that a later repair scheduler may admit concurrently.
pub(crate) const MAX_RAW_TRANSACTION_INGEST_REPAIR_BLOCK_FETCH_IN_FLIGHT: usize = 4;
const MAX_RAW_TRANSACTION_INGEST_REPAIR_BLOCK_FETCH_IN_FLIGHT: usize = 4;
/// Maximum number of slots admitted by one later HTTP repair discovery window.
pub(crate) const MAX_RAW_TRANSACTION_INGEST_REPAIR_DISCOVERY_WINDOW_SLOTS: u64 = 512;
const MAX_RAW_TRANSACTION_INGEST_REPAIR_DISCOVERY_WINDOW_SLOTS: u64 = 512;
/// Maximum inclusive slot span admitted for one run-local repair gap.
pub(crate) const MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS: u64 = 4_096;
const MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS: u64 = 4_096;
/// Private source scope used to prove whether one configured live source can cover another run-local requirement.
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -107,7 +107,7 @@ impl RawTransactionIngestGapRange {
std::option::Option::Some(value) => value,
std::option::Option::None => return std::result::Result::Err(crate::runtime_error("continuity.gap_range_overflow")),
};
if slot_count > crate::MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS {
if slot_count > MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS {
return std::result::Result::Err(crate::runtime_error("continuity.gap_range_too_large"));
}
return std::result::Result::Ok(Self { end_slot, start_slot });
@@ -143,7 +143,7 @@ impl RawTransactionIngestGapRange {
std::option::Option::Some(value) => value,
std::option::Option::None => return std::result::Result::Ok(std::option::Option::None),
};
if slot_count > crate::MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS {
if slot_count > MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS {
return std::result::Result::Ok(std::option::Option::None);
}
return std::result::Result::Ok(std::option::Option::Some(Self { end_slot, start_slot }));
@@ -211,10 +211,10 @@ impl RawTransactionIngestGapLedger {
return std::result::Result::Err(error);
}
}
if open_gap_count > crate::MAX_RAW_TRANSACTION_INGEST_OPEN_REPAIR_GAPS {
if open_gap_count > MAX_RAW_TRANSACTION_INGEST_OPEN_REPAIR_GAPS {
return std::result::Result::Err(crate::runtime_error("continuity.open_gap_limit_exceeded"));
}
if active_gap_count > crate::MAX_RAW_TRANSACTION_INGEST_REPAIR_ACTIVE_GAPS {
if active_gap_count > MAX_RAW_TRANSACTION_INGEST_REPAIR_ACTIVE_GAPS {
return std::result::Result::Err(crate::runtime_error("continuity.active_gap_limit_exceeded"));
}
if !self.gaps.is_empty() && self.next_gap_id <= highest_gap_id {
@@ -250,7 +250,7 @@ impl RawTransactionIngestGapLedger {
}
/// Private source capability descriptor prepared without network I/O from already validated runtime resources.
pub(crate) struct RawTransactionIngestRepairCapabilityDescriptor {
pub(crate) struct RawTransactionIngestContinuityCapabilityDescriptor {
block_material: bool,
commitment: ksp_onchain_transport_lib::SolanaCommitment,
http_block_scan: bool,
@@ -263,7 +263,7 @@ pub(crate) struct RawTransactionIngestRepairCapabilityDescriptor {
source_scope: crate::RawTransactionIngestCoverageScope,
}
impl crate::RawTransactionIngestRepairCapabilityDescriptor {
impl crate::RawTransactionIngestContinuityCapabilityDescriptor {
/// Creates one private descriptor from source-local capabilities that were validated without issuing repair I/O.
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
@@ -324,7 +324,7 @@ struct RawTransactionIngestTargetCoverage {
}
impl RawTransactionIngestTargetCoverage {
fn from_capabilities(capabilities: &[crate::RawTransactionIngestRepairCapabilityDescriptor]) -> ksp_core_lib::Result<Self> {
fn from_capabilities(capabilities: &[crate::RawTransactionIngestContinuityCapabilityDescriptor]) -> ksp_core_lib::Result<Self> {
let mut value = Self { requirements: std::vec::Vec::new() };
for capability in capabilities {
if let std::result::Result::Err(error) = value.include(capability.commitment, capability.source_scope.clone()) {
@@ -363,14 +363,14 @@ impl RawTransactionIngestTargetCoverage {
/// Run-local continuity contracts prepared from the exact caller-composed live-source aggregate before productive source execution.
pub(crate) struct RawTransactionIngestContinuityContracts {
capabilities: std::vec::Vec<crate::RawTransactionIngestRepairCapabilityDescriptor>,
capabilities: std::vec::Vec<crate::RawTransactionIngestContinuityCapabilityDescriptor>,
gap_ledger: RawTransactionIngestGapLedger,
target_coverage: RawTransactionIngestTargetCoverage,
}
impl crate::RawTransactionIngestContinuityContracts {
/// Builds the private capability inventory, conservative `TargetCoverage` and empty run-local gap ledger without issuing network or Store I/O.
pub(crate) fn new(capabilities: std::vec::Vec<crate::RawTransactionIngestRepairCapabilityDescriptor>) -> ksp_core_lib::Result<Self> {
pub(crate) fn new(capabilities: std::vec::Vec<crate::RawTransactionIngestContinuityCapabilityDescriptor>) -> ksp_core_lib::Result<Self> {
if capabilities.is_empty() || capabilities.len() > crate::MAX_RAW_TRANSACTION_INGEST_LIVE_SOURCES {
return std::result::Result::Err(crate::runtime_error("continuity.capability_inventory_size_invalid"));
}
@@ -398,9 +398,9 @@ impl crate::RawTransactionIngestContinuityContracts {
if !coverage_scope_catalog_is_complete() {
return std::result::Result::Err(crate::runtime_error("continuity.coverage_scope_catalog_invalid"));
}
if crate::MAX_RAW_TRANSACTION_INGEST_REPAIR_BLOCK_FETCH_IN_FLIGHT == 0
|| crate::MAX_RAW_TRANSACTION_INGEST_REPAIR_DISCOVERY_WINDOW_SLOTS == 0
|| crate::MAX_RAW_TRANSACTION_INGEST_REPAIR_DISCOVERY_WINDOW_SLOTS > crate::MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS
if MAX_RAW_TRANSACTION_INGEST_REPAIR_BLOCK_FETCH_IN_FLIGHT == 0
|| MAX_RAW_TRANSACTION_INGEST_REPAIR_DISCOVERY_WINDOW_SLOTS == 0
|| MAX_RAW_TRANSACTION_INGEST_REPAIR_DISCOVERY_WINDOW_SLOTS > MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS
{
return std::result::Result::Err(crate::runtime_error("continuity.repair_bounds_invalid"));
}