织梦CMS - 轻松建站从此开始!

我的网站

当前位置: 主页 > 竞争币 > 以太坊

开发者必读:代码解读成为以太坊 2.0 验证人,探索信标链激励机制 (9)

时间:2020-06-26 09:20来源:未知 作者:admin 点击:
信标链的激励机制 信标链的奖励由五部分组成: ⻅证被包含在最新的区块中 ⻅证中包括了正确的检查点的投票 ⻅证中包含了正确的最新区块 ⻅证被很快

信标链的激励机制

信标链的奖励由五部分组成:

  • ⻅证被包含在最新的区块中
  • ⻅证中包括了正确的检查点的投票
  • ⻅证中包含了正确的最新区块
  • ⻅证被很快地包含到链上
  • ⻅证包含正确的分片区块(Phase1 阶段实现)
    *

def get_attestation_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], Sequence[Gwei]]: """ Return attestation reward/penalty deltas for each validator. """ source_rewards, source_penalties = get_source_deltas(state) # 计算检查点 source 奖惩 target_rewards, target_penalties = get_target_deltas(state) # 计算检查点 target 奖惩 head_rewards, head_penalties = get_head_deltas(state) # 计算最新区块奖惩 inclusion_delay_rewards,_= get_inclusion_delay_deltas(state) # 计算入块延迟奖惩 _, inactivity_penalties = get_inactivity_penalty_deltas(state) rewards = [ source_rewards[i] + target_rewards[i] + head_rewards[i] + inclusion_delay_rewards[i] for i in range(len(state.validators)) ] penalties = [ source_penalties[i] + target_penalties[i] + head_penalties[i] + inactivity_penalties[i] for i in range(len(state.validators)) ] return rewards, penalties

(向左滑动,查看完整代码)

上面的代码段就是信标链最新的标准。验证人的奖励实际上奖励由基础奖励 (B) * 执行正确投票的验证人比例 (P) 构成,任何一个没有正确投票的验证人都将受到-B 的惩罚。这样一来,做出正确投票的人越多,大家得到的奖励就会越多,从而抑制作恶的投票。

目前决定一个验证人基础奖励的计算公式如下标准代码所示:

*

def get_attestation_component_deltas(state: BeaconState, attestations: Sequence[PendingAttestation] ) -> Tuple[Sequence[Gwei], Sequence[Gwei]]: """ Helper with shared logic for use by get source, target, and head deltas functions """ rewards = [Gwei(0)] * len(state.validators) penalties = [Gwei(0)] * len(state.validators) total_balance = get_total_active_balance(state) unslashed_attesting_indices = get_unslashed_attesting_indices(state, attestations) attesting_balance = get_total_balance(state, unslashed_attesting_indices) for index in get_eligible_validator_indices(state): if index in unslashed_attesting_indices: increment = EFFECTIVE_BALANCE_INCREMENT # Factored out from balance totals to avoid uint64 overflow if is_in_inactivity_leak(state): # Since full base reward will be canceled out by inactivity penalty deltas, # optimal participation receives full base reward compensation here. rewards[index] += get_base_reward(state, index) else: reward_numerator = get_base_reward(state, index) * (attesting_balance // increment) rewards[index] += reward_numerator // (total_balance // increment) else: penalties[index] += get_base_reward(state, index) (责任编辑:admin)

织梦二维码生成器
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
推荐内容