From defc0b5a7b1c0acbf30c88669800c2ed19e3ee8d Mon Sep 17 00:00:00 2001 From: a10zn8 Date: Wed, 25 Oct 2023 19:16:54 +0400 Subject: [PATCH] - set throttled logger timeout for 20 minutes - set astar chain block time to 1m - add throttled log to liveness checker --- foundation/src/main/resources/chains.yaml | 2 +- .../io/emeraldpay/dshackle/ThrottledLogger.kt | 2 +- .../upstream/ethereum/HeadLivenessValidator.kt | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/foundation/src/main/resources/chains.yaml b/foundation/src/main/resources/chains.yaml index f702d3ae1..8b816c1c9 100644 --- a/foundation/src/main/resources/chains.yaml +++ b/foundation/src/main/resources/chains.yaml @@ -628,7 +628,7 @@ chain-settings: label: Astar zkEVM type: eth settings: - expected-block-time: 2s + expected-block-time: 1m options: validate-peers: false lags: diff --git a/src/main/kotlin/io/emeraldpay/dshackle/ThrottledLogger.kt b/src/main/kotlin/io/emeraldpay/dshackle/ThrottledLogger.kt index 88dda0bb5..be8f7df73 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/ThrottledLogger.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/ThrottledLogger.kt @@ -8,7 +8,7 @@ class ThrottledLogger { companion object { private val cache = Caffeine.newBuilder() - .expireAfterWrite(Duration.ofMinutes(1)) + .expireAfterWrite(Duration.ofMinutes(20)) .build() fun log(log: Logger, msg: String) { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/HeadLivenessValidator.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/HeadLivenessValidator.kt index 51a17e58b..c3136c958 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/HeadLivenessValidator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/HeadLivenessValidator.kt @@ -1,5 +1,6 @@ package io.emeraldpay.dshackle.upstream.ethereum +import io.emeraldpay.dshackle.ThrottledLogger import io.emeraldpay.dshackle.upstream.Head import org.slf4j.LoggerFactory import reactor.core.publisher.Flux @@ -26,7 +27,11 @@ class HeadLivenessValidator( if (value) { Pair(acc.first + 1, true) } else { - log.debug("non consecutive blocks in head for $upstreamId") + if (log.isDebugEnabled) { + log.debug("non consecutive blocks in head for $upstreamId") + } else { + ThrottledLogger.log(log, "non consecutive blocks in head for $upstreamId") + } Pair(0, false) } }.flatMap { (count, value) -> @@ -40,7 +45,11 @@ class HeadLivenessValidator( }.timeout( expectedBlockTime.multipliedBy(CHECKED_BLOCKS_UNTIL_LIVE.toLong() * 2), Flux.just(false).doOnNext { - log.debug("head liveness check broken with timeout in $upstreamId") + if (log.isDebugEnabled) { + log.debug("head liveness check broken with timeout in $upstreamId") + } else { + ThrottledLogger.log(log, "head liveness check broken with timeout in $upstreamId") + } }, ).repeat().subscribeOn(scheduler) }