Skip to content

Commit

Permalink
Add sei errors (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillPamPam authored Nov 7, 2024
1 parent d6b6ca7 commit 4730845
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -52,21 +53,13 @@ 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 {
Flux.just(it, lowerBoundFrom(it, LowerBoundType.LOGS))
}
}

private fun handleError(error: ChainCallError): Boolean {
return NO_BLOCK_ERRORS.any { error.message.contains(it) }
}

override fun types(): Set<LowerBoundType> {
return setOf(LowerBoundType.BLOCK, LowerBoundType.LOGS)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4730845

Please sign in to comment.