From 268537f727c79557401e39cfc2ce6a009d57d643 Mon Sep 17 00:00:00 2001 From: a10zn8 Date: Tue, 14 Feb 2023 22:37:35 +0400 Subject: [PATCH] Support for widers scope of providers - we need to read full block in case transactions is empty OR totalDifficulty is null - we need to log errors in upstream validation process --- .../upstream/ethereum/EthereumUpstreamValidator.kt | 3 +++ .../dshackle/upstream/ethereum/EthereumWsHead.kt | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt index 3ff8e1a6..ca0c2016 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt @@ -81,6 +81,9 @@ open class EthereumUpstreamValidator( } } } + .doOnError { + log.warn("Error validating ${upstream.getId()}", it) + } .onErrorReturn(UpstreamAvailability.UNAVAILABLE) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt index 16e4636a..9bbe36b6 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt @@ -71,8 +71,11 @@ class EthereumWsHead( .flatMap { block -> // newHeads returns incomplete blocks, i.e. without some fields and without transaction hashes, // so we need to fetch the full block data - if (block.difficulty == null || block.transactions == null) { - // TODO do we really need this ? + if (block.difficulty == null || + block.transactions == null || + block.transactions.isEmpty() || + block.totalDifficulty == null + ) { enhanceRealBlock(block) } else { Mono.just(BlockContainer.from(block))