Skip to content

Commit

Permalink
Correct issues with the syncing sim (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning authored Apr 15, 2020
1 parent d3dfd72 commit 040628b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
11 changes: 10 additions & 1 deletion beacon_node/eth2-libp2p/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ where
}

fn inject_connected(&mut self, peer_id: PeerId, connected_point: ConnectedPoint) {
// TODO: Remove this on proper peer discovery
self.events.push(NetworkBehaviourAction::GenerateEvent(
RPCMessage::PeerConnectedHack(peer_id.clone(), connected_point.clone()),
));
// if initialised the connection, report this upwards to send the HELLO request
if let ConnectedPoint::Dialer { .. } = connected_point {
self.events.push(NetworkBehaviourAction::GenerateEvent(
Expand All @@ -135,7 +139,12 @@ where
});
}

fn inject_disconnected(&mut self, peer_id: &PeerId, _: ConnectedPoint) {
fn inject_disconnected(&mut self, peer_id: &PeerId, connected_point: ConnectedPoint) {
// TODO: Remove this on proper peer discovery
self.events.push(NetworkBehaviourAction::GenerateEvent(
RPCMessage::PeerDisconnectedHack(peer_id.clone(), connected_point.clone()),
));

// inform the rpc handler that the peer has disconnected
self.events.push(NetworkBehaviourAction::GenerateEvent(
RPCMessage::PeerDisconnected(peer_id.clone()),
Expand Down
32 changes: 26 additions & 6 deletions tests/simulator/src/sync_sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ use crate::local_network::LocalNetwork;
use clap::ArgMatches;
use futures::{future, stream, Future, IntoFuture, Stream};
use node_test_rig::ClientConfig;
use node_test_rig::{environment::EnvironmentBuilder, testing_client_config, ValidatorConfig};
use std::time::Duration;
use node_test_rig::{
environment::EnvironmentBuilder, testing_client_config, ClientGenesis, ValidatorConfig,
};
use std::net::{IpAddr, Ipv4Addr};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tokio::timer::Interval;
use types::{Epoch, EthSpec};

Expand Down Expand Up @@ -48,15 +51,32 @@ fn syncing_sim(

let spec = &mut env.eth2_config.spec;
let end_after_checks = true;
let eth1_block_time = Duration::from_millis(15_000 / speed_up_factor);

spec.milliseconds_per_slot = spec.milliseconds_per_slot / speed_up_factor;
spec.milliseconds_per_slot /= speed_up_factor;
spec.eth1_follow_distance = 16;
spec.min_genesis_delay = eth1_block_time.as_secs() * spec.eth1_follow_distance * 2;
spec.min_genesis_time = 0;
spec.min_genesis_active_validator_count = 16;
spec.min_genesis_active_validator_count = 64;
spec.seconds_per_eth1_block = 1;

let num_validators = 8;
let slot_duration = Duration::from_millis(spec.milliseconds_per_slot);
let context = env.core_context();
let num_validators = 8;
let beacon_config = testing_client_config();
let mut beacon_config = testing_client_config();

let genesis_time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map_err(|_| "should get system time")?
+ Duration::from_secs(5);
beacon_config.genesis = ClientGenesis::Interop {
validator_count: num_validators,
genesis_time: genesis_time.as_secs(),
};
beacon_config.dummy_eth1_backend = true;
beacon_config.sync_eth1_chain = true;

beacon_config.network.enr_address = Some(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));

let future = LocalNetwork::new(context, beacon_config.clone())
/*
Expand Down

0 comments on commit 040628b

Please sign in to comment.