mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 05:18:30 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -146,6 +146,7 @@ pub struct ChainSpec {
|
||||
pub terminal_total_difficulty: Uint256,
|
||||
pub terminal_block_hash: ExecutionBlockHash,
|
||||
pub terminal_block_hash_activation_epoch: Epoch,
|
||||
pub safe_slots_to_import_optimistically: u64,
|
||||
|
||||
/*
|
||||
* Networking
|
||||
@@ -558,6 +559,7 @@ impl ChainSpec {
|
||||
.expect("addition does not overflow"),
|
||||
terminal_block_hash: ExecutionBlockHash::zero(),
|
||||
terminal_block_hash_activation_epoch: Epoch::new(u64::MAX),
|
||||
safe_slots_to_import_optimistically: 128u64,
|
||||
|
||||
/*
|
||||
* Network specific
|
||||
@@ -755,6 +757,7 @@ impl ChainSpec {
|
||||
.expect("addition does not overflow"),
|
||||
terminal_block_hash: ExecutionBlockHash::zero(),
|
||||
terminal_block_hash_activation_epoch: Epoch::new(u64::MAX),
|
||||
safe_slots_to_import_optimistically: 128u64,
|
||||
|
||||
/*
|
||||
* Network specific
|
||||
@@ -798,6 +801,10 @@ pub struct Config {
|
||||
// TODO(merge): remove this default
|
||||
#[serde(default = "default_terminal_block_hash_activation_epoch")]
|
||||
pub terminal_block_hash_activation_epoch: Epoch,
|
||||
// TODO(merge): remove this default
|
||||
#[serde(default = "default_safe_slots_to_import_optimistically")]
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub safe_slots_to_import_optimistically: u64,
|
||||
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
min_genesis_active_validator_count: u64,
|
||||
@@ -885,6 +892,10 @@ fn default_terminal_block_hash_activation_epoch() -> Epoch {
|
||||
Epoch::new(u64::MAX)
|
||||
}
|
||||
|
||||
fn default_safe_slots_to_import_optimistically() -> u64 {
|
||||
128u64
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
let chain_spec = MainnetEthSpec::default_spec();
|
||||
@@ -942,6 +953,7 @@ impl Config {
|
||||
terminal_total_difficulty: spec.terminal_total_difficulty,
|
||||
terminal_block_hash: spec.terminal_block_hash,
|
||||
terminal_block_hash_activation_epoch: spec.terminal_block_hash_activation_epoch,
|
||||
safe_slots_to_import_optimistically: spec.safe_slots_to_import_optimistically,
|
||||
|
||||
min_genesis_active_validator_count: spec.min_genesis_active_validator_count,
|
||||
min_genesis_time: spec.min_genesis_time,
|
||||
@@ -992,6 +1004,7 @@ impl Config {
|
||||
terminal_total_difficulty,
|
||||
terminal_block_hash,
|
||||
terminal_block_hash_activation_epoch,
|
||||
safe_slots_to_import_optimistically,
|
||||
min_genesis_active_validator_count,
|
||||
min_genesis_time,
|
||||
genesis_fork_version,
|
||||
@@ -1047,6 +1060,7 @@ impl Config {
|
||||
terminal_total_difficulty,
|
||||
terminal_block_hash,
|
||||
terminal_block_hash_activation_epoch,
|
||||
safe_slots_to_import_optimistically,
|
||||
..chain_spec.clone()
|
||||
})
|
||||
}
|
||||
@@ -1157,14 +1171,13 @@ mod tests {
|
||||
#[cfg(test)]
|
||||
mod yaml_tests {
|
||||
use super::*;
|
||||
use std::fs::OpenOptions;
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
#[test]
|
||||
fn minimal_round_trip() {
|
||||
// create temp file
|
||||
let tmp_file = NamedTempFile::new().expect("failed to create temp file");
|
||||
let writer = OpenOptions::new()
|
||||
let writer = File::options()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.open(tmp_file.as_ref())
|
||||
@@ -1175,7 +1188,7 @@ mod yaml_tests {
|
||||
// write fresh minimal config to file
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = OpenOptions::new()
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
.write(false)
|
||||
.open(tmp_file.as_ref())
|
||||
@@ -1188,7 +1201,7 @@ mod yaml_tests {
|
||||
#[test]
|
||||
fn mainnet_round_trip() {
|
||||
let tmp_file = NamedTempFile::new().expect("failed to create temp file");
|
||||
let writer = OpenOptions::new()
|
||||
let writer = File::options()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.open(tmp_file.as_ref())
|
||||
@@ -1197,7 +1210,7 @@ mod yaml_tests {
|
||||
let yamlconfig = Config::from_chain_spec::<MainnetEthSpec>(&mainnet_spec);
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = OpenOptions::new()
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
.write(false)
|
||||
.open(tmp_file.as_ref())
|
||||
@@ -1234,6 +1247,7 @@ mod yaml_tests {
|
||||
#TERMINAL_TOTAL_DIFFICULTY: 115792089237316195423570985008687907853269984665640564039457584007913129638911
|
||||
#TERMINAL_BLOCK_HASH: 0x0000000000000000000000000000000000000000000000000000000000000001
|
||||
#TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: 18446744073709551614
|
||||
#SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY: 2
|
||||
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 16384
|
||||
MIN_GENESIS_TIME: 1606824000
|
||||
GENESIS_FORK_VERSION: 0x00000000
|
||||
@@ -1273,6 +1287,10 @@ mod yaml_tests {
|
||||
chain_spec.terminal_block_hash_activation_epoch,
|
||||
default_terminal_block_hash_activation_epoch()
|
||||
);
|
||||
assert_eq!(
|
||||
chain_spec.safe_slots_to_import_optimistically,
|
||||
default_safe_slots_to_import_optimistically()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
chain_spec.bellatrix_fork_epoch,
|
||||
|
||||
@@ -92,13 +92,13 @@ impl ConfigAndPreset {
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::MainnetEthSpec;
|
||||
use std::fs::OpenOptions;
|
||||
use std::fs::File;
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
#[test]
|
||||
fn extra_fields_round_trip() {
|
||||
let tmp_file = NamedTempFile::new().expect("failed to create temp file");
|
||||
let writer = OpenOptions::new()
|
||||
let writer = File::options()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.open(tmp_file.as_ref())
|
||||
@@ -116,7 +116,7 @@ mod test {
|
||||
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = OpenOptions::new()
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
.write(false)
|
||||
.open(tmp_file.as_ref())
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct ExecutionPayload<T: EthSpec> {
|
||||
pub receipts_root: Hash256,
|
||||
#[serde(with = "ssz_types::serde_utils::hex_fixed_vec")]
|
||||
pub logs_bloom: FixedVector<u8, T::BytesPerLogsBloom>,
|
||||
pub random: Hash256,
|
||||
pub prev_randao: Hash256,
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub block_number: u64,
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct ExecutionPayloadHeader<T: EthSpec> {
|
||||
pub receipts_root: Hash256,
|
||||
#[serde(with = "ssz_types::serde_utils::hex_fixed_vec")]
|
||||
pub logs_bloom: FixedVector<u8, T::BytesPerLogsBloom>,
|
||||
pub random: Hash256,
|
||||
pub prev_randao: Hash256,
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub block_number: u64,
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
|
||||
@@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ProposerPreparationData {
|
||||
/// The validators index.
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub validator_index: u64,
|
||||
/// The fee-recipient address.
|
||||
pub fee_recipient: Address,
|
||||
|
||||
Reference in New Issue
Block a user