Skip to content

Commit

Permalink
Added a test for traces v2 config (#166)
Browse files Browse the repository at this point in the history
* Added a test for traces v2 config
  • Loading branch information
Filter94 authored Oct 14, 2024
1 parent 368e404 commit bdd9fb1
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ expected-traces-api-version-v2="v0.8.0-rc3"
[traces.counters-v2]
endpoints=["http://traces-node-v2:8545/"]
request-limit-per-endpoint=20
request-retry.max-retries=4
request-retry.backoff-delay="PT1S"
request-retry.failures-warning-threshold=2
[traces.conflation-v2]
endpoints=["http://traces-node-v2:8545/"]
request-limit-per-endpoint=2
request-retry.max-retries=4
request-retry.backoff-delay="PT1S"
request-retry.failures-warning-threshold=2

[dynamic-gas-price-service]
geth-gas-price-update-recipients=[
"http://l2-node:8545/"
]

[l2-network-gas-pricing.legacy.sample-transaction-gas-pricing]
plain-transfer-cost-multiplier=1.0
# Ratio of 350 / 29400 is based on data from Mainnet. Only 0.3% of transactions are less profitable than this
# Meaning 99.7% of transactions will be includable if priced using eth_gasPrice
compressed-tx-size=350
expected-gas=29400
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,98 @@ class CoordinatorConfigTest {
}
}

@Test
fun parsesValidTracesV2ConfigOverride() {
val smartContractErrorCodes: SmartContractErrors =
CoordinatorAppCli.loadConfigsOrError<SmartContractErrorCodesConfig>(
listOf(File("../../config/common/smart-contract-errors.toml"))
).get()!!.smartContractErrors
val timeOfDayMultipliers =
CoordinatorAppCli.loadConfigsOrError<GasPriceCapTimeOfDayMultipliersConfig>(
listOf(File("../../config/common/gas-price-cap-time-of-day-multipliers.toml"))
)
val tracesLimitsConfigs =
CoordinatorAppCli.loadConfigsOrError<TracesLimitsV1ConfigFile>(
listOf(File("../../config/common/traces-limits-v1.toml"))
)
val tracesLimitsV2Configs =
CoordinatorAppCli.loadConfigsOrError<TracesLimitsV2ConfigFile>(
listOf(File("../../config/common/traces-limits-v2.toml"))
)

CoordinatorAppCli.loadConfigsOrError<CoordinatorConfigTomlDto>(
listOf(
File("../../config/coordinator/coordinator-docker.config.toml"),
File("../../config/coordinator/coordinator-docker-traces-v2-override.config.toml")
)
)
.onFailure { error: String -> fail(error) }
.onSuccess {
val configs = it.copy(
conflation = it.conflation.copy(
_tracesLimitsV1 = tracesLimitsConfigs.get()?.tracesLimits?.let { TracesCountersV1(it) },
_tracesLimitsV2 = tracesLimitsV2Configs.get()?.tracesLimits?.let { TracesCountersV2(it) },
_smartContractErrors = smartContractErrorCodes
),
l1DynamicGasPriceCapService = it.l1DynamicGasPriceCapService.copy(
gasPriceCapCalculation = it.l1DynamicGasPriceCapService.gasPriceCapCalculation.copy(
timeOfDayMultipliers = timeOfDayMultipliers.get()?.gasPriceCapTimeOfDayMultipliers
)
)
)

val expectedConfig =
coordinatorConfig.copy(
zkTraces = zkTracesConfig.copy(ethApi = URI("http://traces-node-v2:8545").toURL()),
l2NetworkGasPricingService = l2NetworkGasPricingServiceConfig.copy(
legacy =
l2NetworkGasPricingServiceConfig.legacy.copy(
transactionCostCalculatorConfig =
l2NetworkGasPricingServiceConfig.legacy.transactionCostCalculatorConfig?.copy(
compressedTxSize = 350,
expectedGas = 29400
)
)
),
traces = tracesConfig.copy(
switchToLineaBesu = true,
expectedTracesApiVersionV2 = "v0.8.0-rc3",
conflationV2 = tracesConfig.conflation.copy(
endpoints = listOf(URI("http://traces-node-v2:8545/").toURL())
),
countersV2 = TracesConfig.FunctionalityEndpoint(
listOf(
URI("http://traces-node-v2:8545/").toURL()
),
requestLimitPerEndpoint = 20U,
requestRetry = RequestRetryConfigTomlFriendly(
backoffDelay = Duration.parse("PT1S"),
failuresWarningThreshold = 2
)
)
),
proversConfig = proversConfig.copy(
proverA = proversConfig.proverA.copy(
execution = proversConfig.proverA.execution.copy(
requestsDirectory = Path.of("/data/prover/v3/execution/requests"),
responsesDirectory = Path.of("/data/prover/v3/execution/responses")
),
blobCompression = proversConfig.proverA.blobCompression.copy(
requestsDirectory = Path.of("/data/prover/v3/compression/requests"),
responsesDirectory = Path.of("/data/prover/v3/compression/responses")
),
proofAggregation = proversConfig.proverA.proofAggregation.copy(
requestsDirectory = Path.of("/data/prover/v3/aggregation/requests"),
responsesDirectory = Path.of("/data/prover/v3/aggregation/responses")
)
)
)
)

assertEquals(expectedConfig, configs.reified())
}
}

@Test
fun invalidConfigReturnsErrorResult() {
val configs =
Expand Down

0 comments on commit bdd9fb1

Please sign in to comment.