Add additional method detection patterns and support for new RPC methods (#730)
* Add additional method detection patterns and support for new RPC methods * Add additional RPC method detections and error handling for missing arguments
This commit is contained in:
@@ -20,6 +20,8 @@ abstract class UpstreamRpcMethodsDetector(
|
|||||||
"([A-Za-z0-9_]+) found but the containing module is disabled",
|
"([A-Za-z0-9_]+) found but the containing module is disabled",
|
||||||
"[Mm]ethod not found",
|
"[Mm]ethod not found",
|
||||||
"The method ([A-Za-z0-9_]+) is not available",
|
"The method ([A-Za-z0-9_]+) is not available",
|
||||||
|
"The method '([A-Za-z0-9_]+)' is not supported.",
|
||||||
|
"No response for method ([A-Za-z0-9_]+)",
|
||||||
).map { s -> s.toRegex() }
|
).map { s -> s.toRegex() }
|
||||||
|
|
||||||
private val availableRegexps =
|
private val availableRegexps =
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class BasicEthUpstreamRpcMethodsDetector(
|
|||||||
"eth_getBlockReceipts" to ListParams("latest"),
|
"eth_getBlockReceipts" to ListParams("latest"),
|
||||||
"trace_callMany" to ListParams(listOf(listOf<Any>())),
|
"trace_callMany" to ListParams(listOf(listOf<Any>())),
|
||||||
"eth_simulateV1" to ListParams(listOf()),
|
"eth_simulateV1" to ListParams(listOf()),
|
||||||
|
"debug_storageRangeAt" to ListParams(listOf()),
|
||||||
|
"eth_getTdByNumber" to ListParams(listOf()),
|
||||||
|
"eth_callBundle" to ListParams(listOf()),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun parseRpcModules(data: ByteArray): Map<String, Boolean> {
|
private fun parseRpcModules(data: ByteArray): Map<String, Boolean> {
|
||||||
|
|||||||
@@ -57,6 +57,33 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("debug_storageRangeAt", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("eth_getTdByNumber", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("eth_callBundle", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val upstream =
|
val upstream =
|
||||||
@@ -115,6 +142,33 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("debug_storageRangeAt", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("eth_getTdByNumber", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("eth_callBundle", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val upstream =
|
val upstream =
|
||||||
@@ -126,9 +180,13 @@ 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(3)
|
hasSize(6)
|
||||||
containsEntry("eth_getBlockReceipts", true)
|
containsEntry("eth_getBlockReceipts", true)
|
||||||
containsEntry("trace_callMany", true)
|
containsEntry("trace_callMany", true)
|
||||||
|
containsEntry("eth_simulateV1", true)
|
||||||
|
containsEntry("debug_storageRangeAt", true)
|
||||||
|
containsEntry("eth_getTdByNumber", true)
|
||||||
|
containsEntry("eth_callBundle", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,6 +232,33 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
ChainCallError(32602, "missing value for required argument 0"),
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("debug_storageRangeAt", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("eth_getTdByNumber", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
on {
|
||||||
|
read(ChainRequest("eth_callBundle", ListParams(listOf())))
|
||||||
|
} doReturn
|
||||||
|
Mono.just(
|
||||||
|
ChainResponse(
|
||||||
|
null,
|
||||||
|
ChainCallError(32602, "missing value for required argument 0"),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val upstream =
|
val upstream =
|
||||||
@@ -196,6 +281,9 @@ class BasicEthUpstreamRpcMethodsDetectorTest {
|
|||||||
containsEntry("eth_getBlockReceipts", true)
|
containsEntry("eth_getBlockReceipts", true)
|
||||||
containsEntry("debug_traceBlock", true)
|
containsEntry("debug_traceBlock", true)
|
||||||
containsEntry("eth_simulateV1", true)
|
containsEntry("eth_simulateV1", true)
|
||||||
|
containsEntry("debug_storageRangeAt", true)
|
||||||
|
containsEntry("eth_getTdByNumber", true)
|
||||||
|
containsEntry("eth_callBundle", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user