From 5f85149c67478cd9d5ccf4fb7e4f86c33090e5ee Mon Sep 17 00:00:00 2001 From: terminal Date: Mon, 1 Aug 2022 21:26:44 +0400 Subject: [PATCH] ethereum pos doc and some config naming --- docs/04-upstream-config.adoc | 16 ++++++++++++++++ docs/reference-configuration.adoc | 16 ++++++++++++++++ .../dshackle/config/UpstreamsConfig.kt | 4 ++-- .../dshackle/config/UpstreamsConfigReader.kt | 6 +++--- .../dshackle/startup/ConfiguredUpstreams.kt | 4 ++-- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/docs/04-upstream-config.adoc b/docs/04-upstream-config.adoc index ebe27fb0..eb6d3544 100644 --- a/docs/04-upstream-config.adoc +++ b/docs/04-upstream-config.adoc @@ -17,6 +17,13 @@ Those protocols can be configures with additional security, TLS and authenticati - Most of Ethereum nodes support WebSocket connection, in addition to the JSON RPC. If it's available on your node, it's suggested to configure both JSON RPC and WebSocket connection +==== Ethereum PoS + +- The support for PoS Ethereum isn't fully implemented yet. However, we support it in a simplified way. +As we can no longer rely on the difficulty parameter of a block for fork choice algorithm we implement upstream rating. +In short terms, we just consider the upstream with the highest rating to be always correct when reporting its head. +Unless it's down then we will fallback on the upstream with the second highest rating, etc. + ==== Bitcoin - Bitcoind needs to be configured to index/track addresses that you're going to request. @@ -72,6 +79,15 @@ cluster: basic-auth: username: ${INFURA_USER} password: ${INFURA_PASSWD} + - id: ethereum-pos + chain: ropsten + connection: + ethereum-pos: + execution: + rpc: + url: ${ROPSTEN_NODE_RPC_URL} + ws: + url: ${ROPSTEN_NODE_WS_URL} ---- There are two main segments for upstreams configuration: diff --git a/docs/reference-configuration.adoc b/docs/reference-configuration.adoc index c6e5e773..4a61982e 100644 --- a/docs/reference-configuration.adoc +++ b/docs/reference-configuration.adoc @@ -769,6 +769,22 @@ Default is 15Mb |=== +==== PoS Ethereum Connection Options +.Connection Config for PoS Ethereum Upstream +[cols="2a,5"] +|=== +| Option | Description + +| `execution` +a| Here you can specify any option from plain ethereum connection options listed above + +This is your connection to an execution layer of PoS Ethereum + +| `upstream-rating` +a| Rating for this upstream. We will always consider the head of the chain to be + +the latest block we saw from the upstream with the highest rating. + +|=== + ==== Bitcoin Connection Options .Connection Config for Bitcoin Upstream diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfig.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfig.kt index a3f88519..168f2f30 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfig.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfig.kt @@ -102,7 +102,7 @@ open class UpstreamsConfig { var host: String? = null var port: Int = 0 var auth: AuthConfig.ClientTlsAuth? = null - var nodeRating: Int = 0 + var upstreamRating: Int = 0 } class EthereumConnection : RpcConnection() { @@ -117,7 +117,7 @@ open class UpstreamsConfig { class EthereumPosConnection : UpstreamConnection() { var execution: EthereumConnection? = null - var blockPriority: Int = 0 + var upstreamRating: Int = 0 } data class BitcoinZeroMq( diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfigReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfigReader.kt index 6fd9b254..83af5646 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfigReader.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/UpstreamsConfigReader.kt @@ -107,7 +107,7 @@ class UpstreamsConfigReader( val connection = UpstreamsConfig.GrpcConnection() upstream.connection = connection getValueAsInt(connConfigNode, "node-rating")?.let { - connection.nodeRating = it + connection.upstreamRating = it } getValueAsString(connConfigNode, "host")?.let { connection.host = it @@ -170,8 +170,8 @@ class UpstreamsConfigReader( getMapping(connConfigNode, "execution")?.let { connection.execution = readEthereumConnection(it) } - getValueAsInt(connConfigNode, "block-priority")?.let { - connection.blockPriority = it + getValueAsInt(connConfigNode, "node-rating")?.let { + connection.upstreamRating = it } return connection } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/startup/ConfiguredUpstreams.kt b/src/main/kotlin/io/emeraldpay/dshackle/startup/ConfiguredUpstreams.kt index 18dc569f..5097deee 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/startup/ConfiguredUpstreams.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/startup/ConfiguredUpstreams.kt @@ -159,7 +159,7 @@ open class ConfiguredUpstreams( return null } val urls = ArrayList() - val connectorFactory = buildEthereumConnectorFactory(execution, chain, urls, NoChoiceWithPriorityForkChoice(conn.blockPriority)) + val connectorFactory = buildEthereumConnectorFactory(execution, chain, urls, NoChoiceWithPriorityForkChoice(conn.upstreamRating)) val methods = buildMethods(config, chain) if (connectorFactory == null) { return null @@ -256,7 +256,7 @@ open class ConfiguredUpstreams( endpoint.port, endpoint.auth, fileResolver, - endpoint.nodeRating + endpoint.upstreamRating ).apply { timeout = options.timeout }