diff --git a/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptions.kt b/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptions.kt index bbb9b7b8..cd7492bf 100644 --- a/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptions.kt +++ b/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptions.kt @@ -16,6 +16,7 @@ class ChainOptions { val validateGasPrice: Boolean, val validateChain: Boolean, val callLimitSize: Int, + val disableLivenessSubscriptionValidation: Boolean, ) data class DefaultOptions( @@ -36,6 +37,7 @@ class ChainOptions { var validateSyncing: Boolean? = null, var validateChain: Boolean? = null, var callLimitSize: Int? = null, + var disableLivenessSubscriptionValidation: Boolean? = null, ) { companion object { @JvmStatic @@ -64,6 +66,7 @@ class ChainOptions { copy.disableUpstreamValidation = overwrites.disableUpstreamValidation ?: this.disableUpstreamValidation copy.callLimitSize = overwrites.callLimitSize ?: this.callLimitSize + copy.disableLivenessSubscriptionValidation = overwrites.disableLivenessSubscriptionValidation ?: this.disableLivenessSubscriptionValidation return copy } @@ -81,6 +84,7 @@ class ChainOptions { this.validateGasPrice ?: true, this.validateChain ?: true, this.callLimitSize ?: 1_000_000, + this.disableLivenessSubscriptionValidation ?: false, ) } } diff --git a/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptionsReader.kt b/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptionsReader.kt index fc079ff1..7266c88e 100644 --- a/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptionsReader.kt +++ b/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptionsReader.kt @@ -52,6 +52,9 @@ class ChainOptionsReader : YamlConfigReader() { getValueAsBool(values, "disable-upstream-validation")?.let { options.disableUpstreamValidation = it } + getValueAsBool(values, "disable-liveness-subscription-validation")?.let { + options.disableLivenessSubscriptionValidation = it + } return options } } diff --git a/foundation/src/main/resources/public b/foundation/src/main/resources/public index 8c851432..bc98cc70 160000 --- a/foundation/src/main/resources/public +++ b/foundation/src/main/resources/public @@ -1 +1 @@ -Subproject commit 8c8514328c215f87fbeee4c761da63ec28695b7f +Subproject commit bc98cc70ec1c3cc8f16ffa93c844ab013de6b274 diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericUpstream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericUpstream.kt index 82318473..be4a1a8a 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericUpstream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericUpstream.kt @@ -104,7 +104,7 @@ open class GenericUpstream( private val lowerBlockDetectorSubscription = AtomicReference() private val settingsDetectorSubscription = AtomicReference() - private val hasLiveSubscriptionHead: AtomicBoolean = AtomicBoolean(false) + private val hasLiveSubscriptionHead: AtomicBoolean = AtomicBoolean(getOptions().disableLivenessSubscriptionValidation) protected val connector: GenericConnector = connectorFactory.create(this, chain) private val livenessSubscription = AtomicReference() private val settingsDetector = upstreamSettingsDetectorBuilder(chain, this) @@ -323,22 +323,24 @@ open class GenericUpstream( ?.subscribe(this::setStatus), ) } - livenessSubscription.set( - connector.headLivenessEvents().subscribe( - { - val hasSub = it == HeadLivenessState.OK - hasLiveSubscriptionHead.set(hasSub) - if (it == HeadLivenessState.FATAL_ERROR) { - headLivenessState.emitNext(UPSTREAM_FATAL_SETTINGS_ERROR) { _, res -> res == Sinks.EmitResult.FAIL_NON_SERIALIZED } - } else { - sendUpstreamStateEvent(UPDATED) - } - }, - { - log.debug("Error while checking live subscription for ${getId()}", it) - }, - ), - ) + if (!getOptions().disableLivenessSubscriptionValidation) { + livenessSubscription.set( + connector.headLivenessEvents().subscribe( + { + val hasSub = it == HeadLivenessState.OK + hasLiveSubscriptionHead.set(hasSub) + if (it == HeadLivenessState.FATAL_ERROR) { + headLivenessState.emitNext(UPSTREAM_FATAL_SETTINGS_ERROR) { _, res -> res == Sinks.EmitResult.FAIL_NON_SERIALIZED } + } else { + sendUpstreamStateEvent(UPDATED) + } + }, + { + log.debug("Error while checking live subscription for ${getId()}", it) + }, + ), + ) + } detectSettings() detectLowerBlock() diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy index 4c5df8ef..d138478b 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/UpstreamsConfigReaderSpec.groovy @@ -636,7 +636,7 @@ class UpstreamsConfigReaderSpec extends Specification { def options = partialOptions.buildOptions() then: options == new ChainOptions.Options( - false, false, 30, Duration.ofSeconds(60), null, true, 1, true, true, true, true, 1_000_000 + false, false, 30, Duration.ofSeconds(60), null, true, 1, true, true, true, true, 1_000_000, false ) } }