detect trace_callMany (#637)
fix success detection in case of error during other methods detection
This commit is contained in:
@@ -34,13 +34,17 @@ abstract class UpstreamRpcMethodsDetector(
|
|||||||
.getIngressReader()
|
.getIngressReader()
|
||||||
.read(ChainRequest(method, param))
|
.read(ChainRequest(method, param))
|
||||||
.flatMap(ChainResponse::requireResult)
|
.flatMap(ChainResponse::requireResult)
|
||||||
.map { method to true }
|
.map {
|
||||||
|
method to true
|
||||||
|
}
|
||||||
.onErrorResume { err ->
|
.onErrorResume { err ->
|
||||||
val notAvailableError =
|
val notAvailableError =
|
||||||
notAvailableRegexps.any { s -> s.containsMatchIn(err.message ?: "") }
|
notAvailableRegexps.any { s -> s.containsMatchIn(err.message ?: "") }
|
||||||
if (notAvailableError) {
|
if (notAvailableError) {
|
||||||
|
log.error("$method failed with ${err.message}, detect as false")
|
||||||
Mono.just(method to false)
|
Mono.just(method to false)
|
||||||
} else {
|
} else {
|
||||||
|
log.error("$method failed with ${err.message}, do not detect")
|
||||||
Mono.empty()
|
Mono.empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +54,7 @@ abstract class UpstreamRpcMethodsDetector(
|
|||||||
it
|
it
|
||||||
.map { p -> p as Pair<String, Boolean> }
|
.map { p -> p as Pair<String, Boolean> }
|
||||||
.associate { (method, enabled) -> method to enabled }
|
.associate { (method, enabled) -> method to enabled }
|
||||||
}
|
}.switchIfEmpty(Mono.just(emptyMap()))
|
||||||
|
|
||||||
protected abstract fun detectByMagicMethod(): Mono<Map<String, Boolean>>
|
protected abstract fun detectByMagicMethod(): Mono<Map<String, Boolean>>
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class BasicEthUpstreamRpcMethodsDetector(
|
|||||||
override fun rpcMethods(): Set<Pair<String, CallParams>> =
|
override fun rpcMethods(): Set<Pair<String, CallParams>> =
|
||||||
setOf(
|
setOf(
|
||||||
"eth_getBlockReceipts" to ListParams("latest"),
|
"eth_getBlockReceipts" to ListParams("latest"),
|
||||||
|
"trace_callMany" to ListParams(listOf(listOf<Any>())),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun parseRpcModules(data: ByteArray): Map<String, Boolean> {
|
private fun parseRpcModules(data: ByteArray): Map<String, Boolean> {
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("trace_callMany", ListParams(listOf(listOf<Any>()))))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
"[]".toByteArray(),
|
||||||
|
null,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val upstream =
|
val upstream =
|
||||||
@@ -79,6 +88,15 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("trace_callMany", ListParams(listOf(listOf<Any>()))))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
"[]".toByteArray(),
|
||||||
|
null,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val upstream =
|
val upstream =
|
||||||
@@ -90,8 +108,9 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
val detector = BasicEthUpstreamRpcMethodsDetector(upstream, config)
|
val detector = BasicEthUpstreamRpcMethodsDetector(upstream, config)
|
||||||
Assertions.assertThat(detector.detectRpcMethods().block()).apply {
|
Assertions.assertThat(detector.detectRpcMethods().block()).apply {
|
||||||
isNotNull()
|
isNotNull()
|
||||||
hasSize(1)
|
hasSize(2)
|
||||||
containsEntry("eth_getBlockReceipts", true)
|
containsEntry("eth_getBlockReceipts", true)
|
||||||
|
containsEntry("trace_callMany", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +138,15 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("trace_callMany", ListParams(listOf(listOf<Any>()))))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
"[]".toByteArray(),
|
||||||
|
null,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val upstream =
|
val upstream =
|
||||||
|
|||||||
@@ -64,6 +64,6 @@ class BasicPolkadotUpstreamRpcMethodsDetectorTest {
|
|||||||
on { getChain() } doReturn Chain.POLKADOT__MAINNET
|
on { getChain() } doReturn Chain.POLKADOT__MAINNET
|
||||||
}
|
}
|
||||||
val detector = BasicPolkadotUpstreamRpcMethodsDetector(upstream)
|
val detector = BasicPolkadotUpstreamRpcMethodsDetector(upstream)
|
||||||
Assertions.assertThat(detector.detectRpcMethods().block()).isNull()
|
Assertions.assertThat(detector.detectRpcMethods().block()).isEqualTo(emptyMap<String, Boolean>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user