Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c0aba4e
feat(statement-distribution): Implement handleIncomingManifestCommon()
haikoschol Jun 19, 2025
8abae00
remove statementStore interface
haikoschol Jun 19, 2025
73c0826
add tests for handleIncomingManifestCommon()
haikoschol Jun 24, 2025
db90abf
Merge branch 'feat/parachain' into haiko/statement-distribution/incom…
haikoschol Jun 24, 2025
78280bc
Merge branch 'feat/parachain' into haiko/statement-distribution/incom…
haikoschol Jun 25, 2025
d1ed301
feat(statement-distribution): Implement handleIncomingManifest()
haikoschol Jun 25, 2025
d4d9c7d
feat(statement-distribution): Implement handleIncomingAcknowledgement()
haikoschol Jun 25, 2025
c0ed050
add test for StatementDistribution.handleIncomingManifest()
haikoschol Jun 26, 2025
d5d24c1
parallelify the tests
haikoschol Jun 26, 2025
f244c27
review feedback
haikoschol Jun 26, 2025
027e563
Merge branch 'haiko/statement-distribution/incoming-manifest-common' …
haikoschol Jun 26, 2025
ee51a89
parallel test
haikoschol Jun 26, 2025
113d001
Merge branch 'feat/parachain' into haiko/statement-distribution/handl…
haikoschol Jun 26, 2025
07811df
Merge branch 'feat/parachain' into haiko/statement-distribution/handl…
haikoschol Jun 26, 2025
2368d17
feat(statement-distribution): Implement requestManager
haikoschol Jun 30, 2025
a45963e
Merge branch 'feat/parachain' into haiko/statement-distribution/reque…
haikoschol Jul 3, 2025
1cb193d
lint
haikoschol Jul 3, 2025
c748f5b
address review feedback
haikoschol Jul 4, 2025
d071196
Merge branch 'feat/parachain' into haiko/statement-distribution/reque…
haikoschol Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions dot/parachain/network-bridge/messages/attested_candidate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2025 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package messages

import (
"fmt"
"time"

"github.com/ChainSafe/gossamer/dot/network"
parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types"
"github.com/ChainSafe/gossamer/pkg/scale"
)

const (
// AttestedCandidateTimeout We want attested candidate requests to time out relatively fast,
// because slow requests will bottleneck the backing system. Ideally, we'd have
// an adaptive timeout based on the candidate size, because there will be a lot of variance
// in candidate sizes: candidates with no code and no messages vs candidates with code
// and messages.
//
// We supply leniency because there are often large candidates and asynchronous
// backing allows them to be included over a longer window of time. Exponential back-off
// up to a maximum of 10 seconds would be ideal, but isn't supported by the
// infrastructure here yet: see https://github.com/paritytech/polkadot/issues/6009
AttestedCandidateTimeout = time.Millisecond * 2500

// MaxParallelAttestedCandidateRequests We don't want a slow peer to slow down all the others,
// at the same time we want to get out the data quickly in full to at least some peers
// (as this will reduce load on us as they then can start serving the data). So this value is a tradeoff.
// 5 seems to be sensible. So we would need to have 5 slow nodes connected, to delay transfer for others
// by [AttestedCandidateTimeout].
MaxParallelAttestedCandidateRequests = 5
)

// AttestedCandidateRequest is a request for a candidate with statements.
type AttestedCandidateRequest struct {
// Hash of the candidate we want to request.
CandidateHash parachaintypes.CandidateHash
// Statement filter with 'OR' semantics, indicating which validators
// not to send statements for.
//
// The filter must have exactly the minimum size required to
// fit all validators from the backing group.
//
// The response may not contain any statements masked out by this mask.
Mask parachaintypes.StatementFilter
}

// Encode returns the SCALE encoding of the AttestedCandidateRequest
func (r *AttestedCandidateRequest) Encode() ([]byte, error) {
return scale.Marshal(*r)
}

// Decode returns the SCALE decoding of the AttestedCandidateRequest
func (r *AttestedCandidateRequest) Decode(in []byte) (err error) {
return scale.Unmarshal(in, r)
}

func (r *AttestedCandidateRequest) Response() network.ResponseMessage {
return &AttestedCandidateResponse{}
}

func (r *AttestedCandidateRequest) Protocol() ReqProtocolName {
return AttestedCandidateV2
}

// AttestedCandidateResponse is the response to an [AttestedCandidateRequest].
type AttestedCandidateResponse struct {
CandidateReceipt parachaintypes.CommittedCandidateReceiptV2
PersistedValidationData parachaintypes.PersistedValidationData
Statements []any // TODO: implement parachaintypes.UncheckedSignedStatement
}

// Encode returns the SCALE encoding of the AttestedCandidateResponse
func (r *AttestedCandidateResponse) Encode() ([]byte, error) {
return scale.Marshal(*r)
}

// Decode returns the SCALE decoding of the AttestedCandidateResponse
func (r *AttestedCandidateResponse) Decode(in []byte) (err error) {
return scale.Unmarshal(in, r)
}

// String returns a human-readable representation of the AttestedCandidateResponse
func (r *AttestedCandidateResponse) String() string {
return fmt.Sprintf(
"AttestedCandidateResponse CandidateReceipt=%v",
r.CandidateReceipt,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
AvailableDataFetchingV1
StatementFetchingV1
DisputeSendingV1
AttestedCandidateV2
)

func (n ReqProtocolName) String() string {
Expand All @@ -39,6 +40,8 @@ func (n ReqProtocolName) String() string {
return "req_statement/1"
case DisputeSendingV1:
return "send_dispute/1"
case AttestedCandidateV2:
return "/req_attested_candidate/2"
default:
panic("unknown protocol")
}
Expand Down
Loading
Loading