Skip to content

Commit

Permalink
Return validation options and fix gas validator (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillPamPam authored Aug 22, 2024
1 parent 3d9193e commit a8b91fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class ChainOptionsReader : YamlConfigReader<ChainOptions.PartialOptions>() {
getValueAsInt(values, "call-limit-size")?.let {
options.callLimitSize = it
}
getValueAsBool(values, "disable-upstream-validation")?.let {
options.disableUpstreamValidation = it
}
return options
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,18 @@ object EthereumChainSpecific : AbstractPollChainSpecific() {
): List<SingleValidator<ValidateUpstreamSettingsResult>> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ class GasPriceValidator(
val log: Logger = LoggerFactory.getLogger(GasPriceValidator::class.java)
}
override fun validate(onError: ValidateUpstreamSettingsResult): Mono<ValidateUpstreamSettingsResult> {
if (!upstream.getMethods().isCallable("eth_gasPrice")) {
return Mono.just(ValidateUpstreamSettingsResult.UPSTREAM_VALID)
}
return upstream.getIngressReader()
.read(ChainRequest("eth_gasPrice", ListParams()))
.flatMap(ChainResponse::requireStringResult)
Expand Down

0 comments on commit a8b91fa

Please sign in to comment.