Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmack committed Sep 11, 2024
1 parent 020fb6f commit b8bbeb2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dot/parachain/candidate-validation/candidate_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
type CandidateValidation struct {
SubsystemToOverseer chan<- any
BlockState BlockState
pvfHost *host
pvfHost *host // pvfHost is the host for the parachain validation function
}

type BlockState interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
BlockData: bd,
}

sender := make(chan parachaintypes.OverseerFuncRes[ValidationResult])
toSubsystem := make(chan any)
candidateValidationSubsystem := CandidateValidation{
pvfHost: newValidationHost(),
Expand All @@ -387,7 +386,6 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
msg: ValidateFromChainState{
CandidateReceipt: candidateReceipt2,
Pov: pov,
Ch: sender,
},
want: &ValidationResult{
InvalidResult: &povHashMismatch,
Expand All @@ -397,7 +395,6 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
msg: ValidateFromChainState{
CandidateReceipt: candidateReceipt3,
Pov: pov,
Ch: sender,
},
want: &ValidationResult{
InvalidResult: &paramsTooLarge,
Expand All @@ -407,7 +404,6 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
msg: ValidateFromChainState{
CandidateReceipt: candidateReceipt4,
Pov: pov,
Ch: sender,
},
want: &ValidationResult{
InvalidResult: &codeHashMismatch,
Expand All @@ -417,7 +413,6 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
msg: ValidateFromChainState{
CandidateReceipt: candidateReceipt5,
Pov: pov,
Ch: sender,
},
want: &ValidationResult{
InvalidResult: &badSignature,
Expand All @@ -427,7 +422,6 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
msg: ValidateFromChainState{
CandidateReceipt: candidateReceipt,
Pov: pov,
Ch: sender,
},
want: &ValidationResult{
ValidResult: &Valid{
Expand Down Expand Up @@ -459,6 +453,9 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
t.Run(name, func(t *testing.T) {
t.Parallel()

sender := make(chan parachaintypes.OverseerFuncRes[ValidationResult])
tt.msg.Ch = sender

toSubsystem <- tt.msg
result := <-sender
require.Equal(t, tt.want, &result.Data)
Expand Down
1 change: 1 addition & 0 deletions dot/parachain/candidate-validation/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

var logger = log.NewFromGlobal(log.AddContext("pkg", "pvf"), log.SetLevel(log.Debug))

// host is the struct that holds the workerPool which is responsible for executing the validation tasks
type host struct {
workerPool *workerPool
}
Expand Down
6 changes: 5 additions & 1 deletion dot/parachain/candidate-validation/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func TestHost_validate(t *testing.T) {
}

func TestHost_performBasicChecks(t *testing.T) {
t.Parallel()
paramsTooLarge := ParamsTooLarge
povHashMismatch := PoVHashMismatch
codeHashMismatch := CodeHashMismatch
Expand Down Expand Up @@ -313,9 +314,12 @@ func TestHost_performBasicChecks(t *testing.T) {
},
}
for name, tt := range tests {
tt := tt
t.Run(name, func(t *testing.T) {
validationError, _ := performBasicChecks(tt.args.candidate, tt.args.maxPoVSize, tt.args.pov,
t.Parallel()
validationError, internalError := performBasicChecks(tt.args.candidate, tt.args.maxPoVSize, tt.args.pov,
tt.args.validationCodeHash)
require.NoError(t, internalError)
if tt.expectedError != nil {
require.EqualError(t, validationError, tt.expectedError.Error())
} else {
Expand Down
1 change: 0 additions & 1 deletion dot/parachain/candidate-validation/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types"
)

// TODO(ed): figure out a better name for this that describes what it does
type worker struct {
workerID parachaintypes.ValidationCodeHash
instance *parachainruntime.Instance
Expand Down
2 changes: 0 additions & 2 deletions dot/parachain/candidate-validation/worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
)

type workerPool struct {

// todo, make sure other functions work with paraID
workers map[parachaintypes.ValidationCodeHash]*worker
}

Expand Down

0 comments on commit b8bbeb2

Please sign in to comment.