From d39f7870268d4b0168d8339a782c2e5c68bbd602 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB?= <zhitelevkm@m2.ru>
Date: Tue, 27 Aug 2024 14:47:19 +0400
Subject: [PATCH 1/5] Fix test

---
 .../dshackle/upstream/generic/GenericRpcHeadTest.kt | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/test/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericRpcHeadTest.kt b/src/test/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericRpcHeadTest.kt
index 9ea174fad..08df41b08 100644
--- a/src/test/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericRpcHeadTest.kt
+++ b/src/test/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericRpcHeadTest.kt
@@ -16,6 +16,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
 import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionRefJson
 import io.emeraldpay.dshackle.upstream.forkchoice.AlwaysForkChoice
 import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
+import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.Test
 import org.mockito.kotlin.doReturn
 import org.mockito.kotlin.mock
@@ -179,21 +180,17 @@ class GenericRpcHeadTest {
             Duration.ofSeconds(5),
         )
 
-        StepVerifier.withVirtualTime { head.getFlux() }
+        StepVerifier.withVirtualTime { head.headLiveness() }
             .expectSubscription()
             .then { head.start() }
             .expectNoEvent(Duration.ofSeconds(5))
-            .expectNext(BlockContainer.from(block1))
             .expectNoEvent(Duration.ofSeconds(5))
-            .then {
-                StepVerifier.create(head.headLiveness())
-                    .expectNext(HeadLivenessState.FATAL_ERROR)
-                    .thenCancel()
-                    .verify(Duration.ofSeconds(3))
-            }
+            .expectNext(HeadLivenessState.FATAL_ERROR)
             .thenCancel()
             .verify(Duration.ofSeconds(3))
 
+        assertThat(head.getCurrentHeight()).isEqualTo(10000)
+
         verify(reader, times(2)).read(ChainRequest("eth_getBlockByNumber", ListParams("latest", false)))
         verify(reader).read(ChainRequest("eth_chainId", ListParams()))
         verify(reader).read(ChainRequest("net_version", ListParams()))

From 669be621464b39506e008e6e31116b68b46852de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB?= <zhitelevkm@m2.ru>
Date: Tue, 27 Aug 2024 14:55:17 +0400
Subject: [PATCH 2/5] Fix logs

---
 .../ethereum/EthereumUpstreamValidator.kt     | 26 ++++++++++++-------
 1 file changed, 16 insertions(+), 10 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 302e0db6a..3148f1b2f 100644
--- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt
+++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt
@@ -187,7 +187,7 @@ class ChainIdValidator(
                 }
             }
             .onErrorResume {
-                log.error("Error during chain validation", it)
+                log.error("Error during chain validation of upstream {}, reason - {}", upstream.getId(), it.message)
                 Mono.just(onError)
             }
     }
@@ -197,11 +197,13 @@ class ChainIdValidator(
             .read(ChainRequest("eth_chainId", ListParams()))
             .retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
                 log.warn(
-                    "error during chainId retrieving for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
-                        "message ${ctx.exception().message}",
+                    "error during chainId retrieving for {}, iteration {}, reason - {}",
+                    upstream.getId(),
+                    ctx.iteration(),
+                    ctx.exception().message,
                 )
             }
-            .doOnError { log.error("Error during execution 'eth_chainId' - ${it.message} for ${upstream.getId()}") }
+            .doOnError { log.error("Error during execution 'eth_chainId' - {} for {}", it.message, upstream.getId()) }
             .flatMap(ChainResponse::requireStringResult)
     }
 
@@ -210,11 +212,13 @@ class ChainIdValidator(
             .read(ChainRequest("net_version", ListParams()))
             .retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
                 log.warn(
-                    "error during netVersion retrieving for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
-                        "message ${ctx.exception().message}",
+                    "error during netVersion retrieving for {}, iteration {}, reason - {}",
+                    upstream.getId(),
+                    ctx.iteration(),
+                    ctx.exception().message,
                 )
             }
-            .doOnError { log.error("Error during execution 'net_version' - ${it.message} for ${upstream.getId()}") }
+            .doOnError { log.error("Error during execution 'net_version' - {} for {}", it.message, upstream.getId()) }
             .flatMap(ChainResponse::requireStringResult)
     }
 }
