Skip to content

Commit

Permalink
chore(dot/parachain): consistently use ParaID type
Browse files Browse the repository at this point in the history
  • Loading branch information
haikoschol committed Oct 24, 2024
1 parent cc73286 commit adcc739
Show file tree
Hide file tree
Showing 36 changed files with 89 additions and 82 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
badParent = BadParent
)

func createTestCandidateReceiptAndValidationCodeWParaId(t *testing.T, id uint32) (
func createTestCandidateReceiptAndValidationCodeWParaId(t *testing.T, id parachaintypes.ParaID) (
parachaintypes.CandidateReceipt, parachaintypes.ValidationCode) {
t.Helper()
// this wasm was achieved by building polkadot's adder test parachain
Expand Down Expand Up @@ -58,7 +58,7 @@ func createTestCandidateReceiptAndValidationCodeWParaId(t *testing.T, id uint32)
return candidateReceipt, validationCode
}

func makeValidCandidateDescriptor(t *testing.T, paraID uint32, relayParent common.Hash,
func makeValidCandidateDescriptor(t *testing.T, paraID parachaintypes.ParaID, relayParent common.Hash,
persistedValidationDataHash common.Hash, povHash common.Hash,
validationCodeHash parachaintypes.ValidationCodeHash, paraHead common.Hash, erasureRoot common.Hash,
collator sr25519.Keypair,
Expand Down
4 changes: 2 additions & 2 deletions dot/parachain/candidate-validation/mocks_instance_test.go

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/collator-protocol/collation_fetching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestCollationFetchingResponse(t *testing.T) {
collation := parachaintypes.Collation{
CandidateReceipt: parachaintypes.CandidateReceipt{
Descriptor: parachaintypes.CandidateDescriptor{
ParaID: uint32(1),
ParaID: 1,
RelayParent: testHash,
Collator: collatorID,
PersistedValidationDataHash: testHash,
Expand Down
4 changes: 2 additions & 2 deletions dot/parachain/collator-protocol/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ func (cpvs CollatorProtocolValidatorSide) processCollatorProtocolMessage(sender
}

// NOTE: assignments are setting when we handle view changes
_, ok = cpvs.currentAssignments[parachaintypes.ParaID(declareMessage.ParaID)]
_, ok = cpvs.currentAssignments[declareMessage.ParaID]
if ok {
logger.Errorf("declared as collator for current para: %d", declareMessage.ParaID)

peerData.SetCollating(declareMessage.CollatorId, parachaintypes.ParaID(declareMessage.ParaID))
peerData.SetCollating(declareMessage.CollatorId, declareMessage.ParaID)
cpvs.peerData[sender] = peerData
} else {
logger.Errorf("declared as collator for unneeded para: %d", declareMessage.ParaID)
Expand Down
Loading

0 comments on commit adcc739

Please sign in to comment.