diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt index 917de8d8..e4df9564 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumChainSpecific.kt @@ -21,7 +21,6 @@ import io.emeraldpay.dshackle.upstream.calls.CallMethods import io.emeraldpay.dshackle.upstream.calls.CallSelector import io.emeraldpay.dshackle.upstream.calls.EthereumCallSelector 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.NoPendingTxes import io.emeraldpay.dshackle.upstream.ethereum.subscribe.PendingTxesSource diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/subscribe/EthereumLabelsDetector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLabelsDetector.kt similarity index 87% rename from src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/subscribe/EthereumLabelsDetector.kt rename to src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLabelsDetector.kt index 2ee710ab..34bcb612 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/subscribe/EthereumLabelsDetector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLabelsDetector.kt @@ -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.reader.ChainReader import io.emeraldpay.dshackle.upstream.BasicEthLabelsDetector import io.emeraldpay.dshackle.upstream.ChainRequest import io.emeraldpay.dshackle.upstream.ChainResponse -import io.emeraldpay.dshackle.upstream.ethereum.EthereumArchiveBlockNumberReader import io.emeraldpay.dshackle.upstream.rpcclient.ListParams import reactor.core.publisher.Flux import reactor.core.publisher.Mono +const val ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" + class EthereumLabelsDetector( private val reader: ChainReader, private val chain: Chain, @@ -36,7 +37,7 @@ class EthereumLabelsDetector( return reader.read( ChainRequest( "eth_getBalance", - ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", blockNumber), + ListParams(ZERO_ADDRESS, blockNumber), ), ).flatMap(ChainResponse::requireResult) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundBlockDetector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundBlockDetector.kt index e6118e07..289f56b2 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundBlockDetector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundBlockDetector.kt @@ -47,7 +47,7 @@ class EthereumLowerBoundBlockDetector( return upstream.getIngressReader().read( ChainRequest( "eth_getBalance", - ListParams("0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", blockNumber.toHex()), + ListParams(ZERO_ADDRESS, blockNumber.toHex()), ), ) .retryWhen(retrySpec(nonRetryableErrors)) diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLabelsDetectorSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLabelsDetectorSpec.groovy index d8bb5ced..9845489b 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLabelsDetectorSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumLabelsDetectorSpec.groovy @@ -5,7 +5,6 @@ import io.emeraldpay.dshackle.reader.Reader import io.emeraldpay.dshackle.test.ApiReaderMock import io.emeraldpay.dshackle.test.TestingCommons 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.ChainResponse import io.emeraldpay.dshackle.upstream.rpcclient.ListParams @@ -24,8 +23,8 @@ class EthereumLabelsDetectorSpec extends Specification { new ApiReaderMock().tap { answer("web3_clientVersion", [], response) answer("eth_blockNumber", [], "0x10df3e5") - answer("eth_getBalance", ["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x10dccd5"], "") - answer("eth_getBalance", ["0x756F45E3FA69347A9A973A725E3C98bC4db0b5a0", "0x2710"], "") + answer("eth_getBalance", ["0x0000000000000000000000000000000000000000", "0x10dccd5"], "") + answer("eth_getBalance", ["0x0000000000000000000000000000000000000000", "0x2710"], "") } ) 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)) 1 * read(new ChainRequest("eth_blockNumber", new ListParams())) >> 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()) - 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)) } } diff --git a/src/test/kotlin/io/emeraldpay/dshackle/upstream/RecursiveLowerBoundBlockDetectorTest.kt b/src/test/kotlin/io/emeraldpay/dshackle/upstream/RecursiveLowerBoundBlockDetectorTest.kt index 2577a53c..43d79b51 100644 --- a/src/test/kotlin/io/emeraldpay/dshackle/upstream/RecursiveLowerBoundBlockDetectorTest.kt +++ b/src/test/kotlin/io/emeraldpay/dshackle/upstream/RecursiveLowerBoundBlockDetectorTest.kt @@ -3,6 +3,7 @@ package io.emeraldpay.dshackle.upstream import io.emeraldpay.dshackle.Chain import io.emeraldpay.dshackle.reader.ChainReader 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.rpcclient.ListParams import org.junit.jupiter.api.Assertions.assertEquals @@ -86,11 +87,11 @@ class RecursiveLowerBoundBlockDetectorTest { blocks.forEach { if (it == 17964844L) { 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)) } else { 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")) } }