problem: doesn't handle upstream error for additionally allowed methods; allowing an existing method redefines its logic
rel: #67
This commit is contained in:
@@ -36,7 +36,7 @@ open class AlwaysQuorum: CallQuorum {
|
||||
}
|
||||
|
||||
override fun isFailed(): Boolean {
|
||||
return false
|
||||
return rpcError != null
|
||||
}
|
||||
|
||||
override fun record(response: ByteArray, upstream: Upstream): Boolean {
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.quorum
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.infinitape.etherjar.rpc.JacksonRpcConverter
|
||||
|
||||
open class BroadcastQuorum(
|
||||
val quorum: Int = 3
|
||||
@@ -33,11 +31,11 @@ open class BroadcastQuorum(
|
||||
}
|
||||
|
||||
override fun isResolved(): Boolean {
|
||||
return calls >= quorum
|
||||
return calls >= quorum && txid != null
|
||||
}
|
||||
|
||||
override fun isFailed(): Boolean {
|
||||
return false
|
||||
return calls >= quorum && getError() != null
|
||||
}
|
||||
|
||||
override fun getResult(): ByteArray? {
|
||||
|
||||
@@ -62,7 +62,7 @@ class QuorumRpcReader(
|
||||
?: RpcException(-32000, "Unknown Upstream error")
|
||||
)
|
||||
} else {
|
||||
log.warn("Did get any result from upstream. Method [${key.method}] using [$q]")
|
||||
log.warn("Did not get any result from upstream. Method [${key.method}] using [$q]")
|
||||
Mono.empty<Result>()
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ class QuorumRpcReader(
|
||||
}
|
||||
}
|
||||
.doOnNext {
|
||||
if (!it.isResolved()) {
|
||||
if (!it.isResolved() && !it.isFailed()) {
|
||||
log.debug("No quorum for ${key.method} using [${quorum}]. Error: ${it.getError()?.message ?: ""}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class DefaultEthereumMethods(
|
||||
return when {
|
||||
hardcodedMethods.contains(method) -> AlwaysQuorum()
|
||||
firstValueMethods.contains(method) -> AlwaysQuorum()
|
||||
anyResponseMethods.contains(method) -> NotLaggingQuorum(6)
|
||||
anyResponseMethods.contains(method) -> NotLaggingQuorum(4)
|
||||
headVerifiedMethods.contains(method) -> NotLaggingQuorum(1)
|
||||
specialMethods.contains(method) -> {
|
||||
when (method) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package io.emeraldpay.dshackle.upstream.calls
|
||||
|
||||
import io.emeraldpay.dshackle.quorum.AlwaysQuorum
|
||||
import io.emeraldpay.dshackle.quorum.CallQuorum
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -31,15 +32,23 @@ class ManagedCallMethods(
|
||||
private val disabled: Set<String>
|
||||
): CallMethods {
|
||||
|
||||
companion object {
|
||||
private val log = LoggerFactory.getLogger(ManagedCallMethods::class.java)
|
||||
}
|
||||
|
||||
private val delegated = delegate.getSupportedMethods().sorted()
|
||||
private val allAllowed: Set<String> = Collections.unmodifiableSet(
|
||||
enabled + delegate.getSupportedMethods() - disabled
|
||||
enabled + delegated - disabled
|
||||
)
|
||||
|
||||
override fun getQuorumFor(method: String): CallQuorum {
|
||||
return if (enabled.contains(method)) {
|
||||
AlwaysQuorum()
|
||||
} else {
|
||||
delegate.getQuorumFor(method)
|
||||
return when {
|
||||
Collections.binarySearch(delegated, method) >= 0 -> delegate.getQuorumFor(method)
|
||||
enabled.contains(method) -> AlwaysQuorum()
|
||||
else -> {
|
||||
log.warn("Getting quorum for unknown method")
|
||||
AlwaysQuorum()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user