Пример #1
0
        public async Task Election_ChangeVotingOption_With_Expire_Vote_Test()
        {
            var voter      = VoterKeyPairs.First();
            var voteAmount = 100;
            var lockTime   = 120 * 60 * 60 * 24;
            var candidate  = ValidationDataCenterKeyPairs.First();

            await AnnounceElectionAsync(candidate);
            await VoteToCandidate(voter, candidate.PublicKey.ToHex(), lockTime, voteAmount);

            var electionVoteItemId = await ElectionContractStub.GetMinerElectionVotingItemId.CallAsync(new Empty());

            var voteIdOfVoter = await VoteContractStub.GetVotingIds.CallAsync(new GetVotingIdsInput
            {
                Voter        = Address.FromPublicKey(voter.PublicKey),
                VotingItemId = electionVoteItemId
            });

            var voteId = voteIdOfVoter.ActiveVotes[0];

            BlockTimeProvider.SetBlockTime(StartTimestamp.AddSeconds(lockTime + 1));
            var changeOptionRet = await ChangeVoteOption(voter, voteId, candidate.PublicKey.ToHex());

            changeOptionRet.Status.ShouldBe(TransactionResultStatus.Failed);
            changeOptionRet.Error.ShouldContain("This vote already expired");
        }
Пример #2
0
        public async Task GetElectorVoteWithAllRecords_Test()
        {
            var voters = await UserVotesCandidate(2, 500, 100);

            var voterKeyPair = voters[0];
            //without withdraw
            var allRecords = await ElectionContractStub.GetElectorVoteWithAllRecords.CallAsync(new StringValue
            {
                Value = voterKeyPair.PublicKey.ToHex()
            });

            allRecords.ActiveVotingRecords.Count.ShouldBeGreaterThanOrEqualTo(1);
            allRecords.WithdrawnVotingRecordIds.Count.ShouldBe(0);

            //withdraw
            await NextTerm(InitialCoreDataCenterKeyPairs[0]);

            BlockTimeProvider.SetBlockTime(StartTimestamp.AddSeconds(100 * 60 * 60 * 24 + 1));
            var voteId =
                (await ElectionContractStub.GetElectorVote.CallAsync(new StringValue
            {
                Value = voterKeyPair.PublicKey.ToHex()
            })).ActiveVotingRecordIds.First();
            var executionResult = await WithdrawVotes(voterKeyPair, voteId);

            executionResult.Status.ShouldBe(TransactionResultStatus.Mined);

            allRecords = await ElectionContractStub.GetElectorVoteWithAllRecords.CallAsync(new StringValue
            {
                Value = voterKeyPair.PublicKey.ToHex()
            });

            allRecords.WithdrawnVotingRecordIds.Count.ShouldBe(1);
        }
Пример #3
0
        private async Task <TransactionList> AEDPoSContract_GenerateConsensusTransactions_FirstRound_ExtraBlockMiner_Test()
        {
            var usingKeyPair = BootMinerKeyPair;

            KeyPairProvider.SetKeyPair(usingKeyPair);

            var consensusCommand = await AEDPoSContract_GetConsensusCommand_FirstRound_ExtraBlockMiner_Test();

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Mul(AEDPoSContractTestConstants.InitialMinersCount)
                          .Div(1000)
            });

            var triggerForCommand =
                await TriggerInformationProvider
                .GetTriggerInformationForConsensusTransactionsAsync(consensusCommand.ToBytesValue());

            var transactionList = await AEDPoSContractStub.GenerateConsensusTransactions.CallAsync(triggerForCommand);

            transactionList.Transactions.Count.ShouldBe(1);
            transactionList.Transactions[0].MethodName.ShouldBe(nameof(AEDPoSContractStub.NextRound));

            return(transactionList);
        }
Пример #4
0
        private async Task AEDPoSContract_FirstRound_SecondMiner_Test()
        {
            var transaction =
                (await AEDPoSContract_GenerateConsensusTransactions_FirstRound_SecondMiner_Test()).Transactions.First();

            var usingKeyPair = InitialCoreDataCenterKeyPairs[1];

            KeyPairProvider.SetKeyPair(usingKeyPair);

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Mul(2).Div(1000)
            });

            var updateValueInput = new UpdateValueInput();

            updateValueInput.MergeFrom(transaction.Params);

            var stub = GetAEDPoSContractStub(usingKeyPair);
            await stub.UpdateValue.SendAsync(updateValueInput);

            var currentRound = await stub.GetCurrentRoundInformation.CallAsync(new Empty());

            currentRound.RoundNumber.ShouldBe(1);
            currentRound.RealTimeMinersInformation[usingKeyPair.PublicKey.ToHex()].OutValue.ShouldNotBeNull();
        }
Пример #5
0
        private async Task <ConsensusCommand> AEDPoSContract_GetConsensusCommand_FirstRound_ExtraBlockMiner_Test()
        {
            await AEDPoSContract_FirstRound_SecondMiner_Test();

            var usingKeyPair = BootMinerKeyPair;

            KeyPairProvider.SetKeyPair(usingKeyPair);

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Mul(2).Div(1000)
            });

            var triggerForCommand =
                TriggerInformationProvider.GetTriggerInformationForConsensusCommand(new BytesValue());

            var currentRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            var consensusCommand = await AEDPoSContractStub.GetConsensusCommand.CallAsync(triggerForCommand);

            consensusCommand.LimitMillisecondsOfMiningBlock.ShouldBe(AEDPoSContractTestConstants
                                                                     .SmallBlockMiningInterval);
            var hint = new AElfConsensusHint {
                Behaviour = AElfConsensusBehaviour.NextRound
            }
            .ToByteString();

            consensusCommand.Hint.ShouldBe(hint);

            return(consensusCommand);
        }
