Skip to content

Commit

Permalink
make private functions/structs private
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmack committed Sep 4, 2024
1 parent 5820e3f commit 3e5ac28
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions 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
}

type BlockState interface {
Expand All @@ -29,7 +29,7 @@ type BlockState interface {
func NewCandidateValidation(overseerChan chan<- any, blockState BlockState) *CandidateValidation {
candidateValidation := CandidateValidation{
SubsystemToOverseer: overseerChan,
pvfHost: NewValidationHost(),
pvfHost: newValidationHost(),
BlockState: blockState,
}
return &candidateValidation
Expand Down Expand Up @@ -86,7 +86,7 @@ func (cv *CandidateValidation) processMessage(msg any) {
PvfExecTimeoutKind: msg.PvfExecTimeoutKind,
}

result, err := cv.pvfHost.Validate(validationTask)
result, err := cv.pvfHost.validate(validationTask)

if err != nil {
logger.Errorf("failed to validate from exhaustive: %w", err)
Expand Down Expand Up @@ -183,7 +183,7 @@ func (cv *CandidateValidation) validateFromChainState(msg ValidateFromChainState
PvfExecTimeoutKind: parachaintypes.PvfExecTimeoutKind{},
}

result, err := cv.pvfHost.Validate(validationTask)
result, err := cv.pvfHost.validate(validationTask)
if err != nil {
msg.Ch <- parachaintypes.OverseerFuncRes[ValidationResult]{
Err: err,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestCandidateValidation_processMessageValidateFromExhaustive(t *testing.T)
overseerToSubsystem := make(chan any)
sender := make(chan parachaintypes.OverseerFuncRes[ValidationResult])
candidateValidationSubsystem := CandidateValidation{
pvfHost: NewValidationHost(),
pvfHost: newValidationHost(),
}

t.Cleanup(candidateValidationSubsystem.Stop)
Expand Down Expand Up @@ -371,7 +371,7 @@ func TestCandidateValidation_processMessageValidateFromChainState(t *testing.T)
sender := make(chan parachaintypes.OverseerFuncRes[ValidationResult])
toSubsystem := make(chan any)
candidateValidationSubsystem := CandidateValidation{
pvfHost: NewValidationHost(),
pvfHost: newValidationHost(),
BlockState: mockBlockState,
}
defer candidateValidationSubsystem.Stop()
Expand Down
8 changes: 4 additions & 4 deletions dot/parachain/candidate-validation/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (

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

type Host struct {
type host struct {
workerPool *workerPool
}

func NewValidationHost() *Host {
return &Host{
func newValidationHost() *host {
return &host{
workerPool: newValidationWorkerPool(),
}
}

func (v *Host) Validate(msg *ValidationTask) (*ValidationResult, error) {
func (v *host) validate(msg *ValidationTask) (*ValidationResult, error) {
validationCodeHash := msg.ValidationCode.Hash()
// performBasicChecks
validationErr, internalErr := performBasicChecks(&msg.CandidateReceipt.Descriptor,
Expand Down
4 changes: 2 additions & 2 deletions dot/parachain/candidate-validation/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestHost_validate(t *testing.T) {
commitmentsHashMismatch := CommitmentsHashMismatch
executionError := ExecutionError

pvfHost := NewValidationHost()
pvfHost := newValidationHost()

bd, err := scale.Marshal(BlockDataInAdderParachain{
State: uint64(1),
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestHost_validate(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()

taskResult, err := pvfHost.Validate(tt.validationTask)
taskResult, err := pvfHost.validate(tt.validationTask)

require.NoError(t, err)
require.Equal(t, tt.want, taskResult)
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 @@ -44,7 +44,6 @@ func (w *worker) executeRequest(task *workerTask) (*ValidationResult, error) {
return processed, nil
}
validationResult, err := w.instance.ValidateBlock(task.work)

if err != nil {
logger.Errorf("executing validate_block: %w", err)
reasonForInvalidity := ExecutionError
Expand Down
5 changes: 3 additions & 2 deletions dot/parachain/candidate-validation/worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ func (v *workerPool) newValidationWorker(validationCode parachaintypes.Validatio
return nil
}

// submitRequest given a request, the worker pool will get the worker for a given workerID
// a channel in returned that the response will be dispatch on
// submitRequest given a request, the worker pool will get the worker for a given task and submit the request
// to the worker. The worker will execute the request and return the result. If the worker does not exist, a new worker
// will be created and the request will be submitted to the worker.
func (v *workerPool) submitRequest(msg *ValidationTask) (*ValidationResult, error) {
validationCodeHash := msg.ValidationCode.Hash()

Expand Down

0 comments on commit 3e5ac28

Please sign in to comment.