Fix archive (#444)
This commit is contained in:
@@ -21,7 +21,6 @@ import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
|||||||
import io.emeraldpay.dshackle.upstream.calls.CallSelector
|
import io.emeraldpay.dshackle.upstream.calls.CallSelector
|
||||||
import io.emeraldpay.dshackle.upstream.calls.EthereumCallSelector
|
import io.emeraldpay.dshackle.upstream.calls.EthereumCallSelector
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.AggregatedPendingTxes
|
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.AggregatedPendingTxes
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.EthereumLabelsDetector
|
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.EthereumWsIngressSubscription
|
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.EthereumWsIngressSubscription
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.NoPendingTxes
|
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.NoPendingTxes
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.PendingTxesSource
|
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.PendingTxesSource
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
package io.emeraldpay.dshackle.upstream.ethereum.subscribe
|
package io.emeraldpay.dshackle.upstream.ethereum
|
||||||
|
|
||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.reader.ChainReader
|
import io.emeraldpay.dshackle.reader.ChainReader
|
||||||
import io.emeraldpay.dshackle.upstream.BasicEthLabelsDetector
|
import io.emeraldpay.dshackle.upstream.BasicEthLabelsDetector
|
||||||
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.ethereum.EthereumArchiveBlockNumberReader
|
|
||||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||||
import reactor.core.publisher.Flux
|
import reactor.core.publisher.Flux
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
|
|
||||||
|
const val ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"
|
||||||
|
|
||||||
class EthereumLabelsDetector(
|
class EthereumLabelsDetector(
|
||||||
private val reader: ChainReader,
|
private val reader: ChainReader,
|
||||||
private val chain: Chain,
|
private val chain: Chain,
|
||||||
@@ -36,7 +37,7 @@ class EthereumLabelsDetector(
|
|||||||
return reader.read(
|
return reader.read(
|
||||||
ChainRequest(
|
ChainRequest(
|
||||||
"eth_getBalance",
|
"eth_getBalance",
|
||||||
ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", blockNumber),
|
ListParams(ZERO_ADDRESS, blockNumber),
|
||||||
),
|
),
|
||||||
).flatMap(ChainResponse::requireResult)
|
).flatMap(ChainResponse::requireResult)
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ class EthereumLowerBoundBlockDetector(
|
|||||||
return upstream.getIngressReader().read(
|
return upstream.getIngressReader().read(
|
||||||
ChainRequest(
|
ChainRequest(
|
||||||
"eth_getBalance",
|
"eth_getBalance",
|
||||||
ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", blockNumber.toHex()),
|
ListParams(ZERO_ADDRESS, blockNumber.toHex()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.retryWhen(retrySpec(nonRetryableErrors))
|
.retryWhen(retrySpec(nonRetryableErrors))
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import io.emeraldpay.dshackle.reader.Reader
|
|||||||
import io.emeraldpay.dshackle.test.ApiReaderMock
|
import io.emeraldpay.dshackle.test.ApiReaderMock
|
||||||
import io.emeraldpay.dshackle.test.TestingCommons
|
import io.emeraldpay.dshackle.test.TestingCommons
|
||||||
import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.EthereumLabelsDetector
|
|
||||||
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.rpcclient.ListParams
|
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||||
@@ -24,8 +23,8 @@ class EthereumLabelsDetectorSpec extends Specification {
|
|||||||
new ApiReaderMock().tap {
|
new ApiReaderMock().tap {
|
||||||
answer("web3_clientVersion", [], response)
|
answer("web3_clientVersion", [], response)
|
||||||
answer("eth_blockNumber", [], "0x10df3e5")
|
answer("eth_blockNumber", [], "0x10df3e5")
|
||||||
answer("eth_getBalance", ["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x10dccd5"], "")
|
answer("eth_getBalance", ["0x0000000000000000000000000000000000000000", "0x10dccd5"], "")
|
||||||
answer("eth_getBalance", ["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x2710"], "")
|
answer("eth_getBalance", ["0x0000000000000000000000000000000000000000", "0x2710"], "")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
def detector = new EthereumLabelsDetector(up.getIngressReader(), Chain.ETHEREUM__MAINNET)
|
def detector = new EthereumLabelsDetector(up.getIngressReader(), Chain.ETHEREUM__MAINNET)
|
||||||
@@ -57,9 +56,9 @@ class EthereumLabelsDetectorSpec extends Specification {
|
|||||||
Mono.just(new ChainResponse('no/v1.19.3+e8ac1da4/linux-x64/dotnet7.0.8'.getBytes(), null))
|
Mono.just(new ChainResponse('no/v1.19.3+e8ac1da4/linux-x64/dotnet7.0.8'.getBytes(), null))
|
||||||
1 * read(new ChainRequest("eth_blockNumber", new ListParams())) >>
|
1 * read(new ChainRequest("eth_blockNumber", new ListParams())) >>
|
||||||
Mono.just(new ChainResponse("\"0x10df3e5\"".getBytes(), null))
|
Mono.just(new ChainResponse("\"0x10df3e5\"".getBytes(), null))
|
||||||
1 * read(new ChainRequest("eth_getBalance", new ListParams(["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x10dccd5"]))) >>
|
1 * read(new ChainRequest("eth_getBalance", new ListParams(["0x0000000000000000000000000000000000000000", "0x10dccd5"]))) >>
|
||||||
Mono.error(new RuntimeException())
|
Mono.error(new RuntimeException())
|
||||||
1 * read(new ChainRequest("eth_getBalance", new ListParams(["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x2710"]))) >>
|
1 * read(new ChainRequest("eth_getBalance", new ListParams(["0x0000000000000000000000000000000000000000", "0x2710"]))) >>
|
||||||
Mono.just(new ChainResponse("".getBytes(), null))
|
Mono.just(new ChainResponse("".getBytes(), null))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.emeraldpay.dshackle.upstream
|
|||||||
import io.emeraldpay.dshackle.Chain
|
import io.emeraldpay.dshackle.Chain
|
||||||
import io.emeraldpay.dshackle.reader.ChainReader
|
import io.emeraldpay.dshackle.reader.ChainReader
|
||||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLowerBoundBlockDetector
|
import io.emeraldpay.dshackle.upstream.ethereum.EthereumLowerBoundBlockDetector
|
||||||
|
import io.emeraldpay.dshackle.upstream.ethereum.ZERO_ADDRESS
|
||||||
import io.emeraldpay.dshackle.upstream.polkadot.PolkadotLowerBoundBlockDetector
|
import io.emeraldpay.dshackle.upstream.polkadot.PolkadotLowerBoundBlockDetector
|
||||||
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
import io.emeraldpay.dshackle.upstream.rpcclient.ListParams
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
@@ -86,11 +87,11 @@ class RecursiveLowerBoundBlockDetectorTest {
|
|||||||
blocks.forEach {
|
blocks.forEach {
|
||||||
if (it == 17964844L) {
|
if (it == 17964844L) {
|
||||||
on {
|
on {
|
||||||
read(ChainRequest("eth_getBalance", ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
|
read(ChainRequest("eth_getBalance", ListParams(ZERO_ADDRESS, it.toHex())))
|
||||||
} doReturn Mono.just(ChainResponse(ByteArray(0), null))
|
} doReturn Mono.just(ChainResponse(ByteArray(0), null))
|
||||||
} else {
|
} else {
|
||||||
on {
|
on {
|
||||||
read(ChainRequest("eth_getBalance", ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", it.toHex())))
|
read(ChainRequest("eth_getBalance", ListParams(ZERO_ADDRESS, it.toHex())))
|
||||||
} doReturn Mono.error(RuntimeException("missing trie node"))
|
} doReturn Mono.error(RuntimeException("missing trie node"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user