Пример #6
0
        public async Task AEDPoSContract_GetInformationToUpdateConsensus_FirstRound_SecondMiner_Test()
        {
            var usingKeyPair = InitialCoreDataCenterKeyPairs[1];

            KeyPairProvider.SetKeyPair(usingKeyPair);

            var consensusCommand = await AEDPoSContract_GetConsensusCommand_FirstRound_SecondMiner_Test();

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Mul(2).Div(1000)
            });

            var triggerForCommand =
                await TriggerInformationProvider
                .GetTriggerInformationForBlockHeaderExtraDataAsync(consensusCommand.ToBytesValue());

            var extraDataBytes = await AEDPoSContractStub.GetConsensusExtraData.CallAsync(triggerForCommand);

            var extraData = extraDataBytes.ToConsensusHeaderInformation();

            extraData.Round.RoundId.ShouldNotBe(0);
            extraData.Round.RoundNumber.ShouldBe(1);
            extraData.Round.RealTimeMinersInformation[usingKeyPair.PublicKey.ToHex()].OutValue
            .ShouldNotBeNull();
        }
Пример #7
0
        public async Task AEDPoSContract_GetInformationToUpdateConsensus_FirstRound_ExtraBlockMiner_Test()
        {
            var usingKeyPair = BootMinerKeyPair;

            KeyPairProvider.SetKeyPair(usingKeyPair);

            var consensusCommand = await AEDPoSContract_GetConsensusCommand_FirstRound_ExtraBlockMiner_Test();

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Mul(AEDPoSContractTestConstants.InitialMinersCount)
                          .Div(1000)
            });

            var triggerForCommand =
                await TriggerInformationProvider
                .GetTriggerInformationForBlockHeaderExtraDataAsync(consensusCommand.ToBytesValue());

            var extraDataBytes = await AEDPoSContractStub.GetConsensusExtraData.CallAsync(triggerForCommand);

            var extraData = extraDataBytes.ToConsensusHeaderInformation();

            extraData.Round.RoundId.ShouldNotBe(0);
            extraData.Round.RoundNumber.ShouldBe(2);
        }
Пример #8
0
        /// <summary>
        /// Generate encrypted messages and put them to round information.
        /// </summary>
        /// <returns></returns>
        private async Task <Dictionary <string, AElfConsensusTriggerInformation> > GenerateEncryptedMessagesAsync()
        {
            var firstRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            var randomHashes = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount)
                               .Select(_ => Hash.FromString("randomHashes")).ToList();
            var triggers = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount).Select(i =>
                                                                                                                 new AElfConsensusTriggerInformation
            {
                Pubkey  = ByteString.CopyFrom(InitialCoreDataCenterKeyPairs[i].PublicKey),
                InValue = randomHashes[i]
            }).ToDictionary(t => t.Pubkey.ToHex(), t => t);

            foreach (var minerInRound in firstRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order))
            {
                var currentKeyPair = InitialCoreDataCenterKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.Pubkey);

                KeyPairProvider.SetKeyPair(currentKeyPair);

                BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime);

                var tester            = GetAEDPoSContractStub(currentKeyPair);
                var headerInformation = new AElfConsensusHeaderInformation();
                headerInformation.MergeFrom(
                    (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(triggers[minerInRound.Pubkey]
                                                                              .ToBytesValue())).Value);

                // Update consensus information.
                var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.Pubkey);
                await tester.UpdateValue.SendAsync(toUpdate);
            }

            return(triggers);
        }
Пример #9
0
        public async Task AEDPoSContract_GenerateConsensusTransaction_NextTerm_Test()
        {
            var usingKeyPair = BootMinerKeyPair;

            KeyPairProvider.SetKeyPair(usingKeyPair);

            //Next term
            {
                var consensusCommand = await AEDPoSContract_GetConsensusCommand_FirstRound_ExtraBlockMiner_Test();

                var nextTermBehavior = new AElfConsensusHint {
                    Behaviour = AElfConsensusBehaviour.NextTerm
                }
                .ToByteString();
                consensusCommand.Hint = nextTermBehavior;
                BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
                {
                    Seconds = AEDPoSContractTestConstants.MiningInterval
                              .Mul(AEDPoSContractTestConstants.InitialMinersCount)
                              .Div(1000)
                });

                var triggerForCommand = TriggerInformationProvider
                                        .GetTriggerInformationForConsensusTransactions(consensusCommand.ToBytesValue());

                var transactionList =
                    await AEDPoSContractStub.GenerateConsensusTransactions.CallAsync(triggerForCommand);

                transactionList.Transactions.Count.ShouldBe(1);
                transactionList.Transactions[0].MethodName.ShouldBe(nameof(AEDPoSContractStub.NextTerm));
            }
        }
