diff --git a/build.gradle b/build.gradle index d23b1c3e..9d42aa73 100644 --- a/build.gradle +++ b/build.gradle @@ -122,16 +122,8 @@ dependencies { implementation(variantOf(libs.netty.tcnative.boringssl) { classifier("linux-aarch_64") }) implementation(variantOf(libs.netty.tcnative.boringssl) { classifier("osx-x86_64") }) implementation 'dshackle:foundation:1.0.0' - - implementation files('src/main/resources/LogsOracle.jar') } -// Enable 'Foreign Function & Memory API' (JEP 434) -// Drop after update on Java 21 -tasks.withType(JavaCompile) { options.compilerArgs += "--enable-preview" } -tasks.withType(Test) { jvmArgs += "--enable-preview" } -tasks.withType(JavaExec) { jvmArgs += "--enable-preview" } - compileKotlin { compilerOptions.jvmTarget.set(JvmTarget.JVM_21) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/Config.kt b/src/main/kotlin/io/emeraldpay/dshackle/Config.kt index da05fbca..b33ab61b 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/Config.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/Config.kt @@ -21,7 +21,6 @@ import io.emeraldpay.dshackle.config.CacheConfig import io.emeraldpay.dshackle.config.ChainsConfig import io.emeraldpay.dshackle.config.CompressionConfig import io.emeraldpay.dshackle.config.HealthConfig -import io.emeraldpay.dshackle.config.IndexConfig import io.emeraldpay.dshackle.config.MainConfig import io.emeraldpay.dshackle.config.MainConfigReader import io.emeraldpay.dshackle.config.MonitoringConfig @@ -131,11 +130,6 @@ open class Config( return mainConfig.cache ?: CacheConfig() } - @Bean - open fun indexConfig(@Autowired mainConfig: MainConfig): IndexConfig { - return mainConfig.index ?: IndexConfig() - } - @Bean open fun signatureConfig(@Autowired mainConfig: MainConfig): SignatureConfig { return mainConfig.signature ?: SignatureConfig() diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/IndexConfig.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/IndexConfig.kt deleted file mode 100644 index 00202c6e..00000000 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/IndexConfig.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.emeraldpay.dshackle.config - -import io.emeraldpay.dshackle.Chain - -class IndexConfig { - var items: HashMap = HashMap() - - class Index( - var rpc: String, - var store: String, - var ram_limit: Long?, - ) - - fun isChainEnabled(chain: Chain): Boolean { - return items.containsKey(chain) - } - - fun getByChain(chain: Chain): Index? { - return items.get(chain) - } -} diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/IndexConfigReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/IndexConfigReader.kt deleted file mode 100644 index 1297670d..00000000 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/IndexConfigReader.kt +++ /dev/null @@ -1,62 +0,0 @@ -package io.emeraldpay.dshackle.config - -import io.emeraldpay.dshackle.Chain -import io.emeraldpay.dshackle.Global -import io.emeraldpay.dshackle.foundation.YamlConfigReader -import org.apache.commons.lang3.StringUtils -import org.slf4j.LoggerFactory -import org.springframework.util.unit.DataSize -import org.yaml.snakeyaml.nodes.MappingNode - -class IndexConfigReader : YamlConfigReader() { - - companion object { - private val log = LoggerFactory.getLogger(IndexConfigReader::class.java) - } - - override fun read(input: MappingNode?): IndexConfig? { - return getList(input, "index")?.let { items -> - val config = IndexConfig() - - items.value.map { - val blockchainRaw = getValueAsString(it, "chain") - if (blockchainRaw == null || StringUtils.isEmpty(blockchainRaw) || Global.chainById(blockchainRaw) == Chain.UNSPECIFIED) { - throw InvalidConfigYamlException(filename, it.startMark, "Invalid blockchain or not specified") - } - - val blockchain = Global.chainById(blockchainRaw) - if (config.items.containsKey(blockchain)) { - throw InvalidConfigYamlException(filename, it.startMark, "Duplicated indexes") - } - - val rpc = getValueAsString(it, "rpc") - if (rpc == null || StringUtils.isEmpty(rpc)) { - throw InvalidConfigYamlException(filename, it.startMark, "Invalid rpc specified") - } - - val store = getValueAsString(it, "store") - if (store == null || StringUtils.isEmpty(store)) { - throw InvalidConfigYamlException(filename, it.startMark, "Invalid store directory or not specified") - } - - val limit = getMapping(it, "limit") - val ram_limit = limit?.let { - val raw = getValueAsString(limit, "ram") - if (raw == null || StringUtils.isEmpty(raw)) { - return null - } - - try { - DataSize.parse(raw).toBytes() - } catch (e: IllegalArgumentException) { - throw InvalidConfigYamlException(filename, it.startMark, "Invalid limit for index") - } - } - - config.items.put(blockchain, IndexConfig.Index(rpc, store, ram_limit)) - } - - config - } - } -} diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfig.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfig.kt index 23b4fb7a..a1d8e4b4 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfig.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfig.kt @@ -24,7 +24,6 @@ class MainConfig { var tls: AuthConfig.ServerTlsAuth? = null var passthrough: Boolean = false var cache: CacheConfig? = null - var index: IndexConfig? = null var proxy: ProxyConfig? = null var upstreams: UpstreamsConfig? = null set(value) { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfigReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfigReader.kt index 7522c562..90cdef65 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfigReader.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/MainConfigReader.kt @@ -29,7 +29,6 @@ class MainConfigReader( private val optionsReader = ChainOptionsReader() private val upstreamsConfigReader = UpstreamsConfigReader(fileResolver, optionsReader) private val cacheConfigReader = CacheConfigReader() - private val indexConfigReader = IndexConfigReader() private val tokensConfigReader = TokensConfigReader() private val monitoringConfigReader = MonitoringConfigReader() private val accessLogReader = AccessLogReader() @@ -64,9 +63,6 @@ class MainConfigReader( cacheConfigReader.read(input)?.let { config.cache = it } - indexConfigReader.read(input)?.let { - config.index = it - } tokensConfigReader.read(input)?.let { config.tokens = it } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/context/MultistreamsConfig.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/context/MultistreamsConfig.kt index 6b3ba3cf..7e22c928 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/context/MultistreamsConfig.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/context/MultistreamsConfig.kt @@ -3,7 +3,6 @@ package io.emeraldpay.dshackle.config.context import io.emeraldpay.dshackle.BlockchainType.BITCOIN import io.emeraldpay.dshackle.Chain import io.emeraldpay.dshackle.cache.CachesFactory -import io.emeraldpay.dshackle.config.IndexConfig import io.emeraldpay.dshackle.upstream.CallTargetsHolder import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinMultistream @@ -29,9 +28,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory) subScheduler: Scheduler, tracer: Tracer, multistreamEventsScheduler: Scheduler, - indexConfig: IndexConfig, - @Qualifier("logsOracleScheduler") - logsOracleScheduler: Scheduler, ): List { return Chain.entries .filterNot { it == Chain.UNSPECIFIED } @@ -46,8 +42,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory) subScheduler, tracer, multistreamEventsScheduler, - indexConfig.getByChain(chain), - logsOracleScheduler, ) } } @@ -60,8 +54,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory) subScheduler: Scheduler, tracer: Tracer, multistreamEventsScheduler: Scheduler, - logsOracleConfig: IndexConfig.Index?, - logsOracleScheduler: Scheduler, ): Multistream { val name = "multi-$chain" val cs = ChainSpecificRegistry.resolve(chain) @@ -76,9 +68,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory) cs.makeCachingReaderBuilder(tracer), cs::localReaderBuilder, cs.subscriptionBuilder(subScheduler), - logsOracleConfig, - logsOracleScheduler, - tracer, ).also { register(it, name) } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/context/SchedulersConfig.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/context/SchedulersConfig.kt index ae4b068a..356aef2d 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/context/SchedulersConfig.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/context/SchedulersConfig.kt @@ -46,11 +46,6 @@ open class SchedulersConfig { return makeScheduler("sub-scheduler", 4, monitoringConfig) } - @Bean - open fun logsOracleScheduler(monitoringConfig: MonitoringConfig): Scheduler { - return makeScheduler("logs-oracle", 4, monitoringConfig) - } - @Bean open fun multistreamEventsScheduler(monitoringConfig: MonitoringConfig): Scheduler { return makeScheduler("events-scheduler", 4, monitoringConfig) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/BitcoinUpstreamCreator.kt b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/BitcoinUpstreamCreator.kt index 8ba11072..9925aa61 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/BitcoinUpstreamCreator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/BitcoinUpstreamCreator.kt @@ -3,7 +3,6 @@ package io.emeraldpay.dshackle.startup.configure import io.emeraldpay.dshackle.Chain import io.emeraldpay.dshackle.FileResolver import io.emeraldpay.dshackle.config.ChainsConfig -import io.emeraldpay.dshackle.config.IndexConfig import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.foundation.ChainOptions import io.emeraldpay.dshackle.startup.QuorumForLabels @@ -24,12 +23,11 @@ import java.util.concurrent.atomic.AtomicInteger @Component class BitcoinUpstreamCreator( chainsConfig: ChainsConfig, - indexConfig: IndexConfig, callTargets: CallTargetsHolder, private val genericConnectorFactoryCreator: ConnectorFactoryCreator, private val fileResolver: FileResolver, private val headScheduler: Scheduler, -) : UpstreamCreator(chainsConfig, indexConfig, callTargets) { +) : UpstreamCreator(chainsConfig, callTargets) { private var seq = AtomicInteger(0) override fun createUpstream( diff --git a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/EthereumUpstreamCreator.kt b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/EthereumUpstreamCreator.kt index 54df5dbc..2b9243fb 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/EthereumUpstreamCreator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/EthereumUpstreamCreator.kt @@ -2,7 +2,6 @@ package io.emeraldpay.dshackle.startup.configure import io.emeraldpay.dshackle.Chain import io.emeraldpay.dshackle.config.ChainsConfig -import io.emeraldpay.dshackle.config.IndexConfig import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.config.hot.CompatibleVersionsRules import io.emeraldpay.dshackle.foundation.ChainOptions @@ -13,11 +12,10 @@ import java.util.function.Supplier @Component class EthereumUpstreamCreator( chainsConfig: ChainsConfig, - indexConfig: IndexConfig, callTargets: CallTargetsHolder, connectorFactoryCreatorResolver: ConnectorFactoryCreatorResolver, versionRules: Supplier, -) : GenericUpstreamCreator(chainsConfig, indexConfig, callTargets, connectorFactoryCreatorResolver, versionRules) { +) : GenericUpstreamCreator(chainsConfig, callTargets, connectorFactoryCreatorResolver, versionRules) { override fun createUpstream( upstreamsConfig: UpstreamsConfig.Upstream<*>, diff --git a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/GenericUpstreamCreator.kt b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/GenericUpstreamCreator.kt index b1bbfbe8..a813ea67 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/GenericUpstreamCreator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/GenericUpstreamCreator.kt @@ -2,7 +2,6 @@ package io.emeraldpay.dshackle.startup.configure import io.emeraldpay.dshackle.Chain import io.emeraldpay.dshackle.config.ChainsConfig -import io.emeraldpay.dshackle.config.IndexConfig import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.config.hot.CompatibleVersionsRules import io.emeraldpay.dshackle.foundation.ChainOptions @@ -19,11 +18,10 @@ import java.util.function.Supplier @Component open class GenericUpstreamCreator( chainsConfig: ChainsConfig, - indexConfig: IndexConfig, callTargets: CallTargetsHolder, private val connectorFactoryCreatorResolver: ConnectorFactoryCreatorResolver, private val versionRules: Supplier, -) : UpstreamCreator(chainsConfig, indexConfig, callTargets) { +) : UpstreamCreator(chainsConfig, callTargets) { private val hashes = HashSet() override fun createUpstream( diff --git a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/UpstreamCreator.kt b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/UpstreamCreator.kt index 4b354f21..5a7e7f27 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/UpstreamCreator.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/startup/configure/UpstreamCreator.kt @@ -3,7 +3,6 @@ package io.emeraldpay.dshackle.startup.configure import io.emeraldpay.dshackle.Chain import io.emeraldpay.dshackle.Global import io.emeraldpay.dshackle.config.ChainsConfig -import io.emeraldpay.dshackle.config.IndexConfig import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.foundation.ChainOptions import io.emeraldpay.dshackle.foundation.ChainOptions.Options @@ -17,7 +16,6 @@ import kotlin.math.abs abstract class UpstreamCreator( private val chainsConfig: ChainsConfig, - private val indexConfig: IndexConfig, private val callTargets: CallTargetsHolder, ) { protected val log: Logger = LoggerFactory.getLogger(this::class.java) @@ -83,7 +81,7 @@ abstract class UpstreamCreator( } ManagedCallMethods( - delegate = callTargets.getDefaultMethods(chain, indexConfig.isChainEnabled(chain), options, config.connection), + delegate = callTargets.getDefaultMethods(chain, options, config.connection), enabled = config.methods?.enabled?.map { it.name }?.toSet() ?: emptySet(), disabled = config.methods?.disabled?.map { it.name }?.toSet() ?: emptySet(), groupsEnabled = config.methodGroups?.enabled ?: emptySet(), @@ -99,7 +97,7 @@ abstract class UpstreamCreator( } } } else { - callTargets.getDefaultMethods(chain, indexConfig.isChainEnabled(chain), options, config.connection) + callTargets.getDefaultMethods(chain, options, config.connection) } } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/CallTargetsHolder.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/CallTargetsHolder.kt index edc06ab3..22fb1368 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/CallTargetsHolder.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/CallTargetsHolder.kt @@ -29,22 +29,20 @@ class CallTargetsHolder { fun getDefaultMethods( chain: Chain, - hasLogsOracle: Boolean, options: ChainOptions.Options, connection: UpstreamsConfig.UpstreamConnection?, ): CallMethods { - return callTargets[chain] ?: return setupDefaultMethods(chain, hasLogsOracle, options, connection) + return callTargets[chain] ?: return setupDefaultMethods(chain, options, connection) } private fun setupDefaultMethods( chain: Chain, - hasLogsOracle: Boolean, options: ChainOptions.Options, connection: UpstreamsConfig.UpstreamConnection?, ): CallMethods { val created = when (chain.type) { BITCOIN -> DefaultBitcoinMethods(options.providesBalance == true) - ETHEREUM -> DefaultEthereumMethods(chain, hasLogsOracle) + ETHEREUM -> DefaultEthereumMethods(chain) STARKNET -> DefaultStarknetMethods(chain) POLKADOT -> DefaultPolkadotMethods(chain) SOLANA -> DefaultSolanaMethods() diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/LogsOracle.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/LogsOracle.kt deleted file mode 100644 index 13b4e564..00000000 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/LogsOracle.kt +++ /dev/null @@ -1,90 +0,0 @@ -package io.emeraldpay.dshackle.upstream - -import io.emeraldpay.dshackle.config.IndexConfig -import org.slf4j.LoggerFactory -import org.springframework.cloud.sleuth.Tracer -import reactor.core.Disposable -import reactor.core.publisher.Mono -import reactor.core.scheduler.Scheduler - -class LogsOracle( - private val config: IndexConfig.Index, - private val upstream: Multistream, - private val scheduler: Scheduler, - private val tracer: Tracer, -) { - - private val log = LoggerFactory.getLogger(LogsOracle::class.java) - - private var subscription: Disposable? = null - private var conn: org.drpc.logsoracle.LogsOracle? = null - - fun start() { - log.info("liboracle starting: store=${config.store}, ram=${config.ram_limit}") - - conn = org.drpc.logsoracle.LogsOracle(config.store, config.ram_limit ?: 0L) - subscription = upstream.getHead().getFlux() - .publishOn(scheduler) - .doOnError { t -> log.error("Failed to subscribe head for oracle", t) } - .doFinally { log.info("unsubscribe head") } - .subscribe { setHeight(it.height) } - - setUpstream(config.rpc) - } - - fun stop() { - log.info("liboracle closed") - - subscription?.dispose() - subscription = null - - conn?.close() - } - - fun estimate( - limit: Long?, - fromBlock: Long, - toBlock: Long, - address: List, - topics: List>, - ): Mono { - val requestSpan = tracer.currentSpan() - - return Mono.fromCallable { - val span = tracer.nextSpan(requestSpan).name("emerald.blockchain/logsoracle").start() - log.info("query: from=$fromBlock, to=$toBlock, limit=$limit") - - try { - val estimate = conn?.Query(limit, fromBlock, toBlock, address, topics) - "{\"total\":$estimate,\"overflow\":false}" - } catch (e: org.drpc.logsoracle.LogsOracle.LogsOracleException) { - if (e.isQueryOverflow()) { - "{\"total\":-1,\"overflow\":true}" - } else { - throw e - } - } finally { - span.end() - } - } - .publishOn(scheduler) - } - - fun setHeight(height: Long) { - try { - log.info("update state: height=$height") - conn?.UpdateHeight(height) - } catch (e: Exception) { - log.error("couldn't set height", e) - } - } - - fun setUpstream(upstream: String) { - try { - log.info("update state: upstream=$upstream") - conn?.SetUpstream(upstream) - } catch (e: Exception) { - log.error("couldn't set upstream", e) - } - } -} diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt index 7a74581f..d9739b36 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethods.kt @@ -31,7 +31,6 @@ import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException */ class DefaultEthereumMethods( private val chain: Chain, - private val hasLogsOracle: Boolean = false, ) : CallMethods { private val version = "\"EmeraldDshackle/${Global.version}\"" @@ -613,7 +612,6 @@ class DefaultEthereumMethods( specialMethods + headVerifiedMethods - chainUnsupportedMethods(chain) + - getDrpcVendorMethods(chain) + getChainSpecificMethods(chain) } @@ -632,15 +630,6 @@ class DefaultEthereumMethods( } } - private fun getDrpcVendorMethods(chain: Chain): List { - val supported = mutableListOf() - - // Currently tested on eth mainnet only, should potentially work for all compatible ones. - if (chain == Chain.ETHEREUM__MAINNET && hasLogsOracle) { supported.add("drpc_getLogsEstimate") } - - return supported - } - private fun getChainSpecificMethods(chain: Chain): List { return when (chain) { Chain.OPTIMISM__MAINNET, Chain.OPTIMISM__SEPOLIA -> diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt index 7df4311b..0191a83d 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt @@ -14,7 +14,6 @@ import io.emeraldpay.dshackle.upstream.EgressSubscription import io.emeraldpay.dshackle.upstream.GenericSingleCallValidator import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.IngressSubscription -import io.emeraldpay.dshackle.upstream.LogsOracle import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.SingleValidator import io.emeraldpay.dshackle.upstream.Upstream @@ -65,9 +64,8 @@ object EthereumChainSpecific : AbstractPollChainSpecific() { cachingReader: CachingReader, methods: CallMethods, head: Head, - logsOracle: LogsOracle?, ): Mono { - return Mono.just(EthereumLocalReader(cachingReader as EthereumCachingReader, methods, head, logsOracle)) + return Mono.just(EthereumLocalReader(cachingReader as EthereumCachingReader, methods, head)) } override fun subscriptionBuilder(headScheduler: Scheduler): (Multistream) -> EgressSubscription { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReader.kt index cabab516..6a70891e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReader.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReader.kt @@ -22,7 +22,6 @@ import io.emeraldpay.dshackle.reader.ChainReader import io.emeraldpay.dshackle.upstream.ChainRequest import io.emeraldpay.dshackle.upstream.ChainResponse import io.emeraldpay.dshackle.upstream.Head -import io.emeraldpay.dshackle.upstream.LogsOracle import io.emeraldpay.dshackle.upstream.Selector import io.emeraldpay.dshackle.upstream.calls.CallMethods import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity @@ -46,7 +45,6 @@ class EthereumLocalReader( private val reader: EthereumCachingReader, private val methods: CallMethods, private val head: Head, - private val logsOracle: LogsOracle?, ) : ChainReader { override fun read(key: ChainRequest): Mono { @@ -132,10 +130,6 @@ class EthereumLocalReader( .map { ChainResponse(it.data, null, it.resolvedUpstreamData) } } - method == "drpc_getLogsEstimate" -> { - getLogsEstimate(params.list) - } - else -> null } } @@ -193,82 +187,4 @@ class EthereumLocalReader( return reader.blocksByHeightAsCont(upstreamFilter) .read(number).map { ChainResponse(it.data.json, null, it.resolvedUpstreamData) } } - - fun getLogsEstimate(params: List): Mono? { - if (logsOracle == null) { - throw NotImplementedError() - } - if (params.size != 1 || params[0] == null) { - throw RpcException(RpcResponseError.CODE_INVALID_METHOD_PARAMS, "Must provide 1 parameters") - } - - val req = params[0] as LinkedHashMap - - val limit = try { req.get("limit") as Int? } catch (_: IllegalArgumentException) { - throw RpcException(RpcResponseError.CODE_INVALID_METHOD_PARAMS, "Invalid 'limit' parameter") - } - - val fromBlock = try { parseBlockRef(req.get("fromBlock") as String?) } catch (_: IllegalArgumentException) { - throw RpcException(RpcResponseError.CODE_INVALID_METHOD_PARAMS, "Invalid 'fromBlock' parameter") - } - val toBlock = try { parseBlockRef(req.get("toBlock") as String?) } catch (_: IllegalArgumentException) { - throw RpcException(RpcResponseError.CODE_INVALID_METHOD_PARAMS, "Invalid 'toBlock' parameter") - } - val address: List = try { - val it = req.get("address") ?: listOf() - - if (it is String) { - listOf(it) - } else { - it as List - } - } catch (_: Exception) { - throw RpcException(RpcResponseError.CODE_INVALID_METHOD_PARAMS, "Invalid 'address' parameter") - } - val topics: List> = try { - val tpcs = req.get("topics")?.let { it as List } ?: listOf() - if (tpcs.size > 4) { - throw IllegalArgumentException() - } - - tpcs.map { - if (it == null) { - emptyList() - } else if (it is String) { - listOf(it) - } else { - it as List - } - } - } catch (_: Exception) { - throw RpcException(RpcResponseError.CODE_INVALID_METHOD_PARAMS, "Invalid 'topics' parameter") - } - - return logsOracle.estimate(limit?.toLong(), fromBlock, toBlock, address, topics) - .map { ChainResponse(it.toByteArray(), null, emptyList()) } - } - - private fun parseBlockRef(blockRef: String?): Long { - when { - blockRef == "earliest" -> { - return 0 - } - blockRef == null || blockRef == "finalized" || blockRef == "safe" || blockRef == "pending" || blockRef == "latest" -> { - return head.getCurrentHeight() ?: throw Exception("couldn't get current head") - } - blockRef.startsWith("0x") -> { - val quantity = HexQuantity.from(blockRef) ?: throw IllegalArgumentException() - return quantity.value.let { - if (it < BigInteger.valueOf(Long.MAX_VALUE) && it >= BigInteger.ZERO) { - it.toLong() - } else { - throw IllegalArgumentException() - } - } - } - else -> { - throw IllegalArgumentException() - } - } - } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/AbstractChainSpecific.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/AbstractChainSpecific.kt index ee5e922e..559c42c6 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/AbstractChainSpecific.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/AbstractChainSpecific.kt @@ -14,7 +14,6 @@ import io.emeraldpay.dshackle.upstream.EgressSubscription import io.emeraldpay.dshackle.upstream.EmptyEgressSubscription import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.IngressSubscription -import io.emeraldpay.dshackle.upstream.LogsOracle import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.NoIngressSubscription import io.emeraldpay.dshackle.upstream.NoopCachingReader @@ -41,7 +40,6 @@ abstract class AbstractChainSpecific : ChainSpecific { cachingReader: CachingReader, methods: CallMethods, head: Head, - logsOracle: LogsOracle?, ): Mono { return Mono.just(LocalReader(methods)) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/ChainSpecific.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/ChainSpecific.kt index 0c919a43..b060c113 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/ChainSpecific.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/ChainSpecific.kt @@ -23,7 +23,6 @@ import io.emeraldpay.dshackle.upstream.ChainRequest import io.emeraldpay.dshackle.upstream.EgressSubscription import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.IngressSubscription -import io.emeraldpay.dshackle.upstream.LogsOracle import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.SingleValidator import io.emeraldpay.dshackle.upstream.Upstream @@ -51,7 +50,7 @@ import reactor.core.scheduler.Scheduler import java.util.function.Supplier typealias SubscriptionBuilder = (Multistream) -> EgressSubscription -typealias LocalReaderBuilder = (CachingReader, CallMethods, Head, LogsOracle?) -> Mono +typealias LocalReaderBuilder = (CachingReader, CallMethods, Head) -> Mono typealias CachingReaderBuilder = (Multistream, Caches, Factory) -> CachingReader typealias FinalizationDetectorBuilder = () -> FinalizationDetector @@ -70,7 +69,6 @@ interface ChainSpecific { cachingReader: CachingReader, methods: CallMethods, head: Head, - logsOracle: LogsOracle?, ): Mono fun subscriptionBuilder(headScheduler: Scheduler): (Multistream) -> EgressSubscription diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericMultistream.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericMultistream.kt index 564ae4c6..5ee9ede7 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericMultistream.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/generic/GenericMultistream.kt @@ -19,7 +19,6 @@ package io.emeraldpay.dshackle.upstream.generic import io.emeraldpay.api.proto.BlockchainOuterClass import io.emeraldpay.dshackle.Chain import io.emeraldpay.dshackle.cache.Caches -import io.emeraldpay.dshackle.config.IndexConfig import io.emeraldpay.dshackle.config.UpstreamsConfig import io.emeraldpay.dshackle.reader.ChainReader import io.emeraldpay.dshackle.upstream.CachingReader @@ -30,7 +29,6 @@ import io.emeraldpay.dshackle.upstream.EmptyHead import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.HeadLagObserver import io.emeraldpay.dshackle.upstream.Lifecycle -import io.emeraldpay.dshackle.upstream.LogsOracle import io.emeraldpay.dshackle.upstream.MergedHead import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.Selector @@ -39,7 +37,6 @@ import io.emeraldpay.dshackle.upstream.Upstream import io.emeraldpay.dshackle.upstream.calls.CallSelector import io.emeraldpay.dshackle.upstream.forkchoice.PriorityForkChoice import io.emeraldpay.dshackle.upstream.grpc.GrpcUpstream -import org.springframework.cloud.sleuth.Tracer import org.springframework.util.ConcurrentReferenceHashMap import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType.WEAK import reactor.core.publisher.Flux @@ -56,9 +53,6 @@ open class GenericMultistream( cachingReaderBuilder: CachingReaderBuilder, private val localReaderBuilder: LocalReaderBuilder, private val subscriptionBuilder: SubscriptionBuilder, - logsOracleConfig: IndexConfig.Index? = null, - private val logsOracleScheduler: Scheduler, - private val tracer: Tracer, ) : Multistream(chain, caches, callSelector, multistreamEventsScheduler) { private val cachingReader = cachingReaderBuilder(this, caches, getMethodsFactory()) @@ -77,10 +71,6 @@ open class GenericMultistream( headScheduler, ) - private val logsOracle: LogsOracle? = logsOracleConfig?.let { - LogsOracle(logsOracleConfig, this, logsOracleScheduler, tracer) - } - private var subscription: EgressSubscription = subscriptionBuilder(this) private val filteredHeads: MutableMap = @@ -91,14 +81,12 @@ open class GenericMultistream( head.start() onHeadUpdated(head) cachingReader.start() - logsOracle?.start() } override fun stop() { super.stop() cachingReader.stop() filteredHeads.clear() - logsOracle?.stop() } override fun addHead(upstream: Upstream) { @@ -167,7 +155,7 @@ open class GenericMultistream( } override fun getLocalReader(): Mono { - return localReaderBuilder(cachingReader, getMethods(), getHead(), logsOracle) + return localReaderBuilder(cachingReader, getMethods(), getHead()) } override fun getEgressSubscription(): EgressSubscription { diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/polkadot/PolkadotChainSpecific.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/polkadot/PolkadotChainSpecific.kt index 6325ae18..ae8b3b79 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/polkadot/PolkadotChainSpecific.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/polkadot/PolkadotChainSpecific.kt @@ -16,7 +16,6 @@ import io.emeraldpay.dshackle.upstream.EgressSubscription import io.emeraldpay.dshackle.upstream.GenericSingleCallValidator import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.IngressSubscription -import io.emeraldpay.dshackle.upstream.LogsOracle import io.emeraldpay.dshackle.upstream.Multistream import io.emeraldpay.dshackle.upstream.SingleValidator import io.emeraldpay.dshackle.upstream.Upstream @@ -80,7 +79,6 @@ object PolkadotChainSpecific : AbstractPollChainSpecific() { cachingReader: CachingReader, methods: CallMethods, head: Head, - logsOracle: LogsOracle?, ): Mono { return Mono.just(LocalReader(methods)) } diff --git a/src/main/resources/LogsOracle.jar b/src/main/resources/LogsOracle.jar deleted file mode 100644 index d4159295..00000000 Binary files a/src/main/resources/LogsOracle.jar and /dev/null differ diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy index 99cc3add..ff32787b 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy @@ -392,7 +392,7 @@ class NativeCallSpec extends Specification { def "Prepare call adds height selector for not-lagging quorum"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["foo_bar"] as Set, [] as Set, [] as Set, [] as Set ) methods.setQuorum("foo_bar", "not_lagging") @@ -434,7 +434,7 @@ class NativeCallSpec extends Specification { def "Prepare call adds decorator for eth_newFilter"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_newFilter"] as Set, [] as Set, [] as Set, [] as Set ) methods.setQuorum("eth_newFilter", "always") @@ -466,7 +466,7 @@ class NativeCallSpec extends Specification { def "Prepare call adds decorator for eth_getFilterChanges"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_getFilterChanges"] as Set, [] as Set, [] as Set, [] as Set ) def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream()) @@ -497,7 +497,7 @@ class NativeCallSpec extends Specification { def "Prepare call adds decorator for eth_uninstallFilter"() { setup: def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_uninstallFilter"] as Set, [] as Set, [] as Set, [] as Set ) def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream()) @@ -595,7 +595,7 @@ class NativeCallSpec extends Specification { setup: def quorum = new AlwaysQuorum() def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, [] as Set, ["filter"] as Set, [] as Set ) def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, new ArrayList()) @@ -628,7 +628,7 @@ class NativeCallSpec extends Specification { setup: def quorum = new AlwaysQuorum() def methods = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, [] as Set, ["filter"] as Set, [] as Set ) def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, new ArrayList()) diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/GenericUpstreamMock.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/GenericUpstreamMock.groovy index 63be21b2..b22bff24 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/GenericUpstreamMock.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/GenericUpstreamMock.groovy @@ -38,7 +38,7 @@ class GenericUpstreamMock extends GenericUpstream { static CallMethods allMethods() { new AggregatedCallMethods([ - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), new DefaultBitcoinMethods(true), new DirectCallMethods(["eth_test"]) ]) diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy index 933b4ba4..ee98b05e 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/MultistreamHolderMock.groovy @@ -52,8 +52,6 @@ class MultistreamHolderMock implements MultistreamHolder { EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, io.emeraldpay.dshackle.upstream.starknet.StarknetChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), - null, Schedulers.immediate(), - TestingCommons.tracerMock() ) upstreams[chain].addUpstream(up) } else { @@ -106,8 +104,8 @@ class MultistreamHolderMock implements MultistreamHolder { super(chain, Schedulers.immediate(), null, upstreams, caches, Schedulers.boundedElastic(), EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(new BraveTracer(null, null, null)), EthereumChainSpecific.INSTANCE.&localReaderBuilder, - EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), - new BraveTracer(null, null, null)) + EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), + ) } EthereumMultistreamMock(@NotNull Chain chain, @NotNull List upstreams) { diff --git a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy index 27c03b8f..b0af252b 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/test/TestingCommons.groovy @@ -102,9 +102,6 @@ class TestingCommons { EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), - null, - Schedulers.immediate(), - tracerMock() ).tap { it.processUpstreamsEvents( new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up, UpstreamChangeEvent.ChangeType.ADDED) @@ -132,9 +129,7 @@ class TestingCommons { EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), - null, - Schedulers.immediate(), - tracerMock()) + ) } static Multistream multistreamClassicWithoutUpstreams(Chain chain) { @@ -142,9 +137,7 @@ class TestingCommons { EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), - null, - Schedulers.immediate(), - tracerMock()) + ) } static FileResolver fileResolver() { diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy index d0e5da75..417a3227 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/FilteredApisSpec.groovy @@ -37,7 +37,7 @@ import static java.util.List.of class FilteredApisSpec extends Specification { - def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def "Verifies labels"() { setup: diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy index 63bb374f..e17746d2 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/MultistreamSpec.groovy @@ -57,7 +57,7 @@ class MultistreamSpec extends Specification { Schedulers.boundedElastic(), EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, - EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock()) + EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic())) when: aggr.onUpstreamsUpdated() def act = aggr.getMethods() @@ -192,7 +192,7 @@ class MultistreamSpec extends Specification { Schedulers.boundedElastic(), EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, - EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock()) + EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic())) expect: multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).is(up1.ethereumHeadMock) @@ -265,7 +265,7 @@ class MultistreamSpec extends Specification { Schedulers.boundedElastic(), EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, - EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock()) + EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic())) when: ms.processUpstreamsEvents( new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED) @@ -296,7 +296,7 @@ class MultistreamSpec extends Specification { Schedulers.boundedElastic(), EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, - EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock()) + EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic())) def head1 = createBlock(250, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448401b") def head2 = createBlock(270, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448402b") def head3 = createBlock(100, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448412b") @@ -331,7 +331,7 @@ class MultistreamSpec extends Specification { Schedulers.boundedElastic(), EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, - EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock()) + EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic())) multistream.processUpstreamsEvents( new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED) ) @@ -369,7 +369,7 @@ class MultistreamSpec extends Specification { Schedulers.boundedElastic(), EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()), EthereumChainSpecific.INSTANCE.&localReaderBuilder, - StarknetChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock()) + StarknetChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic())) } @NotNull diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy index 91364a6d..b672cac2 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/DefaultEthereumMethodsSpec.groovy @@ -7,7 +7,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "eth_chainId is available"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.isAvailable("eth_chainId") then: @@ -16,7 +16,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "eth_chainId is hardcoded"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.isHardcoded("eth_chainId") then: @@ -25,7 +25,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "eth_chainId is not callable"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.isCallable("eth_chainId") then: @@ -34,7 +34,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "Provides hardcoded correct chainId"() { expect: - new String(new DefaultEthereumMethods(chain, false).executeHardcoded("eth_chainId")) == id + new String(new DefaultEthereumMethods(chain).executeHardcoded("eth_chainId")) == id where: chain | id Chain.ETHEREUM__MAINNET | '"0x1"' @@ -43,7 +43,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "Optimism chain unsupported methods"() { setup: - def methods = new DefaultEthereumMethods(Chain.OPTIMISM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.OPTIMISM__MAINNET) when: def acc = methods.isAvailable("eth_getAccounts") def trans = methods.isAvailable("eth_sendTransaction") @@ -54,7 +54,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "Has supported specific methods"() { expect: - new DefaultEthereumMethods(chain, false).getSupportedMethods().containsAll(methods) + new DefaultEthereumMethods(chain).getSupportedMethods().containsAll(methods) where: chain | methods Chain.POLYGON__MAINNET | ["bor_getAuthor", @@ -68,7 +68,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "Has no filter methods by default"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("filter") } then: @@ -77,7 +77,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "Has no trace methods by default"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) when: def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("trace") } then: @@ -86,7 +86,7 @@ class DefaultEthereumMethodsSpec extends Specification { def "Default eth methods are available"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) expect: methods.isAvailable(method) where: diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy index a5350d19..fa4c1de4 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/calls/ManagedCallMethodsSpec.groovy @@ -94,7 +94,7 @@ class ManagedCallMethodsSpec extends Specification { def "Use custom quorum if provided"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_test", "eth_foo", "eth_bar"] as Set, [] as Set, [] as Set, @@ -120,7 +120,7 @@ class ManagedCallMethodsSpec extends Specification { def "Doesn't reuse same instance"() { def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_test"] as Set, [] as Set, [] as Set, @@ -145,7 +145,7 @@ class ManagedCallMethodsSpec extends Specification { def "Test enable method group"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, [] as Set, ["filter"] as Set, @@ -169,7 +169,7 @@ class ManagedCallMethodsSpec extends Specification { def "Test enable method group minus one"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), [] as Set, ["eth_newPendingTransactionFilter"] as Set, ["filter"] as Set, @@ -193,7 +193,7 @@ class ManagedCallMethodsSpec extends Specification { def "Test disabled group not disable enabled method"() { setup: def managed = new ManagedCallMethods( - new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false), + new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET), ["eth_newPendingTransactionFilter"] as Set, [] as Set, [] as Set, diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy index 157e1cee..8db74557 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumCachingReaderSpec.groovy @@ -45,7 +45,7 @@ class EthereumDirectReaderSpec extends Specification { transactions = [] } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -80,7 +80,7 @@ class EthereumDirectReaderSpec extends Specification { transactions = [] } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -107,7 +107,7 @@ class EthereumDirectReaderSpec extends Specification { def "Produce empty result on non-existing block"() { setup: def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -140,7 +140,7 @@ class EthereumDirectReaderSpec extends Specification { transactions = [] } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -172,7 +172,7 @@ class EthereumDirectReaderSpec extends Specification { blockHash = BlockHash.from(hash1) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -205,7 +205,7 @@ class EthereumDirectReaderSpec extends Specification { blockHash = BlockHash.from(hash1) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -238,7 +238,7 @@ class EthereumDirectReaderSpec extends Specification { blockHash = BlockHash.from(hash1) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -268,7 +268,7 @@ class EthereumDirectReaderSpec extends Specification { blockHash = BlockHash.from(hash1) } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } def caches = Mock(Caches) { // note that the Caches needs a Height value, otherwise it's not cached @@ -297,7 +297,7 @@ class EthereumDirectReaderSpec extends Specification { def "Produce empty on non-existing tx"() { setup: def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -327,7 +327,7 @@ class EthereumDirectReaderSpec extends Specification { } } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -358,7 +358,7 @@ class EthereumDirectReaderSpec extends Specification { } } def calls = Mock(Factory) { - 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() @@ -392,7 +392,7 @@ class EthereumDirectReaderSpec extends Specification { transactions = [] } def calls = Mock(Factory) { - 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } def result = Mono.just( new RequestReader.Result( @@ -432,7 +432,7 @@ class EthereumDirectReaderSpec extends Specification { transactions = [] } def calls = Mock(Factory) { - 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } def result = Mono.just( new RequestReader.Result( @@ -469,7 +469,7 @@ class EthereumDirectReaderSpec extends Specification { } } def calls = Mock(Factory) { - 4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + 4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) } EthereumDirectReader reader = new EthereumDirectReader( up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy index 1c36539c..1e046231 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLocalReaderSpec.groovy @@ -25,17 +25,16 @@ class EthereumLocalReaderSpec extends Specification { def "Calls hardcoded"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader( new EthereumCachingReader( TestingCommons.multistream(TestingCommons.api()), Caches.default(), - ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)), + ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)), TestingCommons.tracerMock() ), methods, new EmptyHead(), - null ) when: def act = router.read(new ChainRequest("eth_coinbase", new ListParams())).block(Duration.ofSeconds(1)) @@ -45,17 +44,16 @@ class EthereumLocalReaderSpec extends Specification { def "Returns empty if nonce set"() { setup: - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) def router = new EthereumLocalReader( new EthereumCachingReader( TestingCommons.multistream(TestingCommons.api()), Caches.default(), - ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)), + ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)), TestingCommons.tracerMock() ), methods, new EmptyHead(), - null ) when: def act = router.read(new ChainRequest("eth_getTransactionByHash", new ListParams(["test"]), 10)) @@ -78,8 +76,8 @@ class EthereumLocalReaderSpec extends Specification { ) } } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) - def router = new EthereumLocalReader(reader, methods, head, null) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) + def router = new EthereumLocalReader(reader, methods, head) when: def act = router.getBlockByNumber(["latest", false], Selector.UpstreamFilter.default) @@ -106,8 +104,8 @@ class EthereumLocalReaderSpec extends Specification { ) } } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) - def router = new EthereumLocalReader(reader, methods, head, null) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) + def router = new EthereumLocalReader(reader, methods, head) when: def act = router.getBlockByNumber(["earliest", false], Selector.UpstreamFilter.default) @@ -134,8 +132,8 @@ class EthereumLocalReaderSpec extends Specification { ) } } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) - def router = new EthereumLocalReader(reader, methods, head, null) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) + def router = new EthereumLocalReader(reader, methods, head) when: def act = router.getBlockByNumber(["0x123ef", false], Selector.UpstreamFilter.default) @@ -160,8 +158,8 @@ class EthereumLocalReaderSpec extends Specification { ) } } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) - def router = new EthereumLocalReader(reader, methods, head, null) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) + def router = new EthereumLocalReader(reader, methods, head) when: def act = router.read( @@ -188,8 +186,8 @@ class EthereumLocalReaderSpec extends Specification { _ * txByHashAsCont(Selector.UpstreamFilter.default) >> new EmptyReader<>() _ * blocksByHeightAsCont(Selector.UpstreamFilter.default) >> new EmptyReader<>() } - def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false) - def router = new EthereumLocalReader(reader, methods, head, null) + def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET) + def router = new EthereumLocalReader(reader, methods, head) when: def act = router.getBlockByNumber(["0x0", true], Selector.UpstreamFilter.default) diff --git a/src/test/kotlin/io/emeraldpay/dshackle/config/reload/ReloadConfigTest.kt b/src/test/kotlin/io/emeraldpay/dshackle/config/reload/ReloadConfigTest.kt index 12c68651..69c6f40a 100644 --- a/src/test/kotlin/io/emeraldpay/dshackle/config/reload/ReloadConfigTest.kt +++ b/src/test/kotlin/io/emeraldpay/dshackle/config/reload/ReloadConfigTest.kt @@ -180,9 +180,6 @@ class ReloadConfigTest { cs.makeCachingReaderBuilder(mock()), cs::localReaderBuilder, cs.subscriptionBuilder(Schedulers.boundedElastic()), - null, - Schedulers.fromExecutor(Executors.newFixedThreadPool(6)), - mock(), ) }