Skip to main content

validate_canonical_sequence

Function validate_canonical_sequence 

Source
pub fn validate_canonical_sequence<N: Network>(
    state: &CanonicalSequenceState,
    batch: &ReactiveInputBatch<N>,
) -> Result<CanonicalSequenceValidation, ReactiveError>
Expand description

Validate one provider-neutral delivery envelope without mutating runtime or cache state.

This is the canonical metadata contract shared by ReactiveRuntime and composite/remote subscribers. It validates explicit reorg controls before records, canonical record identity and implicit-reorg finality, then progress/barrier/safe/finalized controls. All identity assertions in the envelope must agree at each height. Retained history may be sparse; an explicit common ancestor need not itself be retained when the oldest retained entry is at or below it. Ancestors and removed blocks outside that rollback horizon are rejected, so a durable caller cannot persist a partial rollback. The runtime uses this same implementation with an internal observable-deep-reorg policy for its deliberately non-durable ingest path.

The returned state and mutations are cache-free. Callers that durably stage delivery should publish/persist them only at their own acknowledgement boundary.

This validator is deliberately chain-agnostic and does not compare ReactiveInputBatch::chain_id because CanonicalSequenceState carries no chain id. Cross-service/composite callers must bind one authoritative chain identity outside this state before sharing or advancing it; runtime ingestion separately checks the batch id against EvmCache.

ยงErrors

Returns ReactiveError::InvalidInputRecord when record identity/payload metadata is malformed or conflicting, and ReactiveError::InvalidChainControl when the snapshot or envelope has an invalid canonical transition, incomplete rollback proof, contradictory identity, or invalid coverage/finality relationship.