Пример #10
0
        private async Task RunMiningProcess(int roundsCount)
        {
            for (var count = 0; count < roundsCount; count++)
            {
                var currentRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

                var randomHashes = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount)
                                   .Select(_ => Hash.FromString($"random{count}")).ToList();
                var triggers = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount).Select(
                    i =>
                    new AElfConsensusTriggerInformation
                {
                    Pubkey     = ByteString.CopyFrom(InitialCoreDataCenterKeyPairs[i].PublicKey),
                    RandomHash = randomHashes[i]
                }).ToDictionary(t => t.Pubkey.ToHex(), t => t);

                // Exactly one round except extra block time slot.
                foreach (var minerInRound in currentRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order))
                {
                    var currentKeyPair =
                        InitialCoreDataCenterKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.Pubkey);

                    KeyPairProvider.SetKeyPair(currentKeyPair);

                    BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime);

                    var tester            = GetAEDPoSContractStub(currentKeyPair);
                    var headerInformation =
                        (await tester.GetConsensusExtraData.CallAsync(triggers[minerInRound.Pubkey]
                                                                      .ToBytesValue())).ToConsensusHeaderInformation();

                    // Update consensus information.
                    var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.Pubkey);
                    await tester.UpdateValue.SendAsync(toUpdate);

                    for (var i = 0; i < 8; i++)
                    {
                        await tester.UpdateTinyBlockInformation.SendAsync(new TinyBlockInput
                        {
                            ActualMiningTime = TimestampHelper.GetUtcNow(),
                            RoundId          = currentRound.RoundId
                        });
                    }
                }

                currentRound.GenerateNextRoundInformation(TimestampHelper.GetUtcNow(), BlockchainStartTimestamp,
                                                          out var nextRound);
                await AEDPoSContractStub.NextRound.SendAsync(nextRound);

                for (var i = 0; i < 8; i++)
                {
                    await AEDPoSContractStub.UpdateTinyBlockInformation.SendAsync(new TinyBlockInput
                    {
                        ActualMiningTime = TimestampHelper.GetUtcNow(),
                        RoundId          = currentRound.RoundId
                    });
                }
            }
        }
Пример #11
0
        public async Task ElectionContract_Withdraw_Test()
        {
            const int amount   = 1000;
            const int lockTime = 120 * 60 * 60 * 24;

            var candidateKeyPair = ValidationDataCenterKeyPairs[0];

            await AnnounceElectionAsync(candidateKeyPair);

            var voterKeyPair  = VoterKeyPairs[0];
            var beforeBalance = await GetNativeTokenBalance(voterKeyPair.PublicKey);

            // Vote
            {
                var transactionResult =
                    await VoteToCandidate(voterKeyPair, candidateKeyPair.PublicKey.ToHex(), lockTime, amount);

                transactionResult.Status.ShouldBe(TransactionResultStatus.Mined);
            }

            var voteId =
                (await ElectionContractStub.GetElectorVote.CallAsync(new StringInput
            {
                Value = voterKeyPair.PublicKey.ToHex()
            })).ActiveVotingRecordIds.First();

            await NextTerm(InitialCoreDataCenterKeyPairs[0]);

            BlockTimeProvider.SetBlockTime(StartTimestamp.AddSeconds(lockTime + 1));

            // Withdraw
            {
                var executionResult = await WithdrawVotes(voterKeyPair, voteId);

                executionResult.Status.ShouldBe(TransactionResultStatus.Mined);
            }

            // Profit
            var voter = GetProfitContractTester(voterKeyPair);
            await voter.ClaimProfits.SendAsync(new ClaimProfitsInput { SchemeId = ProfitItemsIds[ProfitType.CitizenWelfare] });

            // Check ELF token balance
            {
                var balance = await GetNativeTokenBalance(voterKeyPair.PublicKey);

                balance.ShouldBe(beforeBalance);
            }

            // Check VOTE token balance.
            {
                var balance = await GetVoteTokenBalance(voterKeyPair.PublicKey);

                balance.ShouldBe(0);
            }
        }
Пример #12
0
        public async Task Approve_Proposal_Failed_Test()
        {
            //not found
            {
                var transactionResult = await AssociationAuthContractStub.Approve.SendWithExceptionAsync(new ApproveInput
                {
                    ProposalId = Hash.FromString("Test")
                });

                transactionResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Failed);
            }

            var organizationAddress = await CreateOrganizationAsync();

            var proposalId = await CreateProposalAsync(Reviewer2KeyPair, organizationAddress);

            //not authorize
            {
                AssociationAuthContractStub = GetAssociationAuthContractTester(DefaultSenderKeyPair);
                var transactionResult = await AssociationAuthContractStub.Approve.SendWithExceptionAsync(new ApproveInput
                {
                    ProposalId = proposalId
                });

                transactionResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Failed);
            }

            //expired time
            {
                AssociationAuthContractStub = GetAssociationAuthContractTester(Reviewer1KeyPair);
                BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(5));
                var error = await AssociationAuthContractStub.Approve.CallWithExceptionAsync(new ApproveInput
                {
                    ProposalId = proposalId
                });

                error.Value.ShouldContain("Invalid proposal.");
            }

            //already exist
            {
                AssociationAuthContractStub = GetAssociationAuthContractTester(Reviewer1KeyPair);
                BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(-5));
                var transactionResult1 =
                    await AssociationAuthContractStub.Approve.SendAsync(new ApproveInput { ProposalId = proposalId });

                transactionResult1.TransactionResult.Status.ShouldBe(TransactionResultStatus.Mined);
                transactionResult1.Output.Value.ShouldBe(true);

                var transactionResult2 =
                    await AssociationAuthContractStub.Approve.SendWithExceptionAsync(new ApproveInput { ProposalId = proposalId });

                transactionResult2.TransactionResult.Status.ShouldBe(TransactionResultStatus.Failed);
            }
        }
