diff --git a/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt index 1f6fe5aa..6ae3d6fb 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/quorum/QuorumRpcReader.kt @@ -27,6 +27,7 @@ import io.emeraldpay.dshackle.upstream.Upstream import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse +import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcUpstreamException import io.emeraldpay.dshackle.upstream.signature.ResponseSigner import io.emeraldpay.etherjar.rpc.RpcException import org.slf4j.LoggerFactory @@ -167,7 +168,13 @@ class QuorumRpcReader( private fun withErrorResume(api: Upstream, key: JsonRpcRequest): Function, Mono> { return Function { src -> src.onErrorResume { err -> - log.debug("Error during call upstream ${api.getId()} with method ${key.method}", err) + val msgError = "Error during call upstream ${api.getId()} with method ${key.method}" + if (err is JsonRpcUpstreamException) { + log.debug(msgError, err) + } else { + log.warn(msgError, err) + } + // when the call failed with an error we want to notify the quorum because // it may use the error message or other details // @@ -175,7 +182,13 @@ class QuorumRpcReader( quorum.record(cleanErr, null, api,) // if it's failed after that, then we don't need more calls, stop api source if (quorum.isFailed()) { - log.debug("Quorum is failed, stop api source. Upstream ${api.getId()}, method ${key.method}") + val msgQuorumFailed = "Quorum is failed, stop api source. Upstream ${api.getId()}, method ${key.method}" + if (cleanErr is JsonRpcUpstreamException) { + log.debug(msgQuorumFailed) + } else { + log.warn(msgQuorumFailed) + } + apiControl.resolve() } else { log.debug("Received an error, trying to request next upstream") @@ -194,7 +207,7 @@ class QuorumRpcReader( log.debug("Quorum is failed. Method ${key.method}, message ${err.message}") Mono.error(err) } else { - log.debug("Did not get any result from upstream. Method [${key.method}] using [$q]") + log.warn("Did not get any result from upstream. Method [${key.method}] using [$q]") noResponse(key.method, q) } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcError.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcError.kt index 773fd80c..8d2743fd 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcError.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcError.kt @@ -31,7 +31,7 @@ data class JsonRpcError(val code: Int, val message: String, val details: Any?) { } fun asException(id: JsonRpcResponse.Id?): JsonRpcException { - return JsonRpcException(id ?: JsonRpcResponse.NumberId(-1), this, null, false) + return JsonRpcUpstreamException(id ?: JsonRpcResponse.NumberId(-1), this) } fun asException(id: JsonRpcResponse.Id?, upstreamId: String?): JsonRpcException { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt index 794291f9..13c6a708 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt @@ -17,7 +17,7 @@ package io.emeraldpay.dshackle.upstream.rpcclient import io.emeraldpay.etherjar.rpc.RpcException -class JsonRpcException( +open class JsonRpcException( val id: JsonRpcResponse.Id, val error: JsonRpcError, val upstreamId: String? = null, diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt index 4ec3d81d..6c511e8b 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcHttpClient.kt @@ -131,7 +131,7 @@ class JsonRpcHttpClient( return Function { resp -> resp.flatMap { if (it.hasError()) { - Mono.error(JsonRpcException(it.id, it.error!!, null, false)) + Mono.error(JsonRpcUpstreamException(it.id, it.error!!)) } else { Mono.just(it) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcUpstreamException.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcUpstreamException.kt new file mode 100644 index 00000000..74ba3109 --- /dev/null +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcUpstreamException.kt @@ -0,0 +1,6 @@ +package io.emeraldpay.dshackle.upstream.rpcclient + +class JsonRpcUpstreamException( + id: JsonRpcResponse.Id, + error: JsonRpcError +) : JsonRpcException(id, error, null, false)