Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dot/parachain): consistently use ParaID type #4273

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions dot/core/mock_runtime_instance_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dot/parachain/backing/active_leaves_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func constructPerRelayParentState(
case parachaintypes.OccupiedCore:
if mode.IsEnabled {
// Async backing makes it legal to build on top of occupied core.
coreParaID = parachaintypes.ParaID(v.CandidateDescriptor.ParaID)
coreParaID = v.CandidateDescriptor.ParaID
} else {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion dot/parachain/backing/can_second.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (cb *CandidateBacking) secondingSanityCheck(
candidateRelayParent = v.RelayParent
candidateHash = v.CandidateHash
case parachaintypes.HypotheticalCandidateComplete:
candidateParaID = parachaintypes.ParaID(v.CommittedCandidateReceipt.Descriptor.ParaID)
candidateParaID = v.CommittedCandidateReceipt.Descriptor.ParaID
candidateRelayParent = v.CommittedCandidateReceipt.Descriptor.RelayParent
candidateHash = v.CandidateHash
}
Expand Down
2 changes: 1 addition & 1 deletion dot/parachain/backing/candidate_backing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func getDummyCommittedCandidateReceipt(t *testing.T) parachaintypes.CommittedCan

ccr := parachaintypes.CommittedCandidateReceipt{
Descriptor: parachaintypes.CandidateDescriptor{
ParaID: uint32(1),
ParaID: 1,
RelayParent: hash5,
Collator: collatorID,
PersistedValidationDataHash: hash5,
Expand Down
14 changes: 7 additions & 7 deletions dot/parachain/backing/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func makeErasureRoot(
// newCommittedCandidate creates a new committed candidate receipt for testing purposes.
func newCommittedCandidate(
t *testing.T,
paraID uint32, //nolint:unparam
paraID parachaintypes.ParaID, //nolint:unparam
headData parachaintypes.HeadData,
povHash, relayParent, erasureRoot, pvdHash common.Hash,
validationCode parachaintypes.ValidationCode,
Expand Down Expand Up @@ -265,7 +265,7 @@ func TestSecondsValidCandidate(t *testing.T) {
paraValidators := parachainValidators(t, candidateBacking.Keystore)
numOfValidators := uint(len(paraValidators))
relayParent := getDummyHash(t, 5)
paraID := uint32(1)
paraID := parachaintypes.ParaID(1)

ctrl := gomock.NewController(t)
mockBlockState := backing.NewMockBlockState(ctrl)
Expand Down Expand Up @@ -443,7 +443,7 @@ func TestCandidateReachesQuorum(t *testing.T) {
paraValidators := parachainValidators(t, candidateBacking.Keystore)
numOfValidators := uint(len(paraValidators))
relayParent := getDummyHash(t, 5)
paraID := uint32(1)
paraID := parachaintypes.ParaID(1)

pov := parachaintypes.PoV{BlockData: []byte{1, 2, 3}}
povHash, err := pov.Hash()
Expand Down Expand Up @@ -635,7 +635,7 @@ func TestValidationFailDoesNotStopSubsystem(t *testing.T) {
paraValidators := parachainValidators(t, candidateBacking.Keystore)
numOfValidators := uint(len(paraValidators))
relayParent := getDummyHash(t, 5)
paraID := uint32(1)
paraID := parachaintypes.ParaID(1)

pov := parachaintypes.PoV{BlockData: []byte{1, 2, 3}}
povHash, err := pov.Hash()
Expand Down Expand Up @@ -778,7 +778,7 @@ func TestCanNotSecondMultipleCandidatesPerRelayParent(t *testing.T) {
paraValidators := parachainValidators(t, candidateBacking.Keystore)
numOfValidators := uint(len(paraValidators))
relayParent := getDummyHash(t, 5)
paraID := uint32(1)
paraID := parachaintypes.ParaID(1)

ctrl := gomock.NewController(t)
mockBlockState := backing.NewMockBlockState(ctrl)
Expand Down Expand Up @@ -922,7 +922,7 @@ func TestNewLeafDoesNotClobberOld(t *testing.T) {
numOfValidators := uint(len(paraValidators))
relayParent1 := getDummyHash(t, 5)
relayParent2 := getDummyHash(t, 6)
paraID := uint32(1)
paraID := parachaintypes.ParaID(1)
validationCode := parachaintypes.ValidationCode{1, 2, 3}

ctrl := gomock.NewController(t)
Expand Down Expand Up @@ -1045,7 +1045,7 @@ func TestConflictingStatementIsMisbehavior(t *testing.T) {
paraValidators := parachainValidators(t, candidateBacking.Keystore)
numOfValidators := uint(len(paraValidators))
relayParent := getDummyHash(t, 5)
paraID := uint32(1)
paraID := parachaintypes.ParaID(1)

pov := parachaintypes.PoV{BlockData: []byte{1, 2, 3}}
povHash, err := pov.Hash()
Expand Down
4 changes: 2 additions & 2 deletions dot/parachain/backing/mocks_runtime_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dot/parachain/backing/per_relay_parent_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (rpState *perRelayParentState) importStatement(
return nil, errNilPersistedValidationData
}

paraID := parachaintypes.ParaID(committedCandidateReceipt.Descriptor.ParaID)
paraID := committedCandidateReceipt.Descriptor.ParaID

if rpState.prospectiveParachainsMode.IsEnabled {
chIntroduceCandidate := make(chan error)
Expand Down Expand Up @@ -161,13 +161,13 @@ func (rpState *perRelayParentState) postImportStatement(subSystemToOverseer chan

// Inform the prospective parachains subsystem that the candidate is now backed.
subSystemToOverseer <- parachaintypes.ProspectiveParachainsMessageCandidateBacked{
ParaID: parachaintypes.ParaID(paraID),
ParaID: paraID,
CandidateHash: candidateHash,
}

// Backed candidate potentially unblocks new advertisements, notify collator protocol.
subSystemToOverseer <- collatorprotocolmessages.Backed{
ParaID: parachaintypes.ParaID(paraID),
ParaID: paraID,
ParaHead: backedCandidate.Candidate.Descriptor.ParaHead,
}

Expand Down Expand Up @@ -393,7 +393,7 @@ func getPovFromValidator(
fetchPov := parachaintypes.AvailabilityDistributionMessageFetchPoV{
RelayParent: relayParent,
FromValidator: attesting.fromValidator,
ParaID: parachaintypes.ParaID(attesting.candidate.Descriptor.ParaID),
ParaID: attesting.candidate.Descriptor.ParaID,
CandidateHash: candidateHash,
PovHash: attesting.povHash,
PovCh: make(chan parachaintypes.OverseerFuncRes[parachaintypes.PoV]),
Expand Down
2 changes: 1 addition & 1 deletion dot/parachain/backing/second.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (cb *CandidateBacking) handleSecondMessage(
}

// Sanity check that candidate is from our assignment.
if candidateReceipt.Descriptor.ParaID != uint32(*rpState.assignment) {
if candidateReceipt.Descriptor.ParaID != *rpState.assignment {
return fmt.Errorf("%w: candidate hash: %s; candidate paraID: %d; assignment: %d",
errParaOutsideAssignmentForSeconding,
candidateHash,
Expand Down
2 changes: 1 addition & 1 deletion dot/parachain/backing/statement_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (table *statementTable) importCandidate(
signature parachaintypes.ValidatorSignature,
tableCtx *tableContext,
) (*Summary, parachaintypes.Misbehaviour, error) {
paraID := parachaintypes.ParaID(candidate.Descriptor.ParaID)
paraID := candidate.Descriptor.ParaID

if !tableCtx.isMemberOf(authority, paraID) {
statementSeconded := parachaintypes.NewStatementVDT()
Expand Down
8 changes: 4 additions & 4 deletions dot/parachain/backing/statement_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func TestStatementTable_importCandidate(t *testing.T) {
expectedMisehaviour: nil,
expectedSummary: &Summary{
Candidate: candidateHash,
GroupID: parachaintypes.ParaID(candidate.Descriptor.ParaID),
GroupID: candidate.Descriptor.ParaID,
ValidityVotes: 1,
},
},
Expand Down Expand Up @@ -327,7 +327,7 @@ func TestStatementTable_importCandidate(t *testing.T) {
expectedMisehaviour: nil,
expectedSummary: &Summary{
Candidate: candidateHash,
GroupID: parachaintypes.ParaID(candidate.Descriptor.ParaID),
GroupID: candidate.Descriptor.ParaID,
ValidityVotes: 1,
},
},
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestStatementTable_importCandidate(t *testing.T) {
expectedMisehaviour: nil,
expectedSummary: &Summary{
Candidate: candidateHash,
GroupID: parachaintypes.ParaID(candidate.Descriptor.ParaID),
GroupID: candidate.Descriptor.ParaID,
ValidityVotes: 1,
},
},
Expand Down Expand Up @@ -461,7 +461,7 @@ func TestStatementTable_validityVote(t *testing.T) {
expectedMisehaviour: nil,
expectedSummary: &Summary{
Candidate: candidateHash,
GroupID: parachaintypes.ParaID(committedCandidate.Descriptor.ParaID),
GroupID: committedCandidate.Descriptor.ParaID,
ValidityVotes: 1,
},
},
Expand Down
4 changes: 2 additions & 2 deletions dot/parachain/backing/validated_candidate_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ func (cb *CandidateBacking) handleCommandSecond(
continue
}

secondedAtDepth, ok := leafState.secondedAtDepth[parachaintypes.ParaID(candidate.Descriptor.ParaID)]
secondedAtDepth, ok := leafState.secondedAtDepth[candidate.Descriptor.ParaID]
if !ok {
var btreeMap btree.Map[uint, parachaintypes.CandidateHash]
leafState.secondedAtDepth[parachaintypes.ParaID(candidate.Descriptor.ParaID)] = &btreeMap
leafState.secondedAtDepth[candidate.Descriptor.ParaID] = &btreeMap
secondedAtDepth = &btreeMap
}

Expand Down
7 changes: 4 additions & 3 deletions dot/parachain/candidate-validation/candidate_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type PoVRequestor interface {
}

// getValidationData gets validation data for a parachain block from the runtime instance
func getValidationData(runtimeInstance parachainruntime.RuntimeInstance, paraID uint32,
func getValidationData(runtimeInstance parachainruntime.RuntimeInstance, paraID parachaintypes.ParaID,
) (*parachaintypes.PersistedValidationData, *parachaintypes.ValidationCode, error) {

var mergedError error
Expand Down Expand Up @@ -211,8 +211,9 @@ func (cv *CandidateValidation) validateFromChainState(msg ValidateFromChainState
}
return
}
valid, err := runtimeInstance.ParachainHostCheckValidationOutputs(parachaintypes.ParaID(msg.CandidateReceipt.
Descriptor.ParaID), result.Valid.CandidateCommitments)
valid, err := runtimeInstance.ParachainHostCheckValidationOutputs(
msg.CandidateReceipt.Descriptor.ParaID,
result.Valid.CandidateCommitments)
if err != nil {
msg.Ch <- parachaintypes.OverseerFuncRes[ValidationResult]{
Err: fmt.Errorf("check validation outputs: Bad request: %w", err),
Expand Down
Loading
Loading