コード例 #1
0
        public void Eth1VoteReset()
        {
            // Arrange
            IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider();
            BeaconState      state = TestState.PrepareTestState(testServiceProvider);

            TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value;

            //  skip ahead to the end of the voting period
            state.SetSlot((Slot)(timeParameters.SlotsPerEth1VotingPeriod - 1UL));

            // add a vote for each skipped slot.
            for (Slot index = Slot.Zero; index < state.Slot + new Slot(1); index += new Slot(1))
            {
                ulong    eth1DepositIndex = state.Eth1DepositIndex;
                Root     depositRoot      = new Root(Enumerable.Repeat((byte)0xaa, 32).ToArray());
                Bytes32  blockHash        = new Bytes32(Enumerable.Repeat((byte)0xbb, 32).ToArray());
                Eth1Data eth1Data         = new Eth1Data(depositRoot, eth1DepositIndex, blockHash);
                state.AddEth1DataVote(eth1Data);
            }

            // Act
            RunProcessFinalUpdates(testServiceProvider, state);

            // Assert
            state.Eth1DataVotes.Count.ShouldBe(0);
        }
コード例 #2
0
        public void ProcessEth1Data(BeaconState state, BeaconBlockBody body)
        {
            _logger.LogInformation(Event.ProcessEth1Data, "Process block ETH1 data for block body {BeaconBlockBody}", body);

            state.AddEth1DataVote(body.Eth1Data);
            var eth1DataVoteCount = state.Eth1DataVotes.Count(x => x.Equals(body.Eth1Data));

            if (eth1DataVoteCount * 2 > (int)(ulong)_timeParameterOptions.CurrentValue.SlotsPerEth1VotingPeriod)
            {
                state.SetEth1Data(body.Eth1Data);
            }
        }