/// <summary> /// Processes to the next epoch transition, up to and including the sub-transition named ``process_name`` /// - pre-state('pre'), state before calling ``process_name`` /// - post-state('post'), state after calling ``process_name`` /// </summary> public static void RunEpochProcessingWith(IServiceProvider testServiceProvider, BeaconState state, TestProcessStep step) { RunEpochProcessingTo(testServiceProvider, state, step); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); if (step == TestProcessStep.ProcessJustificationAndFinalization) { beaconStateTransition.ProcessJustificationAndFinalization(state); return; } if (step == TestProcessStep.ProcessRewardsAndPenalties) { beaconStateTransition.ProcessRewardsAndPenalties(state); return; } if (step == TestProcessStep.ProcessRegistryUpdates) { beaconStateTransition.ProcessRegistryUpdates(state); return; } if (step == TestProcessStep.ProcessSlashings) { beaconStateTransition.ProcessSlashings(state); return; } if (step == TestProcessStep.ProcessFinalUpdates) { beaconStateTransition.ProcessFinalUpdates(state); return; } throw new NotImplementedException(); }
public void FullAttestations() { // Arrange IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider(); BeaconState state = TestState.PrepareTestState(testServiceProvider); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); var attestations = PrepareStateWithFullAttestations(testServiceProvider, state); BeaconState preState = BeaconState.Clone(state); // Act RunProcessRewardsAndPenalties(testServiceProvider, state); // Assert var pendingAttestations = attestations.Select(x => new PendingAttestation(x.AggregationBits, x.Data, Slot.None, ValidatorIndex.None)); var attestingIndices = beaconStateTransition.GetUnslashedAttestingIndices(state, pendingAttestations).ToList(); attestingIndices.Count.ShouldBeGreaterThan(0); for (int index = 0; index < preState.Validators.Count; index++) { ValidatorIndex validatorIndex = new ValidatorIndex((ulong)index); if (attestingIndices.Contains(validatorIndex)) { state.Balances[index].ShouldBeGreaterThan(preState.Balances[index], $"Attesting balance {index}"); } else { state.Balances[index].ShouldBeLessThan(preState.Balances[index], $"Non-attesting balance {index}"); } } }
public ForkChoice( ILogger <ForkChoice> logger, IOptionsMonitor <MiscellaneousParameters> miscellaneousParameterOptions, IOptionsMonitor <InitialValues> initialValueOptions, IOptionsMonitor <TimeParameters> timeParameterOptions, IOptionsMonitor <StateListLengths> stateListLengthOptions, IOptionsMonitor <MaxOperationsPerBlock> maxOperationsPerBlockOptions, IOptionsMonitor <ForkChoiceConfiguration> forkChoiceConfigurationOptions, IOptionsMonitor <SignatureDomains> signatureDomainOptions, ICryptographyService cryptographyService, BeaconChainUtility beaconChainUtility, BeaconStateAccessor beaconStateAccessor, BeaconStateTransition beaconStateTransition, IStoreProvider storeProvider) { _logger = logger; _miscellaneousParameterOptions = miscellaneousParameterOptions; _initialValueOptions = initialValueOptions; _timeParameterOptions = timeParameterOptions; _stateListLengthOptions = stateListLengthOptions; _maxOperationsPerBlockOptions = maxOperationsPerBlockOptions; _forkChoiceConfigurationOptions = forkChoiceConfigurationOptions; _signatureDomainOptions = signatureDomainOptions; _cryptographyService = cryptographyService; _beaconChainUtility = beaconChainUtility; _beaconStateAccessor = beaconStateAccessor; _beaconStateTransition = beaconStateTransition; _storeProvider = storeProvider; }
public GenesisChainStart(ILogger <GenesisChainStart> logger, ChainConstants chainConstants, IOptionsMonitor <MiscellaneousParameters> miscellaneousParameterOptions, IOptionsMonitor <GweiValues> gweiValueOptions, IOptionsMonitor <InitialValues> initialValueOptions, IOptionsMonitor <TimeParameters> timeParameterOptions, IOptionsMonitor <StateListLengths> stateListLengthOptions, ICryptographyService cryptographyService, IStore store, BeaconStateAccessor beaconStateAccessor, BeaconStateTransition beaconStateTransition, IForkChoice forkChoice, IDepositStore depositStore) { _logger = logger; _beaconStateAccessor = beaconStateAccessor; _beaconStateTransition = beaconStateTransition; _forkChoice = forkChoice; _depositStore = depositStore; _chainConstants = chainConstants; _miscellaneousParameterOptions = miscellaneousParameterOptions; _gweiValueOptions = gweiValueOptions; _initialValueOptions = initialValueOptions; _timeParameterOptions = timeParameterOptions; _stateListLengthOptions = stateListLengthOptions; _cryptographyService = cryptographyService; _store = store; }
public BlockProducer(ILogger <BlockProducer> logger, IOptionsMonitor <MiscellaneousParameters> miscellaneousParameterOptions, IOptionsMonitor <TimeParameters> timeParameterOptions, IOptionsMonitor <StateListLengths> stateListLengthOptions, IOptionsMonitor <MaxOperationsPerBlock> maxOperationsPerBlockOptions, IOptionsMonitor <HonestValidatorConstants> honestValidatorConstantOptions, ICryptographyService cryptographyService, BeaconStateTransition beaconStateTransition, ForkChoice forkChoice, IStoreProvider storeProvider, IEth1DataProvider eth1DataProvider, IOperationPool operationPool) { _logger = logger; _miscellaneousParameterOptions = miscellaneousParameterOptions; _timeParameterOptions = timeParameterOptions; _stateListLengthOptions = stateListLengthOptions; _maxOperationsPerBlockOptions = maxOperationsPerBlockOptions; _honestValidatorConstantOptions = honestValidatorConstantOptions; _cryptographyService = cryptographyService; _beaconStateTransition = beaconStateTransition; _forkChoice = forkChoice; _storeProvider = storeProvider; _eth1DataProvider = eth1DataProvider; _operationPool = operationPool; }
public ForkChoice( ILogger <ForkChoice> logger, ChainConstants chainConstants, IOptionsMonitor <MiscellaneousParameters> miscellaneousParameterOptions, IOptionsMonitor <TimeParameters> timeParameterOptions, IOptionsMonitor <MaxOperationsPerBlock> maxOperationsPerBlockOptions, IOptionsMonitor <ForkChoiceConfiguration> forkChoiceConfigurationOptions, IOptionsMonitor <SignatureDomains> signatureDomainOptions, ICryptographyService cryptographyService, IBeaconChainUtility beaconChainUtility, BeaconStateAccessor beaconStateAccessor, BeaconStateTransition beaconStateTransition) { _logger = logger; _chainConstants = chainConstants; _miscellaneousParameterOptions = miscellaneousParameterOptions; _timeParameterOptions = timeParameterOptions; _maxOperationsPerBlockOptions = maxOperationsPerBlockOptions; _forkChoiceConfigurationOptions = forkChoiceConfigurationOptions; _signatureDomainOptions = signatureDomainOptions; _cryptographyService = cryptographyService; _beaconChainUtility = beaconChainUtility; _beaconStateAccessor = beaconStateAccessor; _beaconStateTransition = beaconStateTransition; }
// Run ``process_voluntary_exit``, yielding: // - pre-state('pre') // - voluntary_exit('voluntary_exit') // - post-state('post'). //If ``valid == False``, run expecting ``AssertionError`` private void RunVoluntaryExitProcessing(IServiceProvider testServiceProvider, BeaconState state, SignedVoluntaryExit signedVoluntaryExit, bool expectValid) { TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; MaxOperationsPerBlock maxOperationsPerBlock = testServiceProvider.GetService <IOptions <MaxOperationsPerBlock> >().Value; ChainConstants chainConstants = testServiceProvider.GetService <ChainConstants>(); BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); // Act if (!expectValid) { Should.Throw <Exception>(() => { beaconStateTransition.ProcessVoluntaryExit(state, signedVoluntaryExit); }); return; } ValidatorIndex validatorIndex = signedVoluntaryExit.Message.ValidatorIndex; Epoch preExitEpoch = state.Validators[(int)(ulong)validatorIndex].ExitEpoch; beaconStateTransition.ProcessVoluntaryExit(state, signedVoluntaryExit); // Assert preExitEpoch.ShouldBe(chainConstants.FarFutureEpoch); Epoch postExitEpoch = state.Validators[(int)(ulong)validatorIndex].ExitEpoch; postExitEpoch.ShouldBeLessThan(chainConstants.FarFutureEpoch); }
// Run ``process_deposit``, yielding: // - pre-state('pre') // - deposit('deposit') // - post-state('post'). //If ``valid == False``, run expecting ``AssertionError`` private void RunDepositProcessing(IServiceProvider testServiceProvider, BeaconState state, Deposit deposit, ValidatorIndex validatorIndex, bool expectValid, bool effective) { GweiValues gweiValues = testServiceProvider.GetService <IOptions <GweiValues> >().Value; BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); int preValidatorCount = state.Validators.Count; Gwei preBalance = Gwei.Zero; if ((int)(ulong)validatorIndex < preValidatorCount) { preBalance = TestState.GetBalance(state, validatorIndex); } if (!expectValid) { Should.Throw <Exception>(() => { beaconStateTransition.ProcessDeposit(state, deposit); }); return; } beaconStateTransition.ProcessDeposit(state, deposit); if (!effective) { state.Validators.Count.ShouldBe(preValidatorCount); state.Balances.Count.ShouldBe(preValidatorCount); if ((int)(ulong)validatorIndex < preValidatorCount) { Gwei balance = TestState.GetBalance(state, validatorIndex); balance.ShouldBe(preBalance); } } else { if ((int)(ulong)validatorIndex < preValidatorCount) { // top up state.Validators.Count.ShouldBe(preValidatorCount); state.Balances.Count.ShouldBe(preValidatorCount); } else { // new validator state.Validators.Count.ShouldBe(preValidatorCount + 1); state.Balances.Count.ShouldBe(preValidatorCount + 1); } Gwei balance = TestState.GetBalance(state, validatorIndex); Gwei expectedBalance = preBalance + deposit.Data.Item.Amount; balance.ShouldBe(expectedBalance); Gwei expectedEffectiveBalance = Gwei.Min(gweiValues.MaximumEffectiveBalance, expectedBalance); expectedEffectiveBalance -= expectedEffectiveBalance % gweiValues.EffectiveBalanceIncrement; state.Validators[(int)(ulong)validatorIndex].EffectiveBalance.ShouldBe(expectedEffectiveBalance); } state.Eth1DepositIndex.ShouldBe(state.Eth1Data.DepositCount); }
/// <summary> /// Transition to the next slot. /// </summary> public static void NextSlot(IServiceProvider testServiceProvider, BeaconState state) { BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); Slot slot = state.Slot + new Slot(1); beaconStateTransition.ProcessSlots(state, slot); }
/// <summary> /// Transition to the start slot of the next epoch /// </summary> public static void NextEpoch(IServiceProvider testServiceProvider, BeaconState state) { TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); Slot slot = (Slot)(state.Slot + timeParameters.SlotsPerEpoch - state.Slot % timeParameters.SlotsPerEpoch); beaconStateTransition.ProcessSlots(state, slot); }
public async Task GenesisWithEmptyParametersTimeShouldReject() { // Arrange IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider(); ChainConstants chainConstants = testServiceProvider.GetService <ChainConstants>(); IOptionsMonitor <MiscellaneousParameters> miscellaneousParameterOptions = testServiceProvider.GetService <IOptionsMonitor <MiscellaneousParameters> >(); IOptionsMonitor <GweiValues> gweiValueOptions = testServiceProvider.GetService <IOptionsMonitor <GweiValues> >(); IOptionsMonitor <InitialValues> initialValueOptions = testServiceProvider.GetService <IOptionsMonitor <InitialValues> >(); IOptionsMonitor <TimeParameters> timeParameterOptions = testServiceProvider.GetService <IOptionsMonitor <TimeParameters> >(); IOptionsMonitor <StateListLengths> stateListLengthOptions = testServiceProvider.GetService <IOptionsMonitor <StateListLengths> >(); IOptionsMonitor <RewardsAndPenalties> rewardsAndPenaltiesOptions = testServiceProvider.GetService <IOptionsMonitor <RewardsAndPenalties> >(); IOptionsMonitor <MaxOperationsPerBlock> maxOperationsPerBlockOptions = testServiceProvider.GetService <IOptionsMonitor <MaxOperationsPerBlock> >(); IOptionsMonitor <ForkChoiceConfiguration> forkChoiceConfigurationOptions = testServiceProvider.GetService <IOptionsMonitor <ForkChoiceConfiguration> >(); IOptionsMonitor <SignatureDomains> signatureDomainOptions = testServiceProvider.GetService <IOptionsMonitor <SignatureDomains> >(); miscellaneousParameterOptions.CurrentValue.MinimumGenesisActiveValidatorCount = 2; LoggerFactory loggerFactory = new LoggerFactory(new[] { new ConsoleLoggerProvider(TestOptionsMonitor.Create(new ConsoleLoggerOptions())) }); ICryptographyService cryptographyService = testServiceProvider.GetService <ICryptographyService>(); BeaconChainUtility beaconChainUtility = new BeaconChainUtility(loggerFactory.CreateLogger <BeaconChainUtility>(), miscellaneousParameterOptions, gweiValueOptions, timeParameterOptions, cryptographyService); BeaconStateAccessor beaconStateAccessor = new BeaconStateAccessor(miscellaneousParameterOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, signatureDomainOptions, cryptographyService, beaconChainUtility); BeaconStateMutator beaconStateMutator = new BeaconStateMutator(chainConstants, timeParameterOptions, stateListLengthOptions, rewardsAndPenaltiesOptions, beaconChainUtility, beaconStateAccessor); BeaconStateTransition beaconStateTransition = new BeaconStateTransition(loggerFactory.CreateLogger <BeaconStateTransition>(), chainConstants, miscellaneousParameterOptions, gweiValueOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, rewardsAndPenaltiesOptions, maxOperationsPerBlockOptions, signatureDomainOptions, cryptographyService, beaconChainUtility, beaconStateAccessor, beaconStateMutator); BeaconNode.Genesis beaconChain = new BeaconNode.Genesis(loggerFactory.CreateLogger <BeaconNode.Genesis>(), chainConstants, miscellaneousParameterOptions, gweiValueOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, maxOperationsPerBlockOptions, cryptographyService, beaconStateAccessor, beaconStateTransition); MemoryStoreProvider storeProvider = new MemoryStoreProvider(loggerFactory, timeParameterOptions); ForkChoice forkChoice = new ForkChoice(loggerFactory.CreateLogger <ForkChoice>(), miscellaneousParameterOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, maxOperationsPerBlockOptions, forkChoiceConfigurationOptions, signatureDomainOptions, cryptographyService, beaconChainUtility, beaconStateAccessor, beaconStateTransition, storeProvider); ChainStart chainStart = new ChainStart(loggerFactory.CreateLogger <ChainStart>(), beaconChain, forkChoice); // Act Hash32 eth1BlockHash = Hash32.Zero; ulong eth1Timestamp = 106185600uL; // 1973-05-14 Deposit[] deposits = Array.Empty <Deposit>(); bool success = await chainStart.TryGenesisAsync(eth1BlockHash, eth1Timestamp, deposits); // Assert success.ShouldBeFalse(); }
public static void SignBlock(IServiceProvider testServiceProvider, BeaconState state, BeaconBlock block, ValidatorIndex proposerIndex) { MiscellaneousParameters miscellaneousParameters = testServiceProvider.GetService <IOptions <MiscellaneousParameters> >().Value; TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; MaxOperationsPerBlock maxOperationsPerBlock = testServiceProvider.GetService <IOptions <MaxOperationsPerBlock> >().Value; SignatureDomains signatureDomains = testServiceProvider.GetService <IOptions <SignatureDomains> >().Value; ICryptographyService cryptographyService = testServiceProvider.GetService <ICryptographyService>(); BeaconChainUtility beaconChainUtility = testServiceProvider.GetService <BeaconChainUtility>(); BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); if (state.Slot > block.Slot) { throw new ArgumentOutOfRangeException("block.Slot", block.Slot, $"Slot of block must be equal or less that state slot {state.Slot}"); } Epoch blockEpoch = beaconChainUtility.ComputeEpochAtSlot(block.Slot); if (proposerIndex == ValidatorIndex.None) { if (block.Slot == state.Slot) { proposerIndex = beaconStateAccessor.GetBeaconProposerIndex(state); } else { Epoch stateEpoch = beaconChainUtility.ComputeEpochAtSlot(state.Slot); if (stateEpoch + 1 > blockEpoch) { Console.WriteLine("WARNING: Block slot far away, and no proposer index manually given." + " Signing block is slow due to transition for proposer index calculation."); } // use stub state to get proposer index of future slot BeaconState stubState = BeaconState.Clone(state); beaconStateTransition.ProcessSlots(stubState, block.Slot); proposerIndex = beaconStateAccessor.GetBeaconProposerIndex(stubState); } } byte[][] privateKeys = TestKeys.PrivateKeys(timeParameters).ToArray(); byte[] privateKey = privateKeys[(int)(ulong)proposerIndex]; Domain randaoDomain = beaconStateAccessor.GetDomain(state, signatureDomains.Randao, blockEpoch); Hash32 randaoRevealHash = blockEpoch.HashTreeRoot(); BlsSignature randaoReveal = TestSecurity.BlsSign(randaoRevealHash, privateKey, randaoDomain); block.Body.SetRandaoReveal(randaoReveal); Domain signatureDomain = beaconStateAccessor.GetDomain(state, signatureDomains.BeaconProposer, blockEpoch); Hash32 signingRoot = cryptographyService.SigningRoot(block); BlsSignature signature = TestSecurity.BlsSign(signingRoot, privateKey, signatureDomain); block.SetSignature(signature); }
public static SignedBeaconBlock SignBlock(IServiceProvider testServiceProvider, BeaconState state, BeaconBlock block, ValidatorIndex?optionalProposerIndex) { TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; SignatureDomains signatureDomains = testServiceProvider.GetService <IOptions <SignatureDomains> >().Value; ICryptographyService cryptographyService = testServiceProvider.GetService <ICryptographyService>(); BeaconChainUtility beaconChainUtility = testServiceProvider.GetService <BeaconChainUtility>(); BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); if (state.Slot > block.Slot) { throw new ArgumentOutOfRangeException("block.Slot", block.Slot, $"Slot of block must be equal or less that state slot {state.Slot}"); } Epoch blockEpoch = beaconChainUtility.ComputeEpochAtSlot(block.Slot); ValidatorIndex proposerIndex; if (optionalProposerIndex.HasValue) { proposerIndex = optionalProposerIndex.Value; } else { if (block.Slot == state.Slot) { proposerIndex = beaconStateAccessor.GetBeaconProposerIndex(state); } else { Epoch stateEpoch = beaconChainUtility.ComputeEpochAtSlot(state.Slot); if (stateEpoch + 1 > blockEpoch) { Console.WriteLine("WARNING: Block slot far away, and no proposer index manually given." + " Signing block is slow due to transition for proposer index calculation."); } // use stub state to get proposer index of future slot BeaconState stubState = BeaconState.Clone(state); beaconStateTransition.ProcessSlots(stubState, block.Slot); proposerIndex = beaconStateAccessor.GetBeaconProposerIndex(stubState); } } byte[][] privateKeys = TestKeys.PrivateKeys(timeParameters).ToArray(); byte[] privateKey = privateKeys[(int)(ulong)proposerIndex]; Root blockHashTreeRoot = cryptographyService.HashTreeRoot(block); Domain proposerDomain = beaconStateAccessor.GetDomain(state, signatureDomains.BeaconProposer, blockEpoch); Root signingRoot = beaconChainUtility.ComputeSigningRoot(blockHashTreeRoot, proposerDomain); BlsSignature signature = TestSecurity.BlsSign(signingRoot, privateKey); return(new SignedBeaconBlock(block, signature)); }
/// <summary> /// Processes to the next epoch transition, up to, but not including, the sub-transition named ``process_name`` /// </summary> public static void RunEpochProcessingTo(IServiceProvider testServiceProvider, BeaconState state, TestProcessStep step) { TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); Slot slot = (Slot)(state.Slot + (timeParameters.SlotsPerEpoch - state.Slot % timeParameters.SlotsPerEpoch) - 1UL); // transition state to slot before epoch state transition beaconStateTransition.ProcessSlots(state, slot); // start transitioning, do one slot update before the epoch itself. beaconStateTransition.ProcessSlot(state); // process components of epoch transition before final-updates if (step == TestProcessStep.ProcessJustificationAndFinalization) { return; } // Note: only run when present. Later phases introduce more to the epoch-processing. beaconStateTransition.ProcessJustificationAndFinalization(state); if (step == TestProcessStep.ProcessRewardsAndPenalties) { return; } beaconStateTransition.ProcessRewardsAndPenalties(state); if (step == TestProcessStep.ProcessRegistryUpdates) { return; } beaconStateTransition.ProcessRegistryUpdates(state); if (step == TestProcessStep.ProcessSlashings) { return; } beaconStateTransition.ProcessSlashings(state); if (step == TestProcessStep.ProcessFinalUpdates) { return; } beaconStateTransition.ProcessFinalUpdates(state); }
/// <summary> /// State transition via the provided ``block`` /// then package the block with the state root and signature. /// </summary> public static void StateTransitionAndSignBlock(IServiceProvider testServiceProvider, BeaconState state, BeaconBlock block) { MiscellaneousParameters miscellaneousParameters = testServiceProvider.GetService <IOptions <MiscellaneousParameters> >().Value; TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; StateListLengths stateListLengths = testServiceProvider.GetService <IOptions <StateListLengths> >().Value; MaxOperationsPerBlock maxOperationsPerBlock = testServiceProvider.GetService <IOptions <MaxOperationsPerBlock> >().Value; BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); beaconStateTransition.StateTransition(state, block, validateStateRoot: false); Hash32 stateRoot = state.HashTreeRoot(miscellaneousParameters, timeParameters, stateListLengths, maxOperationsPerBlock); block.SetStateRoot(stateRoot); TestBlock.SignBlock(testServiceProvider, state, block, ValidatorIndex.None); }
public static void AddAttestationsToState(IServiceProvider testServiceProvider, BeaconState state, IEnumerable <Attestation> attestations, Slot slot) { BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); BeaconBlock block = TestBlock.BuildEmptyBlock(testServiceProvider, state, slot, BlsSignature.Zero); foreach (Attestation attestation in attestations) { block.Body.AddAttestations(attestation); } beaconStateTransition.ProcessSlots(state, block.Slot); SignedBeaconBlock signedBlock = TestBlock.SignBlock(testServiceProvider, state, block, ValidatorIndex.None); beaconStateTransition.StateTransition(state, signedBlock, validateResult: false); }
public AttestationProducer(ILogger <AttestationProducer> logger, ICryptographyService cryptographyService, BeaconChainUtility beaconChainUtility, BeaconStateAccessor beaconStateAccessor, BeaconStateTransition beaconStateTransition, IForkChoice forkChoice, IStore store) { _logger = logger; _cryptographyService = cryptographyService; _beaconChainUtility = beaconChainUtility; _beaconStateAccessor = beaconStateAccessor; _beaconStateTransition = beaconStateTransition; _forkChoice = forkChoice; _store = store; }
public ValidatorAssignments(ILogger <ValidatorAssignments> logger, IOptionsMonitor <TimeParameters> timeParameterOptions, BeaconChainUtility beaconChainUtility, BeaconStateAccessor beaconStateAccessor, BeaconStateTransition beaconStateTransition, IForkChoice forkChoice, IStore store) { _logger = logger; _timeParameterOptions = timeParameterOptions; _beaconChainUtility = beaconChainUtility; _beaconStateAccessor = beaconStateAccessor; _beaconStateTransition = beaconStateTransition; _forkChoice = forkChoice; _store = store; }
public async Task GenesisWithEmptyParametersTimeShouldReject() { // Arrange var testServiceProvider = TestSystem.BuildTestServiceProvider(); var chainConstants = testServiceProvider.GetService <ChainConstants>(); var miscellaneousParameterOptions = testServiceProvider.GetService <IOptionsMonitor <MiscellaneousParameters> >(); var gweiValueOptions = testServiceProvider.GetService <IOptionsMonitor <GweiValues> >(); var initialValueOptions = testServiceProvider.GetService <IOptionsMonitor <InitialValues> >(); var timeParameterOptions = testServiceProvider.GetService <IOptionsMonitor <TimeParameters> >(); var stateListLengthOptions = testServiceProvider.GetService <IOptionsMonitor <StateListLengths> >(); var rewardsAndPenaltiesOptions = testServiceProvider.GetService <IOptionsMonitor <RewardsAndPenalties> >(); var maxOperationsPerBlockOptions = testServiceProvider.GetService <IOptionsMonitor <MaxOperationsPerBlock> >(); var signatureDomainOptions = testServiceProvider.GetService <IOptionsMonitor <SignatureDomains> >(); miscellaneousParameterOptions.CurrentValue.MinimumGenesisActiveValidatorCount = 2; var loggerFactory = new LoggerFactory(new[] { new ConsoleLoggerProvider(TestOptionsMonitor.Create(new ConsoleLoggerOptions())) }); var cryptographyService = new CryptographyService(); var beaconChainUtility = new BeaconChainUtility(loggerFactory.CreateLogger <BeaconChainUtility>(), miscellaneousParameterOptions, gweiValueOptions, timeParameterOptions, cryptographyService); var beaconStateAccessor = new BeaconStateAccessor(miscellaneousParameterOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, signatureDomainOptions, cryptographyService, beaconChainUtility); var beaconStateMutator = new BeaconStateMutator(chainConstants, timeParameterOptions, stateListLengthOptions, rewardsAndPenaltiesOptions, beaconChainUtility, beaconStateAccessor); var beaconStateTransition = new BeaconStateTransition(loggerFactory.CreateLogger <BeaconStateTransition>(), chainConstants, miscellaneousParameterOptions, gweiValueOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, rewardsAndPenaltiesOptions, maxOperationsPerBlockOptions, signatureDomainOptions, cryptographyService, beaconChainUtility, beaconStateAccessor, beaconStateMutator); var beaconChain = new BeaconChain(loggerFactory.CreateLogger <BeaconChain>(), chainConstants, miscellaneousParameterOptions, gweiValueOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, maxOperationsPerBlockOptions, cryptographyService, beaconChainUtility, beaconStateAccessor, beaconStateMutator, beaconStateTransition); // Act var eth1BlockHash = Hash32.Zero; var eth1Timestamp = (ulong)106185600; // 1973-05-14 var deposits = Array.Empty <Deposit>(); var success = await beaconChain.TryGenesisAsync(eth1BlockHash, eth1Timestamp, deposits); // Assert success.ShouldBeFalse(); beaconChain.State.ShouldBeNull(); }
// Run ``process_block_header``, yielding: // - pre-state('pre') // - block('block') // - post-state('post'). // If ``valid == False``, run expecting ``AssertionError`` private void RunBlockHeaderProcessing(IServiceProvider testServiceProvider, BeaconState state, BeaconBlock block, bool expectValid) { ICryptographyService cryptographyService = testServiceProvider.GetService <ICryptographyService>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); PrepareStateForHeaderProcessing(state, beaconStateTransition); if (expectValid) { beaconStateTransition.ProcessBlockHeader(state, block); } else { Should.Throw <Exception>(() => { beaconStateTransition.ProcessBlockHeader(state, block); }); } }
/// <summary> /// State transition via the provided ``block`` /// then package the block with the state root and signature. /// </summary> public static SignedBeaconBlock StateTransitionAndSignBlock(IServiceProvider testServiceProvider, BeaconState state, BeaconBlock block) { MiscellaneousParameters miscellaneousParameters = testServiceProvider.GetService <IOptions <MiscellaneousParameters> >().Value; TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; StateListLengths stateListLengths = testServiceProvider.GetService <IOptions <StateListLengths> >().Value; MaxOperationsPerBlock maxOperationsPerBlock = testServiceProvider.GetService <IOptions <MaxOperationsPerBlock> >().Value; ICryptographyService cryptographyService = testServiceProvider.GetService <ICryptographyService>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); SignedBeaconBlock preSigningBlock = new SignedBeaconBlock(block, BlsSignature.Zero); beaconStateTransition.StateTransition(state, preSigningBlock, validateResult: false); Root stateRoot = cryptographyService.HashTreeRoot(state); block.SetStateRoot(stateRoot); SignedBeaconBlock signedBlock = TestBlock.SignBlock(testServiceProvider, state, block, ValidatorIndex.None); return(signedBlock); }
public static (IList <Deposit>, Root) PrepareGenesisDeposits(IServiceProvider testServiceProvider, int genesisValidatorCount, Gwei amount, bool signed) { ChainConstants chainConstants = testServiceProvider.GetService <ChainConstants>(); MiscellaneousParameters miscellaneousParameters = testServiceProvider.GetService <IOptions <MiscellaneousParameters> >().Value; InitialValues initialValues = testServiceProvider.GetService <IOptions <InitialValues> >().Value; TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; MaxOperationsPerBlock maxOperationsPerBlock = testServiceProvider.GetService <IOptions <MaxOperationsPerBlock> >().Value; BeaconChainUtility beaconChainUtility = testServiceProvider.GetService <BeaconChainUtility>(); BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); byte[][] privateKeys = TestKeys.PrivateKeys(timeParameters).ToArray(); BlsPublicKey[] publicKeys; if (signed) { publicKeys = TestKeys.PublicKeys(timeParameters).ToArray(); } else { publicKeys = privateKeys.Select(x => new BlsPublicKey(x)).ToArray(); } List <DepositData> depositDataList = new List <DepositData>(); List <Deposit> genesisDeposits = new List <Deposit>(); Root root = Root.Zero; for (int validatorIndex = 0; validatorIndex < genesisValidatorCount; validatorIndex++) { BlsPublicKey publicKey = publicKeys[validatorIndex]; byte[] privateKey = privateKeys[validatorIndex]; // insecurely use pubkey as withdrawal key if no credentials provided byte[] withdrawalCredentialBytes = TestSecurity.Hash(publicKey.AsSpan()); withdrawalCredentialBytes[0] = initialValues.BlsWithdrawalPrefix; Bytes32 withdrawalCredentials = new Bytes32(withdrawalCredentialBytes); (Deposit deposit, Root depositRoot) = BuildDeposit(testServiceProvider, null, depositDataList, publicKey, privateKey, amount, withdrawalCredentials, signed); root = depositRoot; genesisDeposits.Add(deposit); } return(genesisDeposits, root); }
public Genesis(ILogger <Genesis> logger, ChainConstants chainConstants, IOptionsMonitor <MiscellaneousParameters> miscellaneousParameterOptions, IOptionsMonitor <GweiValues> gweiValueOptions, IOptionsMonitor <InitialValues> initialValueOptions, IOptionsMonitor <TimeParameters> timeParameterOptions, IOptionsMonitor <StateListLengths> stateListLengthOptions, IOptionsMonitor <MaxOperationsPerBlock> maxOperationsPerBlockOptions, BeaconStateAccessor beaconStateAccessor, BeaconStateTransition beaconStateTransition) { _logger = logger; _beaconStateAccessor = beaconStateAccessor; _beaconStateTransition = beaconStateTransition; _chainConstants = chainConstants; _miscellaneousParameterOptions = miscellaneousParameterOptions; _gweiValueOptions = gweiValueOptions; _initialValueOptions = initialValueOptions; _timeParameterOptions = timeParameterOptions; _stateListLengthOptions = stateListLengthOptions; _maxOperationsPerBlockOptions = maxOperationsPerBlockOptions; }
// Run ``process_attester_slashing``, yielding: // - pre-state('pre') // - attester_slashing('attester_slashing') // - post-state('post'). //If ``valid == False``, run expecting ``AssertionError`` private void RunAttesterSlashingProcessing(IServiceProvider testServiceProvider, BeaconState state, AttesterSlashing attesterSlashing, bool expectValid) { ChainConstants chainConstants = testServiceProvider.GetService <ChainConstants>(); StateListLengths stateListLengths = testServiceProvider.GetService <IOptions <StateListLengths> >().Value; RewardsAndPenalties rewardsAndPenalties = testServiceProvider.GetService <IOptions <RewardsAndPenalties> >().Value; BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); if (!expectValid) { Should.Throw <Exception>(() => { beaconStateTransition.ProcessAttesterSlashing(state, attesterSlashing); }); return; } var slashedIndices = attesterSlashing.Attestation1.CustodyBit0Indices .Union(attesterSlashing.Attestation1.CustodyBit1Indices) .ToList(); ValidatorIndex proposerIndex = beaconStateAccessor.GetBeaconProposerIndex(state); Gwei preProposerBalance = TestState.GetBalance(state, proposerIndex); var preSlashings = slashedIndices.ToDictionary(x => x, x => TestState.GetBalance(state, x)); var preWithdrawableEpochs = slashedIndices.ToDictionary(x => x, x => state.Validators[(int)(ulong)x].WithdrawableEpoch); Gwei totalProposerRewards = preSlashings.Values.Aggregate(Gwei.Zero, (sum, x) => sum + x / rewardsAndPenalties.WhistleblowerRewardQuotient); // Process slashing beaconStateTransition.ProcessAttesterSlashing(state, attesterSlashing); foreach (ValidatorIndex slashedIndex in slashedIndices) { Console.WriteLine($"Checking index {slashedIndex}"); Epoch preWithdrawableEpoch = preWithdrawableEpochs[slashedIndex]; Validator slashedValidator = state.Validators[(int)(ulong)slashedIndex]; // Check Slashing slashedValidator.IsSlashed.ShouldBeTrue(); slashedValidator.ExitEpoch.ShouldBeLessThan(chainConstants.FarFutureEpoch); if (preWithdrawableEpoch < chainConstants.FarFutureEpoch) { ulong slashingsEpoch = beaconStateAccessor.GetCurrentEpoch(state) + stateListLengths.EpochsPerSlashingsVector; Epoch expectedWithdrawableEpoch = Epoch.Max(preWithdrawableEpoch, (Epoch)slashingsEpoch); slashedValidator.WithdrawableEpoch.ShouldBe(expectedWithdrawableEpoch); } else { slashedValidator.WithdrawableEpoch.ShouldBeLessThan(chainConstants.FarFutureEpoch); } Gwei preSlashing = preSlashings[slashedIndex]; Gwei slashedBalance = TestState.GetBalance(state, slashedIndex); slashedBalance.ShouldBeLessThan(preSlashing); } if (!slashedIndices.Contains(proposerIndex)) { // gained whistleblower reward Gwei expectedProposerBalance = preProposerBalance + totalProposerRewards; Gwei proposerBalance = TestState.GetBalance(state, proposerIndex); proposerBalance.ShouldBe(expectedProposerBalance); } else { // gained rewards for all slashings, which may include others. And only lost that of themselves. Gwei expectedProposerBalance = preProposerBalance + totalProposerRewards - (preSlashings[proposerIndex] / rewardsAndPenalties.MinimumSlashingPenaltyQuotient); Gwei proposerBalance = TestState.GetBalance(state, proposerIndex); proposerBalance.ShouldBe(expectedProposerBalance); } }
public static BeaconBlock BuildEmptyBlock(IServiceProvider testServiceProvider, BeaconState state, Slot slot, BlsSignature randaoReveal) { //if (slot) is none TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; SignatureDomains signatureDomains = testServiceProvider.GetService <IOptions <SignatureDomains> >().Value; ICryptographyService cryptographyService = testServiceProvider.GetService <ICryptographyService>(); BeaconChainUtility beaconChainUtility = testServiceProvider.GetService <BeaconChainUtility>(); BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); Eth1Data eth1Data = new Eth1Data(Root.Zero, state.Eth1DepositIndex, Bytes32.Zero); Root stateRoot = !state.LatestBlockHeader.StateRoot.Equals(Root.Zero) ? state.LatestBlockHeader.StateRoot : cryptographyService.HashTreeRoot(state); BeaconBlockHeader previousBlockHeader = new BeaconBlockHeader(state.LatestBlockHeader.Slot, state.LatestBlockHeader.ParentRoot, stateRoot, state.LatestBlockHeader.BodyRoot); Root previousBlockHashTreeRoot = cryptographyService.HashTreeRoot(previousBlockHeader); if (randaoReveal.Equals(BlsSignature.Zero)) { Epoch blockEpoch = beaconChainUtility.ComputeEpochAtSlot(slot); ValidatorIndex proposerIndex; if (slot == state.Slot) { proposerIndex = beaconStateAccessor.GetBeaconProposerIndex(state); } else { Epoch stateEpoch = beaconChainUtility.ComputeEpochAtSlot(state.Slot); if (blockEpoch > stateEpoch + 1) { Console.WriteLine("WARNING: Block slot (epoch {0}) far away from state (epoch {1}), and no proposer index manually given." + " Signing block is slow due to transition for proposer index calculation.", blockEpoch, stateEpoch); } // use stub state to get proposer index of future slot BeaconState stubState = BeaconState.Clone(state); beaconStateTransition.ProcessSlots(stubState, slot); proposerIndex = beaconStateAccessor.GetBeaconProposerIndex(stubState); } byte[][] privateKeys = TestKeys.PrivateKeys(timeParameters).ToArray(); byte[] privateKey = privateKeys[(int)(ulong)proposerIndex]; Domain randaoDomain = beaconStateAccessor.GetDomain(state, signatureDomains.Randao, blockEpoch); Root epochHashTreeRoot = cryptographyService.HashTreeRoot(blockEpoch); Root randaoSigningRoot = beaconChainUtility.ComputeSigningRoot(epochHashTreeRoot, randaoDomain); randaoReveal = TestSecurity.BlsSign(randaoSigningRoot, privateKey); } BeaconBlock emptyBlock = new BeaconBlock(slot, previousBlockHashTreeRoot, Root.Zero, new BeaconBlockBody( randaoReveal, eth1Data, new Bytes32(), Array.Empty <ProposerSlashing>(), Array.Empty <AttesterSlashing>(), Array.Empty <Attestation>(), Array.Empty <Deposit>(), Array.Empty <SignedVoluntaryExit>() )); return(emptyBlock); }
public void EffectiveBalanceHysteresis() { // Arrange IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider(); BeaconState state = TestState.PrepareTestState(testServiceProvider); //# Prepare state up to the final-updates. //# Then overwrite the balances, we only want to focus to be on the hysteresis based changes. TestProcessUtility.RunEpochProcessingTo(testServiceProvider, state, TestProcessStep.ProcessFinalUpdates); GweiValues gweiValues = testServiceProvider.GetService <IOptions <GweiValues> >().Value; BeaconChainUtility beaconChainUtility = testServiceProvider.GetService <BeaconChainUtility>(); BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); // Set some edge cases for balances Gwei maximum = gweiValues.MaximumEffectiveBalance; Gwei minimum = gweiValues.EjectionBalance; Gwei increment = gweiValues.EffectiveBalanceIncrement; Gwei halfIncrement = increment / 2; EffectiveBalanceCase[] testCases = new[] { new EffectiveBalanceCase(maximum, maximum, maximum, "as-is"), new EffectiveBalanceCase(maximum, (Gwei)(maximum - 1), maximum - increment, "round down, step lower"), new EffectiveBalanceCase(maximum, (Gwei)(maximum + 1), maximum, "round down"), new EffectiveBalanceCase(maximum, (Gwei)(maximum - increment), maximum - increment, "exactly 1 step lower"), new EffectiveBalanceCase(maximum, (Gwei)(maximum - increment - 1), maximum - (increment * 2), "just 1 over 1 step lower"), new EffectiveBalanceCase(maximum, (Gwei)(maximum - increment + 1), maximum - increment, "close to 1 step lower"), new EffectiveBalanceCase(minimum, (Gwei)(minimum + (halfIncrement * 3)), minimum, "bigger balance, but not high enough"), new EffectiveBalanceCase(minimum, (Gwei)(minimum + (halfIncrement * 3) + 1), minimum + increment, "bigger balance, high enough, but small step"), new EffectiveBalanceCase(minimum, (Gwei)(minimum + (halfIncrement * 4) - 1), minimum + increment, "bigger balance, high enough, close to double step"), new EffectiveBalanceCase(minimum, (Gwei)(minimum + (halfIncrement * 4)), minimum + (increment * 2), "exact two step balance increment"), new EffectiveBalanceCase(minimum, (Gwei)(minimum + (halfIncrement * 4) + 1), minimum + (increment * 2), "over two steps, round down"), }; Epoch currentEpoch = beaconStateAccessor.GetCurrentEpoch(state); for (int index = 0; index < testCases.Length; index++) { Validator validator = state.Validators[index]; bool isActive = beaconChainUtility.IsActiveValidator(validator, currentEpoch); isActive.ShouldBeTrue(); EffectiveBalanceCase testCase = testCases[index]; validator.SetEffectiveBalance(testCase.PreEffective); ValidatorIndex validatorIndex = new ValidatorIndex((ulong)index); state.SetBalance(validatorIndex, testCase.Balance); } // Act beaconStateTransition.ProcessFinalUpdates(state); // Assert for (int index = 0; index < testCases.Length; index++) { EffectiveBalanceCase testCase = testCases[index]; Validator validator = state.Validators[index]; validator.EffectiveBalance.ShouldBe(testCase.PostEffective, testCase.Name); } }
private void PrepareStateForHeaderProcessing(BeaconState state, BeaconStateTransition beaconStateTransition) { beaconStateTransition.ProcessSlots(state, state.Slot + new Slot(1)); }
public async Task GenesisWithEmptyParametersTimeShouldReject() { // Arrange IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider(); ChainConstants chainConstants = testServiceProvider.GetService <ChainConstants>(); IOptionsMonitor <MiscellaneousParameters> miscellaneousParameterOptions = testServiceProvider.GetService <IOptionsMonitor <MiscellaneousParameters> >(); IOptionsMonitor <GweiValues> gweiValueOptions = testServiceProvider.GetService <IOptionsMonitor <GweiValues> >(); IOptionsMonitor <InitialValues> initialValueOptions = testServiceProvider.GetService <IOptionsMonitor <InitialValues> >(); IOptionsMonitor <TimeParameters> timeParameterOptions = testServiceProvider.GetService <IOptionsMonitor <TimeParameters> >(); IOptionsMonitor <StateListLengths> stateListLengthOptions = testServiceProvider.GetService <IOptionsMonitor <StateListLengths> >(); IOptionsMonitor <RewardsAndPenalties> rewardsAndPenaltiesOptions = testServiceProvider.GetService <IOptionsMonitor <RewardsAndPenalties> >(); IOptionsMonitor <MaxOperationsPerBlock> maxOperationsPerBlockOptions = testServiceProvider.GetService <IOptionsMonitor <MaxOperationsPerBlock> >(); IOptionsMonitor <ForkChoiceConfiguration> forkChoiceConfigurationOptions = testServiceProvider.GetService <IOptionsMonitor <ForkChoiceConfiguration> >(); IOptionsMonitor <SignatureDomains> signatureDomainOptions = testServiceProvider.GetService <IOptionsMonitor <SignatureDomains> >(); IOptionsMonitor <InMemoryConfiguration> inMemoryConfigurationOptions = testServiceProvider.GetService <IOptionsMonitor <InMemoryConfiguration> >(); miscellaneousParameterOptions.CurrentValue.MinimumGenesisActiveValidatorCount = 2; LoggerFactory loggerFactory = new LoggerFactory(new[] { new ConsoleLoggerProvider(Core2.Configuration.Static.OptionsMonitor <ConsoleLoggerOptions>()) }); ICryptographyService cryptographyService = testServiceProvider.GetService <ICryptographyService>(); IDepositStore depositStore = new DepositStore(cryptographyService, chainConstants); BeaconChainUtility beaconChainUtility = new BeaconChainUtility( loggerFactory.CreateLogger <BeaconChainUtility>(), chainConstants, miscellaneousParameterOptions, initialValueOptions, gweiValueOptions, timeParameterOptions, cryptographyService); BeaconStateAccessor beaconStateAccessor = new BeaconStateAccessor(chainConstants, miscellaneousParameterOptions, timeParameterOptions, stateListLengthOptions, signatureDomainOptions, cryptographyService, beaconChainUtility); BeaconStateMutator beaconStateMutator = new BeaconStateMutator(chainConstants, timeParameterOptions, stateListLengthOptions, rewardsAndPenaltiesOptions, beaconChainUtility, beaconStateAccessor); BeaconStateTransition beaconStateTransition = new BeaconStateTransition( loggerFactory.CreateLogger <BeaconStateTransition>(), chainConstants, gweiValueOptions, timeParameterOptions, stateListLengthOptions, rewardsAndPenaltiesOptions, maxOperationsPerBlockOptions, signatureDomainOptions, cryptographyService, beaconChainUtility, beaconStateAccessor, beaconStateMutator, depositStore); SimpleLatestMessageDrivenGreedyHeaviestObservedSubtree simpleLmdGhost = new SimpleLatestMessageDrivenGreedyHeaviestObservedSubtree( loggerFactory.CreateLogger <SimpleLatestMessageDrivenGreedyHeaviestObservedSubtree>(), chainConstants, beaconChainUtility, beaconStateAccessor); MemoryStore store = new MemoryStore(loggerFactory.CreateLogger <MemoryStore>(), inMemoryConfigurationOptions, new DataDirectory("data"), Substitute.For <IFileSystem>(), simpleLmdGhost, new StoreAccessor()); ForkChoice forkChoice = new ForkChoice(loggerFactory.CreateLogger <ForkChoice>(), chainConstants, miscellaneousParameterOptions, timeParameterOptions, maxOperationsPerBlockOptions, forkChoiceConfigurationOptions, signatureDomainOptions, cryptographyService, beaconChainUtility, beaconStateAccessor, beaconStateTransition); GenesisChainStart genesisChainStart = new GenesisChainStart(loggerFactory.CreateLogger <GenesisChainStart>(), chainConstants, miscellaneousParameterOptions, gweiValueOptions, initialValueOptions, timeParameterOptions, stateListLengthOptions, cryptographyService, store, beaconStateAccessor, beaconStateTransition, forkChoice, depositStore); // Act Bytes32 eth1BlockHash = Bytes32.Zero; ulong eth1Timestamp = 106185600uL; // 1973-05-14 bool success = await genesisChainStart.TryGenesisAsync(eth1BlockHash, eth1Timestamp); // Assert success.ShouldBeFalse(); }