Пример #13
0
        public async Task Approve_Proposal_ExpiredTime()
        {
            var proposalId = await Create_Proposal();

            AssociationAuthContractStub = GetAssociationAuthContractTester(Reviewer1KeyPair);
            BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(5));
            var transactionResult = await AssociationAuthContractStub.Approve.CallAsync(new ApproveInput
            {
                ProposalId = proposalId
            });

            transactionResult.Value.ShouldBe(false);
        }
Пример #14
0
        public async Task Approve_Proposal_ExpiredTime_Test()
        {
            var organizationAddress = await CreateOrganizationAsync();

            var proposalId = await CreateProposalAsync(Reviewer2KeyPair, organizationAddress);

            AssociationAuthContractStub = GetAssociationAuthContractTester(Reviewer1KeyPair);
            BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(5));
            var error = await AssociationAuthContractStub.Approve.CallWithExceptionAsync(new ApproveInput
            {
                ProposalId = proposalId
            });

            error.Value.ShouldContain("Invalid proposal.");
        }
        public async Task Approve_Proposal_ExpiredTime_Test()
        {
            var organizationAddress = await CreateOrganizationAsync();

            var proposalId = await CreateProposalAsync(DefaultSenderKeyPair, organizationAddress);

            ParliamentAuthContractStub = GetParliamentAuthContractTester(InitialMinersKeyPairs[0]);
            BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(5));
            var transactionResult = await ParliamentAuthContractStub.Approve.CallAsync(new ApproveInput
            {
                ProposalId = proposalId
            });

            transactionResult.Value.ShouldBe(false);
        }
        public async Task Approve_Proposal_ExpiredTime_Test()
        {
            var organizationAddress = await CreateOrganizationAsync();

            var proposalId = await CreateProposalAsync(DefaultSenderKeyPair, organizationAddress);

            ParliamentAuthContractStub = GetParliamentAuthContractTester(InitialMinersKeyPairs[0]);
            BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(5));
            var error = await ParliamentAuthContractStub.Approve.CallWithExceptionAsync(new ApproveInput
            {
                ProposalId = proposalId
            });

            error.Value.ShouldContain("Invalid proposal.");
        }
Пример #17
0
        public async Task Approve_Proposal_ExpiredTime()
        {
            _organizationAddress = await Create_Organization();

            var proposalId = await Create_Proposal();

            ReferendumAuthContractStub = GetReferendumAuthContractTester(SampleECKeyPairs.KeyPairs[1]);
            BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(5));

            var transactionResult = await ReferendumAuthContractStub.Approve.CallAsync(new ApproveInput
            {
                ProposalId = proposalId
            });

            transactionResult.Value.ShouldBe(false);
        }
Пример #18
0
        internal async Task <Dictionary <string, DPoSTriggerInformation> > GenerateEncryptedMessagesTest()
        {
            var firstRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty());

            var randomHashes = Enumerable.Range(0, MinersCount).Select(_ => Hash.Generate()).ToList();
            var triggers     = Enumerable.Range(0, MinersCount).Select(i => new DPoSTriggerInformation
            {
                PublicKey  = ByteString.CopyFrom(InitialMinersKeyPairs[i].PublicKey),
                RandomHash = randomHashes[i]
            }).ToDictionary(t => t.PublicKey.ToHex(), t => t);

            foreach (var minerInRound in firstRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order))
            {
                var currentKeyPair = InitialMinersKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.PublicKey);

                ECKeyPairProvider.SetECKeyPair(currentKeyPair);

                BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime.ToDateTime());

                var tester            = GetConsensusContractTester(currentKeyPair);
                var headerInformation =
                    await tester.GetInformationToUpdateConsensus.CallAsync(triggers[minerInRound.PublicKey]);

                var encryptedInValues = headerInformation.Round.RealTimeMinersInformation[minerInRound.PublicKey]
                                        .EncryptedInValues;

                encryptedInValues.Count.ShouldBe(MinersCount - 1);
                foreach (var(key, value) in encryptedInValues)
                {
                    InitialMinersKeyPairs.Select(p => p.PublicKey.ToHex()).ShouldContain(key);
                    value.ShouldNotBeEmpty();
                }

                // Update consensus information.
                var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.PublicKey);
                await tester.UpdateValue.SendAsync(toUpdate);
            }

            var updatedRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty());

            foreach (var minerInRound in updatedRound.RealTimeMinersInformation.Values)
            {
                minerInRound.EncryptedInValues.Count.ShouldBe(MinersCount - 1);
            }

            return(triggers);
        }
Пример #19
0
        public async Task DecryptMessage_Test()
        {
            var previousTriggers = await GenerateEncryptedMessagesAsync();

            await BootMinerChangeRoundAsync();

            var currentRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            var randomHashes = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount)
                               .Select(_ => Hash.FromString("randomHashes")).ToList();
            var triggers = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount).Select(i =>
                                                                                                                 new AElfConsensusTriggerInformation
            {
                Pubkey             = ByteString.CopyFrom(InitialCoreDataCenterKeyPairs[i].PublicKey),
                RandomHash         = randomHashes[i],
                PreviousRandomHash = previousTriggers[InitialCoreDataCenterKeyPairs[i].PublicKey.ToHex()].RandomHash
            }).ToDictionary(t => t.Pubkey.ToHex(), t => t);

            // Just `MinimumCount + 1` miners produce blocks.
            foreach (var minerInRound in currentRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order)
                     .Take(MinimumCount + 1))
            {
                var currentKeyPair = InitialCoreDataCenterKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.Pubkey);

                KeyPairProvider.SetKeyPair(currentKeyPair);

                BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime);

                var tester            = GetAEDPoSContractStub(currentKeyPair);
                var headerInformation = new AElfConsensusHeaderInformation();
                headerInformation.MergeFrom(
                    (await AEDPoSContractStub.GetInformationToUpdateConsensus.CallAsync(triggers[minerInRound.Pubkey]
                                                                                        .ToBytesValue())).Value);
                // Update consensus information.
                var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.Pubkey);
                await tester.UpdateValue.SendAsync(toUpdate);
            }

            // Won't pass because currently we postpone the revealing of in values to extra block time slot.
            // But in values all filled.
