Disable liveness validation (#666)
* Disable liveness validation * Update liveness validation to be configurable via options * Refactor liveness subscription validation logic for improved readability
This commit is contained in:
@@ -16,6 +16,7 @@ class ChainOptions {
|
|||||||
val validateGasPrice: Boolean,
|
val validateGasPrice: Boolean,
|
||||||
val validateChain: Boolean,
|
val validateChain: Boolean,
|
||||||
val callLimitSize: Int,
|
val callLimitSize: Int,
|
||||||
|
val disableLivenessSubscriptionValidation: Boolean,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class DefaultOptions(
|
data class DefaultOptions(
|
||||||
@@ -36,6 +37,7 @@ class ChainOptions {
|
|||||||
var validateSyncing: Boolean? = null,
|
var validateSyncing: Boolean? = null,
|
||||||
var validateChain: Boolean? = null,
|
var validateChain: Boolean? = null,
|
||||||
var callLimitSize: Int? = null,
|
var callLimitSize: Int? = null,
|
||||||
|
var disableLivenessSubscriptionValidation: Boolean? = null,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -64,6 +66,7 @@ class ChainOptions {
|
|||||||
copy.disableUpstreamValidation =
|
copy.disableUpstreamValidation =
|
||||||
overwrites.disableUpstreamValidation ?: this.disableUpstreamValidation
|
overwrites.disableUpstreamValidation ?: this.disableUpstreamValidation
|
||||||
copy.callLimitSize = overwrites.callLimitSize ?: this.callLimitSize
|
copy.callLimitSize = overwrites.callLimitSize ?: this.callLimitSize
|
||||||
|
copy.disableLivenessSubscriptionValidation = overwrites.disableLivenessSubscriptionValidation ?: this.disableLivenessSubscriptionValidation
|
||||||
return copy
|
return copy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +84,7 @@ class ChainOptions {
|
|||||||
this.validateGasPrice ?: true,
|
this.validateGasPrice ?: true,
|
||||||
this.validateChain ?: true,
|
this.validateChain ?: true,
|
||||||
this.callLimitSize ?: 1_000_000,
|
this.callLimitSize ?: 1_000_000,
|
||||||
|
this.disableLivenessSubscriptionValidation ?: false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ class ChainOptionsReader : YamlConfigReader<ChainOptions.PartialOptions>() {
|
|||||||
getValueAsBool(values, "disable-upstream-validation")?.let {
|
getValueAsBool(values, "disable-upstream-validation")?.let {
|
||||||
options.disableUpstreamValidation = it
|
options.disableUpstreamValidation = it
|
||||||
}
|
}
|
||||||
|
getValueAsBool(values, "disable-liveness-subscription-validation")?.let {
|
||||||
|
options.disableLivenessSubscriptionValidation = it
|
||||||
|
}
|
||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule foundation/src/main/resources/public updated: 8c8514328c...bc98cc70ec
@@ -104,7 +104,7 @@ open class GenericUpstream(
|
|||||||
private val lowerBlockDetectorSubscription = AtomicReference<Disposable?>()
|
private val lowerBlockDetectorSubscription = AtomicReference<Disposable?>()
|
||||||
private val settingsDetectorSubscription = AtomicReference<Disposable?>()
|
private val settingsDetectorSubscription = AtomicReference<Disposable?>()
|
||||||
|
|
||||||
private val hasLiveSubscriptionHead: AtomicBoolean = AtomicBoolean(false)
|
private val hasLiveSubscriptionHead: AtomicBoolean = AtomicBoolean(getOptions().disableLivenessSubscriptionValidation)
|
||||||
protected val connector: GenericConnector = connectorFactory.create(this, chain)
|
protected val connector: GenericConnector = connectorFactory.create(this, chain)
|
||||||
private val livenessSubscription = AtomicReference<Disposable?>()
|
private val livenessSubscription = AtomicReference<Disposable?>()
|
||||||
private val settingsDetector = upstreamSettingsDetectorBuilder(chain, this)
|
private val settingsDetector = upstreamSettingsDetectorBuilder(chain, this)
|
||||||
@@ -323,22 +323,24 @@ open class GenericUpstream(
|
|||||||
?.subscribe(this::setStatus),
|
?.subscribe(this::setStatus),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
livenessSubscription.set(
|
if (!getOptions().disableLivenessSubscriptionValidation) {
|
||||||
connector.headLivenessEvents().subscribe(
|
livenessSubscription.set(
|
||||||
{
|
connector.headLivenessEvents().subscribe(
|
||||||
val hasSub = it == HeadLivenessState.OK
|
{
|
||||||
hasLiveSubscriptionHead.set(hasSub)
|
val hasSub = it == HeadLivenessState.OK
|
||||||
if (it == HeadLivenessState.FATAL_ERROR) {
|
hasLiveSubscriptionHead.set(hasSub)
|
||||||
headLivenessState.emitNext(UPSTREAM_FATAL_SETTINGS_ERROR) { _, res -> res == Sinks.EmitResult.FAIL_NON_SERIALIZED }
|
if (it == HeadLivenessState.FATAL_ERROR) {
|
||||||
} else {
|
headLivenessState.emitNext(UPSTREAM_FATAL_SETTINGS_ERROR) { _, res -> res == Sinks.EmitResult.FAIL_NON_SERIALIZED }
|
||||||
sendUpstreamStateEvent(UPDATED)
|
} else {
|
||||||
}
|
sendUpstreamStateEvent(UPDATED)
|
||||||
},
|
}
|
||||||
{
|
},
|
||||||
log.debug("Error while checking live subscription for ${getId()}", it)
|
{
|
||||||
},
|
log.debug("Error while checking live subscription for ${getId()}", it)
|
||||||
),
|
},
|
||||||
)
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
detectSettings()
|
detectSettings()
|
||||||
|
|
||||||
detectLowerBlock()
|
detectLowerBlock()
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ class UpstreamsConfigReaderSpec extends Specification {
|
|||||||
def options = partialOptions.buildOptions()
|
def options = partialOptions.buildOptions()
|
||||||
then:
|
then:
|
||||||
options == new ChainOptions.Options(
|
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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user