@@ -237,8 +241,10 @@ class OldBlockValidator(
             }
             .retryRandomBackoff(3, Duration.ofMillis(100), Duration.ofMillis(500)) { ctx ->
                 log.warn(
-                    "error during old block retrieving for ${upstream.getId()}, iteration ${ctx.iteration()}, " +
-                        "message ${ctx.exception().message}",
+                    "error during old block retrieving for {}, iteration {}, reason - {}",
+                    upstream.getId(),
+                    ctx.iteration(),
+                    ctx.exception().message,
                 )
             }
             .map { result ->
@@ -251,7 +257,7 @@ class OldBlockValidator(
                 ValidateUpstreamSettingsResult.UPSTREAM_VALID
             }
             .onErrorResume {
-                log.warn("Error during old blocks validation", it)
+                log.warn("Error during old blocks validation of upstream {}, reason - {}", upstream.getId(), it.message)
                 Mono.just(ValidateUpstreamSettingsResult.UPSTREAM_VALID)
             }
     }

From 57d66d228555286ee91b188214c7baa734a9a17b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB?= <zhitelevkm@m2.ru>
Date: Tue, 27 Aug 2024 15:02:30 +0400
Subject: [PATCH 3/5] Fix logs

---
 .../dshackle/upstream/ethereum/EthereumUpstreamValidator.kt     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 3148f1b2f..1a1414a35 100644
--- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt
+++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt
@@ -203,7 +203,7 @@ class ChainIdValidator(
                     ctx.exception().message,
                 )
             }
-            .doOnError { log.error("Error during execution 'eth_chainId' - {} for {}", it.message, upstream.getId()) }
+            .doOnError { log.error("Error during execution 'eth_chainId' - {} for {}", upstream.getId(), it.message) }
             .flatMap(ChainResponse::requireStringResult)
     }
 

From c28c163b57b8c237f903ae9792ee702607dd7285 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB?= <zhitelevkm@m2.ru>
Date: Tue, 27 Aug 2024 15:03:34 +0400
Subject: [PATCH 4/5] Fix logs

---
 .../dshackle/upstream/ethereum/EthereumUpstreamValidator.kt     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 1a1414a35..3148f1b2f 100644
--- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt
+++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt
@@ -203,7 +203,7 @@ class ChainIdValidator(
                     ctx.exception().message,
                 )
             }
-            .doOnError { log.error("Error during execution 'eth_chainId' - {} for {}", upstream.getId(), it.message) }
+            .doOnError { log.error("Error during execution 'eth_chainId' - {} for {}", it.message, upstream.getId()) }
             .flatMap(ChainResponse::requireStringResult)
     }
 

From 405a23022299558837bf13d937304c62b8fd57cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB?= <zhitelevkm@m2.ru>
Date: Tue, 27 Aug 2024 15:23:43 +0400
Subject: [PATCH 5/5] Fix another test

---
 .../dshackle/upstream/ethereum/GenericWsHeadTest.kt    | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/test/kotlin/io/emeraldpay/dshackle/upstream/ethereum/GenericWsHeadTest.kt b/src/test/kotlin/io/emeraldpay/dshackle/upstream/ethereum/GenericWsHeadTest.kt
index b405bad2a..b81724c48 100644
--- a/src/test/kotlin/io/emeraldpay/dshackle/upstream/ethereum/GenericWsHeadTest.kt
+++ b/src/test/kotlin/io/emeraldpay/dshackle/upstream/ethereum/GenericWsHeadTest.kt
@@ -437,15 +437,9 @@ class GenericWsHeadTest {
             Duration.ofSeconds(60),
         )
 
-        StepVerifier.create(wsHead.getFlux())
+        StepVerifier.create(wsHead.headLiveness())
             .then { wsHead.start() }
-            .expectNext(BlockContainer.from(block1))
-            .then {
-                StepVerifier.create(wsHead.headLiveness())
-                    .expectNext(HeadLivenessState.FATAL_ERROR)
-                    .thenCancel()
-                    .verify(Duration.ofSeconds(2))
-            }
+            .expectNext(HeadLivenessState.FATAL_ERROR)
             .thenCancel()
             .verify(Duration.ofSeconds(3))