Solana中的投票流程

Posted mutourend

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Solana中的投票流程相关的知识,希望对你有一定的参考价值。

1. 引言

前序博客有:

2. TPU中收集投票

		let (verified_vote_packets_sender, verified_vote_packets_receiver) = unbounded();
        let cluster_info_vote_listener = ClusterInfoVoteListener::new(
            exit,
            cluster_info.clone(),
            verified_vote_packets_sender,
            poh_recorder,
            vote_tracker,
            bank_forks.clone(),
            subscriptions.clone(),
            verified_vote_sender,
            gossip_verified_vote_hash_sender,
            replay_vote_receiver,
            blockstore.clone(),
            bank_notification_sender,
            cluster_confirmed_slot_sender,
        );

TPU中的监听投票流程与banking_stage是并行进行的。

投票的维度有2种,分别为:

  • vote for label packets
  • vote for transactions
		let (verified_vote_label_packets_sender, verified_vote_label_packets_receiver) =
            unbounded();
        let (verified_vote_transactions_sender, verified_vote_transactions_receiver) = unbounded();

并行处理的流程有:

  • 1)recv_loop():通过gossip协议收集投票信息 -》 验证投票中的交易和label信息-》分别发送transactions vote和label packets vote
let (labels, votes) = cluster_info.get_votes(&mut cursor);
.....
let (vote_txs, packets) = Self::verify_votes(votes, labels);
 verified_vote_transactions_sender.send(vote_txs)?;
verified_vote_label_packets_sender.send(packets)?;
  • 2)bank_send_loop():
    2.1)借助receive_and_process_vote_packets(),若当前Validator为leader,则将相应的packets插入到VerifiedVotePackets中;若不是leader,则清空VerifiedVotePackets。
    2.2)为leader时,借助get_latest_votes(),过滤VerifiedVotePackets中,version版本大于last_version的packets。
    2.3)将过滤后的packets通过verified_packets_sender发出,并更新bank中记录的最新version。
  • 3)process_votes_loop():
    verify_for_unrooted_optimistic_slots():Returns any optimistic slots that were not rooted
    log_unrooted_optimistic_slots()
    progress_leader_schedule_epoch():Update with any newly calculated epoch state about future epochs
    purge_stale_state():Purge any outdated slot data
    listen_and_confirm_votes()
    add_new_optimistic_confirmed_slots():只对confirmed slots进行处理。

3. TVU在replay stage进行投票

以上是关于Solana中的投票流程的主要内容,如果未能解决你的问题,请参考以下文章

Solana区块链智能合约开发简要流程

Solana区块链智能合约开发简要流程

Solana 链中的打字稿错误。 (测试网中的 Solana 交易)

Solana中的托管合约

Solana开发入门源码

本文带你轻松搭建solana验证节点