From 5e46a60409eacb35e42419a65732ce51ef973a53 Mon Sep 17 00:00:00 2001 From: kanishka Date: Tue, 13 Jun 2023 16:40:10 +0530 Subject: [PATCH] add imports --- dot/parachain/dispute/mock_runtime_test.go | 33 +------------------ dot/parachain/dispute/mocks_generate_test.go | 1 + .../dispute/scraping/mock_runtime_test.go | 2 +- dot/parachain/mock_runtime_test.go | 31 ----------------- dot/parachain/runtime/instance.go | 7 ++++ lib/babe/inherents/parachain_inherents.go | 6 ++-- 6 files changed, 13 insertions(+), 67 deletions(-) diff --git a/dot/parachain/dispute/mock_runtime_test.go b/dot/parachain/dispute/mock_runtime_test.go index 9d74281b525..d3c1b16388e 100644 --- a/dot/parachain/dispute/mock_runtime_test.go +++ b/dot/parachain/dispute/mock_runtime_test.go @@ -1,7 +1,7 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/ChainSafe/gossamer/dot/parachain/runtime (interfaces: RuntimeInstance) -// Package dispute is a generated GoMock package. +// Package parachain is a generated GoMock package. package dispute import ( @@ -9,7 +9,6 @@ import ( parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types" common "github.com/ChainSafe/gossamer/lib/common" - scale "github.com/ChainSafe/gossamer/pkg/scale" gomock "github.com/golang/mock/gomock" ) @@ -36,21 +35,6 @@ func (m *MockRuntimeInstance) EXPECT() *MockRuntimeInstanceMockRecorder { return m.recorder } -// ParachainHostCandidateEvents mocks base method. -func (m *MockRuntimeInstance) ParachainHostCandidateEvents(arg0 common.Hash) (*scale.VaryingDataTypeSlice, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParachainHostCandidateEvents", arg0) - ret0, _ := ret[0].(*scale.VaryingDataTypeSlice) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ParachainHostCandidateEvents indicates an expected call of ParachainHostCandidateEvents. -func (mr *MockRuntimeInstanceMockRecorder) ParachainHostCandidateEvents(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParachainHostCandidateEvents", reflect.TypeOf((*MockRuntimeInstance)(nil).ParachainHostCandidateEvents), arg0) -} - // ParachainHostCheckValidationOutputs mocks base method. func (m *MockRuntimeInstance) ParachainHostCheckValidationOutputs(arg0 uint32, arg1 parachaintypes.CandidateCommitments) (bool, error) { m.ctrl.T.Helper() @@ -66,21 +50,6 @@ func (mr *MockRuntimeInstanceMockRecorder) ParachainHostCheckValidationOutputs(a return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParachainHostCheckValidationOutputs", reflect.TypeOf((*MockRuntimeInstance)(nil).ParachainHostCheckValidationOutputs), arg0, arg1) } -// ParachainHostOnChainVotes mocks base method. -func (m *MockRuntimeInstance) ParachainHostOnChainVotes(arg0 common.Hash) (*parachaintypes.ScrapedOnChainVotes, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParachainHostOnChainVotes", arg0) - ret0, _ := ret[0].(*parachaintypes.ScrapedOnChainVotes) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ParachainHostOnChainVotes indicates an expected call of ParachainHostOnChainVotes. -func (mr *MockRuntimeInstanceMockRecorder) ParachainHostOnChainVotes(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParachainHostOnChainVotes", reflect.TypeOf((*MockRuntimeInstance)(nil).ParachainHostOnChainVotes), arg0) -} - // ParachainHostPersistedValidationData mocks base method. func (m *MockRuntimeInstance) ParachainHostPersistedValidationData(arg0 uint32, arg1 parachaintypes.OccupiedCoreAssumption) (*parachaintypes.PersistedValidationData, error) { m.ctrl.T.Helper() diff --git a/dot/parachain/dispute/mocks_generate_test.go b/dot/parachain/dispute/mocks_generate_test.go index 3b419880596..5a8837cb971 100644 --- a/dot/parachain/dispute/mocks_generate_test.go +++ b/dot/parachain/dispute/mocks_generate_test.go @@ -3,4 +3,5 @@ package dispute +//go:generate mockgen -destination=mocks_test.go -package=$GOPACKAGE . PoVRequestor //go:generate mockgen -destination=mock_runtime_test.go -package $GOPACKAGE github.com/ChainSafe/gossamer/dot/parachain/runtime RuntimeInstance diff --git a/dot/parachain/dispute/scraping/mock_runtime_test.go b/dot/parachain/dispute/scraping/mock_runtime_test.go index 858babf7477..3ce550991eb 100644 --- a/dot/parachain/dispute/scraping/mock_runtime_test.go +++ b/dot/parachain/dispute/scraping/mock_runtime_test.go @@ -124,4 +124,4 @@ func (m *MockRuntimeInstance) ParachainHostValidationCodeByHash(arg0 common.Hash func (mr *MockRuntimeInstanceMockRecorder) ParachainHostValidationCodeByHash(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParachainHostValidationCodeByHash", reflect.TypeOf((*MockRuntimeInstance)(nil).ParachainHostValidationCodeByHash), arg0, arg1) -} +} \ No newline at end of file diff --git a/dot/parachain/mock_runtime_test.go b/dot/parachain/mock_runtime_test.go index d9614670168..e032f9bc54a 100644 --- a/dot/parachain/mock_runtime_test.go +++ b/dot/parachain/mock_runtime_test.go @@ -9,7 +9,6 @@ import ( parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types" common "github.com/ChainSafe/gossamer/lib/common" - scale "github.com/ChainSafe/gossamer/pkg/scale" gomock "github.com/golang/mock/gomock" ) @@ -36,21 +35,6 @@ func (m *MockRuntimeInstance) EXPECT() *MockRuntimeInstanceMockRecorder { return m.recorder } -// ParachainHostCandidateEvents mocks base method. -func (m *MockRuntimeInstance) ParachainHostCandidateEvents(arg0 common.Hash) (*scale.VaryingDataTypeSlice, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParachainHostCandidateEvents", arg0) - ret0, _ := ret[0].(*scale.VaryingDataTypeSlice) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ParachainHostCandidateEvents indicates an expected call of ParachainHostCandidateEvents. -func (mr *MockRuntimeInstanceMockRecorder) ParachainHostCandidateEvents(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParachainHostCandidateEvents", reflect.TypeOf((*MockRuntimeInstance)(nil).ParachainHostCandidateEvents), arg0) -} - // ParachainHostCheckValidationOutputs mocks base method. func (m *MockRuntimeInstance) ParachainHostCheckValidationOutputs(arg0 uint32, arg1 parachaintypes.CandidateCommitments) (bool, error) { m.ctrl.T.Helper() @@ -66,21 +50,6 @@ func (mr *MockRuntimeInstanceMockRecorder) ParachainHostCheckValidationOutputs(a return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParachainHostCheckValidationOutputs", reflect.TypeOf((*MockRuntimeInstance)(nil).ParachainHostCheckValidationOutputs), arg0, arg1) } -// ParachainHostOnChainVotes mocks base method. -func (m *MockRuntimeInstance) ParachainHostOnChainVotes(arg0 common.Hash) (*parachaintypes.ScrapedOnChainVotes, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParachainHostOnChainVotes", arg0) - ret0, _ := ret[0].(*parachaintypes.ScrapedOnChainVotes) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ParachainHostOnChainVotes indicates an expected call of ParachainHostOnChainVotes. -func (mr *MockRuntimeInstanceMockRecorder) ParachainHostOnChainVotes(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParachainHostOnChainVotes", reflect.TypeOf((*MockRuntimeInstance)(nil).ParachainHostOnChainVotes), arg0) -} - // ParachainHostPersistedValidationData mocks base method. func (m *MockRuntimeInstance) ParachainHostPersistedValidationData(arg0 uint32, arg1 parachaintypes.OccupiedCoreAssumption) (*parachaintypes.PersistedValidationData, error) { m.ctrl.T.Helper() diff --git a/dot/parachain/runtime/instance.go b/dot/parachain/runtime/instance.go index c5a34299df2..4895f8eb735 100644 --- a/dot/parachain/runtime/instance.go +++ b/dot/parachain/runtime/instance.go @@ -5,6 +5,7 @@ package parachain import ( "bytes" + "errors" "fmt" parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types" @@ -13,6 +14,12 @@ import ( "github.com/ChainSafe/gossamer/pkg/scale" ) +var ( + ErrCodeEmpty = errors.New("code is empty") + ErrWASMDecompress = errors.New("wasm decompression failed") + ErrInstanceIsStopped = errors.New("instance is stopped") +) + // ValidationResult is result received from validate_block. It is similar to CandidateCommitments, but different order. type ValidationResult struct { // The head-data is the new head data that should be included in the relay chain state. diff --git a/lib/babe/inherents/parachain_inherents.go b/lib/babe/inherents/parachain_inherents.go index 1ae8fd4a6f9..91a5d51ab2a 100644 --- a/lib/babe/inherents/parachain_inherents.go +++ b/lib/babe/inherents/parachain_inherents.go @@ -369,7 +369,7 @@ type backedCandidate struct { } // MultiDisputeStatementSet is a set of dispute statements. -type MultiDisputeStatementSet []DisputeStatementSet +type MultiDisputeStatementSet []disputeStatementSet // validatorIndex is the index of the validator. type validatorIndex uint32 @@ -387,8 +387,8 @@ type statement struct { DisputeStatement DisputeStatement } -// DisputeStatementSet is a set of statements about a specific candidate. -type DisputeStatementSet struct { +// disputeStatementSet is a set of statements about a specific candidate. +type disputeStatementSet struct { // The candidate referenced by this set. CandidateHash common.Hash `scale:"1"` // The session index of the candidate.