From 00ffc737f5e07b795f615159e2b302408c08a7ed Mon Sep 17 00:00:00 2001 From: Pedro Novais <1478752+jpnovais@users.noreply.github.com> Date: Wed, 23 Oct 2024 09:52:55 +0100 Subject: [PATCH] Coordinator: carve out BlockInterval (#231) * carve out BlockInterval to shared jvm-libs --- ...oviderWithLastEndBlockNumberTrackerTest.kt | 2 +- .../clients/prover/ABProverClientRouter.kt | 2 +- .../prover/GenericFileBasedProverClient.kt | 2 +- .../clients/prover/ProverClientFactory.kt | 2 +- .../GenericFileBasedProverClientTest.kt | 2 +- .../clients/prover/ProverClientFactoryTest.kt | 2 +- .../BlobJsonFileRequestResponse.kt | 2 +- .../BlobCompressionProofJsonResponseTest.kt | 2 +- .../BatchExecutionProverRequestResponse.kt | 2 +- .../BlobCompressionProverRequestResponse.kt | 4 +- .../net/consensys/zkevm/domain/Aggregation.kt | 4 +- .../kotlin/net/consensys/zkevm/domain/Blob.kt | 2 + .../net/consensys/zkevm/domain/Conflation.kt | 94 +------------ .../net/consensys/zkevm/domain/ProofIndex.kt | 2 + ...onTriggerCalculatorByTargetBlockNumbers.kt | 2 +- .../ProofAggregationCoordinatorService.kt | 4 +- .../blob/BlobCompressionProofCoordinator.kt | 6 +- .../blob/BlobCompressionProofHandler.kt | 2 +- .../coordination/blob/BlobShnarfCalulator.kt | 2 +- .../blob/RollingBlobShnarfCalculator.kt | 4 +- .../GlobalBlobAwareConflationCalculator.kt | 2 +- .../GoBackedCalculateShnarfCalculatorTest.kt | 2 +- .../ProofAggregationCoordinatorServiceTest.kt | 2 +- .../blob/RollingBlobShnarfCalculatorTest.kt | 2 +- .../BlockToBatchSubmissionCoordinatorTest.kt | 4 +- .../net/consensys/zkevm/domain/BlobRecord.kt | 1 + .../submission/BlobSubmissionCoordinator.kt | 6 +- .../submission/BlobSubmissionHelper.kt | 8 +- ...lobSubmitterAsEIP4844MultipleBlobsPerTx.kt | 2 +- .../submission/BlobsGrouperForSubmission.kt | 2 +- .../ContractUpgradeSubmissionLatchFilter.kt | 2 +- .../BlobSubmissionCoordinatorTest.kt | 4 +- .../submission/BlobSubmissionHelperKtTest.kt | 4 +- .../AggregationsPostgresDaoTest.kt | 2 +- .../aggregation/PostgresAggregationsDao.kt | 4 +- .../RetryingPostgresAggregationsDaoTest.kt | 2 +- .../BlobCompressionProofCoordinatorIntTest.kt | 2 +- .../dao/blob/BlobsPostgresDaoTest.kt | 2 +- .../BlobCompressionProofCoordinatorTest.kt | 2 +- .../dao/blob/RetryingBlobsPostgresDaoTest.kt | 2 +- .../main/kotlin/build/linea/UrlExtensions.kt | 16 +++ .../build/linea/domain/BlockInterval.kt | 126 ++++++++++++++++++ .../build/linea}/domain/BlockIntervalsTest.kt | 2 +- 43 files changed, 201 insertions(+), 144 deletions(-) create mode 100644 jvm-libs/generic/extensions/kotlin/src/main/kotlin/build/linea/UrlExtensions.kt create mode 100644 jvm-libs/linea/core/domain-models/src/main/kotlin/build/linea/domain/BlockInterval.kt rename {coordinator/core/src/test/kotlin/net/consensys/zkevm => jvm-libs/linea/core/domain-models/src/test/kotlin/build/linea}/domain/BlockIntervalsTest.kt (98%) diff --git a/coordinator/app/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ConsecutiveProvenBlobsProviderWithLastEndBlockNumberTrackerTest.kt b/coordinator/app/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ConsecutiveProvenBlobsProviderWithLastEndBlockNumberTrackerTest.kt index ea0cbca3c..76e25d1d8 100644 --- a/coordinator/app/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ConsecutiveProvenBlobsProviderWithLastEndBlockNumberTrackerTest.kt +++ b/coordinator/app/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ConsecutiveProvenBlobsProviderWithLastEndBlockNumberTrackerTest.kt @@ -1,9 +1,9 @@ package net.consensys.zkevm.ethereum.coordination.aggregation +import build.linea.domain.BlockIntervals import kotlinx.datetime.Instant import net.consensys.zkevm.domain.BlobAndBatchCounters import net.consensys.zkevm.domain.BlobCounters -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.persistence.AggregationsRepository import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ABProverClientRouter.kt b/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ABProverClientRouter.kt index ad5eefa0f..dc118f3f3 100644 --- a/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ABProverClientRouter.kt +++ b/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ABProverClientRouter.kt @@ -1,7 +1,7 @@ package net.consensys.zkevm.coordinator.clients.prover +import build.linea.domain.BlockInterval import net.consensys.zkevm.coordinator.clients.ProverClient -import net.consensys.zkevm.domain.BlockInterval import tech.pegasys.teku.infrastructure.async.SafeFuture class StartBlockNumberBasedSwitchPredicate( diff --git a/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClient.kt b/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClient.kt index dcc24fb2b..4b71a022c 100644 --- a/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClient.kt +++ b/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClient.kt @@ -1,11 +1,11 @@ package net.consensys.zkevm.coordinator.clients.prover +import build.linea.domain.BlockInterval import com.github.michaelbull.result.Err import com.github.michaelbull.result.getOrElse import com.github.michaelbull.result.map import io.vertx.core.Vertx import net.consensys.linea.errors.ErrorResponse -import net.consensys.zkevm.domain.BlockInterval import net.consensys.zkevm.domain.ProofIndex import net.consensys.zkevm.fileio.FileMonitor import net.consensys.zkevm.fileio.FileReader diff --git a/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactory.kt b/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactory.kt index 5802a45c0..ed09edbce 100644 --- a/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactory.kt +++ b/coordinator/clients/prover-client/file-based-client/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactory.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.coordinator.clients.prover +import build.linea.domain.BlockInterval import io.vertx.core.Vertx import net.consensys.linea.contract.Web3JL2MessageServiceLogsClient import net.consensys.linea.metrics.LineaMetricsCategory @@ -9,7 +10,6 @@ import net.consensys.zkevm.coordinator.clients.BlobCompressionProverClientV2 import net.consensys.zkevm.coordinator.clients.ExecutionProverClientV2 import net.consensys.zkevm.coordinator.clients.ProofAggregationProverClientV2 import net.consensys.zkevm.coordinator.clients.ProverClient -import net.consensys.zkevm.domain.BlockInterval import org.web3j.protocol.Web3j class ProverClientFactory( diff --git a/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClientTest.kt b/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClientTest.kt index d945b1b96..766ddc061 100644 --- a/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClientTest.kt +++ b/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/GenericFileBasedProverClientTest.kt @@ -1,9 +1,9 @@ package net.consensys.zkevm.coordinator.clients.prover +import build.linea.domain.BlockInterval import io.vertx.core.Vertx import io.vertx.junit5.VertxExtension import net.consensys.zkevm.coordinator.clients.prover.serialization.JsonSerialization -import net.consensys.zkevm.domain.BlockInterval import net.consensys.zkevm.domain.ProofIndex import net.consensys.zkevm.fileio.FileReader import net.consensys.zkevm.fileio.FileWriter diff --git a/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactoryTest.kt b/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactoryTest.kt index 11396479c..66b01a8ed 100644 --- a/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactoryTest.kt +++ b/coordinator/clients/prover-client/file-based-client/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/ProverClientFactoryTest.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.coordinator.clients.prover +import build.linea.domain.BlockIntervals import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.simple.SimpleMeterRegistry import io.vertx.core.Vertx @@ -8,7 +9,6 @@ import kotlinx.datetime.Clock import net.consensys.ByteArrayExt import net.consensys.linea.metrics.MetricsFacade import net.consensys.linea.metrics.micrometer.MicrometerMetricsFacade -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ProofIndex import net.consensys.zkevm.domain.ProofsToAggregate import org.assertj.core.api.Assertions.assertThat diff --git a/coordinator/clients/prover-client/serialization/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobJsonFileRequestResponse.kt b/coordinator/clients/prover-client/serialization/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobJsonFileRequestResponse.kt index d050c09cf..2ecfa52f1 100644 --- a/coordinator/clients/prover-client/serialization/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobJsonFileRequestResponse.kt +++ b/coordinator/clients/prover-client/serialization/src/main/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobJsonFileRequestResponse.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.coordinator.clients.prover.serialization +import build.linea.domain.BlockIntervals import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.JsonParser @@ -13,7 +14,6 @@ import net.consensys.decodeHex import net.consensys.encodeHex import net.consensys.zkevm.coordinator.clients.BlobCompressionProof import net.consensys.zkevm.coordinator.clients.BlobCompressionProofRequest -import net.consensys.zkevm.domain.BlockIntervals internal class ByteArrayDeserializer : JsonDeserializer() { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ByteArray { diff --git a/coordinator/clients/prover-client/serialization/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobCompressionProofJsonResponseTest.kt b/coordinator/clients/prover-client/serialization/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobCompressionProofJsonResponseTest.kt index 5d0a01be9..334d01a52 100644 --- a/coordinator/clients/prover-client/serialization/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobCompressionProofJsonResponseTest.kt +++ b/coordinator/clients/prover-client/serialization/src/test/kotlin/net/consensys/zkevm/coordinator/clients/prover/serialization/BlobCompressionProofJsonResponseTest.kt @@ -1,7 +1,7 @@ package net.consensys.zkevm.coordinator.clients.prover.serialization +import build.linea.domain.BlockIntervals import net.consensys.zkevm.coordinator.clients.prover.serialization.JsonSerialization.proofResponseMapperV1 -import net.consensys.zkevm.domain.BlockIntervals import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BatchExecutionProverRequestResponse.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BatchExecutionProverRequestResponse.kt index 900827efd..97ecfc618 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BatchExecutionProverRequestResponse.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BatchExecutionProverRequestResponse.kt @@ -1,6 +1,6 @@ package net.consensys.zkevm.coordinator.clients -import net.consensys.zkevm.domain.BlockInterval +import build.linea.domain.BlockInterval import net.consensys.zkevm.toULong import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1 diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BlobCompressionProverRequestResponse.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BlobCompressionProverRequestResponse.kt index a2dc06ca6..2bf32a247 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BlobCompressionProverRequestResponse.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/coordinator/clients/BlobCompressionProverRequestResponse.kt @@ -1,7 +1,7 @@ package net.consensys.zkevm.coordinator.clients -import net.consensys.zkevm.domain.BlockInterval -import net.consensys.zkevm.domain.BlockIntervals +import build.linea.domain.BlockInterval +import build.linea.domain.BlockIntervals import net.consensys.zkevm.domain.ConflationCalculationResult import net.consensys.zkevm.ethereum.coordination.blob.ShnarfResult diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Aggregation.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Aggregation.kt index 90f765de5..417ff331a 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Aggregation.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Aggregation.kt @@ -1,8 +1,10 @@ package net.consensys.zkevm.domain +import build.linea.domain.BlockInterval +import build.linea.domain.BlockIntervals import kotlinx.datetime.Instant -typealias BlobsToAggregate = BlockIntervalData +typealias BlobsToAggregate = BlockInterval /** * Represents an Aggregation request to the Prover diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Blob.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Blob.kt index aee335bf6..7bd83f835 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Blob.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Blob.kt @@ -1,5 +1,7 @@ package net.consensys.zkevm.domain +import build.linea.domain.BlockInterval +import build.linea.domain.BlockIntervals import kotlinx.datetime.Instant import net.consensys.linea.CommonDomainFunctions import net.consensys.zkevm.coordinator.clients.BlobCompressionProof diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Conflation.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Conflation.kt index 70bf2dd47..2a3f6fd51 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Conflation.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/Conflation.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.domain +import build.linea.domain.BlockInterval import kotlinx.datetime.Instant import net.consensys.isSortedBy import net.consensys.linea.CommonDomainFunctions @@ -7,50 +8,6 @@ import net.consensys.linea.traces.TracesCounters import net.consensys.zkevm.toULong import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1 -/** - * Represents a block interval, with inclusive start and end block numbers - * @property startBlockNumber start block number, inclusive - * @property endBlockNumber end block number, inclusive - */ -interface BlockInterval { - val startBlockNumber: ULong - val endBlockNumber: ULong - val blocksRange: ULongRange - get() = startBlockNumber..endBlockNumber - fun intervalString(): String = CommonDomainFunctions.blockIntervalString(startBlockNumber, endBlockNumber) - - companion object { - fun between( - startBlockNumber: ULong, - endBlockNumber: ULong - ): BlockInterval { - return BlockIntervalData(startBlockNumber, endBlockNumber) - } - } -} - -fun List.toBlockIntervalsString(): String { - return this.joinToString( - separator = ", ", - prefix = "[", - postfix = "]$size", - transform = BlockInterval::intervalString - ) -} - -fun List.filterOutWithEndBlockNumberBefore( - endBlockNumberInclusive: ULong -): List { - return this.filter { int -> int.endBlockNumber > endBlockNumberInclusive } -} - -fun assertConsecutiveIntervals(intervals: List) { - require(intervals.isSortedBy { it.startBlockNumber }) { "Intervals must be sorted by startBlockNumber" } - require(intervals.zipWithNext().all { (a, b) -> a.endBlockNumber + 1u == b.startBlockNumber }) { - "Intervals must be consecutive: intervals=${intervals.toBlockIntervalsString()}" - } -} - data class BlocksConflation( val blocks: List, val conflationResult: ConflationCalculationResult @@ -148,52 +105,3 @@ data class BlockCounters( "blockRLPEncoded=${blockRLPEncoded.size}bytes)" } } - -/** - * Represents a block interval - * @property startBlockNumber starting block number inclusive - * @property endBlockNumber ending block number inclusive - */ -data class BlockIntervalData( - override val startBlockNumber: ULong, - override val endBlockNumber: ULong -) : BlockInterval - -/** - * Data class that represents sequential blocks intervals for either Conflations, Blobs or Aggregations. - * Example: - * conflations: [100..110], [111..120], [121..130] --> BlockIntervals(100, [110, 120, 130]) - * Blobs with - * Blob1 2 conflations above: [100..110], [111..120] - * Blob2 1 conflations: [121..130] - * --> BlockIntervals(100, [120, 130]) - */ -data class BlockIntervals( - val startingBlockNumber: ULong, - val upperBoundaries: List -) { - // This default constructor is to avoid the parse error when deserializing - constructor() : this(0UL, listOf()) - - fun toIntervalList(): List { - var previousBlockNumber = startingBlockNumber - val intervals = mutableListOf() - upperBoundaries.forEach { - intervals.add(BlockIntervalData(previousBlockNumber, it)) - previousBlockNumber = it + 1u - } - return intervals - } - - fun toBlockInterval(): BlockInterval { - return BlockIntervalData(startingBlockNumber, upperBoundaries.last()) - } -} - -fun List.toBlockIntervals(): BlockIntervals { - require(isNotEmpty()) { "BlockIntervals list must not be empty" } - return BlockIntervals( - startingBlockNumber = first().startBlockNumber, - upperBoundaries = map { it.endBlockNumber } - ) -} diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/ProofIndex.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/ProofIndex.kt index e6130f88c..bdd1b408b 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/ProofIndex.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/domain/ProofIndex.kt @@ -1,5 +1,7 @@ package net.consensys.zkevm.domain +import build.linea.domain.BlockInterval + data class ProofIndex( override val startBlockNumber: ULong, override val endBlockNumber: ULong, diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/AggregationTriggerCalculatorByTargetBlockNumbers.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/AggregationTriggerCalculatorByTargetBlockNumbers.kt index 0c711fde6..865f60b62 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/AggregationTriggerCalculatorByTargetBlockNumbers.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/AggregationTriggerCalculatorByTargetBlockNumbers.kt @@ -1,8 +1,8 @@ package net.consensys.zkevm.ethereum.coordination.aggregation +import build.linea.domain.BlockInterval import net.consensys.zkevm.domain.BlobCounters import net.consensys.zkevm.domain.BlobsToAggregate -import net.consensys.zkevm.domain.BlockInterval import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorService.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorService.kt index f093b6b37..f12a90350 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorService.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorService.kt @@ -1,5 +1,7 @@ package net.consensys.zkevm.ethereum.coordination.aggregation +import build.linea.domain.BlockIntervals +import build.linea.domain.toBlockIntervalsString import io.vertx.core.Vertx import kotlinx.datetime.Clock import net.consensys.linea.metrics.MetricsFacade @@ -10,10 +12,8 @@ import net.consensys.zkevm.coordinator.clients.ProofAggregationProverClientV2 import net.consensys.zkevm.domain.Aggregation import net.consensys.zkevm.domain.BlobAndBatchCounters import net.consensys.zkevm.domain.BlobsToAggregate -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ProofIndex import net.consensys.zkevm.domain.ProofsToAggregate -import net.consensys.zkevm.domain.toBlockIntervalsString import net.consensys.zkevm.ethereum.coordination.blockcreation.SafeBlockProvider import net.consensys.zkevm.persistence.AggregationsRepository import org.apache.logging.log4j.LogManager diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinator.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinator.kt index bda75ba7a..ae05a29cb 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinator.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinator.kt @@ -1,5 +1,8 @@ package net.consensys.zkevm.ethereum.coordination.blob +import build.linea.domain.BlockInterval +import build.linea.domain.BlockIntervals +import build.linea.domain.toBlockIntervalsString import io.vertx.core.Handler import io.vertx.core.Vertx import kotlinx.datetime.Instant @@ -11,10 +14,7 @@ import net.consensys.zkevm.coordinator.clients.BlobCompressionProverClientV2 import net.consensys.zkevm.domain.Blob import net.consensys.zkevm.domain.BlobRecord import net.consensys.zkevm.domain.BlobStatus -import net.consensys.zkevm.domain.BlockInterval -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ConflationCalculationResult -import net.consensys.zkevm.domain.toBlockIntervalsString import net.consensys.zkevm.ethereum.coordination.conflation.BlobCreationHandler import net.consensys.zkevm.persistence.BlobsRepository import org.apache.logging.log4j.LogManager diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofHandler.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofHandler.kt index 62c7426e2..9b95f5de9 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofHandler.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofHandler.kt @@ -1,7 +1,7 @@ package net.consensys.zkevm.ethereum.coordination.blob +import build.linea.domain.BlockInterval import net.consensys.zkevm.coordinator.clients.BlobCompressionProof -import net.consensys.zkevm.domain.BlockInterval import tech.pegasys.teku.infrastructure.async.SafeFuture data class BlobCompressionProofUpdate( diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobShnarfCalulator.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobShnarfCalulator.kt index 27344a3eb..9350bea78 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobShnarfCalulator.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobShnarfCalulator.kt @@ -1,11 +1,11 @@ package net.consensys.zkevm.ethereum.coordination.blob +import build.linea.domain.BlockIntervals import net.consensys.decodeHex import net.consensys.encodeHex import net.consensys.linea.blob.GoNativeBlobShnarfCalculator import net.consensys.linea.blob.GoNativeShnarfCalculatorFactory import net.consensys.linea.blob.ShnarfCalculatorVersion -import net.consensys.zkevm.domain.BlockIntervals import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger import java.util.Base64 diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculator.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculator.kt index 62d44bd55..954743e0f 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculator.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculator.kt @@ -1,5 +1,7 @@ package net.consensys.zkevm.ethereum.coordination.blob +import build.linea.domain.BlockInterval +import build.linea.domain.BlockIntervals import com.github.michaelbull.result.getOrThrow import com.github.michaelbull.result.map import com.github.michaelbull.result.onSuccess @@ -7,8 +9,6 @@ import com.github.michaelbull.result.recover import com.github.michaelbull.result.runCatching import net.consensys.encodeHex import net.consensys.zkevm.domain.BlobRecord -import net.consensys.zkevm.domain.BlockInterval -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.persistence.BlobsRepository import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger diff --git a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/GlobalBlobAwareConflationCalculator.kt b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/GlobalBlobAwareConflationCalculator.kt index faf5f3318..912ee571d 100644 --- a/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/GlobalBlobAwareConflationCalculator.kt +++ b/coordinator/core/src/main/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/GlobalBlobAwareConflationCalculator.kt @@ -1,11 +1,11 @@ package net.consensys.zkevm.ethereum.coordination.conflation +import build.linea.domain.toBlockIntervalsString import net.consensys.linea.CommonDomainFunctions.blockIntervalString import net.consensys.zkevm.domain.Blob import net.consensys.zkevm.domain.BlockCounters import net.consensys.zkevm.domain.ConflationCalculationResult import net.consensys.zkevm.domain.ConflationTrigger -import net.consensys.zkevm.domain.toBlockIntervalsString import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger import tech.pegasys.teku.infrastructure.async.SafeFuture diff --git a/coordinator/core/src/test/kotlin/net/consensys/zkevm/coordination/blob/GoBackedCalculateShnarfCalculatorTest.kt b/coordinator/core/src/test/kotlin/net/consensys/zkevm/coordination/blob/GoBackedCalculateShnarfCalculatorTest.kt index b7eb3890e..b1db17fc0 100644 --- a/coordinator/core/src/test/kotlin/net/consensys/zkevm/coordination/blob/GoBackedCalculateShnarfCalculatorTest.kt +++ b/coordinator/core/src/test/kotlin/net/consensys/zkevm/coordination/blob/GoBackedCalculateShnarfCalculatorTest.kt @@ -1,10 +1,10 @@ package net.consensys.zkevm.coordination.blob +import build.linea.domain.BlockIntervals import net.consensys.decodeHex import net.consensys.encodeHex import net.consensys.linea.blob.CalculateShnarfResult import net.consensys.linea.blob.GoNativeBlobShnarfCalculator -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.ethereum.coordination.blob.GoBackedBlobShnarfCalculator import net.consensys.zkevm.ethereum.coordination.blob.ShnarfResult import org.apache.tuweni.bytes.Bytes32 diff --git a/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorServiceTest.kt b/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorServiceTest.kt index 7782b7ba7..4698897bd 100644 --- a/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorServiceTest.kt +++ b/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/aggregation/ProofAggregationCoordinatorServiceTest.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.ethereum.coordination.aggregation +import build.linea.domain.BlockIntervals import io.vertx.core.Vertx import kotlinx.datetime.Clock import kotlinx.datetime.Instant @@ -9,7 +10,6 @@ import net.consensys.zkevm.domain.Aggregation import net.consensys.zkevm.domain.BlobAndBatchCounters import net.consensys.zkevm.domain.BlobCounters import net.consensys.zkevm.domain.BlobsToAggregate -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ProofIndex import net.consensys.zkevm.domain.ProofToFinalize import net.consensys.zkevm.domain.ProofsToAggregate diff --git a/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculatorTest.kt b/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculatorTest.kt index 29db3eed4..cb7faf0a0 100644 --- a/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculatorTest.kt +++ b/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/blob/RollingBlobShnarfCalculatorTest.kt @@ -1,7 +1,7 @@ package net.consensys.zkevm.ethereum.coordination.blob +import build.linea.domain.BlockIntervals import net.consensys.zkevm.domain.BlobRecord -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.persistence.BlobsRepository import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach diff --git a/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/BlockToBatchSubmissionCoordinatorTest.kt b/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/BlockToBatchSubmissionCoordinatorTest.kt index 2ebc290df..17451a100 100644 --- a/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/BlockToBatchSubmissionCoordinatorTest.kt +++ b/coordinator/core/src/test/kotlin/net/consensys/zkevm/ethereum/coordination/conflation/BlockToBatchSubmissionCoordinatorTest.kt @@ -24,7 +24,7 @@ import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import tech.pegasys.teku.ethereum.executionclient.schema.randomExecutionPayload import tech.pegasys.teku.infrastructure.async.SafeFuture -import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds import kotlin.time.toJavaDuration @ExtendWith(VertxExtension::class) @@ -79,7 +79,7 @@ class BlockToBatchSubmissionCoordinatorTest { val captor = argumentCaptor() Assertions.assertThat(blockToBatchSubmissionCoordinator.acceptBlock(baseBlock)).isCompleted - Awaitility.await().atMost(200.milliseconds.toJavaDuration()) + Awaitility.await().atMost(1.seconds.toJavaDuration()) .untilAsserted { verify(testLogger, times(1)).error( eq("Failed to conflate block={} errorMessage={}"), diff --git a/coordinator/core/src/testFixtures/kotlin/net/consensys/zkevm/domain/BlobRecord.kt b/coordinator/core/src/testFixtures/kotlin/net/consensys/zkevm/domain/BlobRecord.kt index 97c7c4b8d..226309458 100644 --- a/coordinator/core/src/testFixtures/kotlin/net/consensys/zkevm/domain/BlobRecord.kt +++ b/coordinator/core/src/testFixtures/kotlin/net/consensys/zkevm/domain/BlobRecord.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.domain +import build.linea.domain.BlockIntervals import kotlinx.datetime.Clock import kotlinx.datetime.Instant import net.consensys.linea.blob.ShnarfCalculatorVersion diff --git a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinator.kt b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinator.kt index 8ea0e8c3b..29d63f93d 100644 --- a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinator.kt +++ b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinator.kt @@ -1,5 +1,8 @@ package net.consensys.zkevm.ethereum.submission +import build.linea.domain.filterOutWithEndBlockNumberBefore +import build.linea.domain.toBlockIntervals +import build.linea.domain.toBlockIntervalsString import io.vertx.core.Vertx import kotlinx.datetime.Clock import net.consensys.linea.async.AsyncFilter @@ -9,9 +12,6 @@ import net.consensys.zkevm.coordinator.clients.smartcontract.LineaRollupSmartCon import net.consensys.zkevm.domain.Aggregation import net.consensys.zkevm.domain.BlobRecord import net.consensys.zkevm.domain.ProofToFinalize -import net.consensys.zkevm.domain.filterOutWithEndBlockNumberBefore -import net.consensys.zkevm.domain.toBlockIntervals -import net.consensys.zkevm.domain.toBlockIntervalsString import net.consensys.zkevm.ethereum.gaspricing.GasPriceCapProvider import net.consensys.zkevm.persistence.AggregationsRepository import net.consensys.zkevm.persistence.BlobsRepository diff --git a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelper.kt b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelper.kt index a3b42c042..792fea54e 100644 --- a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelper.kt +++ b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelper.kt @@ -1,9 +1,9 @@ package net.consensys.zkevm.ethereum.submission -import net.consensys.zkevm.domain.BlockInterval -import net.consensys.zkevm.domain.BlockIntervals -import net.consensys.zkevm.domain.assertConsecutiveIntervals -import net.consensys.zkevm.domain.toBlockIntervalsString +import build.linea.domain.BlockInterval +import build.linea.domain.BlockIntervals +import build.linea.domain.assertConsecutiveIntervals +import build.linea.domain.toBlockIntervalsString import org.apache.logging.log4j.Logger import kotlin.math.min diff --git a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmitterAsEIP4844MultipleBlobsPerTx.kt b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmitterAsEIP4844MultipleBlobsPerTx.kt index bc46ae570..2c8a920bf 100644 --- a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmitterAsEIP4844MultipleBlobsPerTx.kt +++ b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmitterAsEIP4844MultipleBlobsPerTx.kt @@ -1,8 +1,8 @@ package net.consensys.zkevm.ethereum.submission +import build.linea.domain.toBlockIntervalsString import net.consensys.zkevm.coordinator.clients.smartcontract.LineaRollupSmartContractClient import net.consensys.zkevm.domain.BlobRecord -import net.consensys.zkevm.domain.toBlockIntervalsString import net.consensys.zkevm.ethereum.gaspricing.GasPriceCapProvider import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger diff --git a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobsGrouperForSubmission.kt b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobsGrouperForSubmission.kt index 59132767c..1fe37f605 100644 --- a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobsGrouperForSubmission.kt +++ b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/BlobsGrouperForSubmission.kt @@ -1,7 +1,7 @@ package net.consensys.zkevm.ethereum.submission +import build.linea.domain.BlockIntervals import net.consensys.zkevm.domain.BlobRecord -import net.consensys.zkevm.domain.BlockIntervals fun interface BlobsGrouperForSubmission { fun chunkBlobs( diff --git a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/ContractUpgradeSubmissionLatchFilter.kt b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/ContractUpgradeSubmissionLatchFilter.kt index 61fb6ba26..a3710ea08 100644 --- a/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/ContractUpgradeSubmissionLatchFilter.kt +++ b/coordinator/ethereum/blob-submitter/src/main/kotlin/net/consensys/zkevm/ethereum/submission/ContractUpgradeSubmissionLatchFilter.kt @@ -1,9 +1,9 @@ package net.consensys.zkevm.ethereum.submission +import build.linea.domain.BlockInterval import net.consensys.linea.async.AsyncFilter import net.consensys.zkevm.coordinator.clients.smartcontract.ContractVersionProvider import net.consensys.zkevm.coordinator.clients.smartcontract.LineaContractVersion -import net.consensys.zkevm.domain.BlockInterval import org.apache.logging.log4j.LogManager import tech.pegasys.teku.infrastructure.async.SafeFuture import java.util.concurrent.atomic.AtomicBoolean diff --git a/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinatorTest.kt b/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinatorTest.kt index ae36c1c0a..bdb155097 100644 --- a/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinatorTest.kt +++ b/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionCoordinatorTest.kt @@ -1,15 +1,15 @@ package net.consensys.zkevm.ethereum.submission +import build.linea.domain.BlockIntervals +import build.linea.domain.toBlockIntervals import io.vertx.core.Vertx import net.consensys.FakeFixedClock import net.consensys.linea.async.AsyncFilter import net.consensys.zkevm.coordinator.clients.smartcontract.BlockAndNonce import net.consensys.zkevm.coordinator.clients.smartcontract.LineaRollupSmartContractClient import net.consensys.zkevm.domain.BlobRecord -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.createAggregation import net.consensys.zkevm.domain.createBlobRecords -import net.consensys.zkevm.domain.toBlockIntervals import net.consensys.zkevm.persistence.AggregationsRepository import net.consensys.zkevm.persistence.BlobsRepository import org.apache.logging.log4j.LogManager diff --git a/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelperKtTest.kt b/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelperKtTest.kt index 055c543b8..6b9b5d602 100644 --- a/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelperKtTest.kt +++ b/coordinator/ethereum/blob-submitter/src/test/kotlin/net/consensys/zkevm/ethereum/submission/BlobSubmissionHelperKtTest.kt @@ -1,7 +1,7 @@ package net.consensys.zkevm.ethereum.submission -import net.consensys.zkevm.domain.BlockIntervalData -import net.consensys.zkevm.domain.BlockIntervals +import build.linea.domain.BlockIntervalData +import build.linea.domain.BlockIntervals import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/coordinator/persistence/aggregation/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/aggregation/AggregationsPostgresDaoTest.kt b/coordinator/persistence/aggregation/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/aggregation/AggregationsPostgresDaoTest.kt index e0e439292..4fe0878e6 100644 --- a/coordinator/persistence/aggregation/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/aggregation/AggregationsPostgresDaoTest.kt +++ b/coordinator/persistence/aggregation/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/aggregation/AggregationsPostgresDaoTest.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.persistence.dao.aggregation +import build.linea.domain.BlockIntervals import io.vertx.junit5.VertxExtension import io.vertx.sqlclient.Row import io.vertx.sqlclient.RowSet @@ -15,7 +16,6 @@ import net.consensys.zkevm.domain.BlobAndBatchCounters import net.consensys.zkevm.domain.BlobCounters import net.consensys.zkevm.domain.BlobRecord import net.consensys.zkevm.domain.BlobStatus -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ProofToFinalize import net.consensys.zkevm.domain.createAggregation import net.consensys.zkevm.domain.createBatch diff --git a/coordinator/persistence/aggregation/src/main/kotlin/net/consensys/zkevm/persistence/dao/aggregation/PostgresAggregationsDao.kt b/coordinator/persistence/aggregation/src/main/kotlin/net/consensys/zkevm/persistence/dao/aggregation/PostgresAggregationsDao.kt index c900f2753..6b5ccba9a 100644 --- a/coordinator/persistence/aggregation/src/main/kotlin/net/consensys/zkevm/persistence/dao/aggregation/PostgresAggregationsDao.kt +++ b/coordinator/persistence/aggregation/src/main/kotlin/net/consensys/zkevm/persistence/dao/aggregation/PostgresAggregationsDao.kt @@ -1,5 +1,7 @@ package net.consensys.zkevm.persistence.dao.aggregation +import build.linea.domain.BlockIntervals +import build.linea.domain.toBlockIntervalsString import io.vertx.core.Future import io.vertx.pgclient.PgException import io.vertx.sqlclient.Row @@ -13,9 +15,7 @@ import net.consensys.zkevm.coordinator.clients.prover.serialization.ProofToFinal import net.consensys.zkevm.domain.Aggregation import net.consensys.zkevm.domain.BlobAndBatchCounters import net.consensys.zkevm.domain.BlobCounters -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ProofToFinalize -import net.consensys.zkevm.domain.toBlockIntervalsString import net.consensys.zkevm.persistence.db.DuplicatedRecordException import net.consensys.zkevm.persistence.db.SQLQueryLogger import org.apache.logging.log4j.Level diff --git a/coordinator/persistence/aggregation/src/test/kotlin/net/consensys/zkevm/persistence/dao/aggregation/RetryingPostgresAggregationsDaoTest.kt b/coordinator/persistence/aggregation/src/test/kotlin/net/consensys/zkevm/persistence/dao/aggregation/RetryingPostgresAggregationsDaoTest.kt index 3a706901e..7fc455d11 100644 --- a/coordinator/persistence/aggregation/src/test/kotlin/net/consensys/zkevm/persistence/dao/aggregation/RetryingPostgresAggregationsDaoTest.kt +++ b/coordinator/persistence/aggregation/src/test/kotlin/net/consensys/zkevm/persistence/dao/aggregation/RetryingPostgresAggregationsDaoTest.kt @@ -1,12 +1,12 @@ package net.consensys.zkevm.persistence.dao.aggregation +import build.linea.domain.BlockIntervals import io.vertx.core.Vertx import io.vertx.junit5.VertxExtension import kotlinx.datetime.Instant import net.consensys.FakeFixedClock import net.consensys.zkevm.domain.Aggregation import net.consensys.zkevm.domain.BlobAndBatchCounters -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.blobCounters import net.consensys.zkevm.domain.createAggregation import net.consensys.zkevm.domain.createProofToFinalize diff --git a/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinatorIntTest.kt b/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinatorIntTest.kt index 390c04d10..a38cc1fb1 100644 --- a/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinatorIntTest.kt +++ b/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/ethereum/coordination/blob/BlobCompressionProofCoordinatorIntTest.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.ethereum.coordination.blob +import build.linea.domain.BlockIntervals import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.github.michaelbull.result.Ok @@ -15,7 +16,6 @@ import net.consensys.zkevm.coordinator.clients.BlobCompressionProverClientV2 import net.consensys.zkevm.coordinator.clients.GetZkEVMStateMerkleProofResponse import net.consensys.zkevm.coordinator.clients.Type2StateManagerClient import net.consensys.zkevm.domain.Blob -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ConflationCalculationResult import net.consensys.zkevm.domain.ConflationTrigger import net.consensys.zkevm.domain.createBlobRecord diff --git a/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/blob/BlobsPostgresDaoTest.kt b/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/blob/BlobsPostgresDaoTest.kt index b65fe6966..c5e20c028 100644 --- a/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/blob/BlobsPostgresDaoTest.kt +++ b/coordinator/persistence/blob/src/integrationTest/kotlin/net/consensys/zkevm/persistence/dao/blob/BlobsPostgresDaoTest.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.persistence.dao.blob +import build.linea.domain.BlockIntervals import io.vertx.junit5.VertxExtension import io.vertx.sqlclient.PreparedQuery import io.vertx.sqlclient.Row @@ -14,7 +15,6 @@ import net.consensys.trimToSecondPrecision import net.consensys.zkevm.coordinator.clients.BlobCompressionProof import net.consensys.zkevm.domain.BlobRecord import net.consensys.zkevm.domain.BlobStatus -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.createBlobRecord import net.consensys.zkevm.persistence.db.DbHelper import net.consensys.zkevm.persistence.db.DuplicatedRecordException diff --git a/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/ethereum/coordinator/blob/BlobCompressionProofCoordinatorTest.kt b/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/ethereum/coordinator/blob/BlobCompressionProofCoordinatorTest.kt index cdcd2e0ac..416356d30 100644 --- a/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/ethereum/coordinator/blob/BlobCompressionProofCoordinatorTest.kt +++ b/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/ethereum/coordinator/blob/BlobCompressionProofCoordinatorTest.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.ethereum.coordinator.blob +import build.linea.domain.BlockIntervals import io.vertx.core.Vertx import io.vertx.junit5.VertxExtension import net.consensys.FakeFixedClock @@ -8,7 +9,6 @@ import net.consensys.zkevm.coordinator.clients.BlobCompressionProof import net.consensys.zkevm.coordinator.clients.BlobCompressionProofRequest import net.consensys.zkevm.coordinator.clients.BlobCompressionProverClientV2 import net.consensys.zkevm.domain.Blob -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.ConflationCalculationResult import net.consensys.zkevm.domain.ConflationTrigger import net.consensys.zkevm.ethereum.coordination.blob.BlobCompressionProofCoordinator diff --git a/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/persistence/dao/blob/RetryingBlobsPostgresDaoTest.kt b/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/persistence/dao/blob/RetryingBlobsPostgresDaoTest.kt index 2e663249d..1339ff8ad 100644 --- a/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/persistence/dao/blob/RetryingBlobsPostgresDaoTest.kt +++ b/coordinator/persistence/blob/src/test/kotlin/net/consensys/zkevm/persistence/dao/blob/RetryingBlobsPostgresDaoTest.kt @@ -1,5 +1,6 @@ package net.consensys.zkevm.persistence.dao.blob +import build.linea.domain.BlockIntervals import io.vertx.core.Vertx import io.vertx.junit5.VertxExtension import net.consensys.FakeFixedClock @@ -7,7 +8,6 @@ import net.consensys.setFirstByteToZero import net.consensys.trimToSecondPrecision import net.consensys.zkevm.coordinator.clients.BlobCompressionProof import net.consensys.zkevm.domain.BlobStatus -import net.consensys.zkevm.domain.BlockIntervals import net.consensys.zkevm.domain.createBlobRecord import net.consensys.zkevm.persistence.db.PersistenceRetryer import org.junit.jupiter.api.BeforeEach diff --git a/jvm-libs/generic/extensions/kotlin/src/main/kotlin/build/linea/UrlExtensions.kt b/jvm-libs/generic/extensions/kotlin/src/main/kotlin/build/linea/UrlExtensions.kt new file mode 100644 index 000000000..30a5e0f8e --- /dev/null +++ b/jvm-libs/generic/extensions/kotlin/src/main/kotlin/build/linea/UrlExtensions.kt @@ -0,0 +1,16 @@ +package build.linea + +import java.net.URI + +fun URI.getPortWithSchemaDefaults(): Int { + return if (port != -1) { + port + } else { + when (scheme.lowercase()) { + "http" -> 80 + "https" -> 443 + // Focous on HTTP as it what we need for now + else -> throw IllegalArgumentException("Unsupported scheme: $scheme") + } + } +} diff --git a/jvm-libs/linea/core/domain-models/src/main/kotlin/build/linea/domain/BlockInterval.kt b/jvm-libs/linea/core/domain-models/src/main/kotlin/build/linea/domain/BlockInterval.kt new file mode 100644 index 000000000..62a06ebc8 --- /dev/null +++ b/jvm-libs/linea/core/domain-models/src/main/kotlin/build/linea/domain/BlockInterval.kt @@ -0,0 +1,126 @@ +package build.linea.domain + +import net.consensys.isSortedBy +import net.consensys.linea.CommonDomainFunctions + +/** + * Represents a block interval, with inclusive start and end block numbers + * @property startBlockNumber start block number, inclusive + * @property endBlockNumber end block number, inclusive + */ +interface BlockInterval { + val startBlockNumber: ULong + val endBlockNumber: ULong + val blocksRange: ULongRange + get() = startBlockNumber..endBlockNumber + + fun intervalString(): String = CommonDomainFunctions.blockIntervalString(startBlockNumber, endBlockNumber) + + companion object { + operator fun invoke( + startBlockNumber: ULong, + endBlockNumber: ULong + ): BlockInterval { + return BlockIntervalData(startBlockNumber, endBlockNumber) + } + + operator fun invoke( + startBlockNumber: Number, + endBlockNumber: Number + ): BlockInterval { + assert(startBlockNumber.toLong() >= 0 && endBlockNumber.toLong() >= 0) { + "startBlockNumber=${startBlockNumber.toLong()} and " + + "endBlockNumber=${endBlockNumber.toLong()} must be non-negative!" + } + return BlockIntervalData(startBlockNumber.toLong().toULong(), endBlockNumber.toLong().toULong()) + } + + // Todo: remove later + /** + * Please use BlockInterval(startBlockNumber, endBlockNumber) instead + */ + fun between( + startBlockNumber: ULong, + endBlockNumber: ULong + ): BlockInterval { + return BlockIntervalData(startBlockNumber, endBlockNumber) + } + } +} + +/** + * Represents a block interval + * @property startBlockNumber starting block number inclusive + * @property endBlockNumber ending block number inclusive + */ +data class BlockIntervalData( + override val startBlockNumber: ULong, + override val endBlockNumber: ULong +) : BlockInterval { + init { + require(startBlockNumber <= endBlockNumber) { + "startBlockNumber=$startBlockNumber must be less than or equal to endBlockNumber$endBlockNumber" + } + } +} + +fun List.toBlockIntervalsString(): String { + return this.joinToString( + separator = ", ", + prefix = "[", + postfix = "]$size", + transform = BlockInterval::intervalString + ) +} + +fun List.filterOutWithEndBlockNumberBefore( + endBlockNumberInclusive: ULong +): List { + return this.filter { int -> int.endBlockNumber > endBlockNumberInclusive } +} + +fun assertConsecutiveIntervals(intervals: List) { + require(intervals.isSortedBy { it.startBlockNumber }) { "Intervals must be sorted by startBlockNumber" } + require(intervals.zipWithNext().all { (a, b) -> a.endBlockNumber + 1u == b.startBlockNumber }) { + "Intervals must be consecutive: intervals=${intervals.toBlockIntervalsString()}" + } +} + +/** + * Data class that represents sequential blocks intervals for either Conflations, Blobs or Aggregations. + * Example: + * conflations: [100..110], [111..120], [121..130] --> BlockIntervals(100, [110, 120, 130]) + * Blobs with + * Blob1 2 conflations above: [100..110], [111..120] + * Blob2 1 conflations: [121..130] + * --> BlockIntervals(100, [120, 130]) + */ +data class BlockIntervals( + val startingBlockNumber: ULong, + val upperBoundaries: List +) { + // This default constructor is to avoid the parse error when deserializing + constructor() : this(0UL, listOf()) + + fun toIntervalList(): List { + var previousBlockNumber = startingBlockNumber + val intervals = mutableListOf() + upperBoundaries.forEach { + intervals.add(BlockIntervalData(previousBlockNumber, it)) + previousBlockNumber = it + 1u + } + return intervals + } + + fun toBlockInterval(): BlockInterval { + return BlockIntervalData(startingBlockNumber, upperBoundaries.last()) + } +} + +fun List.toBlockIntervals(): BlockIntervals { + require(isNotEmpty()) { "BlockIntervals list must not be empty" } + return BlockIntervals( + startingBlockNumber = first().startBlockNumber, + upperBoundaries = map { it.endBlockNumber } + ) +} diff --git a/coordinator/core/src/test/kotlin/net/consensys/zkevm/domain/BlockIntervalsTest.kt b/jvm-libs/linea/core/domain-models/src/test/kotlin/build/linea/domain/BlockIntervalsTest.kt similarity index 98% rename from coordinator/core/src/test/kotlin/net/consensys/zkevm/domain/BlockIntervalsTest.kt rename to jvm-libs/linea/core/domain-models/src/test/kotlin/build/linea/domain/BlockIntervalsTest.kt index 4fd73b46d..f76d706e0 100644 --- a/coordinator/core/src/test/kotlin/net/consensys/zkevm/domain/BlockIntervalsTest.kt +++ b/jvm-libs/linea/core/domain-models/src/test/kotlin/build/linea/domain/BlockIntervalsTest.kt @@ -1,4 +1,4 @@ -package net.consensys.zkevm.domain +package build.linea.domain import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test