mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Plumb reward cache through reward calc
This commit is contained in:
@@ -3280,7 +3280,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
metrics::start_timer(&metrics::BLOCK_PRODUCTION_UNAGGREGATED_TIMES);
|
||||
for attestation in self.naive_aggregation_pool.read().iter() {
|
||||
let import = |attestation: &Attestation<T::EthSpec>| {
|
||||
let attesting_indices = get_attesting_indices_from_state(&state, &attestation)?;
|
||||
let attesting_indices = get_attesting_indices_from_state(&state, attestation)?;
|
||||
self.op_pool
|
||||
.insert_attestation(attestation.clone(), attesting_indices)
|
||||
};
|
||||
@@ -3342,8 +3342,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
"err" => ?e,
|
||||
"block_slot" => state.slot(),
|
||||
);
|
||||
assert!(false);
|
||||
false
|
||||
panic!("Attempted to include an invalid attestation");
|
||||
// false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
||||
@@ -13,14 +13,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
block: BeaconBlockRef<'_, T::EthSpec, Payload>,
|
||||
block_root: Hash256,
|
||||
state: &BeaconState<T::EthSpec>,
|
||||
reward_cache: &mut RewardCache,
|
||||
include_attestations: bool,
|
||||
) -> Result<BlockReward, BeaconChainError> {
|
||||
if block.slot() != state.slot() {
|
||||
return Err(BeaconChainError::BlockRewardSlotError);
|
||||
}
|
||||
|
||||
// FIXME(sproul): pass this in
|
||||
let mut reward_cache = RewardCache::default();
|
||||
reward_cache.update(state)?;
|
||||
|
||||
let total_active_balance = state.get_total_active_balance()?;
|
||||
@@ -41,7 +40,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
AttMaxCover::new(
|
||||
att.as_ref(),
|
||||
state,
|
||||
&reward_cache,
|
||||
reward_cache,
|
||||
total_active_balance,
|
||||
&self.spec,
|
||||
)
|
||||
|
||||
@@ -1278,8 +1278,14 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
|
||||
*/
|
||||
if let Some(ref event_handler) = chain.event_handler {
|
||||
if event_handler.has_block_reward_subscribers() {
|
||||
let block_reward =
|
||||
chain.compute_block_reward(block.message(), block_root, &state, true)?;
|
||||
let mut reward_cache = Default::default();
|
||||
let block_reward = chain.compute_block_reward(
|
||||
block.message(),
|
||||
block_root,
|
||||
&state,
|
||||
&mut reward_cache,
|
||||
true,
|
||||
)?;
|
||||
event_handler.register(EventKind::BlockReward(block_reward));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user