public AuRaSealValidator(AuRaParameters parameters, IAuRaStepCalculator stepCalculator, IAuRaValidator validator, IEthereumEcdsa ecdsa, ILogManager logManager) { _parameters = parameters ?? throw new ArgumentNullException(nameof(parameters)); _stepCalculator = stepCalculator ?? throw new ArgumentNullException(nameof(stepCalculator)); _validator = validator ?? throw new ArgumentNullException(nameof(validator)); _ecdsa = ecdsa ?? throw new ArgumentNullException(nameof(ecdsa)); _logger = logManager.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); }
public AuRaBlockFinalizationManager(IBlockTree blockTree, IChainLevelInfoRepository chainLevelInfoRepository, IBlockProcessor blockProcessor, IAuRaValidator auRaValidator, ILogManager logManager) { _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _chainLevelInfoRepository = chainLevelInfoRepository ?? throw new ArgumentNullException(nameof(chainLevelInfoRepository)); _auRaValidator = auRaValidator ?? throw new ArgumentNullException(nameof(auRaValidator)); _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _blockProcessor = blockProcessor ?? throw new ArgumentNullException(nameof(blockProcessor)); _blockProcessor.BlockProcessed += OnBlockProcessed; Initialize(); }
public void Initialize() { _chainLevelInfoRepository = Substitute.For <IChainLevelInfoRepository>(); _blockProcessor = Substitute.For <IBlockProcessor>(); _auraValidator = Substitute.For <IAuRaValidator>(); _logManager = Substitute.For <ILogManager>(); _auraValidator.MinSealersForFinalization.Returns(2); Rlp.Decoders[typeof(BlockInfo)] = new BlockInfoDecoder(true); }
public AuRaSealer( IBlockTree blockTree, IAuRaValidator validator, IAuRaStepCalculator auRaStepCalculator, Address nodeAddress, IBasicWallet wallet, ILogManager logManager) { _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _validator = validator ?? throw new ArgumentNullException(nameof(validator)); _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _nodeAddress = nodeAddress ?? throw new ArgumentNullException(nameof(nodeAddress)); _wallet = wallet ?? throw new ArgumentNullException(nameof(wallet)); _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); }
public void returns_correct_validator_type(AuRaParameters.ValidatorType validatorType, Type expectedType) { IDb stateDb = Substitute.For <IDb>(); stateDb[Arg.Any <byte[]>()].Returns((byte[])null); AuRaValidatorFactory factory = new(Substitute.For <IAbiEncoder>(), Substitute.For <IStateProvider>(), Substitute.For <ITransactionProcessor>(), Substitute.For <IBlockTree>(), Substitute.For <IReadOnlyTxProcessorSource>(), Substitute.For <IReceiptStorage>(), Substitute.For <IValidatorStore>(), Substitute.For <IAuRaBlockFinalizationManager>(), Substitute.For <ITxSender>(), Substitute.For <ITxPool>(), new MiningConfig(), LimboLogs.Instance, Substitute.For <ISigner>(), Substitute.For <ISpecProvider>(), Substitute.For <IGasPriceOracle>(), new ReportingContractBasedValidator.Cache(), long.MaxValue); AuRaParameters.Validator validator = new() { ValidatorType = validatorType, Addresses = new[] { Address.Zero }, Validators = new Dictionary <long, AuRaParameters.Validator>() { { 0, new AuRaParameters.Validator() { ValidatorType = AuRaParameters.ValidatorType.List, Addresses = new[] { Address.SystemUser } } } } }; IAuRaValidator result = factory.CreateValidatorProcessor(validator); result.Should().BeOfType(expectedType); } }
public void Setup() { _blockTree = Substitute.For <IBlockTree>(); _headStep = 10; _blockTree.Head.Returns(Build.A.BlockHeader.WithHash(Keccak.Compute("hash")).WithAura(_headStep, Bytes.Empty).TestObject); _auRaStepCalculator = Substitute.For <IAuRaStepCalculator>(); _auRaValidator = Substitute.For <IAuRaValidator>(); var wallet = new DevWallet(new WalletConfig(), NullLogManager.Instance); _address = wallet.NewAccount(new NetworkCredential(string.Empty, "AAA").SecurePassword); _auRaSealer = new AuRaSealer( _blockTree, _auRaValidator, _auRaStepCalculator, _address, wallet, NullLogManager.Instance); }
private void SetCurrentValidator(long finalizedAtBlockNumber, AuRaParameters.Validator validatorPrototype, BlockHeader parentHeader) { if (validatorPrototype != _currentValidatorPrototype) { (_currentValidator as IDisposable)?.Dispose(); _currentValidator = CreateValidator(finalizedAtBlockNumber, validatorPrototype, parentHeader); _currentValidatorPrototype = validatorPrototype; if (!_forSealing) { if (_currentValidator.Validators != null) { _validatorStore.SetValidators(finalizedAtBlockNumber, _currentValidator.Validators); } else if (_blockTree.Head != null) { if (_logger.IsWarn) { _logger.Warn($"Validators not found in validator initialized at block {finalizedAtBlockNumber}, even after genesis block loaded."); } } } } }
public static IReportingValidator GetReportingValidator(this IAuRaValidator validator) => validator as IReportingValidator ?? NullReportingValidator.Instance;
public AuRaSealValidator(IAuRaValidator validator, IEthereumEcdsa ecdsa, ILogManager logManager) { _validator = validator ?? throw new ArgumentNullException(nameof(validator)); _ecdsa = ecdsa ?? throw new ArgumentNullException(nameof(ecdsa)); _logger = logManager.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); }