Merge pull request #107 from p2p-org/fix/ehtereum-call-selector

ethereum call selector and passthrough interaction: keep same upstrea…
This commit is contained in:
Vyacheslav Shebanov
2023-01-12 15:11:08 +02:00
committed by GitHub
3 changed files with 37 additions and 24 deletions

View File

@@ -80,12 +80,10 @@ open class NativeCall(
@EventListener
fun onUpstreamChangeEvent(event: UpstreamChangeEvent) {
if (!passthrough) {
casting[BlockchainType.from(event.chain)]?.let { cast ->
multistreamHolder.getUpstream(event.chain).let { up ->
val reader = up.cast(cast).getReader()
ethereumCallSelectors.putIfAbsent(event.chain, EthereumCallSelector(reader.heightByHash()))
}
casting[BlockchainType.from(event.chain)]?.let { cast ->
multistreamHolder.getUpstream(event.chain).let { up ->
val reader = up.cast(cast).getReader()
ethereumCallSelectors.putIfAbsent(event.chain, EthereumCallSelector(reader.heightByHash()))
}
}
}
@@ -227,7 +225,7 @@ open class NativeCall(
// for ethereum the actual block needed for the call may be specified in the call parameters
val callSpecificMatcher: Mono<Selector.Matcher> =
if (BlockchainType.from(upstream.chain) == BlockchainType.EVM_POS || BlockchainType.from(upstream.chain) == BlockchainType.EVM_POW) {
ethereumCallSelectors[chain]?.getMatcher(method, params, upstream.getHead())
ethereumCallSelectors[chain]?.getMatcher(method, params, upstream.getHead(), passthrough)
} else {
null
} ?: Mono.empty()

View File

@@ -53,10 +53,10 @@ class EthereumCallSelector(
* @param method JSON RPC name
* @param params JSON-encoded list of parameters for the method
*/
fun getMatcher(method: String, params: String, head: Head): Mono<Selector.Matcher> {
if (Collections.binarySearch(TAG_METHODS, method) >= 0) {
fun getMatcher(method: String, params: String, head: Head, passthrough: Boolean): Mono<Selector.Matcher> {
if (!passthrough && Collections.binarySearch(TAG_METHODS, method) >= 0) {
return blockTagSelector(params, 1, head)
} else if (method == "eth_getStorageAt") {
} else if (!passthrough && method == "eth_getStorageAt") {
return blockTagSelector(params, 2, head)
} else if (method in DefaultEthereumMethods.withFilterIdMethods) {
return sameUpstreamMatcher(params)