flashblocks detection (#687)

This commit is contained in:
a10zn8
2025-07-16 19:28:23 +03:00
committed by GitHub
parent 4b0650b8dc
commit 323d23a126
2 changed files with 33 additions and 1 deletions

View File

@@ -28,9 +28,34 @@ class EthereumUpstreamSettingsDetector(
detectNodeType(),
detectArchiveNode(notArchived),
detectGasLabels(),
detectFlashBlocks(),
)
}
private fun detectFlashBlocks(): Mono<Pair<String, String>>? {
return upstream.getIngressReader().read(
ChainRequest(
"eth_getBlockByNumber",
ListParams(
"pending",
false,
),
),
).flatMap {
it.requireResult()
}.flatMap {
val json = Global.objectMapper.readValue(it, JsonNode::class.java)
if (json.get("stateRoot")?.asText() == "0x0000000000000000000000000000000000000000000000000000000000000000") {
Mono.just(Pair("flashblocks", "true"))
} else {
Mono.just(Pair("flashblocks", "false"))
}
}.onErrorResume {
log.error("Error during flashblocks detection", it)
Mono.empty()
}
}
override fun mapping(node: JsonNode): String {
return node.asText()
}