//            var secondRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty());
//            secondRound.RealTimeMinersInformation.Values.Count(v => v.PreviousInValue != null)
//                .ShouldBe(AEDPoSContractTestConstants.InitialMinersCount);
        }
Пример #20
0
        public async Task Approve_Proposal_ExpiredTime_Test()
        {
            await InitializeParliamentContracts();

            var minimalApprovalThreshold   = 6667;
            var maximalAbstentionThreshold = 2000;
            var maximalRejectionThreshold  = 3000;
            var minimalVoteThreshold       = 8000;
            var organizationAddress        = await CreateOrganizationAsync(minimalApprovalThreshold,
                                                                           maximalAbstentionThreshold, maximalRejectionThreshold, minimalVoteThreshold);

            var proposalId = await CreateProposalAsync(DefaultSenderKeyPair, organizationAddress);

            var parliamentContractStub = GetParliamentContractTester(InitialMinersKeyPairs[0]);

            BlockTimeProvider.SetBlockTime(BlockTimeProvider.GetBlockTime().AddDays(5));
            var error = await parliamentContractStub.Approve.CallWithExceptionAsync(proposalId);

            error.Value.ShouldContain("Invalid proposal.");
        }
Пример #21
0
        public async Task Update_TinyBlockInformation_Test()
        {
            await AEDPoSContract_FirstRound_BootMiner_Test();

            var roundInfo = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Div(1000)
            });
            var input = new TinyBlockInput
            {
                RoundId          = roundInfo.RoundId,
                ProducedBlocks   = 4,
                ActualMiningTime = BlockTimeProvider.GetBlockTime()
            };
            var transactionResult = await AEDPoSContractStub.UpdateTinyBlockInformation.SendAsync(input);

            transactionResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Mined);
        }
Пример #22
0
        internal async Task <TransactionList> AEDPoSContract_GenerateConsensusTransactions_FirstRound_BootMiner()
        {
            var consensusCommand = await AEDPoSContract_GetConsensusCommand_FirstRound_BootMiner_Test();

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Div(1000)
            });

            var triggerForCommand =
                await TriggerInformationProvider
                .GetTriggerInformationForConsensusTransactionsAsync(consensusCommand.ToBytesValue());

            var transactionList = await AEDPoSContractStub.GenerateConsensusTransactions.CallAsync(triggerForCommand);

            transactionList.Transactions.Count.ShouldBe(1);
            transactionList.Transactions[0].MethodName.ShouldBe(nameof(AEDPoSContractStub.UpdateValue));

            return(transactionList);
        }
Пример #23
0
        public async Task AEDPoSContract_FirstRound_Terminate_Test()
        {
            var transaction =
                (await AEDPoSContract_GenerateConsensusTransactions_FirstRound_ExtraBlockMiner_Test()).Transactions.First();

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Mul(AEDPoSContractTestConstants.InitialMinersCount)
                          .Div(1000)
            });

            var nextRound = new Round();

            nextRound.MergeFrom(transaction.Params);

            await AEDPoSContractStub.NextRound.SendAsync(nextRound);

            var currentRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            currentRound.RoundNumber.ShouldBe(2);
        }
Пример #24
0
        public async Task DecryptMessageTest()
        {
            var previousTriggers = await GenerateEncryptedMessagesTest();

            await BootMinerChangeRoundAsync();

            var currentRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty());

            var randomHashes = Enumerable.Range(0, MinersCount).Select(_ => Hash.Generate()).ToList();
            var triggers     = Enumerable.Range(0, MinersCount).Select(i => new DPoSTriggerInformation
            {
                PublicKey          = ByteString.CopyFrom(InitialMinersKeyPairs[i].PublicKey),
                RandomHash         = randomHashes[i],
                PreviousRandomHash = previousTriggers[InitialMinersKeyPairs[i].PublicKey.ToHex()].RandomHash
            }).ToDictionary(t => t.PublicKey.ToHex(), t => t);

            // Just `MinimumCount + 1` miners produce blocks.
            foreach (var minerInRound in currentRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order)
                     .Take(MinimumCount + 1))
            {
                var currentKeyPair = InitialMinersKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.PublicKey);

                ECKeyPairProvider.SetECKeyPair(currentKeyPair);

                BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime.ToDateTime());

                var tester            = GetConsensusContractTester(currentKeyPair);
                var headerInformation =
                    await tester.GetInformationToUpdateConsensus.CallAsync(triggers[minerInRound.PublicKey]);

                // Update consensus information.
                var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.PublicKey);
                await tester.UpdateValue.SendAsync(toUpdate);
            }

            // But in values all filled.
            var secondRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty());

            secondRound.RealTimeMinersInformation.Values.Count(v => v.PreviousInValue != null).ShouldBe(MinersCount);
        }
