Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First change to validate #4527

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/eth1_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ fn is_candidate_block(block: &Eth1Block, period_start: u64, spec: &ChainSpec) ->
#[cfg(test)]
mod test {
use super::*;
use environment::null_logger;
use logging::test_logger;
use types::{DepositData, MinimalEthSpec, Signature};

type E = MinimalEthSpec;
Expand Down Expand Up @@ -743,7 +743,7 @@ mod test {
..Eth1Config::default()
};

let log = null_logger().unwrap();
let log = test_logger();
Eth1Chain::new(
CachingEth1Backend::new(eth1_config, log, MainnetEthSpec::default_spec()).unwrap(),
)
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/shuffling_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl BlockShufflingIds {
#[cfg(not(debug_assertions))]
#[cfg(test)]
mod test {
use task_executor::test_utils::null_logger;
use logging::test_logger;
use types::*;

use crate::test_utils::EphemeralHarnessType;
Expand All @@ -315,7 +315,7 @@ mod test {
previous: Some(shuffling_id(current_epoch - 1)),
block_root: Hash256::from_low_u64_le(0),
};
let logger = null_logger().unwrap();
let logger = test_logger().unwrap();
ShufflingCache::new(TEST_CACHE_SIZE, head_shuffling_ids, logger)
}

Expand Down
27 changes: 10 additions & 17 deletions beacon_node/eth1/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
#![cfg(test)]
use environment::{Environment, EnvironmentBuilder};
use environment::{test_logger, Environment, EnvironmentBuilder};
use eth1::{Config, Eth1Endpoint, Service};
use eth1::{DepositCache, DEFAULT_CHAIN_ID};
use eth1_test_rig::{AnvilEth1Instance, Http, Middleware, Provider};
use execution_layer::http::{deposit_methods::*, HttpJsonRpc, Log};
use merkle_proof::verify_merkle_proof;
use sensitive_url::SensitiveUrl;
use slog::Logger;
use sloggers::{null::NullLoggerBuilder, Build};
use std::ops::Range;
use std::time::Duration;
use tree_hash::TreeHash;
use types::{DepositData, EthSpec, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec, Signature};

const DEPOSIT_CONTRACT_TREE_DEPTH: usize = 32;

pub fn null_logger() -> Logger {
let log_builder = NullLoggerBuilder;
log_builder.build().expect("should build logger")
}

pub fn new_env() -> Environment<MinimalEthSpec> {
EnvironmentBuilder::minimal()
.multi_threaded_tokio_runtime()
.expect("should start tokio runtime")
.null_logger()
.test_logger()
.expect("should start null logger")
.build()
.expect("should build env")
Expand Down Expand Up @@ -104,7 +97,7 @@ mod eth1_cache {
#[tokio::test]
async fn simple_scenario() {
async {
let log = null_logger();
let log = test_logger();

for follow_distance in 0..3 {
let eth1 = new_anvil_instance()
Expand Down Expand Up @@ -186,7 +179,7 @@ mod eth1_cache {
#[tokio::test]
async fn big_skip() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down Expand Up @@ -241,7 +234,7 @@ mod eth1_cache {
#[tokio::test]
async fn pruning() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down Expand Up @@ -293,7 +286,7 @@ mod eth1_cache {
#[tokio::test]
async fn double_update() {
async {
let log = null_logger();
let log = test_logger();

let n = 16;

Expand Down Expand Up @@ -346,7 +339,7 @@ mod deposit_tree {
#[tokio::test]
async fn updating() {
async {
let log = null_logger();
let log = test_logger();

let n = 4;

Expand Down Expand Up @@ -427,7 +420,7 @@ mod deposit_tree {
#[tokio::test]
async fn double_update() {
async {
let log = null_logger();
let log = test_logger();

let n = 8;

Expand Down Expand Up @@ -689,7 +682,7 @@ mod fast {
#[tokio::test]
async fn deposit_cache_query() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down Expand Up @@ -772,7 +765,7 @@ mod persist {
#[tokio::test]
async fn test_persist_caches() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/execution_layer/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::engine_api::{
auth::Auth, http::JSONRPC_VERSION, ExecutionBlock, PayloadStatusV1, PayloadStatusV1Status,
};
use bytes::Bytes;
use environment::null_logger;
use environment::test_logger;
use execution_block_generator::PoWBlock;
use handle_rpc::handle_rpc;
use parking_lot::{Mutex, RwLock, RwLockWriteGuard};
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<T: EthSpec> MockServer<T> {
let ctx: Arc<Context<T>> = Arc::new(Context {
config: server_config,
jwt_key,
log: null_logger().unwrap(),
log: test_logger(),
last_echo_request: last_echo_request.clone(),
execution_block_generator: RwLock::new(execution_block_generator),
previous_request: <_>::default(),
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/genesis/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! You can start a suitable instance using the `anvil_test_node.sh` script in the `scripts`
//! dir in the root of the `lighthouse` repo.
#![cfg(test)]
use environment::{Environment, EnvironmentBuilder};
use environment::{test_logger, Environment, EnvironmentBuilder};
use eth1::{Eth1Endpoint, DEFAULT_CHAIN_ID};
use eth1_test_rig::{AnvilEth1Instance, DelayThenDeposit, Middleware};
use genesis::{Eth1Config, Eth1GenesisService};
Expand All @@ -16,7 +16,7 @@ pub fn new_env() -> Environment<MinimalEthSpec> {
EnvironmentBuilder::minimal()
.multi_threaded_tokio_runtime()
.expect("should start tokio runtime")
.null_logger()
.test_logger()
.expect("should start null logger")
.build()
.expect("should build env")
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/http_api/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use beacon_chain::{
test_utils::{AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType},
BeaconChain, StateSkipConfig, WhenSlotSkipped,
};
use environment::null_logger;
use eth2::{
mixin::{RequestAccept, ResponseForkName, ResponseOptional},
reqwest::RequestBuilder,
Expand All @@ -22,6 +21,7 @@ use http_api::{
BlockId, StateId,
};
use lighthouse_network::{Enr, EnrExt, PeerId};
use logging::test_logger;
use network::NetworkReceivers;
use proto_array::ExecutionStatus;
use sensitive_url::SensitiveUrl;
Expand Down Expand Up @@ -229,7 +229,7 @@ impl ApiTester {
"precondition: justification"
);

let log = null_logger().unwrap();
let log = test_logger();

let ApiServer {
server,
Expand Down Expand Up @@ -315,7 +315,7 @@ impl ApiTester {

let chain = harness.chain.clone();

let log = null_logger().unwrap();
let log = test_logger();

let ApiServer {
server,
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/http_metrics/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use beacon_chain::test_utils::EphemeralHarnessType;
use environment::null_logger;
use environment::test_logger;
use http_metrics::Config;
use reqwest::header::HeaderValue;
use reqwest::StatusCode;
Expand All @@ -13,7 +13,7 @@ type Context = http_metrics::Context<EphemeralHarnessType<MainnetEthSpec>>;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn returns_200_ok() {
async {
let log = null_logger().unwrap();
let log = test_logger();

let context = Arc::new(Context {
config: Config {
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![cfg(test)]

use beacon_chain::StateSkipConfig;
use logging::test_logger;
use node_test_rig::{
environment::{Environment, EnvironmentBuilder},
eth2::types::StateId,
Expand All @@ -25,8 +26,7 @@ fn build_node<E: EthSpec>(env: &mut Environment<E>) -> LocalBeaconNode<E> {
#[test]
fn http_server_genesis_state() {
let mut env = env_builder()
.null_logger()
//.async_logger("debug", None)
.test_logger()
.expect("should build env logger")
.multi_threaded_tokio_runtime()
.expect("should start tokio runtime")
Expand Down
12 changes: 5 additions & 7 deletions lcli/src/transition_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ use beacon_chain::{
};
use clap::ArgMatches;
use clap_utils::{parse_optional, parse_required};
use environment::{null_logger, Environment};
use environment::{test_logger, Environment};
use eth2::{
types::{BlockId, StateId},
BeaconNodeHttpClient, SensitiveUrl, Timeouts,
};
use eth2_network_config::Eth2NetworkConfig;
use logging::test_logger;
use ssz::Encode;
use state_processing::state_advance::complete_state_advance;
use state_processing::{
Expand Down Expand Up @@ -192,12 +193,9 @@ pub fn run<T: EthSpec>(
* Create a `BeaconStore` and `ValidatorPubkeyCache` for block signature verification.
*/

let store = HotColdDB::open_ephemeral(
<_>::default(),
spec.clone(),
null_logger().map_err(|e| format!("Failed to create null_logger: {:?}", e))?,
)
.map_err(|e| format!("Failed to create ephemeral store: {:?}", e))?;
let store = HotColdDB::open_ephemeral(<_>::default(), spec.clone(), test_logger())
.map_err(|e| format!("Failed to create ephemeral store: {:?}", e))?;

let store = Arc::new(store);

debug!("Building pubkey cache (might take some time)");
Expand Down
6 changes: 3 additions & 3 deletions lighthouse/environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use {
#[cfg(not(target_family = "unix"))]
use {futures::channel::oneshot, std::cell::RefCell};

pub use task_executor::test_utils::null_logger;
pub use logging::test_logger;

const LOG_CHANNEL_SIZE: usize = 2048;
const SSE_LOG_CHANNEL_SIZE: usize = 2048;
Expand Down Expand Up @@ -185,8 +185,8 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
}

/// Specifies that all logs should be sent to `null` (i.e., ignored).
pub fn null_logger(mut self) -> Result<Self, String> {
self.log = Some(null_logger()?);
pub fn test_logger(mut self) -> Result<Self, String> {
self.log = Some(test_logger());
Ok(self)
}

Expand Down
3 changes: 2 additions & 1 deletion lighthouse/environment/tests/environment_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

use environment::EnvironmentBuilder;
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK};
use logging::test_logger;
use std::path::PathBuf;
use types::{Config, MainnetEthSpec};

fn builder() -> EnvironmentBuilder<MainnetEthSpec> {
EnvironmentBuilder::mainnet()
.multi_threaded_tokio_runtime()
.expect("should set runtime")
.null_logger()
.test_logger()
.expect("should set logger")
}

Expand Down
2 changes: 1 addition & 1 deletion testing/web3signer_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ mod tests {

impl ValidatorStoreRig {
pub async fn new(validator_definitions: Vec<ValidatorDefinition>, spec: ChainSpec) -> Self {
let log = environment::null_logger().unwrap();
let log = logging::test_logger();
let validator_dir = TempDir::new().unwrap();

let validator_definitions = ValidatorDefinitions::from(validator_definitions);
Expand Down
4 changes: 2 additions & 2 deletions validator_client/src/doppelganger_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ impl DoppelgangerService {
#[cfg(test)]
mod test {
use super::*;
use environment::null_logger;
use futures::executor::block_on;
use logging::test_logger;
use slot_clock::TestingSlotClock;
use std::collections::HashSet;
use std::future;
Expand Down Expand Up @@ -717,7 +717,7 @@ mod test {
fn build(self) -> TestScenario {
let mut rng = XorShiftRng::from_seed([42; 16]);
let slot_clock = TestingSlotClock::new(Slot::new(0), GENESIS_TIME, SLOT_DURATION);
let log = null_logger().unwrap();
let log = test_logger();

TestScenario {
validators: (0..self.validator_count)
Expand Down
Loading