Fix minor bugs whilst testing

This commit is contained in:
Paul Hauner
2019-11-25 14:52:09 +11:00
parent 73572c32d4
commit 713c0a8c10
6 changed files with 59 additions and 32 deletions

View File

@@ -10,7 +10,7 @@ use lmd_ghost::LmdGhost;
use operation_pool::DepositInsertStatus;
use operation_pool::{OperationPool, PersistedOperationPool};
use parking_lot::RwLock;
use slog::{crit, debug, error, info, trace, warn, Logger};
use slog::{debug, error, info, trace, warn, Logger};
use slot_clock::SlotClock;
use ssz::Encode;
use state_processing::per_block_processing::{
@@ -355,9 +355,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// We log warnings or simply fail if there are too many skip slots. This is a
// protection against DoS attacks.
if slot > head_state.slot + BLOCK_SKIPPING_FAILURE_THRESHOLD {
crit!(
error!(
self.log,
"Refusing to skip more than {} blocks", BLOCK_SKIPPING_LOGGING_THRESHOLD;
"Refusing to skip more than {} blocks", BLOCK_SKIPPING_FAILURE_THRESHOLD;
"head_slot" => head_state.slot,
"request_slot" => slot
);

View File

@@ -137,19 +137,21 @@ pub fn get_deposit_count(
block_number,
timeout,
)
.and_then(|result| result.ok_or_else(|| "No response to deposit count".to_string()))
.and_then(|bytes| {
if bytes.is_empty() {
Ok(None)
} else if bytes.len() == DEPOSIT_COUNT_RESPONSE_BYTES {
let mut array = [0; 8];
array.copy_from_slice(&bytes[32 + 32..32 + 32 + 8]);
Ok(Some(u64::from_le_bytes(array)))
} else {
Err(format!(
"Deposit count response was not {} bytes: {:?}",
DEPOSIT_COUNT_RESPONSE_BYTES, bytes
))
.and_then(|result| match result {
None => Ok(None),
Some(bytes) => {
if bytes.is_empty() {
Ok(None)
} else if bytes.len() == DEPOSIT_COUNT_RESPONSE_BYTES {
let mut array = [0; 8];
array.copy_from_slice(&bytes[32 + 32..32 + 32 + 8]);
Ok(Some(u64::from_le_bytes(array)))
} else {
Err(format!(
"Deposit count response was not {} bytes: {:?}",
DEPOSIT_COUNT_RESPONSE_BYTES, bytes
))
}
}
})
}
@@ -172,17 +174,19 @@ pub fn get_deposit_root(
block_number,
timeout,
)
.and_then(|result| result.ok_or_else(|| "No response to deposit root".to_string()))
.and_then(|bytes| {
if bytes.is_empty() {
Ok(None)
} else if bytes.len() == DEPOSIT_ROOT_BYTES {
Ok(Some(Hash256::from_slice(&bytes)))
} else {
Err(format!(
"Deposit root response was not {} bytes: {:?}",
DEPOSIT_ROOT_BYTES, bytes
))
.and_then(|result| match result {
None => Ok(None),
Some(bytes) => {
if bytes.is_empty() {
Ok(None)
} else if bytes.len() == DEPOSIT_ROOT_BYTES {
Ok(Some(Hash256::from_slice(&bytes)))
} else {
Err(format!(
"Deposit root response was not {} bytes: {:?}",
DEPOSIT_ROOT_BYTES, bytes
))
}
}
})
}

View File

@@ -121,7 +121,7 @@ impl Default for Config {
lowest_cached_block_number: 0,
follow_distance: 128,
block_cache_truncation: Some(4_096),
auto_update_interval_millis: 500,
auto_update_interval_millis: 7_000,
blocks_per_log_query: 1_000,
max_log_requests_per_update: None,
max_blocks_per_update: None,

View File

@@ -268,7 +268,6 @@ fn process_testnet_subcommand(
spec.max_effective_balance = 3_200_000_000;
spec.ejection_balance = 1_600_000_000;
spec.effective_balance_increment = 100_000_000;
spec.min_genesis_time = 0;
spec.genesis_fork = Fork {
previous_version: [0; 4],
current_version: [0, 0, 0, 42],
@@ -276,11 +275,19 @@ fn process_testnet_subcommand(
};
client_config.eth1.deposit_contract_address =
format!("{}", eth2_testnet_dir.deposit_contract_address()?);
format!("{:?}", eth2_testnet_dir.deposit_contract_address()?);
client_config.eth1.deposit_contract_deploy_block =
eth2_testnet_dir.deposit_contract_deploy_block;
spec.min_genesis_time = eth2_testnet_dir.min_genesis_time;
// Note: these constants _should_ only be used during genesis to determine the genesis
// time. This allows the testnet to start shortly after the time + validator count
// conditions are satisified, not 1-2 days.
spec.seconds_per_day = 60;
client_config.eth1.follow_distance = 16;
client_config.dummy_eth1_backend = false;
client_config.sync_eth1_chain = true;
builder.set_genesis(ClientGenesis::DepositContract)
}