Пример #25
0
        private async Task <ConsensusCommand> AEDPoSContract_GetConsensusCommand_FirstRound_SecondMiner_Test()
        {
            await AEDPoSContract_FirstRound_BootMiner_Test();

            // Now the first time slot of first round already filled by boot miner.

            var usingKeyPair = InitialCoreDataCenterKeyPairs[1];

            KeyPairProvider.SetKeyPair(usingKeyPair);

            var blockchainStartTimestamp = BlockchainStartTimestamp;

            BlockTimeProvider.SetBlockTime(blockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Div(1000)
            });

            var triggerForCommand =
                TriggerInformationProvider.GetTriggerInformationForConsensusCommand(new BytesValue());

            var consensusCommand = await AEDPoSContractStub.GetConsensusCommand.CallAsync(triggerForCommand);

            consensusCommand.LimitMillisecondsOfMiningBlock.ShouldBe(AEDPoSContractTestConstants
                                                                     .SmallBlockMiningInterval);
            var hint = new AElfConsensusHint {
                Behaviour = AElfConsensusBehaviour.UpdateValue
            }
            .ToByteString();

            consensusCommand.Hint.ShouldBe(hint);
            consensusCommand.ArrangedMiningTime.ShouldBe(blockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Mul(7).Div(1000)
            });

            return(consensusCommand);
        }
Пример #26
0
        public async Task AEDPoSContract_ChangeMinersCount_Test()
        {
            const int termIntervalMin = 31536000 / 60;

            var maxCount = ValidationDataCenterKeyPairs.Count;

            await InitializeCandidates(maxCount);

            var firstRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            var randomHashes = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount)
                               .Select(_ => Hash.FromString("randomHashes")).ToList();
            var triggers = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount).Select(i =>
                                                                                                                 new AElfConsensusTriggerInformation
            {
                Pubkey  = ByteString.CopyFrom(InitialCoreDataCenterKeyPairs[i].PublicKey),
                InValue = randomHashes[i]
            }).ToDictionary(t => t.Pubkey.ToHex(), t => t);

            var voter = GetElectionContractTester(VoterKeyPairs[0]);

            foreach (var candidateKeyPair in ValidationDataCenterKeyPairs)
            {
                var voteResult = await voter.Vote.SendAsync(new VoteMinerInput
                {
                    CandidatePubkey = candidateKeyPair.PublicKey.ToHex(),
                    Amount          = 10 + new Random().Next(1, 10),
                    EndTimestamp    = TimestampHelper.GetUtcNow().AddDays(100)
                });

                voteResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Mined);
            }

            foreach (var minerInRound in firstRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order))
            {
                var currentKeyPair = InitialCoreDataCenterKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.Pubkey);

                KeyPairProvider.SetKeyPair(currentKeyPair);

                BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime);

                var tester            = GetAEDPoSContractStub(currentKeyPair);
                var headerInformation =
                    (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(triggers[minerInRound.Pubkey]
                                                                              .ToBytesValue())).ToConsensusHeaderInformation();

                // Update consensus information.
                var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.Pubkey);
                await tester.UpdateValue.SendAsync(toUpdate);
            }

            var changeTermTime = BlockchainStartTimestamp.ToDateTime();

            BlockTimeProvider.SetBlockTime(changeTermTime.ToTimestamp());

            var nextTermInformation = (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(
                                           new AElfConsensusTriggerInformation
            {
                Behaviour = AElfConsensusBehaviour.NextRound,
                Pubkey = ByteString.CopyFrom(BootMinerKeyPair.PublicKey)
            }.ToBytesValue())).ToConsensusHeaderInformation();

            await AEDPoSContractStub.NextRound.SendAsync(nextTermInformation.Round);

            changeTermTime = BlockchainStartTimestamp.ToDateTime().AddMinutes(termIntervalMin).AddSeconds(10);
            BlockTimeProvider.SetBlockTime(changeTermTime.ToTimestamp());

            nextTermInformation = (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(
                                       new AElfConsensusTriggerInformation
            {
                Behaviour = AElfConsensusBehaviour.NextTerm,
                Pubkey = ByteString.CopyFrom(BootMinerKeyPair.PublicKey)
            }.ToBytesValue())).ToConsensusHeaderInformation();

            var transactionResult = await AEDPoSContractStub.NextTerm.SendAsync(nextTermInformation.Round);

            transactionResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Mined);

            var newMinerStub = GetAEDPoSContractStub(ValidationDataCenterKeyPairs[0]);
            var termCount    = 0;
            var minerCount   = 0;

            while (minerCount < maxCount)
            {
                var currentRound = await newMinerStub.GetCurrentRoundInformation.CallAsync(new Empty());

                var firstPubKey = currentRound.RealTimeMinersInformation.Keys.First();
                newMinerStub = GetAEDPoSContractStub(ValidationDataCenterKeyPairs.First(o => o.PublicKey.ToHex() == firstPubKey));

                minerCount = currentRound.RealTimeMinersInformation.Count;
                Assert.Equal(AEDPoSContractTestConstants.SupposedMinersCount.Add(termCount.Mul(2)), minerCount);

                changeTermTime = BlockchainStartTimestamp.ToDateTime()
                                 .AddMinutes((termCount + 2).Mul(termIntervalMin)).AddSeconds(10);
                BlockTimeProvider.SetBlockTime(changeTermTime.ToTimestamp());
                var nextRoundInformation = (await newMinerStub.GetConsensusExtraData.CallAsync(
                                                new AElfConsensusTriggerInformation
                {
                    Behaviour = AElfConsensusBehaviour.NextTerm,
                    Pubkey = currentRound.RealTimeMinersInformation.ElementAt(0).Value.Pubkey.ToByteString()
                }.ToBytesValue())).ToConsensusHeaderInformation();

                await newMinerStub.NextTerm.SendAsync(nextRoundInformation.Round);

                termCount++;
            }
        }
