Remove oracle (#620)
This commit is contained in:
@@ -122,16 +122,8 @@ dependencies {
|
|||||||
implementation(variantOf(libs.netty.tcnative.boringssl) { classifier("linux-aarch_64") })
|
implementation(variantOf(libs.netty.tcnative.boringssl) { classifier("linux-aarch_64") })
|
||||||
implementation(variantOf(libs.netty.tcnative.boringssl) { classifier("osx-x86_64") })
|
implementation(variantOf(libs.netty.tcnative.boringssl) { classifier("osx-x86_64") })
|
||||||
implementation 'dshackle:foundation:1.0.0'
|
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 {
|
compileKotlin {
|
||||||
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
|
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import io.emeraldpay.dshackle.config.CacheConfig
|
|||||||
import io.emeraldpay.dshackle.config.ChainsConfig
|
import io.emeraldpay.dshackle.config.ChainsConfig
|
||||||
import io.emeraldpay.dshackle.config.CompressionConfig
|
import io.emeraldpay.dshackle.config.CompressionConfig
|
||||||
import io.emeraldpay.dshackle.config.HealthConfig
|
import io.emeraldpay.dshackle.config.HealthConfig
|
||||||
import io.emeraldpay.dshackle.config.IndexConfig
|
|
||||||
import io.emeraldpay.dshackle.config.MainConfig
|
import io.emeraldpay.dshackle.config.MainConfig
|
||||||
import io.emeraldpay.dshackle.config.MainConfigReader
|
import io.emeraldpay.dshackle.config.MainConfigReader
|
||||||
import io.emeraldpay.dshackle.config.MonitoringConfig
|
import io.emeraldpay.dshackle.config.MonitoringConfig
|
||||||
@@ -131,11 +130,6 @@ open class Config(
|
|||||||
return mainConfig.cache ?: CacheConfig()
|
return mainConfig.cache ?: CacheConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
open fun indexConfig(@Autowired mainConfig: MainConfig): IndexConfig {
|
|
||||||
return mainConfig.index ?: IndexConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
open fun signatureConfig(@Autowired mainConfig: MainConfig): SignatureConfig {
|
open fun signatureConfig(@Autowired mainConfig: MainConfig): SignatureConfig {
|
||||||
return mainConfig.signature ?: SignatureConfig()
|
return mainConfig.signature ?: SignatureConfig()
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package io.emeraldpay.dshackle.config
|
|
||||||
|
|
||||||
import io.emeraldpay.dshackle.Chain
|
|
||||||
|
|
||||||
class IndexConfig {
|
|
||||||
var items: HashMap<Chain, Index> = HashMap<Chain, Index>()
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<IndexConfig>() {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val log = LoggerFactory.getLogger(IndexConfigReader::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(input: MappingNode?): IndexConfig? {
|
|
||||||
return getList<MappingNode>(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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,6 @@ class MainConfig {
|
|||||||
var tls: AuthConfig.ServerTlsAuth? = null
|
var tls: AuthConfig.ServerTlsAuth? = null
|
||||||
var passthrough: Boolean = false
|
var passthrough: Boolean = false
|
||||||
var cache: CacheConfig? = null
|
var cache: CacheConfig? = null
|
||||||
var index: IndexConfig? = null
|
|
||||||
var proxy: ProxyConfig? = null
|
var proxy: ProxyConfig? = null
|
||||||
var upstreams: UpstreamsConfig? = null
|
var upstreams: UpstreamsConfig? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class MainConfigReader(
|
|||||||
private val optionsReader = ChainOptionsReader()
|
private val optionsReader = ChainOptionsReader()
|
||||||
private val upstreamsConfigReader = UpstreamsConfigReader(fileResolver, optionsReader)
|
private val upstreamsConfigReader = UpstreamsConfigReader(fileResolver, optionsReader)
|
||||||
private val cacheConfigReader = CacheConfigReader()
|
private val cacheConfigReader = CacheConfigReader()
|
||||||
private val indexConfigReader = IndexConfigReader()
|
|
||||||
private val tokensConfigReader = TokensConfigReader()
|
private val tokensConfigReader = TokensConfigReader()
|
||||||
private val monitoringConfigReader = MonitoringConfigReader()
|
private val monitoringConfigReader = MonitoringConfigReader()
|
||||||
private val accessLogReader = AccessLogReader()
|
private val accessLogReader = AccessLogReader()
|
||||||
@@ -64,9 +63,6 @@ class MainConfigReader(
|
|||||||
cacheConfigReader.read(input)?.let {
|
cacheConfigReader.read(input)?.let {
|
||||||
config.cache = it
|
config.cache = it
|
||||||
}
|
}
|
||||||
indexConfigReader.read(input)?.let {
|
|
||||||
config.index = it
|
|
||||||
}
|
|
||||||
tokensConfigReader.read(input)?.let {
|
tokensConfigReader.read(input)?.let {
|
||||||
config.tokens = it
|
config.tokens = it
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.emeraldpay.dshackle.config.context
|
|||||||
import io.emeraldpay.dshackle.BlockchainType.BITCOIN
|
import io.emeraldpay.dshackle.BlockchainType.BITCOIN
|
||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.cache.CachesFactory
|
import io.emeraldpay.dshackle.cache.CachesFactory
|
||||||
import io.emeraldpay.dshackle.config.IndexConfig
|
|
||||||
import io.emeraldpay.dshackle.upstream.CallTargetsHolder
|
import io.emeraldpay.dshackle.upstream.CallTargetsHolder
|
||||||
import io.emeraldpay.dshackle.upstream.Multistream
|
import io.emeraldpay.dshackle.upstream.Multistream
|
||||||
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinMultistream
|
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinMultistream
|
||||||
@@ -29,9 +28,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory)
|
|||||||
subScheduler: Scheduler,
|
subScheduler: Scheduler,
|
||||||
tracer: Tracer,
|
tracer: Tracer,
|
||||||
multistreamEventsScheduler: Scheduler,
|
multistreamEventsScheduler: Scheduler,
|
||||||
indexConfig: IndexConfig,
|
|
||||||
@Qualifier("logsOracleScheduler")
|
|
||||||
logsOracleScheduler: Scheduler,
|
|
||||||
): List<Multistream> {
|
): List<Multistream> {
|
||||||
return Chain.entries
|
return Chain.entries
|
||||||
.filterNot { it == Chain.UNSPECIFIED }
|
.filterNot { it == Chain.UNSPECIFIED }
|
||||||
@@ -46,8 +42,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory)
|
|||||||
subScheduler,
|
subScheduler,
|
||||||
tracer,
|
tracer,
|
||||||
multistreamEventsScheduler,
|
multistreamEventsScheduler,
|
||||||
indexConfig.getByChain(chain),
|
|
||||||
logsOracleScheduler,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,8 +54,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory)
|
|||||||
subScheduler: Scheduler,
|
subScheduler: Scheduler,
|
||||||
tracer: Tracer,
|
tracer: Tracer,
|
||||||
multistreamEventsScheduler: Scheduler,
|
multistreamEventsScheduler: Scheduler,
|
||||||
logsOracleConfig: IndexConfig.Index?,
|
|
||||||
logsOracleScheduler: Scheduler,
|
|
||||||
): Multistream {
|
): Multistream {
|
||||||
val name = "multi-$chain"
|
val name = "multi-$chain"
|
||||||
val cs = ChainSpecificRegistry.resolve(chain)
|
val cs = ChainSpecificRegistry.resolve(chain)
|
||||||
@@ -76,9 +68,6 @@ open class MultistreamsConfig(val beanFactory: ConfigurableListableBeanFactory)
|
|||||||
cs.makeCachingReaderBuilder(tracer),
|
cs.makeCachingReaderBuilder(tracer),
|
||||||
cs::localReaderBuilder,
|
cs::localReaderBuilder,
|
||||||
cs.subscriptionBuilder(subScheduler),
|
cs.subscriptionBuilder(subScheduler),
|
||||||
logsOracleConfig,
|
|
||||||
logsOracleScheduler,
|
|
||||||
tracer,
|
|
||||||
).also { register(it, name) }
|
).also { register(it, name) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,11 +46,6 @@ open class SchedulersConfig {
|
|||||||
return makeScheduler("sub-scheduler", 4, monitoringConfig)
|
return makeScheduler("sub-scheduler", 4, monitoringConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
open fun logsOracleScheduler(monitoringConfig: MonitoringConfig): Scheduler {
|
|
||||||
return makeScheduler("logs-oracle", 4, monitoringConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
open fun multistreamEventsScheduler(monitoringConfig: MonitoringConfig): Scheduler {
|
open fun multistreamEventsScheduler(monitoringConfig: MonitoringConfig): Scheduler {
|
||||||
return makeScheduler("events-scheduler", 4, monitoringConfig)
|
return makeScheduler("events-scheduler", 4, monitoringConfig)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.emeraldpay.dshackle.startup.configure
|
|||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.FileResolver
|
import io.emeraldpay.dshackle.FileResolver
|
||||||
import io.emeraldpay.dshackle.config.ChainsConfig
|
import io.emeraldpay.dshackle.config.ChainsConfig
|
||||||
import io.emeraldpay.dshackle.config.IndexConfig
|
|
||||||
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
||||||
import io.emeraldpay.dshackle.foundation.ChainOptions
|
import io.emeraldpay.dshackle.foundation.ChainOptions
|
||||||
import io.emeraldpay.dshackle.startup.QuorumForLabels
|
import io.emeraldpay.dshackle.startup.QuorumForLabels
|
||||||
@@ -24,12 +23,11 @@ import java.util.concurrent.atomic.AtomicInteger
|
|||||||
@Component
|
@Component
|
||||||
class BitcoinUpstreamCreator(
|
class BitcoinUpstreamCreator(
|
||||||
chainsConfig: ChainsConfig,
|
chainsConfig: ChainsConfig,
|
||||||
indexConfig: IndexConfig,
|
|
||||||
callTargets: CallTargetsHolder,
|
callTargets: CallTargetsHolder,
|
||||||
private val genericConnectorFactoryCreator: ConnectorFactoryCreator,
|
private val genericConnectorFactoryCreator: ConnectorFactoryCreator,
|
||||||
private val fileResolver: FileResolver,
|
private val fileResolver: FileResolver,
|
||||||
private val headScheduler: Scheduler,
|
private val headScheduler: Scheduler,
|
||||||
) : UpstreamCreator(chainsConfig, indexConfig, callTargets) {
|
) : UpstreamCreator(chainsConfig, callTargets) {
|
||||||
private var seq = AtomicInteger(0)
|
private var seq = AtomicInteger(0)
|
||||||
|
|
||||||
override fun createUpstream(
|
override fun createUpstream(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package io.emeraldpay.dshackle.startup.configure
|
|||||||
|
|
||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.config.ChainsConfig
|
import io.emeraldpay.dshackle.config.ChainsConfig
|
||||||
import io.emeraldpay.dshackle.config.IndexConfig
|
|
||||||
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
||||||
import io.emeraldpay.dshackle.config.hot.CompatibleVersionsRules
|
import io.emeraldpay.dshackle.config.hot.CompatibleVersionsRules
|
||||||
import io.emeraldpay.dshackle.foundation.ChainOptions
|
import io.emeraldpay.dshackle.foundation.ChainOptions
|
||||||
@@ -13,11 +12,10 @@ import java.util.function.Supplier
|
|||||||
@Component
|
@Component
|
||||||
class EthereumUpstreamCreator(
|
class EthereumUpstreamCreator(
|
||||||
chainsConfig: ChainsConfig,
|
chainsConfig: ChainsConfig,
|
||||||
indexConfig: IndexConfig,
|
|
||||||
callTargets: CallTargetsHolder,
|
callTargets: CallTargetsHolder,
|
||||||
connectorFactoryCreatorResolver: ConnectorFactoryCreatorResolver,
|
connectorFactoryCreatorResolver: ConnectorFactoryCreatorResolver,
|
||||||
versionRules: Supplier<CompatibleVersionsRules?>,
|
versionRules: Supplier<CompatibleVersionsRules?>,
|
||||||
) : GenericUpstreamCreator(chainsConfig, indexConfig, callTargets, connectorFactoryCreatorResolver, versionRules) {
|
) : GenericUpstreamCreator(chainsConfig, callTargets, connectorFactoryCreatorResolver, versionRules) {
|
||||||
|
|
||||||
override fun createUpstream(
|
override fun createUpstream(
|
||||||
upstreamsConfig: UpstreamsConfig.Upstream<*>,
|
upstreamsConfig: UpstreamsConfig.Upstream<*>,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package io.emeraldpay.dshackle.startup.configure
|
|||||||
|
|
||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.config.ChainsConfig
|
import io.emeraldpay.dshackle.config.ChainsConfig
|
||||||
import io.emeraldpay.dshackle.config.IndexConfig
|
|
||||||
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
||||||
import io.emeraldpay.dshackle.config.hot.CompatibleVersionsRules
|
import io.emeraldpay.dshackle.config.hot.CompatibleVersionsRules
|
||||||
import io.emeraldpay.dshackle.foundation.ChainOptions
|
import io.emeraldpay.dshackle.foundation.ChainOptions
|
||||||
@@ -19,11 +18,10 @@ import java.util.function.Supplier
|
|||||||
@Component
|
@Component
|
||||||
open class GenericUpstreamCreator(
|
open class GenericUpstreamCreator(
|
||||||
chainsConfig: ChainsConfig,
|
chainsConfig: ChainsConfig,
|
||||||
indexConfig: IndexConfig,
|
|
||||||
callTargets: CallTargetsHolder,
|
callTargets: CallTargetsHolder,
|
||||||
private val connectorFactoryCreatorResolver: ConnectorFactoryCreatorResolver,
|
private val connectorFactoryCreatorResolver: ConnectorFactoryCreatorResolver,
|
||||||
private val versionRules: Supplier<CompatibleVersionsRules?>,
|
private val versionRules: Supplier<CompatibleVersionsRules?>,
|
||||||
) : UpstreamCreator(chainsConfig, indexConfig, callTargets) {
|
) : UpstreamCreator(chainsConfig, callTargets) {
|
||||||
private val hashes = HashSet<Short>()
|
private val hashes = HashSet<Short>()
|
||||||
|
|
||||||
override fun createUpstream(
|
override fun createUpstream(
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.emeraldpay.dshackle.startup.configure
|
|||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.Global
|
import io.emeraldpay.dshackle.Global
|
||||||
import io.emeraldpay.dshackle.config.ChainsConfig
|
import io.emeraldpay.dshackle.config.ChainsConfig
|
||||||
import io.emeraldpay.dshackle.config.IndexConfig
|
|
||||||
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
||||||
import io.emeraldpay.dshackle.foundation.ChainOptions
|
import io.emeraldpay.dshackle.foundation.ChainOptions
|
||||||
import io.emeraldpay.dshackle.foundation.ChainOptions.Options
|
import io.emeraldpay.dshackle.foundation.ChainOptions.Options
|
||||||
@@ -17,7 +16,6 @@ import kotlin.math.abs
|
|||||||
|
|
||||||
abstract class UpstreamCreator(
|
abstract class UpstreamCreator(
|
||||||
private val chainsConfig: ChainsConfig,
|
private val chainsConfig: ChainsConfig,
|
||||||
private val indexConfig: IndexConfig,
|
|
||||||
private val callTargets: CallTargetsHolder,
|
private val callTargets: CallTargetsHolder,
|
||||||
) {
|
) {
|
||||||
protected val log: Logger = LoggerFactory.getLogger(this::class.java)
|
protected val log: Logger = LoggerFactory.getLogger(this::class.java)
|
||||||
@@ -83,7 +81,7 @@ abstract class UpstreamCreator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ManagedCallMethods(
|
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(),
|
enabled = config.methods?.enabled?.map { it.name }?.toSet() ?: emptySet(),
|
||||||
disabled = config.methods?.disabled?.map { it.name }?.toSet() ?: emptySet(),
|
disabled = config.methods?.disabled?.map { it.name }?.toSet() ?: emptySet(),
|
||||||
groupsEnabled = config.methodGroups?.enabled ?: emptySet(),
|
groupsEnabled = config.methodGroups?.enabled ?: emptySet(),
|
||||||
@@ -99,7 +97,7 @@ abstract class UpstreamCreator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callTargets.getDefaultMethods(chain, indexConfig.isChainEnabled(chain), options, config.connection)
|
callTargets.getDefaultMethods(chain, options, config.connection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,22 +29,20 @@ class CallTargetsHolder {
|
|||||||
|
|
||||||
fun getDefaultMethods(
|
fun getDefaultMethods(
|
||||||
chain: Chain,
|
chain: Chain,
|
||||||
hasLogsOracle: Boolean,
|
|
||||||
options: ChainOptions.Options,
|
options: ChainOptions.Options,
|
||||||
connection: UpstreamsConfig.UpstreamConnection?,
|
connection: UpstreamsConfig.UpstreamConnection?,
|
||||||
): CallMethods {
|
): CallMethods {
|
||||||
return callTargets[chain] ?: return setupDefaultMethods(chain, hasLogsOracle, options, connection)
|
return callTargets[chain] ?: return setupDefaultMethods(chain, options, connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDefaultMethods(
|
private fun setupDefaultMethods(
|
||||||
chain: Chain,
|
chain: Chain,
|
||||||
hasLogsOracle: Boolean,
|
|
||||||
options: ChainOptions.Options,
|
options: ChainOptions.Options,
|
||||||
connection: UpstreamsConfig.UpstreamConnection?,
|
connection: UpstreamsConfig.UpstreamConnection?,
|
||||||
): CallMethods {
|
): CallMethods {
|
||||||
val created = when (chain.type) {
|
val created = when (chain.type) {
|
||||||
BITCOIN -> DefaultBitcoinMethods(options.providesBalance == true)
|
BITCOIN -> DefaultBitcoinMethods(options.providesBalance == true)
|
||||||
ETHEREUM -> DefaultEthereumMethods(chain, hasLogsOracle)
|
ETHEREUM -> DefaultEthereumMethods(chain)
|
||||||
STARKNET -> DefaultStarknetMethods(chain)
|
STARKNET -> DefaultStarknetMethods(chain)
|
||||||
POLKADOT -> DefaultPolkadotMethods(chain)
|
POLKADOT -> DefaultPolkadotMethods(chain)
|
||||||
SOLANA -> DefaultSolanaMethods()
|
SOLANA -> DefaultSolanaMethods()
|
||||||
|
|||||||
@@ -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<String>,
|
|
||||||
topics: List<List<String>>,
|
|
||||||
): Mono<String> {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -31,7 +31,6 @@ import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
|||||||
*/
|
*/
|
||||||
class DefaultEthereumMethods(
|
class DefaultEthereumMethods(
|
||||||
private val chain: Chain,
|
private val chain: Chain,
|
||||||
private val hasLogsOracle: Boolean = false,
|
|
||||||
) : CallMethods {
|
) : CallMethods {
|
||||||
|
|
||||||
private val version = "\"EmeraldDshackle/${Global.version}\""
|
private val version = "\"EmeraldDshackle/${Global.version}\""
|
||||||
@@ -613,7 +612,6 @@ class DefaultEthereumMethods(
|
|||||||
specialMethods +
|
specialMethods +
|
||||||
headVerifiedMethods -
|
headVerifiedMethods -
|
||||||
chainUnsupportedMethods(chain) +
|
chainUnsupportedMethods(chain) +
|
||||||
getDrpcVendorMethods(chain) +
|
|
||||||
getChainSpecificMethods(chain)
|
getChainSpecificMethods(chain)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -632,15 +630,6 @@ class DefaultEthereumMethods(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDrpcVendorMethods(chain: Chain): List<String> {
|
|
||||||
val supported = mutableListOf<String>()
|
|
||||||
|
|
||||||
// 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<String> {
|
private fun getChainSpecificMethods(chain: Chain): List<String> {
|
||||||
return when (chain) {
|
return when (chain) {
|
||||||
Chain.OPTIMISM__MAINNET, Chain.OPTIMISM__SEPOLIA ->
|
Chain.OPTIMISM__MAINNET, Chain.OPTIMISM__SEPOLIA ->
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import io.emeraldpay.dshackle.upstream.EgressSubscription
|
|||||||
import io.emeraldpay.dshackle.upstream.GenericSingleCallValidator
|
import io.emeraldpay.dshackle.upstream.GenericSingleCallValidator
|
||||||
import io.emeraldpay.dshackle.upstream.Head
|
import io.emeraldpay.dshackle.upstream.Head
|
||||||
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.LogsOracle
|
|
||||||
import io.emeraldpay.dshackle.upstream.Multistream
|
import io.emeraldpay.dshackle.upstream.Multistream
|
||||||
import io.emeraldpay.dshackle.upstream.SingleValidator
|
import io.emeraldpay.dshackle.upstream.SingleValidator
|
||||||
import io.emeraldpay.dshackle.upstream.Upstream
|
import io.emeraldpay.dshackle.upstream.Upstream
|
||||||
@@ -65,9 +64,8 @@ object EthereumChainSpecific : AbstractPollChainSpecific() {
|
|||||||
cachingReader: CachingReader,
|
cachingReader: CachingReader,
|
||||||
methods: CallMethods,
|
methods: CallMethods,
|
||||||
head: Head,
|
head: Head,
|
||||||
logsOracle: LogsOracle?,
|
|
||||||
): Mono<ChainReader> {
|
): Mono<ChainReader> {
|
||||||
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 {
|
override fun subscriptionBuilder(headScheduler: Scheduler): (Multistream) -> EgressSubscription {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import io.emeraldpay.dshackle.reader.ChainReader
|
|||||||
import io.emeraldpay.dshackle.upstream.ChainRequest
|
import io.emeraldpay.dshackle.upstream.ChainRequest
|
||||||
import io.emeraldpay.dshackle.upstream.ChainResponse
|
import io.emeraldpay.dshackle.upstream.ChainResponse
|
||||||
import io.emeraldpay.dshackle.upstream.Head
|
import io.emeraldpay.dshackle.upstream.Head
|
||||||
import io.emeraldpay.dshackle.upstream.LogsOracle
|
|
||||||
import io.emeraldpay.dshackle.upstream.Selector
|
import io.emeraldpay.dshackle.upstream.Selector
|
||||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
||||||
@@ -46,7 +45,6 @@ class EthereumLocalReader(
|
|||||||
private val reader: EthereumCachingReader,
|
private val reader: EthereumCachingReader,
|
||||||
private val methods: CallMethods,
|
private val methods: CallMethods,
|
||||||
private val head: Head,
|
private val head: Head,
|
||||||
private val logsOracle: LogsOracle?,
|
|
||||||
) : ChainReader {
|
) : ChainReader {
|
||||||
|
|
||||||
override fun read(key: ChainRequest): Mono<ChainResponse> {
|
override fun read(key: ChainRequest): Mono<ChainResponse> {
|
||||||
@@ -132,10 +130,6 @@ class EthereumLocalReader(
|
|||||||
.map { ChainResponse(it.data, null, it.resolvedUpstreamData) }
|
.map { ChainResponse(it.data, null, it.resolvedUpstreamData) }
|
||||||
}
|
}
|
||||||
|
|
||||||
method == "drpc_getLogsEstimate" -> {
|
|
||||||
getLogsEstimate(params.list)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,82 +187,4 @@ class EthereumLocalReader(
|
|||||||
return reader.blocksByHeightAsCont(upstreamFilter)
|
return reader.blocksByHeightAsCont(upstreamFilter)
|
||||||
.read(number).map { ChainResponse(it.data.json, null, it.resolvedUpstreamData) }
|
.read(number).map { ChainResponse(it.data.json, null, it.resolvedUpstreamData) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLogsEstimate(params: List<Any?>): Mono<ChainResponse>? {
|
|
||||||
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<String, Any?>
|
|
||||||
|
|
||||||
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<String> = try {
|
|
||||||
val it = req.get("address") ?: listOf<String>()
|
|
||||||
|
|
||||||
if (it is String) {
|
|
||||||
listOf<String>(it)
|
|
||||||
} else {
|
|
||||||
it as List<String>
|
|
||||||
}
|
|
||||||
} catch (_: Exception) {
|
|
||||||
throw RpcException(RpcResponseError.CODE_INVALID_METHOD_PARAMS, "Invalid 'address' parameter")
|
|
||||||
}
|
|
||||||
val topics: List<List<String>> = try {
|
|
||||||
val tpcs = req.get("topics")?.let { it as List<Any?> } ?: listOf<Any?>()
|
|
||||||
if (tpcs.size > 4) {
|
|
||||||
throw IllegalArgumentException()
|
|
||||||
}
|
|
||||||
|
|
||||||
tpcs.map {
|
|
||||||
if (it == null) {
|
|
||||||
emptyList<String>()
|
|
||||||
} else if (it is String) {
|
|
||||||
listOf<String>(it)
|
|
||||||
} else {
|
|
||||||
it as List<String>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} 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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import io.emeraldpay.dshackle.upstream.EgressSubscription
|
|||||||
import io.emeraldpay.dshackle.upstream.EmptyEgressSubscription
|
import io.emeraldpay.dshackle.upstream.EmptyEgressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.Head
|
import io.emeraldpay.dshackle.upstream.Head
|
||||||
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.LogsOracle
|
|
||||||
import io.emeraldpay.dshackle.upstream.Multistream
|
import io.emeraldpay.dshackle.upstream.Multistream
|
||||||
import io.emeraldpay.dshackle.upstream.NoIngressSubscription
|
import io.emeraldpay.dshackle.upstream.NoIngressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.NoopCachingReader
|
import io.emeraldpay.dshackle.upstream.NoopCachingReader
|
||||||
@@ -41,7 +40,6 @@ abstract class AbstractChainSpecific : ChainSpecific {
|
|||||||
cachingReader: CachingReader,
|
cachingReader: CachingReader,
|
||||||
methods: CallMethods,
|
methods: CallMethods,
|
||||||
head: Head,
|
head: Head,
|
||||||
logsOracle: LogsOracle?,
|
|
||||||
): Mono<ChainReader> {
|
): Mono<ChainReader> {
|
||||||
return Mono.just(LocalReader(methods))
|
return Mono.just(LocalReader(methods))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import io.emeraldpay.dshackle.upstream.ChainRequest
|
|||||||
import io.emeraldpay.dshackle.upstream.EgressSubscription
|
import io.emeraldpay.dshackle.upstream.EgressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.Head
|
import io.emeraldpay.dshackle.upstream.Head
|
||||||
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.LogsOracle
|
|
||||||
import io.emeraldpay.dshackle.upstream.Multistream
|
import io.emeraldpay.dshackle.upstream.Multistream
|
||||||
import io.emeraldpay.dshackle.upstream.SingleValidator
|
import io.emeraldpay.dshackle.upstream.SingleValidator
|
||||||
import io.emeraldpay.dshackle.upstream.Upstream
|
import io.emeraldpay.dshackle.upstream.Upstream
|
||||||
@@ -51,7 +50,7 @@ import reactor.core.scheduler.Scheduler
|
|||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
|
||||||
typealias SubscriptionBuilder = (Multistream) -> EgressSubscription
|
typealias SubscriptionBuilder = (Multistream) -> EgressSubscription
|
||||||
typealias LocalReaderBuilder = (CachingReader, CallMethods, Head, LogsOracle?) -> Mono<ChainReader>
|
typealias LocalReaderBuilder = (CachingReader, CallMethods, Head) -> Mono<ChainReader>
|
||||||
typealias CachingReaderBuilder = (Multistream, Caches, Factory<CallMethods>) -> CachingReader
|
typealias CachingReaderBuilder = (Multistream, Caches, Factory<CallMethods>) -> CachingReader
|
||||||
typealias FinalizationDetectorBuilder = () -> FinalizationDetector
|
typealias FinalizationDetectorBuilder = () -> FinalizationDetector
|
||||||
|
|
||||||
@@ -70,7 +69,6 @@ interface ChainSpecific {
|
|||||||
cachingReader: CachingReader,
|
cachingReader: CachingReader,
|
||||||
methods: CallMethods,
|
methods: CallMethods,
|
||||||
head: Head,
|
head: Head,
|
||||||
logsOracle: LogsOracle?,
|
|
||||||
): Mono<ChainReader>
|
): Mono<ChainReader>
|
||||||
|
|
||||||
fun subscriptionBuilder(headScheduler: Scheduler): (Multistream) -> EgressSubscription
|
fun subscriptionBuilder(headScheduler: Scheduler): (Multistream) -> EgressSubscription
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package io.emeraldpay.dshackle.upstream.generic
|
|||||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.cache.Caches
|
import io.emeraldpay.dshackle.cache.Caches
|
||||||
import io.emeraldpay.dshackle.config.IndexConfig
|
|
||||||
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
||||||
import io.emeraldpay.dshackle.reader.ChainReader
|
import io.emeraldpay.dshackle.reader.ChainReader
|
||||||
import io.emeraldpay.dshackle.upstream.CachingReader
|
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.Head
|
||||||
import io.emeraldpay.dshackle.upstream.HeadLagObserver
|
import io.emeraldpay.dshackle.upstream.HeadLagObserver
|
||||||
import io.emeraldpay.dshackle.upstream.Lifecycle
|
import io.emeraldpay.dshackle.upstream.Lifecycle
|
||||||
import io.emeraldpay.dshackle.upstream.LogsOracle
|
|
||||||
import io.emeraldpay.dshackle.upstream.MergedHead
|
import io.emeraldpay.dshackle.upstream.MergedHead
|
||||||
import io.emeraldpay.dshackle.upstream.Multistream
|
import io.emeraldpay.dshackle.upstream.Multistream
|
||||||
import io.emeraldpay.dshackle.upstream.Selector
|
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.calls.CallSelector
|
||||||
import io.emeraldpay.dshackle.upstream.forkchoice.PriorityForkChoice
|
import io.emeraldpay.dshackle.upstream.forkchoice.PriorityForkChoice
|
||||||
import io.emeraldpay.dshackle.upstream.grpc.GrpcUpstream
|
import io.emeraldpay.dshackle.upstream.grpc.GrpcUpstream
|
||||||
import org.springframework.cloud.sleuth.Tracer
|
|
||||||
import org.springframework.util.ConcurrentReferenceHashMap
|
import org.springframework.util.ConcurrentReferenceHashMap
|
||||||
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType.WEAK
|
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType.WEAK
|
||||||
import reactor.core.publisher.Flux
|
import reactor.core.publisher.Flux
|
||||||
@@ -56,9 +53,6 @@ open class GenericMultistream(
|
|||||||
cachingReaderBuilder: CachingReaderBuilder,
|
cachingReaderBuilder: CachingReaderBuilder,
|
||||||
private val localReaderBuilder: LocalReaderBuilder,
|
private val localReaderBuilder: LocalReaderBuilder,
|
||||||
private val subscriptionBuilder: SubscriptionBuilder,
|
private val subscriptionBuilder: SubscriptionBuilder,
|
||||||
logsOracleConfig: IndexConfig.Index? = null,
|
|
||||||
private val logsOracleScheduler: Scheduler,
|
|
||||||
private val tracer: Tracer,
|
|
||||||
) : Multistream(chain, caches, callSelector, multistreamEventsScheduler) {
|
) : Multistream(chain, caches, callSelector, multistreamEventsScheduler) {
|
||||||
|
|
||||||
private val cachingReader = cachingReaderBuilder(this, caches, getMethodsFactory())
|
private val cachingReader = cachingReaderBuilder(this, caches, getMethodsFactory())
|
||||||
@@ -77,10 +71,6 @@ open class GenericMultistream(
|
|||||||
headScheduler,
|
headScheduler,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val logsOracle: LogsOracle? = logsOracleConfig?.let {
|
|
||||||
LogsOracle(logsOracleConfig, this, logsOracleScheduler, tracer)
|
|
||||||
}
|
|
||||||
|
|
||||||
private var subscription: EgressSubscription = subscriptionBuilder(this)
|
private var subscription: EgressSubscription = subscriptionBuilder(this)
|
||||||
|
|
||||||
private val filteredHeads: MutableMap<String, Head> =
|
private val filteredHeads: MutableMap<String, Head> =
|
||||||
@@ -91,14 +81,12 @@ open class GenericMultistream(
|
|||||||
head.start()
|
head.start()
|
||||||
onHeadUpdated(head)
|
onHeadUpdated(head)
|
||||||
cachingReader.start()
|
cachingReader.start()
|
||||||
logsOracle?.start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun stop() {
|
override fun stop() {
|
||||||
super.stop()
|
super.stop()
|
||||||
cachingReader.stop()
|
cachingReader.stop()
|
||||||
filteredHeads.clear()
|
filteredHeads.clear()
|
||||||
logsOracle?.stop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addHead(upstream: Upstream) {
|
override fun addHead(upstream: Upstream) {
|
||||||
@@ -167,7 +155,7 @@ open class GenericMultistream(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getLocalReader(): Mono<ChainReader> {
|
override fun getLocalReader(): Mono<ChainReader> {
|
||||||
return localReaderBuilder(cachingReader, getMethods(), getHead(), logsOracle)
|
return localReaderBuilder(cachingReader, getMethods(), getHead())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getEgressSubscription(): EgressSubscription {
|
override fun getEgressSubscription(): EgressSubscription {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import io.emeraldpay.dshackle.upstream.EgressSubscription
|
|||||||
import io.emeraldpay.dshackle.upstream.GenericSingleCallValidator
|
import io.emeraldpay.dshackle.upstream.GenericSingleCallValidator
|
||||||
import io.emeraldpay.dshackle.upstream.Head
|
import io.emeraldpay.dshackle.upstream.Head
|
||||||
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
import io.emeraldpay.dshackle.upstream.IngressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.LogsOracle
|
|
||||||
import io.emeraldpay.dshackle.upstream.Multistream
|
import io.emeraldpay.dshackle.upstream.Multistream
|
||||||
import io.emeraldpay.dshackle.upstream.SingleValidator
|
import io.emeraldpay.dshackle.upstream.SingleValidator
|
||||||
import io.emeraldpay.dshackle.upstream.Upstream
|
import io.emeraldpay.dshackle.upstream.Upstream
|
||||||
@@ -80,7 +79,6 @@ object PolkadotChainSpecific : AbstractPollChainSpecific() {
|
|||||||
cachingReader: CachingReader,
|
cachingReader: CachingReader,
|
||||||
methods: CallMethods,
|
methods: CallMethods,
|
||||||
head: Head,
|
head: Head,
|
||||||
logsOracle: LogsOracle?,
|
|
||||||
): Mono<ChainReader> {
|
): Mono<ChainReader> {
|
||||||
return Mono.just(LocalReader(methods))
|
return Mono.just(LocalReader(methods))
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -392,7 +392,7 @@ class NativeCallSpec extends Specification {
|
|||||||
def "Prepare call adds height selector for not-lagging quorum"() {
|
def "Prepare call adds height selector for not-lagging quorum"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new ManagedCallMethods(
|
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
|
["foo_bar"] as Set, [] as Set, [] as Set, [] as Set
|
||||||
)
|
)
|
||||||
methods.setQuorum("foo_bar", "not_lagging")
|
methods.setQuorum("foo_bar", "not_lagging")
|
||||||
@@ -434,7 +434,7 @@ class NativeCallSpec extends Specification {
|
|||||||
def "Prepare call adds decorator for eth_newFilter"() {
|
def "Prepare call adds decorator for eth_newFilter"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new ManagedCallMethods(
|
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
|
["eth_newFilter"] as Set, [] as Set, [] as Set, [] as Set
|
||||||
)
|
)
|
||||||
methods.setQuorum("eth_newFilter", "always")
|
methods.setQuorum("eth_newFilter", "always")
|
||||||
@@ -466,7 +466,7 @@ class NativeCallSpec extends Specification {
|
|||||||
def "Prepare call adds decorator for eth_getFilterChanges"() {
|
def "Prepare call adds decorator for eth_getFilterChanges"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new ManagedCallMethods(
|
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
|
["eth_getFilterChanges"] as Set, [] as Set, [] as Set, [] as Set
|
||||||
)
|
)
|
||||||
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream())
|
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"() {
|
def "Prepare call adds decorator for eth_uninstallFilter"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new ManagedCallMethods(
|
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
|
["eth_uninstallFilter"] as Set, [] as Set, [] as Set, [] as Set
|
||||||
)
|
)
|
||||||
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream())
|
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, TestingCommons.upstream())
|
||||||
@@ -595,7 +595,7 @@ class NativeCallSpec extends Specification {
|
|||||||
setup:
|
setup:
|
||||||
def quorum = new AlwaysQuorum()
|
def quorum = new AlwaysQuorum()
|
||||||
def methods = new ManagedCallMethods(
|
def methods = new ManagedCallMethods(
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
[] as Set, [] as Set, ["filter"] as Set, [] as Set
|
[] as Set, [] as Set, ["filter"] as Set, [] as Set
|
||||||
)
|
)
|
||||||
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, new ArrayList<GenericUpstream>())
|
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, new ArrayList<GenericUpstream>())
|
||||||
@@ -628,7 +628,7 @@ class NativeCallSpec extends Specification {
|
|||||||
setup:
|
setup:
|
||||||
def quorum = new AlwaysQuorum()
|
def quorum = new AlwaysQuorum()
|
||||||
def methods = new ManagedCallMethods(
|
def methods = new ManagedCallMethods(
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
[] as Set, [] as Set, ["filter"] as Set, [] as Set
|
[] as Set, [] as Set, ["filter"] as Set, [] as Set
|
||||||
)
|
)
|
||||||
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, new ArrayList<GenericUpstream>())
|
def multistream = new MultistreamHolderMock.EthereumMultistreamMock(Chain.ETHEREUM__MAINNET, new ArrayList<GenericUpstream>())
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class GenericUpstreamMock extends GenericUpstream {
|
|||||||
|
|
||||||
static CallMethods allMethods() {
|
static CallMethods allMethods() {
|
||||||
new AggregatedCallMethods([
|
new AggregatedCallMethods([
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
new DefaultBitcoinMethods(true),
|
new DefaultBitcoinMethods(true),
|
||||||
new DirectCallMethods(["eth_test"])
|
new DirectCallMethods(["eth_test"])
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ class MultistreamHolderMock implements MultistreamHolder {
|
|||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
io.emeraldpay.dshackle.upstream.starknet.StarknetChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
io.emeraldpay.dshackle.upstream.starknet.StarknetChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
||||||
null, Schedulers.immediate(),
|
|
||||||
TestingCommons.tracerMock()
|
|
||||||
)
|
)
|
||||||
upstreams[chain].addUpstream(up)
|
upstreams[chain].addUpstream(up)
|
||||||
} else {
|
} else {
|
||||||
@@ -106,8 +104,8 @@ class MultistreamHolderMock implements MultistreamHolder {
|
|||||||
super(chain, Schedulers.immediate(), null, upstreams, caches, Schedulers.boundedElastic(),
|
super(chain, Schedulers.immediate(), null, upstreams, caches, Schedulers.boundedElastic(),
|
||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(new BraveTracer(null, null, null)),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(new BraveTracer(null, null, null)),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(),
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
||||||
new BraveTracer(null, null, null))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EthereumMultistreamMock(@NotNull Chain chain, @NotNull List<GenericUpstream> upstreams) {
|
EthereumMultistreamMock(@NotNull Chain chain, @NotNull List<GenericUpstream> upstreams) {
|
||||||
|
|||||||
@@ -102,9 +102,6 @@ class TestingCommons {
|
|||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
||||||
null,
|
|
||||||
Schedulers.immediate(),
|
|
||||||
tracerMock()
|
|
||||||
).tap {
|
).tap {
|
||||||
it.processUpstreamsEvents(
|
it.processUpstreamsEvents(
|
||||||
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up, UpstreamChangeEvent.ChangeType.ADDED)
|
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up, UpstreamChangeEvent.ChangeType.ADDED)
|
||||||
@@ -132,9 +129,7 @@ class TestingCommons {
|
|||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
||||||
null,
|
)
|
||||||
Schedulers.immediate(),
|
|
||||||
tracerMock())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Multistream multistreamClassicWithoutUpstreams(Chain chain) {
|
static Multistream multistreamClassicWithoutUpstreams(Chain chain) {
|
||||||
@@ -142,9 +137,7 @@ class TestingCommons {
|
|||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()),
|
||||||
null,
|
)
|
||||||
Schedulers.immediate(),
|
|
||||||
tracerMock())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FileResolver fileResolver() {
|
static FileResolver fileResolver() {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import static java.util.List.of
|
|||||||
|
|
||||||
class FilteredApisSpec extends Specification {
|
class FilteredApisSpec extends Specification {
|
||||||
|
|
||||||
def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def ethereumTargets = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
|
|
||||||
def "Verifies labels"() {
|
def "Verifies labels"() {
|
||||||
setup:
|
setup:
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class MultistreamSpec extends Specification {
|
|||||||
Schedulers.boundedElastic(),
|
Schedulers.boundedElastic(),
|
||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock())
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()))
|
||||||
when:
|
when:
|
||||||
aggr.onUpstreamsUpdated()
|
aggr.onUpstreamsUpdated()
|
||||||
def act = aggr.getMethods()
|
def act = aggr.getMethods()
|
||||||
@@ -192,7 +192,7 @@ class MultistreamSpec extends Specification {
|
|||||||
Schedulers.boundedElastic(),
|
Schedulers.boundedElastic(),
|
||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock())
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()))
|
||||||
|
|
||||||
expect:
|
expect:
|
||||||
multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).is(up1.ethereumHeadMock)
|
multistream.getHead(new Selector.LabelMatcher("provider", ["internal"])).is(up1.ethereumHeadMock)
|
||||||
@@ -265,7 +265,7 @@ class MultistreamSpec extends Specification {
|
|||||||
Schedulers.boundedElastic(),
|
Schedulers.boundedElastic(),
|
||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock())
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()))
|
||||||
when:
|
when:
|
||||||
ms.processUpstreamsEvents(
|
ms.processUpstreamsEvents(
|
||||||
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)
|
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)
|
||||||
@@ -296,7 +296,7 @@ class MultistreamSpec extends Specification {
|
|||||||
Schedulers.boundedElastic(),
|
Schedulers.boundedElastic(),
|
||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock())
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()))
|
||||||
def head1 = createBlock(250, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448401b")
|
def head1 = createBlock(250, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448401b")
|
||||||
def head2 = createBlock(270, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448402b")
|
def head2 = createBlock(270, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448402b")
|
||||||
def head3 = createBlock(100, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448412b")
|
def head3 = createBlock(100, "0x0d050c785de17179f935b9b93aca09c442964cc59972c71ae68e74731448412b")
|
||||||
@@ -331,7 +331,7 @@ class MultistreamSpec extends Specification {
|
|||||||
Schedulers.boundedElastic(),
|
Schedulers.boundedElastic(),
|
||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock())
|
EthereumChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()))
|
||||||
multistream.processUpstreamsEvents(
|
multistream.processUpstreamsEvents(
|
||||||
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)
|
new UpstreamChangeEvent(Chain.ETHEREUM__MAINNET, up1, UpstreamChangeEvent.ChangeType.ADDED)
|
||||||
)
|
)
|
||||||
@@ -369,7 +369,7 @@ class MultistreamSpec extends Specification {
|
|||||||
Schedulers.boundedElastic(),
|
Schedulers.boundedElastic(),
|
||||||
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
EthereumChainSpecific.INSTANCE.makeCachingReaderBuilder(TestingCommons.tracerMock()),
|
||||||
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
EthereumChainSpecific.INSTANCE.&localReaderBuilder,
|
||||||
StarknetChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()), null, Schedulers.immediate(), TestingCommons.tracerMock())
|
StarknetChainSpecific.INSTANCE.subscriptionBuilder(Schedulers.boundedElastic()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "eth_chainId is available"() {
|
def "eth_chainId is available"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
when:
|
when:
|
||||||
def act = methods.isAvailable("eth_chainId")
|
def act = methods.isAvailable("eth_chainId")
|
||||||
then:
|
then:
|
||||||
@@ -16,7 +16,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "eth_chainId is hardcoded"() {
|
def "eth_chainId is hardcoded"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
when:
|
when:
|
||||||
def act = methods.isHardcoded("eth_chainId")
|
def act = methods.isHardcoded("eth_chainId")
|
||||||
then:
|
then:
|
||||||
@@ -25,7 +25,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "eth_chainId is not callable"() {
|
def "eth_chainId is not callable"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
when:
|
when:
|
||||||
def act = methods.isCallable("eth_chainId")
|
def act = methods.isCallable("eth_chainId")
|
||||||
then:
|
then:
|
||||||
@@ -34,7 +34,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "Provides hardcoded correct chainId"() {
|
def "Provides hardcoded correct chainId"() {
|
||||||
expect:
|
expect:
|
||||||
new String(new DefaultEthereumMethods(chain, false).executeHardcoded("eth_chainId")) == id
|
new String(new DefaultEthereumMethods(chain).executeHardcoded("eth_chainId")) == id
|
||||||
where:
|
where:
|
||||||
chain | id
|
chain | id
|
||||||
Chain.ETHEREUM__MAINNET | '"0x1"'
|
Chain.ETHEREUM__MAINNET | '"0x1"'
|
||||||
@@ -43,7 +43,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "Optimism chain unsupported methods"() {
|
def "Optimism chain unsupported methods"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.OPTIMISM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.OPTIMISM__MAINNET)
|
||||||
when:
|
when:
|
||||||
def acc = methods.isAvailable("eth_getAccounts")
|
def acc = methods.isAvailable("eth_getAccounts")
|
||||||
def trans = methods.isAvailable("eth_sendTransaction")
|
def trans = methods.isAvailable("eth_sendTransaction")
|
||||||
@@ -54,7 +54,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "Has supported specific methods"() {
|
def "Has supported specific methods"() {
|
||||||
expect:
|
expect:
|
||||||
new DefaultEthereumMethods(chain, false).getSupportedMethods().containsAll(methods)
|
new DefaultEthereumMethods(chain).getSupportedMethods().containsAll(methods)
|
||||||
where:
|
where:
|
||||||
chain | methods
|
chain | methods
|
||||||
Chain.POLYGON__MAINNET | ["bor_getAuthor",
|
Chain.POLYGON__MAINNET | ["bor_getAuthor",
|
||||||
@@ -68,7 +68,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "Has no filter methods by default"() {
|
def "Has no filter methods by default"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
when:
|
when:
|
||||||
def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("filter") }
|
def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("filter") }
|
||||||
then:
|
then:
|
||||||
@@ -77,7 +77,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "Has no trace methods by default"() {
|
def "Has no trace methods by default"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
when:
|
when:
|
||||||
def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("trace") }
|
def act = methods.getSupportedMethods().findAll { it.containsIgnoreCase("trace") }
|
||||||
then:
|
then:
|
||||||
@@ -86,7 +86,7 @@ class DefaultEthereumMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "Default eth methods are available"() {
|
def "Default eth methods are available"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
expect:
|
expect:
|
||||||
methods.isAvailable(method)
|
methods.isAvailable(method)
|
||||||
where:
|
where:
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class ManagedCallMethodsSpec extends Specification {
|
|||||||
def "Use custom quorum if provided"() {
|
def "Use custom quorum if provided"() {
|
||||||
setup:
|
setup:
|
||||||
def managed = new ManagedCallMethods(
|
def managed = new ManagedCallMethods(
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
["eth_test", "eth_foo", "eth_bar"] as Set,
|
["eth_test", "eth_foo", "eth_bar"] as Set,
|
||||||
[] as Set,
|
[] as Set,
|
||||||
[] as Set,
|
[] as Set,
|
||||||
@@ -120,7 +120,7 @@ class ManagedCallMethodsSpec extends Specification {
|
|||||||
|
|
||||||
def "Doesn't reuse same instance"() {
|
def "Doesn't reuse same instance"() {
|
||||||
def managed = new ManagedCallMethods(
|
def managed = new ManagedCallMethods(
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
["eth_test"] as Set,
|
["eth_test"] as Set,
|
||||||
[] as Set,
|
[] as Set,
|
||||||
[] as Set,
|
[] as Set,
|
||||||
@@ -145,7 +145,7 @@ class ManagedCallMethodsSpec extends Specification {
|
|||||||
def "Test enable method group"() {
|
def "Test enable method group"() {
|
||||||
setup:
|
setup:
|
||||||
def managed = new ManagedCallMethods(
|
def managed = new ManagedCallMethods(
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
[] as Set,
|
[] as Set,
|
||||||
[] as Set,
|
[] as Set,
|
||||||
["filter"] as Set,
|
["filter"] as Set,
|
||||||
@@ -169,7 +169,7 @@ class ManagedCallMethodsSpec extends Specification {
|
|||||||
def "Test enable method group minus one"() {
|
def "Test enable method group minus one"() {
|
||||||
setup:
|
setup:
|
||||||
def managed = new ManagedCallMethods(
|
def managed = new ManagedCallMethods(
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
[] as Set,
|
[] as Set,
|
||||||
["eth_newPendingTransactionFilter"] as Set,
|
["eth_newPendingTransactionFilter"] as Set,
|
||||||
["filter"] as Set,
|
["filter"] as Set,
|
||||||
@@ -193,7 +193,7 @@ class ManagedCallMethodsSpec extends Specification {
|
|||||||
def "Test disabled group not disable enabled method"() {
|
def "Test disabled group not disable enabled method"() {
|
||||||
setup:
|
setup:
|
||||||
def managed = new ManagedCallMethods(
|
def managed = new ManagedCallMethods(
|
||||||
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false),
|
new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET),
|
||||||
["eth_newPendingTransactionFilter"] as Set,
|
["eth_newPendingTransactionFilter"] as Set,
|
||||||
[] as Set,
|
[] as Set,
|
||||||
[] as Set,
|
[] as Set,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
transactions = []
|
transactions = []
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -80,7 +80,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
transactions = []
|
transactions = []
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
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"() {
|
def "Produce empty result on non-existing block"() {
|
||||||
setup:
|
setup:
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -140,7 +140,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
transactions = []
|
transactions = []
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -172,7 +172,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
blockHash = BlockHash.from(hash1)
|
blockHash = BlockHash.from(hash1)
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -205,7 +205,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
blockHash = BlockHash.from(hash1)
|
blockHash = BlockHash.from(hash1)
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -238,7 +238,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
blockHash = BlockHash.from(hash1)
|
blockHash = BlockHash.from(hash1)
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -268,7 +268,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
blockHash = BlockHash.from(hash1)
|
blockHash = BlockHash.from(hash1)
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
def caches = Mock(Caches) {
|
def caches = Mock(Caches) {
|
||||||
// note that the Caches needs a Height value, otherwise it's not cached
|
// 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"() {
|
def "Produce empty on non-existing tx"() {
|
||||||
setup:
|
setup:
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
Stub(Multistream), Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -327,7 +327,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -358,7 +358,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
@@ -392,7 +392,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
transactions = []
|
transactions = []
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
def result = Mono.just(
|
def result = Mono.just(
|
||||||
new RequestReader.Result(
|
new RequestReader.Result(
|
||||||
@@ -432,7 +432,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
transactions = []
|
transactions = []
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
3 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
def result = Mono.just(
|
def result = Mono.just(
|
||||||
new RequestReader.Result(
|
new RequestReader.Result(
|
||||||
@@ -469,7 +469,7 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
4 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
}
|
}
|
||||||
EthereumDirectReader reader = new EthereumDirectReader(
|
EthereumDirectReader reader = new EthereumDirectReader(
|
||||||
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
up, Caches.default(), new CurrentBlockCache(), calls, TestingCommons.tracerMock()
|
||||||
|
|||||||
@@ -25,17 +25,16 @@ class EthereumLocalReaderSpec extends Specification {
|
|||||||
|
|
||||||
def "Calls hardcoded"() {
|
def "Calls hardcoded"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
def router = new EthereumLocalReader(
|
def router = new EthereumLocalReader(
|
||||||
new EthereumCachingReader(
|
new EthereumCachingReader(
|
||||||
TestingCommons.multistream(TestingCommons.api()),
|
TestingCommons.multistream(TestingCommons.api()),
|
||||||
Caches.default(),
|
Caches.default(),
|
||||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)),
|
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)),
|
||||||
TestingCommons.tracerMock()
|
TestingCommons.tracerMock()
|
||||||
),
|
),
|
||||||
methods,
|
methods,
|
||||||
new EmptyHead(),
|
new EmptyHead(),
|
||||||
null
|
|
||||||
)
|
)
|
||||||
when:
|
when:
|
||||||
def act = router.read(new ChainRequest("eth_coinbase", new ListParams())).block(Duration.ofSeconds(1))
|
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"() {
|
def "Returns empty if nonce set"() {
|
||||||
setup:
|
setup:
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
def router = new EthereumLocalReader(
|
def router = new EthereumLocalReader(
|
||||||
new EthereumCachingReader(
|
new EthereumCachingReader(
|
||||||
TestingCommons.multistream(TestingCommons.api()),
|
TestingCommons.multistream(TestingCommons.api()),
|
||||||
Caches.default(),
|
Caches.default(),
|
||||||
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)),
|
ConstantFactory.constantFactory(new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)),
|
||||||
TestingCommons.tracerMock()
|
TestingCommons.tracerMock()
|
||||||
),
|
),
|
||||||
methods,
|
methods,
|
||||||
new EmptyHead(),
|
new EmptyHead(),
|
||||||
null
|
|
||||||
)
|
)
|
||||||
when:
|
when:
|
||||||
def act = router.read(new ChainRequest("eth_getTransactionByHash", new ListParams(["test"]), 10))
|
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 methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
def router = new EthereumLocalReader(reader, methods, head)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def act = router.getBlockByNumber(["latest", false], Selector.UpstreamFilter.default)
|
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 methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
def router = new EthereumLocalReader(reader, methods, head)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def act = router.getBlockByNumber(["earliest", false], Selector.UpstreamFilter.default)
|
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 methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
def router = new EthereumLocalReader(reader, methods, head)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def act = router.getBlockByNumber(["0x123ef", false], Selector.UpstreamFilter.default)
|
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 methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
def router = new EthereumLocalReader(reader, methods, head)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def act = router.read(
|
def act = router.read(
|
||||||
@@ -188,8 +186,8 @@ class EthereumLocalReaderSpec extends Specification {
|
|||||||
_ * txByHashAsCont(Selector.UpstreamFilter.default) >> new EmptyReader<>()
|
_ * txByHashAsCont(Selector.UpstreamFilter.default) >> new EmptyReader<>()
|
||||||
_ * blocksByHeightAsCont(Selector.UpstreamFilter.default) >> new EmptyReader<>()
|
_ * blocksByHeightAsCont(Selector.UpstreamFilter.default) >> new EmptyReader<>()
|
||||||
}
|
}
|
||||||
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET, false)
|
def methods = new DefaultEthereumMethods(Chain.ETHEREUM__MAINNET)
|
||||||
def router = new EthereumLocalReader(reader, methods, head, null)
|
def router = new EthereumLocalReader(reader, methods, head)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def act = router.getBlockByNumber(["0x0", true], Selector.UpstreamFilter.default)
|
def act = router.getBlockByNumber(["0x0", true], Selector.UpstreamFilter.default)
|
||||||
|
|||||||
@@ -180,9 +180,6 @@ class ReloadConfigTest {
|
|||||||
cs.makeCachingReaderBuilder(mock<Tracer>()),
|
cs.makeCachingReaderBuilder(mock<Tracer>()),
|
||||||
cs::localReaderBuilder,
|
cs::localReaderBuilder,
|
||||||
cs.subscriptionBuilder(Schedulers.boundedElastic()),
|
cs.subscriptionBuilder(Schedulers.boundedElastic()),
|
||||||
null,
|
|
||||||
Schedulers.fromExecutor(Executors.newFixedThreadPool(6)),
|
|
||||||
mock<Tracer>(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user