Upstream validation and enhancement improvement: (#146)
- now validation of upstream starts immediately after upstream starts - it allows it became available asap - now we don't enrich PoS blocks which improves performance and decrease number of requests to node
This commit is contained in:
@@ -23,7 +23,7 @@ class ConnectorFactoryMock implements ConnectorFactory {
|
||||
return true
|
||||
}
|
||||
|
||||
EthereumConnector create(DefaultUpstream upstream, EthereumUpstreamValidator validator, Chain chain) {
|
||||
EthereumConnector create(DefaultUpstream upstream, EthereumUpstreamValidator validator, Chain chain, boolean skipEnhance) {
|
||||
return new EthereumConnectorMock(api, head)
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package io.emeraldpay.dshackle.test
|
||||
import io.emeraldpay.dshackle.Chain
|
||||
import io.emeraldpay.dshackle.config.ChainsConfig
|
||||
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
||||
import io.emeraldpay.dshackle.config.UpstreamsConfig.Options
|
||||
import io.emeraldpay.dshackle.data.BlockContainer
|
||||
import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.startup.QuorumForLabels
|
||||
@@ -34,6 +35,7 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.reactivestreams.Publisher
|
||||
|
||||
|
||||
class EthereumPosRpcUpstreamMock extends EthereumPosRpcUpstream {
|
||||
EthereumHeadMock ethereumHeadMock
|
||||
|
||||
@@ -68,7 +70,7 @@ class EthereumPosRpcUpstreamMock extends EthereumPosRpcUpstream {
|
||||
|
||||
EthereumPosRpcUpstreamMock(@NotNull String id, @NotNull Chain chain, @NotNull Reader<JsonRpcRequest, JsonRpcResponse> api, CallMethods methods, Map<String, String> labels) {
|
||||
super(id, (byte)id.hashCode(), chain,
|
||||
UpstreamsConfig.Options.getDefaults(),
|
||||
getOpts(),
|
||||
UpstreamsConfig.UpstreamRole.PRIMARY,
|
||||
methods,
|
||||
new QuorumForLabels.QuorumItem(1, UpstreamsConfig.Labels.fromMap(labels)),
|
||||
@@ -80,6 +82,12 @@ class EthereumPosRpcUpstreamMock extends EthereumPosRpcUpstream {
|
||||
start()
|
||||
}
|
||||
|
||||
static Options getOpts() {
|
||||
def opt = UpstreamsConfig.Options.getDefaults()
|
||||
opt.setDisableValidation(true)
|
||||
return opt
|
||||
}
|
||||
|
||||
void nextBlock(BlockContainer block) {
|
||||
this.ethereumHeadMock.nextBlock(block)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class EthereumWsHeadSpec extends Specification {
|
||||
|
||||
def ws = Mock(WsSubscriptions)
|
||||
|
||||
def head = new EthereumWsHead("fake", new AlwaysForkChoice(), BlockValidator.ALWAYS_VALID, apiMock, ws)
|
||||
def head = new EthereumWsHead("fake", new AlwaysForkChoice(), BlockValidator.ALWAYS_VALID, apiMock, ws, false)
|
||||
|
||||
when:
|
||||
def act = head.listenNewHeads().blockFirst()
|
||||
|
||||
Reference in New Issue
Block a user