add tron evm, fix syncing validator for tron, add more messages for finalization detector (#534)

This commit is contained in:
msizov
2024-07-29 18:58:57 +05:00
committed by GitHub
parent 0095426d34
commit e463583874
6 changed files with 44 additions and 7 deletions

View File

@@ -457,6 +457,9 @@ class DefaultEthereumMethods(
"rsk_getRawBlockHeaderByNumber",
"rsk_protocolVersion",
)
Chain.TRON__MAINNET, Chain.TRON__SHASTA -> listOf(
"buildTransaction",
)
else -> emptyList()
}

View File

@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory
import org.springframework.cloud.sleuth.Tracer
import reactor.core.publisher.Mono
import reactor.core.scheduler.Scheduler
import java.math.BigInteger
object EthereumChainSpecific : AbstractPollChainSpecific() {
@@ -115,8 +116,24 @@ object EthereumChainSpecific : AbstractPollChainSpecific() {
UpstreamAvailability.OK
}
} else {
log.warn("Received syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}")
UpstreamAvailability.SYNCING
when (chain) {
Chain.TRON__MAINNET, Chain.TRON__SHASTA -> {
var current =
BigInteger(raw.get("currentBlock")?.asText()?.lowercase()?.substringAfter("x"), 16)
var highest =
BigInteger(raw.get("highestBlock")?.asText()?.lowercase()?.substringAfter("x"), 16)
if (highest - current > config.syncingLagSize.toBigInteger()) {
UpstreamAvailability.SYNCING
} else {
UpstreamAvailability.OK
}
}
else -> {
log.warn("Received syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}")
UpstreamAvailability.SYNCING
}
}
}
}
}

View File

@@ -29,6 +29,16 @@ class EthereumFinalizationDetector : FinalizationDetector {
private val disableDetector: ConcurrentHashMap<FinalizationType, Boolean> = ConcurrentHashMap()
private val finalizationSink = Sinks.many().multicast().directBestEffort<FinalizationData>()
private val errorRegex = "(" +
".*bad request.*" +
"|.*block not found.*" +
"|.*Unknown block.*" +
"|.*tag not supported on pre-merge network.*" +
"|.*hex string without 0x prefix.*" +
"|.*Invalid params.*" +
"|.*invalid syntax.*" +
"|.*invalid block number.*" +
")"
override fun detectFinalization(
upstream: Upstream,
blockTime: Duration,
@@ -65,7 +75,7 @@ class EthereumFinalizationDetector : FinalizationDetector {
.getIngressReader()
.read(req)
.onErrorResume {
if (it.message != null && it.message!!.matches(Regex("(.*bad request.*|.*block not found.*|.*Unknown block.*|.*tag not supported on pre-merge network.*)"))) {
if (it.message != null && it.message!!.matches(Regex(errorRegex))) {
log.warn("Can't retrieve tagged block, finalization detector for upstream ${upstream.getId()} $chain tag $type disabled")
disableDetector[type] = true
} else {

View File

@@ -34,6 +34,7 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import reactor.core.publisher.Mono
import reactor.kotlin.extra.retry.retryRandomBackoff
import java.math.BigInteger
import java.time.Duration
import java.util.concurrent.TimeoutException
interface CallLimitValidator : SingleValidator<ValidateUpstreamSettingsResult> {
@@ -155,13 +156,19 @@ class ChainIdValidator(
netVersion(),
)
.map {
var netver: BigInteger
if (it.t2.lowercase().contains("x")) {
netver = BigInteger(it.t2.lowercase().substringAfter("x"), 16)
} else {
netver = BigInteger(it.t2)
}
val isChainValid = chain.chainId.lowercase() == it.t1.lowercase() &&
chain.netVersion.toString() == it.t2
chain.netVersion == netver
if (!isChainValid) {
val actualChain = Global.chainByChainId(it.t1).chainName
log.warn(
"${chain.chainName} is specified for upstream ${upstream.getId()} " +
"${chain.chainName} is specified for upstream ${upstream.getId()} (${chain.chainId.lowercase()} $netver) " +
"but actually it is $actualChain with chainId ${it.t1} and net_version ${it.t2}",
)
}