Documentation
¶
Index ¶
- Constants
- func NewAuditShardRequestHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
- func NewSegmentShardRequestHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
- func NewSegmentShardRequestJustificationHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
- func NewShardDistributionHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
- func WriteMessageWithContext(ctx context.Context, w io.Writer, content []byte) error
- type AuditShardRequestHandler
- type AuditShardRequestSender
- type BlockAnnouncementHandler
- func (bh *BlockAnnouncementHandler) AddOnBlockReceiveHook(hook BlockReceiveHook)
- func (bh *BlockAnnouncementHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
- func (bh *BlockAnnouncementHandler) NewBlockAnnouncer(bs *chain.BlockService, ctx context.Context, stream quic.Stream, ...) *BlockAnnouncer
- type BlockAnnouncer
- type BlockReceiveHook
- type BlockRequestHandler
- type BlockRequester
- type BlockRequestor
- type ErasureRootAndShardIndex
- type ErasureRootShardAndSegmentIndexes
- type Message
- type SafroleTicketDistributionRequestHandler
- type SafroleTicketSubmitRequestHandler
- type SafroleTicketSubmiter
- type SegmentRootMapping
- type SegmentShardRequestHandler
- type SegmentShardRequestJustificationHandler
- type SegmentShardRequestJustificationSender
- type SegmentShardRequestSender
- type ShardDistributionHandler
- type ShardDistributionSender
- type StateRequestHandler
- type StateRequester
- type WorkPackageSharingHandler
- type WorkPackageSharingRequester
- type WorkPackageSharingResponse
- type WorkPackageSubmissionHandler
- type WorkPackageSubmitter
- type WorkReportDistributionHandler
- type WorkReportDistributionSender
- type WorkReportGuarantor
- type WorkReportProcessAndGuarantee
- type WorkReportRequestHandler
- type WorkReportRequester
Constants ¶
const ( SendingHandshake connState = iota // Initial state: sending handshake to peer ReceivingHandshake // Awaiting handshake response from peer Ready // Handshake completed, ready for announcements )
const SegmentShardSize = 4104 / common.ErasureCodingOriginalShards
Variables ¶
This section is empty.
Functions ¶
func NewAuditShardRequestHandler ¶
func NewAuditShardRequestHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
NewAuditShardRequestHandler creates a new AuditShardRequestHandler
func NewSegmentShardRequestHandler ¶
func NewSegmentShardRequestHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
NewSegmentShardRequestHandler creates a new segment shard request handler
func NewSegmentShardRequestJustificationHandler ¶
func NewSegmentShardRequestJustificationHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
NewSegmentShardRequestJustificationHandler creates a new segment shard request handler
func NewShardDistributionHandler ¶
func NewShardDistributionHandler(validatorSvc validator.ValidatorService) protocol.StreamHandler
NewShardDistributionHandler creates a new ShardDistributionHandler
func WriteMessageWithContext ¶
WriteMessageWithContext writes a message to an io.Writer with context cancellation support. The message format is:
- 4 bytes: content size as little-endian uint32
- N bytes: content itself
The write operation can be cancelled via the provided context.
Parameters:
- ctx: Context for cancellation
- w: Destination writer
- content: Message content to write
Returns an error if:
- Writing the size fails
- Writing the content fails
- Context is cancelled during write
Types ¶
type AuditShardRequestHandler ¶
type AuditShardRequestHandler struct {
// contains filtered or unexported fields
}
AuditShardRequestHandler handles the receiving part of the CE 138 protocol
func (*AuditShardRequestHandler) HandleStream ¶
func (h *AuditShardRequestHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream handles the incoming CE 138 protocol Justification = [0 ++ Hash OR 1 ++ Hash ++ Hash] (Each discriminator is a single byte)
Auditor -> Assurer
--> Erasure-Root ++ Shard Index --> FIN <-- Bundle Shard <-- Justification <-- FIN
type AuditShardRequestSender ¶
type AuditShardRequestSender struct{}
func (*AuditShardRequestSender) AuditShardRequest ¶
func (s *AuditShardRequestSender) AuditShardRequest(ctx context.Context, stream quic.Stream, erasureRoot crypto.Hash, shardIndex uint16) (bundleShard []byte, justification [][]byte, err error)
AuditShardRequest implements the sender side of the CE 138 protocol for more details see AuditShardRequestHandler
type BlockAnnouncementHandler ¶
type BlockAnnouncementHandler struct {
*chain.BlockService // Provides access to the local node's chain state
Announcers map[string]*BlockAnnouncer // Maps peer keys to their respective announcers
// contains filtered or unexported fields
}
BlockAnnouncementHandler implements the UP 0 block announcement protocol from the JAMNP spec. It maintains a map of active block announcers for each connected peer and handles new announcement streams according to protocol rules for Unique Persistent streams.
func NewBlockAnnouncementHandler ¶
func NewBlockAnnouncementHandler(bs *chain.BlockService, requestor BlockRequestor) *BlockAnnouncementHandler
NewBlockAnnouncementHandler creates a new handler with the provided block service and block requestor. The block service provides access to the node's chain state, while the requestor allows fetching blocks from peers after receiving announcements.
func (*BlockAnnouncementHandler) AddOnBlockReceiveHook ¶
func (bh *BlockAnnouncementHandler) AddOnBlockReceiveHook(hook BlockReceiveHook)
AddOnBlockReceiveHook add on block received hook, required to kick off other processes like assurance and auditing
func (*BlockAnnouncementHandler) HandleStream ¶
func (bh *BlockAnnouncementHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream processes a new UP 0 stream according to the JAMNP requirements. Since UP streams should be unique per connection, it handles the case where a stream already exists for the peer by keeping only the stream with the higher stream ID. This implements the spec rule: "If exists: Close old connection, cleanup peer state."
func (*BlockAnnouncementHandler) NewBlockAnnouncer ¶
func (bh *BlockAnnouncementHandler) NewBlockAnnouncer(bs *chain.BlockService, ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) *BlockAnnouncer
NewBlockAnnouncer creates a new announcer for a given stream and peer. It initializes the announcer in the SendingHandshake state and registers it in the handler's Announcers map using the peer's Ed25519 key.
type BlockAnnouncer ¶
type BlockAnnouncer struct {
*chain.BlockService // Access to local chain state
// contains filtered or unexported fields
}
BlockAnnouncer manages a single UP 0 block announcement stream with a peer. It handles the initial handshake, tracking peer's chain state (finalized blocks and leaves), and bidirectional exchange of block announcements according to the protocol rules.
func (*BlockAnnouncer) SendAnnouncement ¶
func (ba *BlockAnnouncer) SendAnnouncement(header *block.Header) error
SendAnnouncement sends a block announcement to the peer. It first checks if the block should be announced, then serializes the header along with our latest finalized block information as required by the protocol. Format: Block Header + Finalized Block Hash + Finalized Block Slot
func (*BlockAnnouncer) Start ¶
func (ba *BlockAnnouncer) Start() error
Start initiates the block announcement protocol by triggering the handshake process. It waits for the handshake to complete before returning to ensure the announcer is ready for operation. Returns an error if the context is canceled before completion.
type BlockRequestHandler ¶
type BlockRequestHandler struct {
// contains filtered or unexported fields
}
BlockRequestHandler processes CE 128 block request streams from peers. It implements protocol specification section "CE 128: Block request". Block requests allow peers to request sequences of blocks either: - Ascending from a given block (exclusive of the block itself) - Descending from a given block (inclusive of the block itself)
func NewBlockRequestHandler ¶
func NewBlockRequestHandler(blockService *chain.BlockService) *BlockRequestHandler
NewBlockRequestHandler creates a new handler for processing block requests. It requires a BlockService to fetch requested blocks from storage.
func (*BlockRequestHandler) HandleStream ¶
func (h *BlockRequestHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream processes an incoming block request stream according to CE 128 protocol. Message format:
- Header hash (32 bytes): Starting block hash
- Direction (1 byte): 0 for ascending exclusive, 1 for descending inclusive
- Maximum blocks (4 bytes): Little-endian uint32 maximum blocks to return
Response format:
- Length-prefixed sequence of encoded blocks
- Stream is closed with FIN bit set after response
The response sequence starts from the given block hash and follows the chain either forward (for ascending) or backward (for descending), limited by MaxBlocks. For ascending requests, the sequence starts with a child of the given block. For descending requests, the sequence starts with the given block itself.
type BlockRequester ¶
type BlockRequester struct{}
BlockRequester handles outgoing CE 128 block requests to peers. It implements the client side of the block request protocol.
func (*BlockRequester) RequestBlocks ¶
func (r *BlockRequester) RequestBlocks(ctx context.Context, stream quic.Stream, headerHash [32]byte, ascending bool, maxBlocks uint32) ([]block.Block, error)
RequestBlocks sends a block request to a peer and receives the response. Parameters:
- ctx: Context for cancellation
- stream: QUIC stream for the request
- headerHash: Hash of the starting block
- ascending: If true, gets blocks after header (exclusive) If false, gets blocks before and including header
- maxBlocks: Maximum number of blocks to request
The request follows CE 128 protocol format:
--> Header Hash (32 bytes) ++ Direction (1 byte) ++ Maximum Blocks (4 bytes LE) --> FIN <-- [Block] <-- FIN
Returns:
- Sequence of blocks if successful
- Error if request fails, response invalid, or context cancelled
type BlockRequestor ¶
type BlockRequestor interface {
RequestBlocks(ctx context.Context, hash crypto.Hash, ascending bool, maxBlocks uint32, peerKey ed25519.PublicKey) ([]block.Block, error)
}
BlockRequestor defines an interface for requesting blocks from peers.
type Message ¶
type Message struct {
// Size is the length of the content in bytes
Size uint32
// Content contains the actual message data
Content []byte
}
Message represents a protocol message that includes both size and content. The size is encoded as a little-endian uint32 followed by the actual content bytes.
func ReadMessageWithContext ¶
ReadMessageWithContext reads a message from an io.Reader with context cancellation support. The expected message format is:
- 4 bytes: content size as little-endian uint32
- N bytes: content itself
The read operation can be cancelled via the provided context.
Parameters:
- ctx: Context for cancellation
- r: Source reader
Returns:
- The read Message and nil if successful
- nil and an error if:
- Reading the size fails
- Reading the content fails
- Context is cancelled during read
- Size exceeds available memory
type SafroleTicketDistributionRequestHandler ¶
type SafroleTicketDistributionRequestHandler struct {
// contains filtered or unexported fields
}
SafroleTicketDistributionRequestHandler handles CE 132 Safrole ticket distribution protocol. This is the second step where the proxy validator broadcasts the received ticket to all current validators for use in block production.
Protocol Flow (CE 132): 1. Proxy validator receives ticket via CE 131 (handled by submit handler above) 2. After timing delay (3 minutes), proxy broadcasts to ALL current validators 3. Current validators receive ticket via this handler 4. Validators store ticket for potential use in block sealing
func NewSafroleTicketBroadcastRequestHandler ¶
func NewSafroleTicketBroadcastRequestHandler(state *state.State, vm *validator.ValidatorManager, store *store.Ticket) *SafroleTicketDistributionRequestHandler
NewSafroleTicketBroadcastRequestHandler creates a handler for CE 132 (ticket distribution). This handler receives tickets from proxy validators during the broadcast phase. All current validators should receive tickets via this handler.
func (*SafroleTicketDistributionRequestHandler) HandleStream ¶
func (h *SafroleTicketDistributionRequestHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream implements CE 132 Safrole ticket distribution protocol. This method receives tickets from proxy validators during the broadcast phase. All current validators should receive and store these tickets.
Storage Process: 1. Verify ticket proof is valid 2. Store ticket for potential use in block sealing 3. Ticket becomes available for lottery participation
type SafroleTicketSubmitRequestHandler ¶
type SafroleTicketSubmitRequestHandler struct {
// contains filtered or unexported fields
}
SafroleTicketSubmitRequestHandler handles CE 131 Safrole ticket submission protocol. This is the first step in the two-phase ticket distribution process where a generating validator sends their ticket to a deterministically-selected proxy validator.
Protocol Flow (CE 131): 1. Validator generates Safrole ticket for current epoch 2. Validator determines proxy using: last 4 bytes of VRF output % validator_count 3. Validator sends ticket to proxy validator (this handler receives it) 4. Proxy validates ticket and stores it for later distribution (CE 132)
func NewSafroleTicketSubmitRequestHandler ¶
func NewSafroleTicketSubmitRequestHandler(state *state.State, vm *validator.ValidatorManager, store *store.Ticket) *SafroleTicketSubmitRequestHandler
NewSafroleTicketSubmitRequestHandler creates a handler for CE 131 (ticket submission). This handler receives tickets from generating validators and validates that the current node is the correct proxy for the ticket.
func (*SafroleTicketSubmitRequestHandler) HandleStream ¶
func (h *SafroleTicketSubmitRequestHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream implements CE 131 Safrole ticket submission protocol. This method receives tickets from generating validators and validates that the current node is the designated proxy for the ticket.
Validation Process: 1. Verify ticket proof against ring commitment 2. Check that this node is the correct proxy (based on VRF output) 3. Store ticket for later distribution via CE 132
type SafroleTicketSubmiter ¶
type SafroleTicketSubmiter struct{}
SafroleTicketSubmiter handles the client side of both CE 131 and CE 132 protocols. It formats and sends ticket submission/distribution requests to other validators.
func (*SafroleTicketSubmiter) Submit ¶
func (r *SafroleTicketSubmiter) Submit(ctx context.Context, stream quic.Stream, ticketProof block.TicketProof) error
Submit implements the client side of CE 131/132 Safrole ticket protocols. This method is used by:
- CE 131: Generating validators to send tickets to proxy validators
- CE 132: Proxy validators to broadcast tickets to all current validators Which protocol is used depends on the stream kind of the connection.
Wire Protocol: --> Epoch Index ++ Ticket (Epoch index identifies when ticket will be used) --> FIN <-- FIN
type SegmentRootMapping ¶
SegmentRootMapping It maps a work-package hash (h⊞) to the actual segment root (H).
type SegmentShardRequestHandler ¶
type SegmentShardRequestHandler struct {
// contains filtered or unexported fields
}
SegmentShardRequestHandler handles the incoming CE 139 requests
func (*SegmentShardRequestHandler) HandleStream ¶
func (s *SegmentShardRequestHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream handles the incoming CE 139 protocol Segment Index = u16
Guarantor -> Assurer
--> [Erasure-Root ++ Shard Index ++ len++[Segment Index]] --> FIN <-- [Segment Shard] <-- FIN
type SegmentShardRequestJustificationHandler ¶
type SegmentShardRequestJustificationHandler struct {
// contains filtered or unexported fields
}
SegmentShardRequestJustificationHandler handles the incoming CE 140 requests
func (*SegmentShardRequestJustificationHandler) HandleStream ¶
func (s *SegmentShardRequestJustificationHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream handles the incoming CE 140 protocol Segment Index = u16 Justification = [0 ++ Hash OR 1 ++ Hash ++ Hash OR 2 ++ Segment Shard] (Each discriminator is a single byte)
Guarantor -> Assurer
--> [Erasure-Root ++ Shard Index ++ len++[Segment Index]] --> FIN <-- [Segment Shard]
for each segment shard {
<-- Justification
}
<-- FIN
type SegmentShardRequestJustificationSender ¶
type SegmentShardRequestJustificationSender struct{}
SegmentShardRequestJustificationSender CE 140 sender protocol
func (*SegmentShardRequestJustificationSender) SegmentShardRequestJustification ¶
func (s *SegmentShardRequestJustificationSender) SegmentShardRequestJustification(ctx context.Context, stream quic.Stream, erasureRoot crypto.Hash, shardIndex uint16, segmentIndexes []uint16) (segmentShards [][]byte, justification [][][]byte, err error)
SegmentShardRequestJustification implements the sending of the CE 140 protocol, for more details reference SegmentShardRequestHandler
type SegmentShardRequestSender ¶
type SegmentShardRequestSender struct{}
SegmentShardRequestSender CE 139 sender protocol
func (*SegmentShardRequestSender) SegmentShardRequest ¶
func (s *SegmentShardRequestSender) SegmentShardRequest(ctx context.Context, stream quic.Stream, erasureRoot crypto.Hash, shardIndex uint16, segmentIndexes []uint16) (segmentShards [][]byte, err error)
SegmentShardRequest implements the sending of the CE 139 protocol, for more details reference SegmentShardRequestHandler
type ShardDistributionHandler ¶
type ShardDistributionHandler struct {
// contains filtered or unexported fields
}
ShardDistributionHandler processes incoming CE-137 submission streams
func (*ShardDistributionHandler) HandleStream ¶
func (h *ShardDistributionHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream handles protocol CE 137, decodes the erasure root and shard index requests the shards and justification from the validator service encodes and returns the respective shards and justification
Justification = [0 ++ Hash OR 1 ++ Hash ++ Hash] (Each discriminator is a single byte)
Assurer -> Guarantor
--> Erasure-Root ++ Shard Index --> FIN <-- Bundle Shard <-- [Segment Shard] (Should include all exported and proof segment shards with the given index) <-- Justification <-- FIN
type ShardDistributionSender ¶
type ShardDistributionSender struct{}
ShardDistributionSender handles outgoing CE-137 calls
func (*ShardDistributionSender) ShardDistribution ¶
func (s *ShardDistributionSender) ShardDistribution(ctx context.Context, stream quic.Stream, erasureRoot crypto.Hash, shardIndex uint16) (bundleShard []byte, segmentShard [][]byte, justification [][]byte, err error)
ShardDistribution implements the sender side of the CE 137 protocol for more details check ShardDistributionHandler
type StateRequestHandler ¶
type StateRequestHandler struct {
// contains filtered or unexported fields
}
StateRequestHandler processes incoming state request streams according to the CE 129 protocol. It provides access to the trie data structure that stores the blockchain state.
func NewStateRequestHandler ¶
func NewStateRequestHandler(trie *store.Trie) *StateRequestHandler
NewStateRequestHandler creates a new handler for processing state requests. It takes a reference to a store.Trie that will be used to serve state data.
func (*StateRequestHandler) HandleStream ¶
func (h *StateRequestHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream processes an incoming state request stream according to CE 129 protocol. Key = [u8; 31] (First 31 bytes of key only) Maximum Size = u32 Boundary Node = As returned by B/L, defined in the State Merklization appendix of the GP Value = len++[u8] Node -> Node --> Header Hash ++ Key (Start) ++ Key (End) ++ Maximum Size --> FIN <-- [Boundary Node] <-- [Key ++ Value] <-- FIN
type StateRequester ¶
type StateRequester struct{}
StateRequester provides functionality for making state requests to other nodes. It implements the client side of the CE 129 protocol.
func (*StateRequester) RequestState ¶
func (h *StateRequester) RequestState(ctx context.Context, stream quic.Stream, headerHash crypto.Hash, keyStart [31]byte, keyEnd [31]byte, maxSize uint32) (store.TrieRangeResult, error)
RequestState sends a state request to another node and processes the response. This implements the client side of the CE 129 protocol.
Parameters: - ctx: The context for the request, used for cancellation and timeouts - stream: The QUIC stream for sending/receiving data - headerHash: The hash of the block header whose state is being requested - keyStart: The first key in the requested range (inclusive) - keyEnd: The last key in the requested range (inclusive) - maxSize: Maximum size in bytes for the response
Returns: - A TrieRangeResult containing the boundary nodes and key-value pairs - An error if the request or response processing fails
type WorkPackageSharingHandler ¶
type WorkPackageSharingHandler struct {
// contains filtered or unexported fields
}
WorkPackageSharingHandler processes incoming CE-134 streams This handler is used by a guarantor who receives a work-package bundle from another guarantor.
func NewWorkPackageSharingHandler ¶
func NewWorkPackageSharingHandler( auth authorization.AuthPVMInvoker, refine refine.RefinePVMInvoker, privateKey ed25519.PrivateKey, serviceState service.ServiceState, store *store.WorkReport, validatorService validator.ValidatorService, ) *WorkPackageSharingHandler
NewWorkPackageSharingHandler creates a new WorkPackageSharingHandler instance.
func (*WorkPackageSharingHandler) HandleStream ¶
func (h *WorkPackageSharingHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream implements the guarantor side of the CE-134 protocol. It reads two messages:
- [Core Index ++ Segments-Root Mappings]
- [Work-Package Bundle]
[Work-Report Hash ++ Ed25519 Signature].
func (*WorkPackageSharingHandler) SetCurrentCore ¶
func (h *WorkPackageSharingHandler) SetCurrentCore(core uint16)
type WorkPackageSharingRequester ¶
type WorkPackageSharingRequester struct{}
func NewWorkPackageSharingRequester ¶
func NewWorkPackageSharingRequester() *WorkPackageSharingRequester
func (*WorkPackageSharingRequester) SendRequest ¶
func (r *WorkPackageSharingRequester) SendRequest( ctx context.Context, g *peer.Peer, coreIndex uint16, imported []SegmentRootMapping, bundleBytes []byte, ) (*WorkPackageSharingResponse, error)
SendRequest hands CE 134 sends 2 messages to another guarantor and closes the stream :
--> Core Index ++ Segments-Root Mappings
- Informs the receiving guarantor which core this work-package belongs to.
- Provides the mapping between imported segment hashes and their Merkle roots.
- This mapping is used during refinement to validate imported segments.
--> Work-Package Bundle
- Contains the actual work-package bundle and any associated extrinsics.
--> FIN
- Closes the stream after sending both messages. The response is expected before finalization.
<-- Work-Report Hash ++ Ed25519 Signature
- The receiving guarantor performs refinement and responds with:
- The hash of the resulting work-report.
- Their Ed25519 signature over the hash.
- This response is used to help assemble a guaranteed work-report.
<-- FIN
- The stream is closed after the response is read and decoded.
Returns: - A `workPackageSharingResponse` containing the signed hash of the refined work-report. - An error if sending, receiving, decoding, or stream closure fails.
type WorkPackageSharingResponse ¶
type WorkPackageSharingResponse struct {
WorkReportHash crypto.Hash
Signature crypto.Ed25519Signature
}
WorkPackageSharingResponse is the response payload of CE-134 <-- Work-Report Hash ++ Ed25519 Signature
type WorkPackageSubmissionHandler ¶
type WorkPackageSubmissionHandler struct {
// Fetcher is used to retrieve imported segments referenced in the work-package.
Fetcher d3l.SegmentsFetcher
// contains filtered or unexported fields
}
WorkPackageSubmissionHandler processes incoming CE-133 submission streams
func NewWorkPackageSubmissionHandler ¶
func NewWorkPackageSubmissionHandler(fetcher d3l.SegmentsFetcher, wpSharingHandler WorkReportProcessAndGuarantee, segmentRootLookup work.SegmentRootLookup) *WorkPackageSubmissionHandler
NewWorkPackageSubmissionHandler creates a new handler instance with the given fetcher.
func (*WorkPackageSubmissionHandler) HandleStream ¶
func (h *WorkPackageSubmissionHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream processes the CE-133 submission stream from a builder. This starts the full flow (CE-133 → CE-134 → CE-135). It reads two messages:
- [Core Index (u16) ++ work.Package]
- [Extrinsics (raw bytes)]
Then fetches imported segments (if needed), wraps the data into a bundle, and starts validation, refinement, and distribution.
type WorkPackageSubmitter ¶
type WorkPackageSubmitter struct{}
WorkPackageSubmitter handles outgoing CE-133 submissions (builder side).
func (*WorkPackageSubmitter) SubmitWorkPackage ¶
func (s *WorkPackageSubmitter) SubmitWorkPackage(ctx context.Context, stream quic.Stream, coreIndex uint16, pkg work.Package, extrinsics []byte) error
SubmitWorkPackage sends a work-package submission to a guarantor over the given stream. It sends two messages:
Message 1: [Core Index (u16) ++ work.Package] Message 2: [Extrinsic data]
type WorkReportDistributionHandler ¶
type WorkReportDistributionHandler struct {
}
WorkReportDistributionHandler processes incoming CE-135 streams This handler is used by a validator who receives a work-report guarantee
func NewWorkReportDistributionHandler ¶
func NewWorkReportDistributionHandler() *WorkReportDistributionHandler
func (*WorkReportDistributionHandler) HandleStream ¶
type WorkReportDistributionSender ¶
type WorkReportDistributionSender struct{}
func NewWorkReportDistributionSender ¶
func NewWorkReportDistributionSender() *WorkReportDistributionSender
func (*WorkReportDistributionSender) SendGuarantee ¶
func (s *WorkReportDistributionSender) SendGuarantee( ctx context.Context, stream quic.Stream, validatorIndex uint16, guaranteeData []byte, ) error
SendGuarantee handles CE-135 and sends guaranteed work report to validator
Guaranteed Work-Report = Work-Report ++ Slot ++ len++[Validator Index ++ Ed25519 Signature] (As in GP)
Guarantor -> Validator
--> Guaranteed Work-Report --> FIN <-- FIN
type WorkReportGuarantor ¶
type WorkReportGuarantor struct {
// contains filtered or unexported fields
}
WorkReportGuarantor handles CE-134 and CE-135: - CE-134: share a work-package with other guarantors, run local refinement, collect wr hashes signatures - CE-135: if enough signatures are gathered, broadcast the guaranteed work-report to validators
func NewWorkReportGuarantor ¶
func NewWorkReportGuarantor( validatorIndex uint16, privateKey ed25519.PrivateKey, auth authorization.AuthPVMInvoker, refine refine.RefinePVMInvoker, state state.State, peerSet *peer.PeerSet, store *store.WorkReport, requester *WorkReportRequester, workPackageSharingRequester *WorkPackageSharingRequester, workReportDistributionSender *WorkReportDistributionSender, validatorService validator.ValidatorService, segmentRootLookup work.SegmentRootLookup, ) *WorkReportGuarantor
func (*WorkReportGuarantor) SetGuarantors ¶
func (h *WorkReportGuarantor) SetGuarantors(guarantors []*peer.Peer)
func (*WorkReportGuarantor) ValidateAndProcessWorkPackage ¶
func (h *WorkReportGuarantor) ValidateAndProcessWorkPackage(ctx context.Context, coreIndex uint16, bundle *work.PackageBundle) error
ValidateAndProcessWorkPackage sends the work-package bundle to other guarantors and runs local refinement
type WorkReportRequestHandler ¶
type WorkReportRequestHandler struct {
// contains filtered or unexported fields
}
WorkReportRequestHandler handles CE-136: inbound work-report requests.
This handler responds to a peer's request for a work-report by its hash. If the report is found in the local store, it is sent back in full.
If the report is not found, the stream is closed with an error.
func NewWorkReportRequestHandler ¶
func NewWorkReportRequestHandler(store *store.WorkReport) *WorkReportRequestHandler
func (*WorkReportRequestHandler) HandleStream ¶
func (h *WorkReportRequestHandler) HandleStream(ctx context.Context, stream quic.Stream, peerKey ed25519.PublicKey) error
HandleStream processes an incoming CE-136 Work-Report Request
Protocol flow: Auditor -> Auditor
--> Work-Report Hash (32 bytes) --> FIN <-- Work-Report (full, encoded) <-- FIN
This handler assumes that the node has previously stored the requested work report during the guarantee process
type WorkReportRequester ¶
type WorkReportRequester struct {
}
WorkReportRequester handles CE-136: requesting work-reports from peer This client-side handler sends a hash to a peer and requests the full work-report
This should be used by auditors to request missing work-reports which have been negatively judged by other auditors. This protocol is also used when local refinement fails and a node needs to fetch the body of the work-report from another peer that has already produced it.
func NewWorkReportRequester ¶
func NewWorkReportRequester() *WorkReportRequester
func (*WorkReportRequester) RequestWorkReport ¶
func (r *WorkReportRequester) RequestWorkReport( ctx context.Context, stream quic.Stream, hash crypto.Hash, ) (*block.WorkReport, error)
RequestWorkReport sends a CE-136 request over the given stream to fetch a work-report by its hash It marshals the hash, sends it, reads the response, decodes it into a WorkReport, and returns it
If the remote peer cannot fulfill the request, or if an error occurs during transmission, an error is returned
Source Files
¶
- audit_shard_request.go
- block_announcement.go
- block_request.go
- message.go
- safrole_ticket_submit.go
- segment_shard_request.go
- segment_shard_request_just.go
- shard_distribution.go
- state_request.go
- work_package_sharing.go
- work_package_submission.go
- work_report_distribution.go
- work_report_guarantor.go
- work_report_request.go