add tron evm, fix syncing validator for tron, add more messages for finalization detector (#534)
This commit is contained in:
Submodule emerald-grpc updated: 7ea7781064...85b3220c27
Submodule foundation/src/main/resources/public updated: 4250696e57...9e6453e3f2
@@ -457,6 +457,9 @@ class DefaultEthereumMethods(
|
|||||||
"rsk_getRawBlockHeaderByNumber",
|
"rsk_getRawBlockHeaderByNumber",
|
||||||
"rsk_protocolVersion",
|
"rsk_protocolVersion",
|
||||||
)
|
)
|
||||||
|
Chain.TRON__MAINNET, Chain.TRON__SHASTA -> listOf(
|
||||||
|
"buildTransaction",
|
||||||
|
)
|
||||||
|
|
||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory
|
|||||||
import org.springframework.cloud.sleuth.Tracer
|
import org.springframework.cloud.sleuth.Tracer
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
import reactor.core.scheduler.Scheduler
|
import reactor.core.scheduler.Scheduler
|
||||||
|
import java.math.BigInteger
|
||||||
|
|
||||||
object EthereumChainSpecific : AbstractPollChainSpecific() {
|
object EthereumChainSpecific : AbstractPollChainSpecific() {
|
||||||
|
|
||||||
@@ -115,8 +116,24 @@ object EthereumChainSpecific : AbstractPollChainSpecific() {
|
|||||||
UpstreamAvailability.OK
|
UpstreamAvailability.OK
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Received syncing object ${raw.toPrettyString()} for upstream ${upstream.getId()}")
|
when (chain) {
|
||||||
UpstreamAvailability.SYNCING
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,16 @@ class EthereumFinalizationDetector : FinalizationDetector {
|
|||||||
private val disableDetector: ConcurrentHashMap<FinalizationType, Boolean> = ConcurrentHashMap()
|
private val disableDetector: ConcurrentHashMap<FinalizationType, Boolean> = ConcurrentHashMap()
|
||||||
private val finalizationSink = Sinks.many().multicast().directBestEffort<FinalizationData>()
|
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(
|
override fun detectFinalization(
|
||||||
upstream: Upstream,
|
upstream: Upstream,
|
||||||
blockTime: Duration,
|
blockTime: Duration,
|
||||||
@@ -65,7 +75,7 @@ class EthereumFinalizationDetector : FinalizationDetector {
|
|||||||
.getIngressReader()
|
.getIngressReader()
|
||||||
.read(req)
|
.read(req)
|
||||||
.onErrorResume {
|
.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")
|
log.warn("Can't retrieve tagged block, finalization detector for upstream ${upstream.getId()} $chain tag $type disabled")
|
||||||
disableDetector[type] = true
|
disableDetector[type] = true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.slf4j.Logger
|
|||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
import reactor.kotlin.extra.retry.retryRandomBackoff
|
import reactor.kotlin.extra.retry.retryRandomBackoff
|
||||||
|
import java.math.BigInteger
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
interface CallLimitValidator : SingleValidator<ValidateUpstreamSettingsResult> {
|
interface CallLimitValidator : SingleValidator<ValidateUpstreamSettingsResult> {
|
||||||
@@ -155,13 +156,19 @@ class ChainIdValidator(
|
|||||||
netVersion(),
|
netVersion(),
|
||||||
)
|
)
|
||||||
.map {
|
.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() &&
|
val isChainValid = chain.chainId.lowercase() == it.t1.lowercase() &&
|
||||||
chain.netVersion.toString() == it.t2
|
chain.netVersion == netver
|
||||||
|
|
||||||
if (!isChainValid) {
|
if (!isChainValid) {
|
||||||
val actualChain = Global.chainByChainId(it.t1).chainName
|
val actualChain = Global.chainByChainId(it.t1).chainName
|
||||||
log.warn(
|
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}",
|
"but actually it is $actualChain with chainId ${it.t1} and net_version ${it.t2}",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user