mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-26 01:03:40 +00:00
Merge branch 'unstable' into validator-manager
This commit is contained in:
@@ -482,7 +482,7 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
/// Spec v0.12.1
|
||||
pub fn get_committee_count_at_slot(&self, slot: Slot) -> Result<u64, Error> {
|
||||
let cache = self.committee_cache_at_slot(slot)?;
|
||||
Ok(cache.committees_per_slot() as u64)
|
||||
Ok(cache.committees_per_slot())
|
||||
}
|
||||
|
||||
/// Compute the number of committees in an entire epoch.
|
||||
|
||||
@@ -144,7 +144,7 @@ impl CommitteeCache {
|
||||
self.committees_per_slot as usize,
|
||||
index as usize,
|
||||
);
|
||||
let committee = self.compute_committee(committee_index as usize)?;
|
||||
let committee = self.compute_committee(committee_index)?;
|
||||
|
||||
Some(BeaconCommittee {
|
||||
slot,
|
||||
|
||||
@@ -344,12 +344,7 @@ mod committees {
|
||||
|
||||
let cache_epoch = cache_epoch.into_epoch(state_epoch);
|
||||
|
||||
execute_committee_consistency_test(
|
||||
new_head_state,
|
||||
cache_epoch,
|
||||
validator_count as usize,
|
||||
spec,
|
||||
);
|
||||
execute_committee_consistency_test(new_head_state, cache_epoch, validator_count, spec);
|
||||
}
|
||||
|
||||
async fn committee_consistency_test_suite<T: EthSpec>(cached_epoch: RelativeEpoch) {
|
||||
@@ -361,18 +356,13 @@ mod committees {
|
||||
.mul(spec.target_committee_size)
|
||||
.add(1);
|
||||
|
||||
committee_consistency_test::<T>(validator_count as usize, Epoch::new(0), cached_epoch)
|
||||
committee_consistency_test::<T>(validator_count, Epoch::new(0), cached_epoch).await;
|
||||
|
||||
committee_consistency_test::<T>(validator_count, T::genesis_epoch() + 4, cached_epoch)
|
||||
.await;
|
||||
|
||||
committee_consistency_test::<T>(
|
||||
validator_count as usize,
|
||||
T::genesis_epoch() + 4,
|
||||
cached_epoch,
|
||||
)
|
||||
.await;
|
||||
|
||||
committee_consistency_test::<T>(
|
||||
validator_count as usize,
|
||||
validator_count,
|
||||
T::genesis_epoch()
|
||||
+ (T::slots_per_historical_root() as u64)
|
||||
.mul(T::slots_per_epoch())
|
||||
|
||||
74
consensus/types/src/execution_block_header.rs
Normal file
74
consensus/types/src/execution_block_header.rs
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2022 Reth Contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
use crate::{Address, EthSpec, ExecutionPayload, Hash256, Hash64, Uint256};
|
||||
use metastruct::metastruct;
|
||||
|
||||
/// Execution block header as used for RLP encoding and Keccak hashing.
|
||||
///
|
||||
/// Credit to Reth for the type definition.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[metastruct(mappings(map_execution_block_header_fields()))]
|
||||
pub struct ExecutionBlockHeader {
|
||||
pub parent_hash: Hash256,
|
||||
pub ommers_hash: Hash256,
|
||||
pub beneficiary: Address,
|
||||
pub state_root: Hash256,
|
||||
pub transactions_root: Hash256,
|
||||
pub receipts_root: Hash256,
|
||||
pub logs_bloom: Vec<u8>,
|
||||
pub difficulty: Uint256,
|
||||
pub number: Uint256,
|
||||
pub gas_limit: Uint256,
|
||||
pub gas_used: Uint256,
|
||||
pub timestamp: u64,
|
||||
pub extra_data: Vec<u8>,
|
||||
pub mix_hash: Hash256,
|
||||
pub nonce: Hash64,
|
||||
pub base_fee_per_gas: Uint256,
|
||||
}
|
||||
|
||||
impl ExecutionBlockHeader {
|
||||
pub fn from_payload<E: EthSpec>(
|
||||
payload: &ExecutionPayload<E>,
|
||||
rlp_empty_list_root: Hash256,
|
||||
rlp_transactions_root: Hash256,
|
||||
) -> Self {
|
||||
// Most of these field mappings are defined in EIP-3675 except for `mixHash`, which is
|
||||
// defined in EIP-4399.
|
||||
ExecutionBlockHeader {
|
||||
parent_hash: payload.parent_hash.into_root(),
|
||||
ommers_hash: rlp_empty_list_root,
|
||||
beneficiary: payload.fee_recipient,
|
||||
state_root: payload.state_root,
|
||||
transactions_root: rlp_transactions_root,
|
||||
receipts_root: payload.receipts_root,
|
||||
logs_bloom: payload.logs_bloom.clone().into(),
|
||||
difficulty: Uint256::zero(),
|
||||
number: payload.block_number.into(),
|
||||
gas_limit: payload.gas_limit.into(),
|
||||
gas_used: payload.gas_used.into(),
|
||||
timestamp: payload.timestamp,
|
||||
extra_data: payload.extra_data.clone().into(),
|
||||
mix_hash: payload.prev_randao,
|
||||
nonce: Hash64::zero(),
|
||||
base_fee_per_gas: payload.base_fee_per_gas,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ pub mod withdrawal_credentials;
|
||||
#[macro_use]
|
||||
pub mod slot_epoch_macros;
|
||||
pub mod config_and_preset;
|
||||
pub mod execution_block_header;
|
||||
pub mod fork_context;
|
||||
pub mod participation_flags;
|
||||
pub mod participation_list;
|
||||
@@ -128,6 +129,7 @@ pub use crate::enr_fork_id::EnrForkId;
|
||||
pub use crate::eth1_data::Eth1Data;
|
||||
pub use crate::eth_spec::EthSpecId;
|
||||
pub use crate::execution_block_hash::ExecutionBlockHash;
|
||||
pub use crate::execution_block_header::ExecutionBlockHeader;
|
||||
pub use crate::execution_payload::{ExecutionPayload, Transaction, Transactions};
|
||||
pub use crate::execution_payload_header::ExecutionPayloadHeader;
|
||||
pub use crate::fork::Fork;
|
||||
@@ -181,6 +183,7 @@ pub type Hash256 = H256;
|
||||
pub type Uint256 = ethereum_types::U256;
|
||||
pub type Address = H160;
|
||||
pub type ForkVersion = [u8; 4];
|
||||
pub type Hash64 = ethereum_types::H64;
|
||||
|
||||
pub use bls::{
|
||||
AggregatePublicKey, AggregateSignature, Keypair, PublicKey, PublicKeyBytes, SecretKey,
|
||||
|
||||
@@ -202,7 +202,7 @@ mod test {
|
||||
}
|
||||
|
||||
fn preset_from_file<T: DeserializeOwned>(preset_name: &str, filename: &str) -> T {
|
||||
let f = File::open(&presets_base_path().join(preset_name).join(filename))
|
||||
let f = File::open(presets_base_path().join(preset_name).join(filename))
|
||||
.expect("preset file exists");
|
||||
serde_yaml::from_reader(f).unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user