From 4730845839d8e0f13edebd565866e241e6edd180 Mon Sep 17 00:00:00 2001 From: KirillPamPam Date: Thu, 7 Nov 2024 17:06:56 +0400 Subject: [PATCH] Add sei errors (#592) --- .../ethereum/EthereumLowerBoundBlockDetector.kt | 17 +++++------------ .../ethereum/EthereumLowerBoundStateDetector.kt | 1 + .../ethereum/EthereumLowerBoundTxDetector.kt | 6 +++++- 3 files changed, 11 insertions(+), 13 deletions(-) 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 4ba27a96d..3d27ca491 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundBlockDetector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundBlockDetector.kt @@ -1,8 +1,6 @@ package io.emeraldpay.dshackle.upstream.ethereum import io.emeraldpay.dshackle.Defaults -import io.emeraldpay.dshackle.upstream.ChainCallError -import io.emeraldpay.dshackle.upstream.ChainCallUpstreamException import io.emeraldpay.dshackle.upstream.ChainRequest import io.emeraldpay.dshackle.upstream.ChainResponse import io.emeraldpay.dshackle.upstream.Upstream @@ -22,14 +20,17 @@ class EthereumLowerBoundBlockDetector( companion object { private const val NO_BLOCK_DATA = "No block data" - private val NO_BLOCK_ERRORS = listOf( + val NO_BLOCK_ERRORS = setOf( + NO_BLOCK_DATA, "error loading messages for tipset", "bad tipset height", "Block with such an ID is pruned", // zksync + "height is not available", // sei + "method handler crashed", // sei ) } - private val recursiveLowerBound = RecursiveLowerBound(upstream, LowerBoundType.BLOCK, setOf(NO_BLOCK_DATA), lowerBounds) + private val recursiveLowerBound = RecursiveLowerBound(upstream, LowerBoundType.BLOCK, NO_BLOCK_ERRORS, lowerBounds) override fun period(): Long { return 3 @@ -52,10 +53,6 @@ class EthereumLowerBoundBlockDetector( if (it.hasResult() && it.getResult().contentEquals("null".toByteArray())) { throw IllegalStateException(NO_BLOCK_DATA) } - }.doOnError { - if (it is ChainCallUpstreamException && handleError(it.error)) { - throw IllegalStateException(NO_BLOCK_DATA) - } } } }.flatMap { @@ -63,10 +60,6 @@ class EthereumLowerBoundBlockDetector( } } - private fun handleError(error: ChainCallError): Boolean { - return NO_BLOCK_ERRORS.any { error.message.contains(it) } - } - override fun types(): Set { return setOf(LowerBoundType.BLOCK, LowerBoundType.LOGS) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundStateDetector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundStateDetector.kt index dc26d2c59..c94ff6e05 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundStateDetector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundStateDetector.kt @@ -48,6 +48,7 @@ class EthereumLowerBoundStateDetector( "state at block", // berachain, eth "unsupported block number", // arb "unexpected state root", // fantom + "evm module does not exist on height", // sei ) } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundTxDetector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundTxDetector.kt index a4c2d6df5..a9c624728 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundTxDetector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumLowerBoundTxDetector.kt @@ -19,9 +19,13 @@ class EthereumLowerBoundTxDetector( companion object { const val MAX_OFFSET = 20 private const val NO_TX_DATA = "No tx data" + + private val NO_TX_ERRORS = setOf( + NO_TX_DATA, + ).plus(EthereumLowerBoundBlockDetector.NO_BLOCK_ERRORS) } - private val recursiveLowerBound = RecursiveLowerBound(upstream, LowerBoundType.TX, setOf(NO_TX_DATA), lowerBounds) + private val recursiveLowerBound = RecursiveLowerBound(upstream, LowerBoundType.TX, NO_TX_ERRORS, lowerBounds) override fun period(): Long { return 3