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 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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ class ChainOptionsReader : YamlConfigReader<ChainOptions.PartialOptions>() {
|
||||
getValueAsBool(values, "disable-upstream-validation")?.let {
|
||||
options.disableUpstreamValidation = it
|
||||
}
|
||||
getValueAsBool(values, "disable-liveness-subscription-validation")?.let {
|
||||
options.disableLivenessSubscriptionValidation = it
|
||||
}
|
||||
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 settingsDetectorSubscription = AtomicReference<Disposable?>()
|
||||
|
||||
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<Disposable?>()
|
||||
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()
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user