Log better error message (#1981)

## Issue Addressed

Fixes #1965 

## Proposed Changes

Log an error and don't update eth1 caches if `chain_id = 0`
This commit is contained in:
Pawan Dhananjay 2020-11-26 23:13:46 +00:00
parent 3486d6a809
commit 0589a14afe

View File

@ -32,7 +32,7 @@ const GET_BLOCK_TIMEOUT_MILLIS: u64 = STANDARD_TIMEOUT_MILLIS;
/// Timeout when doing an eth_getLogs to read the deposit contract logs. /// Timeout when doing an eth_getLogs to read the deposit contract logs.
const GET_DEPOSIT_LOG_TIMEOUT_MILLIS: u64 = STANDARD_TIMEOUT_MILLIS; const GET_DEPOSIT_LOG_TIMEOUT_MILLIS: u64 = STANDARD_TIMEOUT_MILLIS;
const WARNING_MSG: &str = "BLOCK PROPOSALS WILL FAIL WITHOUT VALID ETH1 CONNECTION"; const WARNING_MSG: &str = "BLOCK PROPOSALS WILL FAIL WITHOUT VALID, SYNCED ETH1 CONNECTION";
/// A factor used to reduce the eth1 follow distance to account for discrepancies in the block time. /// A factor used to reduce the eth1 follow distance to account for discrepancies in the block time.
const ETH1_BLOCK_TIME_TOLERANCE_FACTOR: u64 = 4; const ETH1_BLOCK_TIME_TOLERANCE_FACTOR: u64 = 4;
@ -450,6 +450,16 @@ impl Service {
); );
return Ok(()); return Ok(());
} }
// Eth1 nodes return chain_id = 0 if the node is not synced
// Handle the special case
if chain_id == Eth1Id::Custom(0) {
crit!(
self.log,
"Remote eth1 node is not synced";
"warning" => WARNING_MSG,
);
return Ok(());
}
if chain_id != config_chain_id { if chain_id != config_chain_id {
crit!( crit!(
self.log, self.log,