Пример #27
0
        public async Task Normal_Round_First_Miner_Test()
        {
            await BootMinerChangeRoundAsync();

            // Check second round information.
            var secondRound = await BootMiner.GetCurrentRoundInformation.CallAsync(new Empty());

            secondRound.RoundNumber.ShouldBe(2);

            var firstMinerInSecondRound =
                secondRound.RealTimeMinersInformation.Values.First(m => m.Order == 1).PublicKey;

            var secondRoundStartTime =
                BlockchainStartTime.GetRoundExpectedStartTime(secondRound.TotalMilliseconds(MiningInterval), 2);

            var minerKeyPair = InitialMinersKeyPairs.First(k => k.PublicKey.ToHex() == firstMinerInSecondRound);
            var miner        = GetConsensusContractTester(minerKeyPair);

            var expectedMiningTime = secondRound.RealTimeMinersInformation[minerKeyPair.PublicKey.ToHex()]
                                     .ExpectedMiningTime.ToDateTime();

            // Normal block
            {
                // Set current time as the start time of 2rd round.
                BlockTimeProvider.SetBlockTime(secondRoundStartTime);


                var leftMilliseconds = (int)(expectedMiningTime - secondRoundStartTime).TotalMilliseconds;

                var command = await miner.GetConsensusCommand.CallAsync(new CommandInput
                                                                        { PublicKey = ByteString.CopyFrom(minerKeyPair.PublicKey) });

                command.NextBlockMiningLeftMilliseconds.ShouldBe(leftMilliseconds);
                command.LimitMillisecondsOfMiningBlock.ShouldBe(MiningInterval);
                command.Hint.ShouldBe(new DPoSHint {
                    Behaviour = DPoSBehaviour.UpdateValue
                }
                                      .ToByteArray());
            }

            // Extra block
            {
                // Pretend the miner passed his time slot.
                var fakeTime = expectedMiningTime.AddMilliseconds(MiningInterval);
                BlockTimeProvider.SetBlockTime(fakeTime);

                var extraBlockMiningTime = secondRound.GetExpectedEndTime().ToDateTime().AddMilliseconds(MiningInterval);
                var leftMilliseconds     = (int)(extraBlockMiningTime - fakeTime).TotalMilliseconds;

                var command = await miner.GetConsensusCommand.CallAsync(new CommandInput
                                                                        { PublicKey = ByteString.CopyFrom(minerKeyPair.PublicKey) });

                if (secondRound.GetExtraBlockProducerInformation().PublicKey == minerKeyPair.PublicKey.ToHex())
                {
                    // If this node is EBP
                    command.NextBlockMiningLeftMilliseconds.ShouldBe(
                        (int)(secondRound.GetExtraBlockMiningTime() - fakeTime).TotalMilliseconds);
                }
                else
                {
                    command.NextBlockMiningLeftMilliseconds.ShouldBe(leftMilliseconds);
                }
                command.LimitMillisecondsOfMiningBlock.ShouldBe(MiningInterval);
                command.Hint.ShouldBe(new DPoSHint {
                    Behaviour = DPoSBehaviour.NextRound
                }
                                      .ToByteArray());
            }
        }
Пример #28
0
        internal async Task <Hash> AEDPoSContract_GetRandomNumber_Test()
        {
            var order = await AEDPoSContract_RequestRandomNumber_Test();

            var currentRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            var randomHashes = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount)
                               .Select(i => Hash.FromString($"random{i}")).ToList();
            var triggers = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount).Select(i =>
                                                                                                                 new AElfConsensusTriggerInformation
            {
                Pubkey     = ByteString.CopyFrom(InitialCoreDataCenterKeyPairs[i].PublicKey),
                RandomHash = randomHashes[i]
            }).ToDictionary(t => t.Pubkey.ToHex(), t => t);

            // Exactly one round except extra block time slot.
            foreach (var minerInRound in currentRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order))
            {
                var currentKeyPair =
                    InitialCoreDataCenterKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.Pubkey);

                KeyPairProvider.SetKeyPair(currentKeyPair);

                BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime);

                var stub = GetAEDPoSContractStub(currentKeyPair);
                var headerInformation =
                    (await stub.GetConsensusExtraData.CallAsync(triggers[minerInRound.Pubkey]
                                                                .ToBytesValue())).ToConsensusHeaderInformation();

                // Update consensus information.
                var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.Pubkey);
                await stub.UpdateValue.SendAsync(toUpdate);

                {
                    var chain = await BlockchainService.GetChainAsync();

                    if (chain.BestChainHeight < order.BlockHeight)
                    {
                        // Not enough.
                        var transactionResult = (await AEDPoSContractStub.GetRandomNumber.SendAsync(order.TokenHash))
                                                .TransactionResult;
                        transactionResult.Error.ShouldContain("Still preparing random number.");
                    }
                }

                for (var i = 0; i < 7; i++)
                {
                    await stub.UpdateTinyBlockInformation.SendAsync(new TinyBlockInput
                    {
                        ActualMiningTime = TimestampHelper.GetUtcNow(),
                        RoundId          = currentRound.RoundId
                    });
                }
            }

            // Now it's enough.
            {
                var randomNumber = (await AEDPoSContractStub.GetRandomNumber.SendAsync(order.TokenHash)).Output;
                randomNumber.Value.ShouldNotBeEmpty();
            }

            return(order.TokenHash);
        }
