Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CorroborationGate ¶
func CorroborationGate(t *CorroborationTracker, minSources int, trusted func(peer.ID) bool, connectedPeers func() int) func(cid.Cid) bool
CorroborationGate builds the head-adoption corroboration predicate the ingestor consults before walking head onto a new tip (#80 part 2).
- minSources <= 0 disables the gate (returns nil: always adopt).
- trusted, when non-nil, is the super-vote: if ANY forwarding peer is trusted (the #80 part 1 protected floor / configured beacons), the head is corroborated regardless of count.
- connectedPeers, when non-nil, is the graceful-degradation input: a node with fewer connected peers than minSources cannot possibly meet the bar, so the requirement clamps to the peer count (floor 1). A 1-peer node must never wedge (#79 StatusInsufficient philosophy).
Types ¶
type Config ¶
type Config struct {
// Topic name. Defaults to build.MainnetGossipTopicBlocks
// (/fil/blocks/testnetnet on mainnet).
Topic string
// DryRun: when true, Publish runs all validation but does not push
// the bytes to gossipsub. Useful for SP rehearsal flows.
DryRun bool
// OnBlock fires for every block received from the network. Nil
// means "ignore inbound traffic." Validation is the consumer's
// job — we deliver any block that decodes cleanly.
OnBlock func(*ltypes.BlockMsg)
}
Config configures a Publisher.
type CorroborationTracker ¶
type CorroborationTracker struct {
// contains filtered or unexported fields
}
CorroborationTracker counts distinct forwarding peers per block header CID, fed by gossipsub tracer events. Safe for concurrent use: pubsub invokes tracer hooks from its own goroutines while the ingestor's gate reads counts from the processor goroutine.
func NewCorroborationTracker ¶
func NewCorroborationTracker(topic string) *CorroborationTracker
NewCorroborationTracker builds a tracker that only counts messages on the given gossipsub topic (the /fil/blocks/<network> topic).
func (*CorroborationTracker) SourceCount ¶
func (t *CorroborationTracker) SourceCount(c cid.Cid) int
SourceCount returns how many distinct peers have forwarded the block.
func (*CorroborationTracker) Sources ¶
func (t *CorroborationTracker) Sources(c cid.Cid) []peer.ID
Sources returns the distinct peers that forwarded the block.
func (*CorroborationTracker) Stats ¶
func (t *CorroborationTracker) Stats() (tracked int, recorded uint64)
Stats returns (distinct blocks tracked, lifetime votes recorded).
func (*CorroborationTracker) Tracer ¶
func (t *CorroborationTracker) Tracer() pubsub.RawTracer
Tracer returns the pubsub.RawTracer to register at gossipsub construction (net/libp2p HostConfig.PubSubTracer). Nil-safe: a nil tracker returns a nil tracer, so callers can wire `PubSubTracer: maybeNilTracker.Tracer()` unconditionally.
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher publishes + subscribes on the block gossipsub topic.
func New ¶
New joins the block topic and (if OnBlock is set) starts the read loop. Subscribe is unconditional so we can count inbound traffic even without a handler.
Issue #18: also registers a TopicValidator so gossipsub's peer-score machinery sees us as an active participant in the mesh, not a passive sink. Without a validator, gossipsub never credits us with first-message-delivery (P2) score against peers that forwarded us valid blocks, and the remote peers' score machinery eventually downgrades us. The validator does the SAME superficiallyValid check the read-loop does; the difference is gossipsub now ATTRIBUTES the accept/reject decision to the source peer's score.
func (*Publisher) Publish ¶
Publish marshals + publishes a BlockMsg on the topic.
IMPORTANT: callers should only invoke Publish from a context where AllowBlockSubmit is true AND a VM bridge has produced the correct post-execution state root for the block's ParentStateRoot. Publishing a block with an incorrect stateRoot is a soft-fault: the network rejects it and the publishing peer eats a little reputation cost. See TRUST-MODEL.md.
func (*Publisher) PublishBlock ¶
PublishBlock matches the rpc/handlers.BlockPublisher interface signature. It wraps Publish and discards the returned CID, which the caller can recompute via blk.Header.Cid() if needed.