信标链的激励机制信标链的奖励由五部分组成:
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) |