detect trace_callMany (#637)

fix success detection in case of error during other methods detection
This commit is contained in:
a10zn8
2025-03-11 13:12:55 +03:00
committed by GitHub
parent 98d29c064f
commit 21e6cb94ff
4 changed files with 37 additions and 4 deletions

View File

@@ -34,13 +34,17 @@ abstract class UpstreamRpcMethodsDetector(
.getIngressReader()
.read(ChainRequest(method, param))
.flatMap(ChainResponse::requireResult)
.map { method to true }
.map {
method to true
}
.onErrorResume { err ->
val notAvailableError =
notAvailableRegexps.any { s -> s.containsMatchIn(err.message ?: "") }
if (notAvailableError) {
log.error("$method failed with ${err.message}, detect as false")
Mono.just(method to false)
} else {
log.error("$method failed with ${err.message}, do not detect")
Mono.empty()
}
}
@@ -50,7 +54,7 @@ abstract class UpstreamRpcMethodsDetector(
it
.map { p -> p as Pair<String, Boolean> }
.associate { (method, enabled) -> method to enabled }
}
}.switchIfEmpty(Mono.just(emptyMap()))
protected abstract fun detectByMagicMethod(): Mono<Map<String, Boolean>>

View File

@@ -33,6 +33,7 @@ class BasicEthUpstreamRpcMethodsDetector(
override fun rpcMethods(): Set<Pair<String, CallParams>> =
setOf(
"eth_getBlockReceipts" to ListParams("latest"),
"trace_callMany" to ListParams(listOf(listOf<Any>())),
)
private fun parseRpcModules(data: ByteArray): Map<String, Boolean> {