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

sovereign extra header verifier in runtype components #6140

Merged
7 changes: 0 additions & 7 deletions cmd/sovereignnode/sovereignNodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import (
"github.com/multiversx/mx-chain-go/node/metrics"
trieIteratorsFactory "github.com/multiversx/mx-chain-go/node/trieIterators/factory"
"github.com/multiversx/mx-chain-go/process"
"github.com/multiversx/mx-chain-go/process/headerCheck"
"github.com/multiversx/mx-chain-go/process/interceptors"
"github.com/multiversx/mx-chain-go/process/rating"
"github.com/multiversx/mx-chain-go/sharding"
Expand Down Expand Up @@ -1639,17 +1638,11 @@ func (snr *sovereignNodeRunner) CreateSovereignArgsRunTypeComponents(coreCompone
return nil, err
}

sovHeaderSigVerifier, err := headerCheck.NewSovereignHeaderSigVerifier(cryptoComponents.BlockSigner())
if err != nil {
return nil, err
}

return &runType.ArgsSovereignRunTypeComponents{
RunTypeComponentsFactory: runTypeComponentsFactory,
Config: *snr.configs.SovereignExtraConfig,
DataCodec: dataCodecHandler,
TopicsChecker: incomingHeader.NewTopicsChecker(),
ExtraVerifier: sovHeaderSigVerifier,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion factory/runType/runTypeComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func (rcf *runTypeComponentsFactory) Create() (*runTypeComponents, error) {
consensusModel: consensus.ConsensusModelV1,
vmContainerMetaFactory: vmContainerMetaCreator,
vmContainerShardFactory: vmContainerShardCreator,
accountsParser: accountsParser,
accountsCreator: accountsCreator,
outGoingOperationsPoolHandler: disabled.NewDisabledOutGoingOperationPool(),
dataCodecHandler: disabled.NewDisabledDataCodec(),
Expand All @@ -252,7 +253,6 @@ func (rcf *runTypeComponentsFactory) Create() (*runTypeComponents, error) {
extraHeaderSigVerifierHandler: headerCheck.NewExtraHeaderSigVerifierHolder(),
genesisBlockCreatorFactory: processGenesis.NewGenesisBlockCreatorFactory(),
genesisMetaBlockCheckerCreator: processGenesis.NewGenesisMetaBlockChecker(),
accountsParser: accountsParser,
}, nil
}

Expand Down
2 changes: 2 additions & 0 deletions factory/runType/runTypeComponentsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/consensus"
"github.com/multiversx/mx-chain-go/consensus/mock"
"github.com/multiversx/mx-chain-go/errors"
"github.com/multiversx/mx-chain-go/factory"
"github.com/multiversx/mx-chain-go/factory/runType"
Expand Down Expand Up @@ -201,6 +202,7 @@ func createArgsRunTypeComponents() runType.ArgsRunTypeComponents {
},
CryptoComponents: &mockCoreComp.CryptoComponentsStub{
TxKeyGen: &mockCoreComp.KeyGenMock{},
BlockSig: &mock.SingleSignerMock{},
},
Configs: config.Configs{
EconomicsConfig: &config.EconomicsConfig{
Expand Down
14 changes: 6 additions & 8 deletions factory/runType/sovereignRunTypeComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
"github.com/multiversx/mx-chain-go/genesis"
"github.com/multiversx/mx-chain-go/genesis/parsing"
processComp "github.com/multiversx/mx-chain-go/genesis/process"
"github.com/multiversx/mx-chain-go/process"
"github.com/multiversx/mx-chain-go/process/block"
"github.com/multiversx/mx-chain-go/process/block/preprocess"
"github.com/multiversx/mx-chain-go/process/block/sovereign"
"github.com/multiversx/mx-chain-go/process/coordinator"
"github.com/multiversx/mx-chain-go/process/factory/interceptorscontainer"
"github.com/multiversx/mx-chain-go/process/headerCheck"
"github.com/multiversx/mx-chain-go/process/peer"
"github.com/multiversx/mx-chain-go/process/smartContract/hooks"
"github.com/multiversx/mx-chain-go/process/smartContract/processorV2"
Expand All @@ -42,15 +42,13 @@ type ArgsSovereignRunTypeComponents struct {
Config config.SovereignConfig
DataCodec sovereign.DataCodecHandler
TopicsChecker sovereign.TopicsCheckerHandler
ExtraVerifier process.ExtraHeaderSigVerifierHandler
}

type sovereignRunTypeComponentsFactory struct {
*runTypeComponentsFactory
sovConfig config.SovereignConfig
dataCodec sovereign.DataCodecHandler
topicsChecker sovereign.TopicsCheckerHandler
extraVerifier process.ExtraHeaderSigVerifierHandler
}

// NewSovereignRunTypeComponentsFactory will return a new instance of runTypeComponentsFactory
Expand All @@ -64,16 +62,12 @@ func NewSovereignRunTypeComponentsFactory(args ArgsSovereignRunTypeComponents) (
if check.IfNil(args.TopicsChecker) {
return nil, errors.ErrNilTopicsChecker
}
if check.IfNil(args.ExtraVerifier) {
return nil, errors.ErrNilExtraSubRoundSigner
}

return &sovereignRunTypeComponentsFactory{
runTypeComponentsFactory: args.RunTypeComponentsFactory,
sovConfig: args.Config,
dataCodec: args.DataCodec,
topicsChecker: args.TopicsChecker,
extraVerifier: args.ExtraVerifier,
}, nil
}

Expand Down Expand Up @@ -212,7 +206,11 @@ func (rcf *sovereignRunTypeComponentsFactory) Create() (*runTypeComponents, erro

expiryTime := time.Second * time.Duration(rcf.sovConfig.OutgoingSubscribedEvents.TimeToWaitForUnconfirmedOutGoingOperationInSeconds)

err = rtc.extraHeaderSigVerifierHandler.RegisterExtraHeaderSigVerifier(rcf.extraVerifier)
sovHeaderSigVerifier, err := headerCheck.NewSovereignHeaderSigVerifier(rcf.cryptoComponents.BlockSigner())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also removed from normal run type ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal RunType doesn't use an extra header sig verifier, it's just:
extraHeaderSigVerifierHandler: headerCheck.NewExtraHeaderSigVerifierHolder(),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the variable was wrong and confused me;
extraHeaderSigVerifierHandler -> this is a holder, not a handler, please rename it

if err != nil {
return nil, fmt.Errorf("sovereignRunTypeComponentsFactory - NewSovereignHeaderSigVerifier failed: %w", err)
}
err = rtc.extraHeaderSigVerifierHandler.RegisterExtraHeaderSigVerifier(sovHeaderSigVerifier)
if err != nil {
return nil, fmt.Errorf("sovereignRunTypeComponentsFactory - RegisterExtraHeaderSigVerifier failed: %w", err)
}
Expand Down
2 changes: 0 additions & 2 deletions factory/runType/sovereignRunTypeComponents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/errors"
"github.com/multiversx/mx-chain-go/factory/runType"
"github.com/multiversx/mx-chain-go/testscommon/headerSigVerifier"
"github.com/multiversx/mx-chain-go/testscommon/sovereign"

"github.com/stretchr/testify/require"
Expand All @@ -24,7 +23,6 @@ func createSovRunTypeArgs() runType.ArgsSovereignRunTypeComponents {
},
DataCodec: &sovereign.DataCodecMock{},
TopicsChecker: &sovereign.TopicsCheckerMock{},
ExtraVerifier: &headerSigVerifier.ExtraHeaderSigVerifierHandlerMock{},
}
}

Expand Down
4 changes: 2 additions & 2 deletions testscommon/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/multiversx/mx-chain-go/common"
commonFactory "github.com/multiversx/mx-chain-go/common/factory"
"github.com/multiversx/mx-chain-go/config"
mockConsensus "github.com/multiversx/mx-chain-go/consensus/mock"
"github.com/multiversx/mx-chain-go/consensus/spos"
"github.com/multiversx/mx-chain-go/consensus/spos/bls"
"github.com/multiversx/mx-chain-go/dataRetriever"
Expand Down Expand Up @@ -43,7 +44,6 @@ import (
"github.com/multiversx/mx-chain-go/testscommon/dblookupext"
"github.com/multiversx/mx-chain-go/testscommon/enableEpochsHandlerMock"
"github.com/multiversx/mx-chain-go/testscommon/hashingMocks"
"github.com/multiversx/mx-chain-go/testscommon/headerSigVerifier"
"github.com/multiversx/mx-chain-go/testscommon/mainFactoryMocks"
"github.com/multiversx/mx-chain-go/testscommon/marshallerMock"
"github.com/multiversx/mx-chain-go/testscommon/shardingMocks"
Expand Down Expand Up @@ -1023,6 +1023,7 @@ func createArgsRunTypeComponents() runType.ArgsRunTypeComponents {
},
CryptoComponents: &mockCoreComp.CryptoComponentsStub{
TxKeyGen: &mockCoreComp.KeyGenMock{},
BlockSig: &mockConsensus.SingleSignerMock{},
},
Configs: config.Configs{
EconomicsConfig: &config.EconomicsConfig{
Expand Down Expand Up @@ -1149,7 +1150,6 @@ func createSovRunTypeArgs() runType.ArgsSovereignRunTypeComponents {
},
DataCodec: &sovereign.DataCodecMock{},
TopicsChecker: &sovereign.TopicsCheckerMock{},
ExtraVerifier: &headerSigVerifier.ExtraHeaderSigVerifierHandlerMock{},
}
}

Expand Down