Correct status fork digest (#1016)

* Correct status fork digest

* Correct port issues with tests
This commit is contained in:
Age Manning 2020-04-18 11:45:52 +10:00 committed by GitHub
parent 62d7a71fd9
commit f9e8dad1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 25 deletions

View File

@ -99,13 +99,9 @@ pub fn get_enr(node: &LibP2PService<E>) -> Enr {
// Returns `n` libp2p peers in fully connected topology.
#[allow(dead_code)]
pub fn build_full_mesh(
log: slog::Logger,
n: usize,
start_port: Option<u16>,
) -> Vec<LibP2PService<E>> {
let base_port = start_port.unwrap_or(10000);
let mut nodes: Vec<LibP2PService<E>> = (base_port..base_port + n as u16)
pub fn build_full_mesh(log: slog::Logger, n: usize) -> Vec<LibP2PService<E>> {
let mut nodes: Vec<LibP2PService<E>> = (0..n)
.map(|_| unused_port("tcp").unwrap())
.map(|p| build_libp2p_instance(p, vec![], None, log.clone()))
.collect();
let multiaddrs: Vec<Multiaddr> = nodes
@ -149,9 +145,9 @@ pub fn build_node_pair(
// Returns `n` peers in a linear topology
#[allow(dead_code)]
pub fn build_linear(log: slog::Logger, n: usize, start_port: Option<u16>) -> Vec<LibP2PService<E>> {
let base_port = start_port.unwrap_or(9000);
let mut nodes: Vec<LibP2PService<E>> = (base_port..base_port + n as u16)
pub fn build_linear(log: slog::Logger, n: usize) -> Vec<LibP2PService<E>> {
let mut nodes: Vec<LibP2PService<E>> = (0..n)
.map(|_| unused_port("tcp").unwrap())
.map(|p| build_libp2p_instance(p, vec![], None, log.clone()))
.collect();
let multiaddrs: Vec<Multiaddr> = nodes

View File

@ -25,8 +25,7 @@ fn test_gossipsub_forward() {
let log = common::build_log(Level::Info, false);
let num_nodes = 20;
let base_port = 54236;
let mut nodes = common::build_linear(log.clone(), num_nodes, Some(base_port));
let mut nodes = common::build_linear(log.clone(), num_nodes);
let mut received_count = 0;
let spec = E::default_spec();
let empty_block = BeaconBlock::empty(&spec);
@ -99,8 +98,7 @@ fn test_gossipsub_full_mesh_publish() {
// as nodes may get pruned out of the mesh before the gossipsub message
// is published to them.
let num_nodes = 12;
let base_port = 5264;
let mut nodes = common::build_full_mesh(log, num_nodes, Some(base_port));
let mut nodes = common::build_full_mesh(log, num_nodes);
let mut publishing_node = nodes.pop().unwrap();
let spec = E::default_spec();
let empty_block = BeaconBlock::empty(&spec);

View File

@ -13,7 +13,8 @@ use std::sync::Arc;
use store::Store;
use tokio::sync::{mpsc, oneshot};
use types::{
Attestation, Epoch, EthSpec, Hash256, SignedAggregateAndProof, SignedBeaconBlock, Slot,
Attestation, ChainSpec, Epoch, EthSpec, Hash256, SignedAggregateAndProof, SignedBeaconBlock,
Slot,
};
//TODO: Rate limit requests
@ -644,10 +645,13 @@ pub(crate) fn status_message<T: BeaconChainTypes>(
beacon_chain: &BeaconChain<T>,
) -> Option<StatusMessage> {
let head_info = beacon_chain.head_info().ok()?;
let genesis_validators_root = beacon_chain.genesis_validators_root;
let fork_digest =
ChainSpec::compute_fork_digest(head_info.fork.current_version, genesis_validators_root);
// TODO: Update fork digest calculation
Some(StatusMessage {
fork_digest: head_info.fork.current_version,
fork_digest,
finalized_root: head_info.finalized_checkpoint.root,
finalized_epoch: head_info.finalized_checkpoint.epoch,
head_root: head_info.block_root,

View File

@ -41,10 +41,3 @@ pub fn syncing<T: EthSpec>(
sync_status,
})
}
pub fn lighthouse_syncing<T: EthSpec>(
req: Request<Body>,
network: Arc<NetworkGlobals<T>>,
) -> ApiResult {
ResponseBuilder::new(&req)?.body_no_ssz(&network.sync_state())
}

View File

@ -3,7 +3,7 @@ use clap::ArgMatches;
use client::{config::DEFAULT_DATADIR, ClientConfig, ClientGenesis};
use eth2_libp2p::{Enr, Multiaddr};
use eth2_testnet_config::Eth2TestnetConfig;
use slog::{crit, info, warn, Logger};
use slog::{crit, info, Logger};
use ssz::Encode;
use std::fs;
use std::fs::File;