mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 06:14:38 +00:00
Merge branch 'master' into proto-array
This commit is contained in:
@@ -311,11 +311,7 @@ fn bench_block<T: EthSpec>(
|
||||
)
|
||||
.expect("should get indexed attestation");
|
||||
|
||||
(
|
||||
local_spec.clone(),
|
||||
local_state.clone(),
|
||||
indexed_attestation.clone(),
|
||||
)
|
||||
(local_spec.clone(), local_state.clone(), indexed_attestation)
|
||||
},
|
||||
|(spec, ref mut state, indexed_attestation)| {
|
||||
black_box(
|
||||
@@ -349,11 +345,7 @@ fn bench_block<T: EthSpec>(
|
||||
)
|
||||
.expect("should get indexed attestation");
|
||||
|
||||
(
|
||||
local_spec.clone(),
|
||||
local_state.clone(),
|
||||
indexed_attestation.clone(),
|
||||
)
|
||||
(local_spec.clone(), local_state.clone(), indexed_attestation)
|
||||
},
|
||||
|(spec, ref mut state, indexed_attestation)| {
|
||||
black_box(
|
||||
@@ -373,7 +365,7 @@ fn bench_block<T: EthSpec>(
|
||||
);
|
||||
|
||||
let local_block = block.clone();
|
||||
let local_state = state.clone();
|
||||
let local_state = state;
|
||||
c.bench(
|
||||
&title,
|
||||
Benchmark::new("get_attesting_indices", move |b| {
|
||||
@@ -409,7 +401,7 @@ fn bench_block<T: EthSpec>(
|
||||
.sample_size(10),
|
||||
);
|
||||
|
||||
let local_block = block.clone();
|
||||
let local_block = block;
|
||||
c.bench(
|
||||
&title,
|
||||
Benchmark::new("ssz_block_len", move |b| {
|
||||
|
||||
23
eth2/state_processing/src/common/get_base_reward.rs
Normal file
23
eth2/state_processing/src/common/get_base_reward.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use integer_sqrt::IntegerSquareRoot;
|
||||
use types::*;
|
||||
|
||||
/// Returns the base reward for some validator.
|
||||
///
|
||||
/// Spec v0.9.1
|
||||
pub fn get_base_reward<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
index: usize,
|
||||
// Should be == get_total_active_balance(state, spec)
|
||||
total_active_balance: u64,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<u64, BeaconStateError> {
|
||||
if total_active_balance == 0 {
|
||||
Ok(0)
|
||||
} else {
|
||||
Ok(
|
||||
state.get_effective_balance(index, spec)? * spec.base_reward_factor
|
||||
/ total_active_balance.integer_sqrt()
|
||||
/ spec.base_rewards_per_epoch,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
mod get_attesting_indices;
|
||||
mod get_base_reward;
|
||||
mod get_indexed_attestation;
|
||||
mod initiate_validator_exit;
|
||||
mod slash_validator;
|
||||
|
||||
pub use get_attesting_indices::get_attesting_indices;
|
||||
pub use get_base_reward::get_base_reward;
|
||||
pub use get_indexed_attestation::get_indexed_attestation;
|
||||
pub use initiate_validator_exit::initiate_validator_exit;
|
||||
pub use slash_validator::slash_validator;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::super::common::get_base_reward;
|
||||
use super::validator_statuses::{TotalBalances, ValidatorStatus, ValidatorStatuses};
|
||||
use super::Error;
|
||||
use integer_sqrt::IntegerSquareRoot;
|
||||
|
||||
use types::*;
|
||||
|
||||
/// Use to track the changes to a validators balance.
|
||||
@@ -211,24 +212,3 @@ fn get_attestation_delta<T: EthSpec>(
|
||||
|
||||
delta
|
||||
}
|
||||
|
||||
/// Returns the base reward for some validator.
|
||||
///
|
||||
/// Spec v0.9.1
|
||||
fn get_base_reward<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
index: usize,
|
||||
// Should be == get_total_active_balance(state, spec)
|
||||
total_active_balance: u64,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<u64, BeaconStateError> {
|
||||
if total_active_balance == 0 {
|
||||
Ok(0)
|
||||
} else {
|
||||
Ok(
|
||||
state.get_effective_balance(index, spec)? * spec.base_reward_factor
|
||||
/ total_active_balance.integer_sqrt()
|
||||
/ spec.base_rewards_per_epoch,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ where
|
||||
F: FnMut(&mut BlockBuilder<T>),
|
||||
G: FnMut(&mut BeaconBlock<T>),
|
||||
{
|
||||
let (mut block, state) = get_block::<T, _>(mutate_builder);
|
||||
let (mut block, mut state) = get_block::<T, _>(mutate_builder);
|
||||
|
||||
/*
|
||||
* Control check to ensure the valid block should pass verification.
|
||||
@@ -79,7 +79,7 @@ where
|
||||
|
||||
assert_eq!(
|
||||
per_block_processing(
|
||||
&mut state.clone(),
|
||||
&mut state,
|
||||
&block,
|
||||
None,
|
||||
BlockSignatureStrategy::VerifyBulk,
|
||||
|
||||
Reference in New Issue
Block a user