Пример #29
0
        public async Task Candidates_NotEnough_Test()
        {
            //await ElectionContractStub.RegisterElectionVotingEvent.SendAsync(new Empty());

            //await InitializeVoters();
            await InitializeCandidates(EconomicContractsTestConstants.InitialCoreDataCenterCount);

            var firstRound = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            var randomHashes = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount)
                               .Select(_ => Hash.FromString("hash3")).ToList();
            var triggers = Enumerable.Range(0, EconomicContractsTestConstants.InitialCoreDataCenterCount).Select(i =>
                                                                                                                 new AElfConsensusTriggerInformation
            {
                Pubkey  = ByteString.CopyFrom(InitialCoreDataCenterKeyPairs[i].PublicKey),
                InValue = randomHashes[i]
            }).ToDictionary(t => t.Pubkey.ToHex(), t => t);

            var voter = GetElectionContractTester(VoterKeyPairs[0]);

            foreach (var candidateKeyPair in ValidationDataCenterKeyPairs.Take(EconomicContractsTestConstants
                                                                               .InitialCoreDataCenterCount))
            {
                await voter.Vote.SendAsync(new VoteMinerInput
                {
                    CandidatePubkey = candidateKeyPair.PublicKey.ToHex(),
                    Amount          = 100 + new Random().Next(1, 200),
                    EndTimestamp    = TimestampHelper.GetUtcNow().AddDays(100)
                });
            }

            foreach (var minerInRound in firstRound.RealTimeMinersInformation.Values.OrderBy(m => m.Order))
            {
                var currentKeyPair =
                    InitialCoreDataCenterKeyPairs.First(p => p.PublicKey.ToHex() == minerInRound.Pubkey);

                KeyPairProvider.SetKeyPair(currentKeyPair);

                BlockTimeProvider.SetBlockTime(minerInRound.ExpectedMiningTime);

                var tester            = GetAEDPoSContractStub(currentKeyPair);
                var headerInformation =
                    (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(triggers[minerInRound.Pubkey]
                                                                              .ToBytesValue())).ToConsensusHeaderInformation();

                // Update consensus information.
                var toUpdate = headerInformation.Round.ExtractInformationToUpdateConsensus(minerInRound.Pubkey);
                await tester.UpdateValue.SendAsync(toUpdate);
            }

            var changeTermTime = BlockchainStartTimestamp.ToDateTime()
                                 .AddMinutes(AEDPoSContractTestConstants.TimeEachTerm + 1);

            BlockTimeProvider.SetBlockTime(changeTermTime.ToTimestamp());

            var nextTermInformation = (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(
                                           new AElfConsensusTriggerInformation
            {
                Behaviour = AElfConsensusBehaviour.NextTerm,
                Pubkey = ByteString.CopyFrom(BootMinerKeyPair.PublicKey)
            }.ToBytesValue())).ToConsensusHeaderInformation();

            await AEDPoSContractStub.NextTerm.SendAsync(nextTermInformation.Round);

            // First candidate cheat others with in value.
            var oneCandidate             = GetAEDPoSContractStub(ValidationDataCenterKeyPairs[0]);
            var anotherCandidate         = GetAEDPoSContractStub(ValidationDataCenterKeyPairs[1]);
            var randomHash               = Hash.FromString("hash5");
            var informationOfSecondRound = (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(
                                                new AElfConsensusTriggerInformation
            {
                Behaviour = AElfConsensusBehaviour.UpdateValue,
                PreviousInValue = Hash.Empty,
                InValue = randomHash,
                Pubkey = ByteString.CopyFrom(ValidationDataCenterKeyPairs[0].PublicKey)
            }.ToBytesValue())).ToConsensusHeaderInformation();
            var updateResult = await oneCandidate.UpdateValue.SendAsync(
                informationOfSecondRound.Round.ExtractInformationToUpdateConsensus(ValidationDataCenterKeyPairs[0]
                                                                                   .PublicKey.ToHex()));

            var thirdRoundStartTime = changeTermTime.AddMinutes(AEDPoSContractTestConstants.TimeEachTerm + 2);

            BlockTimeProvider.SetBlockTime(thirdRoundStartTime.ToTimestamp());
            var thirdRound = (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(
                                  new AElfConsensusTriggerInformation
            {
                Behaviour = AElfConsensusBehaviour.NextRound,
                Pubkey = ByteString.CopyFrom(ValidationDataCenterKeyPairs[0].PublicKey)
            }.ToBytesValue())).ToConsensusHeaderInformation().Round;

            await oneCandidate.NextRound.SendAsync(thirdRound);

            var cheatInformation = (await AEDPoSContractStub.GetConsensusExtraData.CallAsync(
                                        new AElfConsensusTriggerInformation
            {
                Behaviour = AElfConsensusBehaviour.UpdateValue,
                PreviousInValue = Hash.FromMessage(randomHash), // Not same as before.
                InValue = Hash.FromString("InValue"),           // Don't care this value in current test case.
                Pubkey = ByteString.CopyFrom(ValidationDataCenterKeyPairs[0].PublicKey)
            }.ToBytesValue())).ToConsensusHeaderInformation();
            await oneCandidate.UpdateValue.SendAsync(
                cheatInformation.Round.ExtractInformationToUpdateConsensus(ValidationDataCenterKeyPairs[0].PublicKey
                                                                           .ToHex()));
        }