Altair consensus changes and refactors (#2279)

## Proposed Changes

Implement the consensus changes necessary for the upcoming Altair hard fork.

## Additional Info

This is quite a heavy refactor, with pivotal types like the `BeaconState` and `BeaconBlock` changing from structs to enums. This ripples through the whole codebase with field accesses changing to methods, e.g. `state.slot` => `state.slot()`.


Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
Michael Sproul
2021-07-09 06:15:32 +00:00
parent 89361573d4
commit b4689e20c6
271 changed files with 9652 additions and 8444 deletions

View File

@@ -3,10 +3,10 @@
use environment::EnvironmentBuilder;
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK};
use std::path::PathBuf;
use types::{V012LegacyEthSpec, YamlConfig};
use types::{Config, MainnetEthSpec};
fn builder() -> EnvironmentBuilder<V012LegacyEthSpec> {
EnvironmentBuilder::v012_legacy()
fn builder() -> EnvironmentBuilder<MainnetEthSpec> {
EnvironmentBuilder::mainnet()
.multi_threaded_tokio_runtime()
.expect("should set runtime")
.null_logger()
@@ -23,11 +23,11 @@ mod setup_eth2_config {
#[test]
fn update_spec_with_yaml_config() {
if let Some(mut eth2_network_config) = eth2_network_config() {
let config_yaml = PathBuf::from("./tests/testnet_dir/config.yaml");
let testnet_dir = PathBuf::from("./tests/testnet_dir");
let config = testnet_dir.join("config.yaml");
eth2_network_config.yaml_config = Some(
YamlConfig::from_file(config_yaml.as_path()).expect("should load yaml config"),
);
eth2_network_config.config =
Config::from_file(config.as_path()).expect("should load yaml config");
let environment = builder()
.eth2_network_config(eth2_network_config)
@@ -36,8 +36,15 @@ mod setup_eth2_config {
.expect("should build environment");
assert_eq!(
environment.eth2_config.spec.max_committees_per_slot,
128 // see testnet_dir/config.yaml
environment
.eth2_config
.spec
.min_genesis_active_validator_count,
100000 // see testnet_dir/config.yaml
);
assert_eq!(
environment.eth2_config.spec.inactivity_score_bias,
2 // see testnet_dir/config.yaml
);
}
}