Fix aztec (#807)

This commit is contained in:
KirillPamPam
2026-03-31 18:25:22 +04:00
committed by GitHub
parent cbf6ae9723
commit 93b8ad0aeb

View File

@@ -30,50 +30,23 @@ object AztecChainSpecific : AbstractPollChainSpecific() {
val height = parseLong( val height = parseLong(
findNode( findNode(
root, root,
"number", "proposed.number",
"header.number",
"blockNumber",
"header.blockNumber",
"header.globalVariables.blockNumber",
), ),
) ?: 0L ) ?: 0L
val hashValue = parseText(findNode(root, "hash", "header.hash", "blockHash", "header.blockHash")) val hashValue = parseText(findNode(root, "proposed.hash"))
val parentValue = parseText(
findNode(
root,
"parentHash",
"header.parentHash",
"parent_hash",
"header.parent_hash",
"prevHash",
"header.prevHash",
),
)
val timestamp = parseInstant(
findNode(
root,
"timestamp",
"header.timestamp",
"header.globalVariables.timestamp",
),
) ?: Instant.EPOCH
if (hashValue == null) {
log.warn("Aztec block hash is missing in response from upstream {}", upstreamId)
}
return Mono.just( return Mono.just(
BlockContainer( BlockContainer(
height = height, height = height,
hash = BlockId.from(hashValue ?: "0x0"), hash = BlockId.from(hashValue ?: "0x0"),
difficulty = BigInteger.ZERO, difficulty = BigInteger.ZERO,
timestamp = timestamp, timestamp = Instant.EPOCH,
full = false, full = false,
json = data, json = data,
parsed = root, parsed = root,
transactions = emptyList(), transactions = emptyList(),
upstreamId = upstreamId, upstreamId = upstreamId,
parentHash = parentValue?.let { BlockId.from(it) }, parentHash = null,
), ),
) )
} }
@@ -126,7 +99,7 @@ object AztecChainSpecific : AbstractPollChainSpecific() {
} }
override fun latestBlockRequest(): ChainRequest = override fun latestBlockRequest(): ChainRequest =
ChainRequest("node_getBlock", ListParams("latest")) ChainRequest("node_getL2Tips", ListParams())
private fun findNode(root: JsonNode, vararg paths: String): JsonNode? { private fun findNode(root: JsonNode, vararg paths: String): JsonNode? {
for (path in paths) { for (path in paths) {