Skip to content

Commit

Permalink
Remove conflict-checking logic from JdbcLedgerDao [DPP-808] (#12555)
Browse files Browse the repository at this point in the history
* Remove conflict-checking logic from JdbcLedgerDao

changelog_begin
changelog_end

* Remove configuration conflict-checking logic and testing

changelog_begin
changelog_end

* Addressed review comments
* Removed one metric
* Removed Rejections transformation used in sandbox-classic and unit tests
  • Loading branch information
tudor-da authored Jan 27, 2022
1 parent 4038d0a commit 89ce7d0
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 1,882 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,9 @@ object domain {
override val description: String = "DuplicateKey: contract key is not unique"
}

final case class PartiesNotKnownOnLedger(parties: Set[String]) extends RejectionReason {
override val description: String = "Some parties are unallocated"
}

/** The ledger time of the submission violated some constraint on the ledger time. */
final case class InvalidLedgerTime(description: String) extends RejectionReason

final case class LedgerConfigNotFound(description: String) extends RejectionReason

/** The transaction relied on contracts being active that were no longer
* active at the point where it was sequenced.
*/
Expand Down
5 changes: 0 additions & 5 deletions ledger/metrics/src/main/scala/com/daml/metrics/Metrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ final class Metrics(val registry: MetricRegistry) {
private val Prefix: MetricName = index.Prefix :+ "db"

val storePartyEntry: Timer = registry.timer(Prefix :+ "store_party_entry")
val storeInitialState: Timer = registry.timer(Prefix :+ "store_initial_state")
val storePackageEntry: Timer = registry.timer(Prefix :+ "store_package_entry")

val storeTransaction: Timer = registry.timer(Prefix :+ "store_ledger_entry")
Expand Down Expand Up @@ -473,7 +472,6 @@ final class Metrics(val registry: MetricRegistry) {
val prepareBatches: Timer = registry.timer(dbPrefix :+ "prepare_batches")

// in order within SQL transaction
val commitValidation: Timer = registry.timer(dbPrefix :+ "commit_validation")
val eventsBatch: Timer = registry.timer(dbPrefix :+ "events_batch")
val deleteContractWitnessesBatch: Timer =
registry.timer(dbPrefix :+ "delete_contract_witnesses_batch")
Expand All @@ -490,9 +488,6 @@ final class Metrics(val registry: MetricRegistry) {
val storeRejectionDbMetrics: DatabaseMetrics = createDbMetrics(
"store_rejection"
) // FIXME Base name conflicts with storeRejection
val storeInitialStateFromScenario: DatabaseMetrics = createDbMetrics(
"store_initial_state_from_scenario"
)
val loadParties: DatabaseMetrics = createDbMetrics("load_parties")
val loadAllParties: DatabaseMetrics = createDbMetrics("load_all_parties")
val loadPackages: DatabaseMetrics = createDbMetrics("load_packages")
Expand Down
1 change: 0 additions & 1 deletion ledger/participant-integration-api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ compile_deps = [
"//libs-scala/build-info",
"//libs-scala/contextualized-logging",
"//libs-scala/concurrent",
"//libs-scala/grpc-utils",
"//libs-scala/logging-entries",
"//libs-scala/ports",
"//libs-scala/resources",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,18 @@ package com.daml.platform.store

import anorm.Column.nonNull
import anorm._
import com.daml.error.ContextualizedErrorLogger
import com.daml.error.definitions.LedgerApiErrors
import com.daml.grpc.GrpcStatus
import com.daml.ledger.api.domain
import com.daml.ledger.offset.Offset
import com.daml.ledger.participant.state.v2.Update.CommandRejected
import com.daml.ledger.participant.state.{v2 => state}
import com.daml.lf.crypto.Hash
import com.daml.lf.data.Ref
import com.daml.lf.ledger.EventId
import com.daml.lf.value.Value
import com.daml.platform.server.api.validation.ErrorFactories
import spray.json.DefaultJsonProtocol._
import spray.json._

import scala.util.Try
import java.io.BufferedReader
import java.sql.{PreparedStatement, SQLNonTransientException, Types}
import java.util.stream.Collectors
import scala.annotation.nowarn
import scala.util.Try

// TODO append-only: split this file on cleanup, and move anorm/db conversion related stuff to the right place

Expand Down Expand Up @@ -390,67 +382,4 @@ private[platform] object Conversions {
override val sqlType: String = ParameterMetaData.StringParameterMetaData.sqlType
override val jdbcType: Int = ParameterMetaData.StringParameterMetaData.jdbcType
}

implicit class RejectionReasonOps(rejectionReason: domain.RejectionReason) {
@nowarn("msg=deprecated")
def toParticipantStateRejectionReason(
errorFactories: ErrorFactories
)(implicit
contextualizedErrorLogger: ContextualizedErrorLogger
): state.Update.CommandRejected.RejectionReasonTemplate =
rejectionReason match {
case domain.RejectionReason.ContractsNotFound(missingContractIds) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.contractsNotFound(missingContractIds)
)
case domain.RejectionReason.Inconsistent(reason) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.inconsistent(reason)
)
case domain.RejectionReason.InconsistentContractKeys(lookupResult, currentResult) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections
.inconsistentContractKeys(lookupResult, currentResult)
)
case rejection @ domain.RejectionReason.DuplicateContractKey(key) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections
.duplicateContractKey(rejection.description, key)
)
case domain.RejectionReason.Disputed(reason) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.Deprecated.disputed(reason)
)
case domain.RejectionReason.OutOfQuota(reason) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.Deprecated.outOfQuota(reason)
)
case domain.RejectionReason.PartiesNotKnownOnLedger(parties) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.partiesNotKnownToLedger(parties)
)
case domain.RejectionReason.PartyNotKnownOnLedger(description) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.partyNotKnownOnLedger(description)
)
case domain.RejectionReason.SubmitterCannotActViaParticipant(reason) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.submitterCannotActViaParticipant(reason)
)
case domain.RejectionReason.InvalidLedgerTime(reason) =>
CommandRejected.FinalReason(
errorFactories.CommandRejections.invalidLedgerTime(reason)
)
case domain.RejectionReason.LedgerConfigNotFound(description) =>
// This rejection is returned only for V2 error codes already so we don't need to
// wrap it in ErrorFactories (see [[com.daml.platform.sandbox.stores.ledger.Rejection.NoLedgerConfiguration]]
CommandRejected.FinalReason(
GrpcStatus.toProto(
LedgerApiErrors.RequestValidation.NotFound.LedgerConfiguration
.RejectWithMessage(description)
.asGrpcStatusFromContext
)
)
}
}
}
Loading

0 comments on commit 89ce7d0

Please sign in to comment.