From a8b91fa84aefcf8aac3bbe97eac7fe8182b288c9 Mon Sep 17 00:00:00 2001 From: KirillPamPam Date: Thu, 22 Aug 2024 12:33:47 +0400 Subject: [PATCH] Return validation options and fix gas validator (#553) --- .../dshackle/foundation/ChainOptionsReader.kt | 3 +++ .../upstream/ethereum/EthereumChainSpecific.kt | 15 +++++++++------ .../ethereum/EthereumUpstreamValidator.kt | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) 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 2e146008..fc079ff1 100644 --- a/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptionsReader.kt +++ b/foundation/src/main/kotlin/io/emeraldpay/dshackle/foundation/ChainOptionsReader.kt @@ -49,6 +49,9 @@ class ChainOptionsReader : YamlConfigReader() { getValueAsInt(values, "call-limit-size")?.let { options.callLimitSize = it } + getValueAsBool(values, "disable-upstream-validation")?.let { + options.disableUpstreamValidation = it + } return options } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt index 21ac06ec..a4a134d4 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt @@ -155,15 +155,18 @@ object EthereumChainSpecific : AbstractPollChainSpecific() { ): List> { val limitValidator = callLimitValidatorFactory(upstream, options, config, chain) - return listOf( + val validators = mutableListOf( ChainIdValidator(upstream, chain), OldBlockValidator(upstream), - GasPriceValidator(upstream, config), - ) + if (limitValidator.isEnabled()) { - listOf(limitValidator) - } else { - emptyList() + ) + if (limitValidator.isEnabled()) { + validators.add(limitValidator) } + if (options.validateGasPrice) { + validators.add(GasPriceValidator(upstream, config)) + } + + return validators } override fun chainSettingsValidator( 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 f17e9d37..302e0db6 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamValidator.kt @@ -267,6 +267,9 @@ class GasPriceValidator( val log: Logger = LoggerFactory.getLogger(GasPriceValidator::class.java) } override fun validate(onError: ValidateUpstreamSettingsResult): Mono { + if (!upstream.getMethods().isCallable("eth_gasPrice")) { + return Mono.just(ValidateUpstreamSettingsResult.UPSTREAM_VALID) + } return upstream.getIngressReader() .read(ChainRequest("eth_gasPrice", ListParams())) .flatMap(ChainResponse::requireStringResult)