protected override void InitSealEngine() { if (_context.DbProvider == null) { throw new StepDependencyException(nameof(_context.DbProvider)); } if (_context.ChainSpec == null) { throw new StepDependencyException(nameof(_context.ChainSpec)); } if (_context.EthereumEcdsa == null) { throw new StepDependencyException(nameof(_context.EthereumEcdsa)); } if (_context.NodeKey == null) { throw new StepDependencyException(nameof(_context.NodeKey)); } AbiEncoder abiEncoder = new AbiEncoder(); _context.ValidatorStore = new ValidatorStore(_context.DbProvider.BlockInfosDb); IReadOnlyTransactionProcessorSource readOnlyTransactionProcessorSource = new ReadOnlyTransactionProcessorSource(_context.DbProvider, _context.BlockTree, _context.SpecProvider, _context.LogManager); IAuRaValidatorProcessorExtension validatorProcessorExtension = new AuRaValidatorProcessorFactory(_context.StateProvider, abiEncoder, _context.TransactionProcessor, readOnlyTransactionProcessorSource, _context.BlockTree, _context.ReceiptStorage, _context.ValidatorStore, _context.LogManager) .CreateValidatorProcessor(_context.ChainSpec.AuRa.Validators); AuRaStepCalculator auRaStepCalculator = new AuRaStepCalculator(_context.ChainSpec.AuRa.StepDuration, _context.Timestamper); _context.SealValidator = new AuRaSealValidator(_context.ChainSpec.AuRa, auRaStepCalculator, _context.ValidatorStore, _context.EthereumEcdsa, _context.LogManager); _context.RewardCalculatorSource = AuRaRewardCalculator.GetSource(_context.ChainSpec.AuRa, abiEncoder); _context.Sealer = new AuRaSealer(_context.BlockTree, _context.ValidatorStore, auRaStepCalculator, _context.NodeKey.Address, new BasicWallet(_context.NodeKey), new ValidSealerStrategy(), _context.LogManager); _context.AuRaBlockProcessorExtension = validatorProcessorExtension; }
public void returns_correct_validator_type(AuRaParameters.ValidatorType validatorType, Type expectedType) { var stateDb = Substitute.For <IDb>(); stateDb[Arg.Any <byte[]>()].Returns((byte[])null); var factory = new AuRaValidatorProcessorFactory(Substitute.For <IStateProvider>(), Substitute.For <IAbiEncoder>(), Substitute.For <ITransactionProcessor>(), Substitute.For <IReadOnlyTransactionProcessorSource>(), Substitute.For <IBlockTree>(), Substitute.For <IReceiptStorage>(), Substitute.For <IValidatorStore>(), LimboLogs.Instance); var validator = new AuRaParameters.Validator() { ValidatorType = validatorType, Addresses = new[] { Address.Zero }, Validators = new Dictionary <long, AuRaParameters.Validator>() { { 0, new AuRaParameters.Validator() { ValidatorType = AuRaParameters.ValidatorType.List, Addresses = new[] { Address.SystemUser } } } } }; var result = factory.CreateValidatorProcessor(validator); result.Should().BeOfType(expectedType); }
protected override BlockProcessor CreateBlockProcessor( ReadOnlyTxProcessingEnv readOnlyTxProcessingEnv, ReadOnlyTransactionProcessorSource readOnlyTransactionProcessorSource, IReadOnlyDbProvider readOnlyDbProvider) { if (_context.RewardCalculatorSource == null) { throw new StepDependencyException(nameof(_context.RewardCalculatorSource)); } if (_context.ValidatorStore == null) { throw new StepDependencyException(nameof(_context.ValidatorStore)); } if (_context.ChainSpec == null) { throw new StepDependencyException(nameof(_context.ChainSpec)); } var validator = new AuRaValidatorProcessorFactory( readOnlyTxProcessingEnv.StateProvider, _context.AbiEncoder, readOnlyTxProcessingEnv.TransactionProcessor, readOnlyTransactionProcessorSource, readOnlyTxProcessingEnv.BlockTree, _context.ReceiptStorage, _context.ValidatorStore, _context.LogManager) .CreateValidatorProcessor(_context.ChainSpec.AuRa.Validators); var blockProducer = new AuRaBlockProcessor( _context.SpecProvider, _context.BlockValidator, _context.RewardCalculatorSource.Get(readOnlyTxProcessingEnv.TransactionProcessor), readOnlyTxProcessingEnv.TransactionProcessor, readOnlyDbProvider.StateDb, readOnlyDbProvider.CodeDb, readOnlyTxProcessingEnv.StateProvider, readOnlyTxProcessingEnv.StorageProvider, _context.TxPool, _context.ReceiptStorage, _context.LogManager, validator, readOnlyTxProcessingEnv.BlockTree, GetTxPermissionFilter(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource, readOnlyTxProcessingEnv.StateProvider), GetGasLimitOverride(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource, readOnlyTxProcessingEnv.StateProvider)); validator.SetFinalizationManager(_context.FinalizationManager, true); return(blockProducer); }