From e3318168bbd8505e4efc77b03a71e790135e2b73 Mon Sep 17 00:00:00 2001 From: pawan Date: Tue, 10 Dec 2019 23:23:35 +0530 Subject: [PATCH] Fetch deposit root and deposit count from cache --- beacon_node/eth1/src/service.rs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/beacon_node/eth1/src/service.rs b/beacon_node/eth1/src/service.rs index 80fd6c4799..3bba5ca747 100644 --- a/beacon_node/eth1/src/service.rs +++ b/beacon_node/eth1/src/service.rs @@ -614,6 +614,16 @@ fn download_eth1_block<'a>( cache: Arc, block_number: u64, ) -> impl Future + 'a { + let deposit_root = cache + .deposit_cache + .read() + .cache + .get_deposit_root_from_cache(block_number); + let deposit_count = cache + .deposit_cache + .read() + .cache + .get_deposit_count_from_cache(block_number); // Performs a `get_blockByNumber` call to an eth1 node. get_block( &cache.config.read().endpoint, @@ -621,24 +631,7 @@ fn download_eth1_block<'a>( Duration::from_millis(GET_BLOCK_TIMEOUT_MILLIS), ) .map_err(Error::BlockDownloadFailed) - .join3( - // Perform 2x `eth_call` via an eth1 node to read the deposit contract root and count. - get_deposit_root( - &cache.config.read().endpoint, - &cache.config.read().deposit_contract_address, - block_number, - Duration::from_millis(GET_DEPOSIT_ROOT_TIMEOUT_MILLIS), - ) - .map_err(Error::GetDepositRootFailed), - get_deposit_count( - &cache.config.read().endpoint, - &cache.config.read().deposit_contract_address, - block_number, - Duration::from_millis(GET_DEPOSIT_COUNT_TIMEOUT_MILLIS), - ) - .map_err(Error::GetDepositCountFailed), - ) - .map(|(http_block, deposit_root, deposit_count)| Eth1Block { + .map(move |http_block| Eth1Block { hash: http_block.hash, number: http_block.number, timestamp: http_block.timestamp,