diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetector.kt index c94c1f04..cfe2924c 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetector.kt @@ -82,7 +82,9 @@ class EthereumUpstreamSettingsDetector( }.flatMapMany { val gaslimit = String(it).drop(3).dropLast(1).toBigInteger(16) + (21182).toBigInteger() val labels = mutableListOf(Pair("gas-limit", gaslimit.toString(10))) - labels.add(Pair("extra_gas_limit", gaslimit.toString(10))) + if (gaslimit.toLong() > 590_000_000L) { + labels.add(Pair("extra_gas_limit", 600_000_000.toString())) + } Flux.fromIterable(labels) }.onErrorResume { Flux.empty() diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetectorSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetectorSpec.groovy index e67b52f4..33f61478 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetectorSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/ethereum/EthereumUpstreamSettingsDetectorSpec.groovy @@ -34,7 +34,7 @@ class EthereumUpstreamSettingsDetectorSpec extends Specification { "0x53Daa71B04d589429f6d3DF52db123913B818F22": [ "code": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c806351be4eaa14602d575b600080fd5b60336047565b604051603e91906066565b60405180910390f35b60005a905090565b6000819050919050565b606081604f565b82525050565b6000602082019050607960008301846059565b9291505056fea26469706673582212201c0202887c1afe66974b06ee355dee07542bbc424cf4d1659c91f56c08c3dcc064736f6c63430008130033", ], - ]], "0x2fa9dc2") + ]], gas) } ) def detector = new EthereumUpstreamSettingsDetector(up, Chain.ETHEREUM__MAINNET) @@ -42,22 +42,23 @@ class EthereumUpstreamSettingsDetectorSpec extends Specification { when: def act = detector.internalDetectLabels() then: - StepVerifier.create(act) + def result = StepVerifier.create(act) .expectNext( new Pair("client_type", clientType), new Pair("client_version", version), new Pair("archive", "true"), - new Pair("gas-limit", "50000000"), - new Pair("extra_gas_limit", "50000000") + new Pair("gas-limit", gasv), ) - .expectComplete() - .verify(Duration.ofSeconds(1)) + if (extragas != null) { + result.expectNext(new Pair("extra_gas_limit", extragas)) + } + result.expectComplete().verify(Duration.ofSeconds(1)) where: - response | clientType | version - "Nethermind/v1.19.3+e8ac1da4/linux-x64/dotnet7.0.8" | "nethermind" | "v1.19.3+e8ac1da4" - "Geth/v1.12.0-stable-e501b3b0/linux-amd64/go1.20.3" | "geth" | "v1.12.0-stable-e501b3b0" - "Erigon/v1.12.0-stable-e501b3b0/linux-amd64/go1.20.3" | "erigon" | "v1.12.0-stable-e501b3b0" - "Bor/v0.4.0/linux-amd64/go1.19.10" | "bor" | "v0.4.0" + response | gas | gasv | extragas | clientType | version + "Nethermind/v1.19.3+e8ac1da4/linux-x64/dotnet7.0.8" | "0x2fa9dc2" | "50000000" | null | "nethermind" | "v1.19.3+e8ac1da4" + "Geth/v1.12.0-stable-e501b3b0/linux-amd64/go1.20.3" | "0x2fa9dc2" | "50000000" | null | "geth" | "v1.12.0-stable-e501b3b0" + "Erigon/v1.12.0-stable-e501b3b0/linux-amd64/go1.20.3" | "0x2fa9dc2" | "50000000" | null | "erigon" | "v1.12.0-stable-e501b3b0" + "Bor/v0.4.0/linux-amd64/go1.19.10" | "0x23c2f342"| "600000000" | "600000000" | "bor" | "v0.4.0" } def "Not archival node if null response"() {