Skip to content

Commit

Permalink
LF: drop com.daml.lf.transaction.Transaction.Transaction type alias. (#…
Browse files Browse the repository at this point in the history
…11470)

After dropping type parameter from GenTransaction we do not
com.daml.lf.transaction.Transaction.Transaction type alias.  We use
instead directly com.daml.lf.transaction.VersionedTransaction, wich is
anyway more informative.

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
remyhaemmerle-da authored Nov 2, 2021
1 parent 505a7f5 commit f81d880
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.daml.lf.transaction.Node.{
NodeFetch,
NodeLookupByKey,
}
import com.daml.lf.transaction.{BlindingInfo, GenTransaction, NodeId, Transaction}
import com.daml.lf.transaction.{BlindingInfo, GenTransaction, NodeId, VersionedTransaction}
import com.daml.lf.ledger._
import com.daml.lf.data.Relation.Relation

Expand All @@ -29,7 +29,7 @@ object Blinding {
*
* @param tx transaction to be blinded
*/
def blind(tx: Transaction.Transaction): BlindingInfo =
def blind(tx: VersionedTransaction): BlindingInfo =
BlindingTransaction.calculateBlindingInfo(tx)

/** Returns the part of the transaction which has to be divulged to the given party.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.daml.lf.language.Ast._
import com.daml.lf.speedy.{InitialSeeding, PartialTransaction, Pretty, SError, SExpr}
import com.daml.lf.speedy.Speedy.Machine
import com.daml.lf.speedy.SResult._
import com.daml.lf.transaction.{SubmittedTransaction, Transaction => Tx}
import com.daml.lf.transaction.{SubmittedTransaction, VersionedTransaction, Transaction => Tx}
import com.daml.lf.transaction.Node._
import java.nio.file.Files

Expand Down Expand Up @@ -484,7 +484,7 @@ object Engine {
crypto.Hash.deriveTransactionSeed(submissionSeed, participant, submissionTime)
)

private def profileDesc(tx: Tx.Transaction): String = {
private def profileDesc(tx: VersionedTransaction): String = {
if (tx.roots.length == 1) {
val makeDesc = (kind: String, tmpl: Ref.Identifier, extra: Option[String]) =>
s"$kind:${tmpl.qualifiedName.name}${extra.map(extra => s":$extra").getOrElse("")}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,7 @@ object EngineTest {
Validation.isReplayedBy(Normalization.normalizeTx(recorded), replayed)
}

private def suffix(tx: Tx.Transaction) =
private def suffix(tx: VersionedTransaction) =
data.assertRight(tx.suffixCid(_ => dummySuffix))

private[this] case class ReinterpretState(
Expand Down Expand Up @@ -2246,13 +2246,13 @@ object EngineTest {
engine: Engine,
submitters: Set[Party],
nodes: ImmArray[NodeId],
tx: Tx.Transaction,
tx: VersionedTransaction,
txMeta: Tx.Metadata,
ledgerEffectiveTime: Time.Timestamp,
lookupPackages: PackageId => Option[Package],
contracts: Map[ContractId, VersionedContractInstance] = Map.empty,
keys: Map[GlobalKey, ContractId] = Map.empty,
): Either[Error, (Tx.Transaction, Tx.Metadata)] = {
): Either[Error, (VersionedTransaction, Tx.Metadata)] = {

val nodeSeedMap = txMeta.nodeSeeds.toSeq.toMap

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import com.daml.lf.data.Ref._
import com.daml.lf.data.{FrontStack, ImmArray, Ref, Time}
import com.daml.lf.language.Ast
import com.daml.lf.scenario.ScenarioLedger
import com.daml.lf.transaction.SubmittedTransaction
import com.daml.lf.transaction.Transaction.Transaction
import com.daml.lf.transaction.{Node => N, Transaction => Tx}
import com.daml.lf.transaction.{
Node => N,
SubmittedTransaction,
VersionedTransaction,
Transaction => Tx,
}
import com.daml.lf.value.Value
import com.daml.lf.value.Value._
import com.daml.lf.command._
Expand All @@ -41,7 +44,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
submitter: Party,
effectiveAt: Time.Timestamp,
tx: SubmittedTransaction,
): Transaction =
): VersionedTransaction =
ScenarioLedger
.commitTransaction(
actAs = Set(submitter),
Expand Down Expand Up @@ -170,7 +173,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
val ledger = new MutableLedger()
val rangeOfIntsTemplateId = Identifier(largeTx._1, qn("LargeTransaction:RangeOfInts"))
val createCmd = rangeOfIntsCreateCmd(rangeOfIntsTemplateId, 0, 1, num)
val createCmdTx: Transaction =
val createCmdTx: VersionedTransaction =
submitCommand(ledger, engine)(
submitter = party,
cmd = createCmd,
Expand Down Expand Up @@ -201,7 +204,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
val ledger = new MutableLedger()
val listUtilTemplateId = Identifier(largeTx._1, qn("LargeTransaction:ListUtil"))
val createCmd = listUtilCreateCmd(listUtilTemplateId)
val createCmdTx: Transaction =
val createCmdTx: VersionedTransaction =
submitCommand(ledger, engine)(
submitter = party,
cmd = createCmd,
Expand Down Expand Up @@ -229,7 +232,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
private def qn(str: String): QualifiedName = QualifiedName.assertFromString(str)

private def assertOneContractWithManyInts(
exerciseCmdTx: Transaction,
exerciseCmdTx: VersionedTransaction,
expected: List[Long],
): Assertion = {

Expand All @@ -245,7 +248,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
}

private def assertManyContractsOneIntPerContract(
exerciseCmdTx: Transaction,
exerciseCmdTx: VersionedTransaction,
expectedNumberOfContracts: Int,
): Assertion = {

Expand All @@ -266,7 +269,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
cmd: ApiCommand,
cmdReference: String,
seed: crypto.Hash,
): Transaction = {
): VersionedTransaction = {
val effectiveAt = Time.Timestamp.now()
def enrich(tx: SubmittedTransaction): SubmittedTransaction = {
val enricher = new ValueEnricher(engine)
Expand Down Expand Up @@ -348,7 +351,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
}

private def assertSizeExerciseTransaction(
exerciseCmdTx: Transaction,
exerciseCmdTx: VersionedTransaction,
expected: Long,
): Assertion = {

Expand All @@ -364,7 +367,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
}

private def extractResultFieldFromExerciseTransaction(
exerciseCmdTx: Transaction,
exerciseCmdTx: VersionedTransaction,
fieldName: String,
): Value = {

Expand All @@ -388,7 +391,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
}

private def extractResultFromExerciseTransaction(
exerciseCmdTx: Transaction
exerciseCmdTx: VersionedTransaction
): Value = {

exerciseCmdTx.roots.length shouldBe 1
Expand All @@ -405,7 +408,7 @@ class LargeTransactionTest extends AnyWordSpec with Matchers with BazelRunfiles
}
}

private def firstRootNode(tx: Tx.Transaction): Tx.Node = tx.nodes(tx.roots.head)
private def firstRootNode(tx: VersionedTransaction): Tx.Node = tx.nodes(tx.roots.head)

private def measureWithResult[R](body: => R): (R, Quantity[Double]) = {
lazy val result: R = body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.daml.lf.data.Ref.Party
import com.daml.lf.data.Relation.Relation
import com.daml.lf.transaction.BlindingInfo
import com.daml.lf.transaction.Node
import com.daml.lf.transaction.{NodeId, Transaction => Tx}
import com.daml.lf.transaction.{NodeId, VersionedTransaction}
import com.daml.lf.value.Value.ContractId
import com.daml.nameof.NameOf

Expand Down Expand Up @@ -55,7 +55,7 @@ object BlindingTransaction {

/** Calculate blinding information for a transaction. */
def calculateBlindingInfo(
tx: Tx.Transaction
tx: VersionedTransaction
): BlindingInfo = {

val initialParentExerciseWitnesses: Set[Party] = Set.empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.daml.lf.data.Ref.{Identifier, Party}
import com.daml.lf.data.Time
import com.daml.lf.ledger.EventId
import com.daml.lf.speedy.SError.SError
import com.daml.lf.transaction.{GlobalKey, Transaction}
import com.daml.lf.transaction.{GlobalKey, VersionedTransaction}
import com.daml.lf.value.Value.ContractId

import scala.util.control.NoStackTrace
Expand Down Expand Up @@ -67,7 +67,7 @@ object Error {
final case class CommitError(commitError: ScenarioLedger.CommitError) extends Error

/** The transaction produced by the update expression in a 'mustFailAt' succeeded. */
final case class MustFailSucceeded(tx: Transaction.Transaction) extends Error
final case class MustFailSucceeded(tx: VersionedTransaction) extends Error

/** Invalid party name supplied to 'getParty'. */
final case class InvalidPartyName(name: String, msg: String) extends Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package test

import com.daml.lf.data._
import com.daml.lf.language.LanguageVersion
import com.daml.lf.transaction.{Transaction => Tx}
import com.daml.lf.value.Value
import com.daml.lf.value.Value.{ContractId, ContractInstance, VersionedContractInstance}

Expand Down Expand Up @@ -51,7 +50,7 @@ final class TransactionBuilder(pkgTxVersion: Ref.PackageId => TransactionVersion
nodeId
}

def build(): Tx.Transaction = ids.synchronized {
def build(): VersionedTransaction = ids.synchronized {
import TransactionVersion.Ordering
val finalNodes = nodes.transform {
case (nid, rb: TxRollBack) =>
Expand Down Expand Up @@ -226,7 +225,7 @@ object TransactionBuilder {

def newCid: ContractId = newV1Cid

def just(node: Node, nodes: Node*): Tx.Transaction = {
def just(node: Node, nodes: Node*): VersionedTransaction = {
val builder = TransactionBuilder()
val _ = builder.add(node)
for (node <- nodes) {
Expand All @@ -242,7 +241,7 @@ object TransactionBuilder {
CommittedTransaction(just(node, nodes: _*))

// not valid transactions.
val Empty: Tx.Transaction =
val Empty: VersionedTransaction =
VersionedTransaction(
TransactionVersion.minVersion, // A normalized empty tx is V10
HashMap.empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,14 +792,9 @@ object Transaction {
type ActionNode = Node.GenActionNode
type LeafNode = Node.LeafOnlyActionNode

/** (Complete) transactions, which are the result of interpreting a
* ledger-update. These transactions are consumed by either the
* scenario-interpreter or the Daml-engine code. Both of these
* code-paths share the computations for segregating the
* transaction into party-specific ledgers and for computing
* divulgence of contracts.
*/
@deprecated("use com.daml.transaction.VersionedTransaction", since = "1.18.0")
type Transaction = VersionedTransaction
@deprecated("use com.daml.transaction.VersionedTransaction", since = "1.18.0")
val Transaction: VersionedTransaction.type = VersionedTransaction

/** Transaction meta data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import anorm.{BatchSql, NamedParameter}
import com.daml.lf.data.Ref
import com.daml.lf.ledger.EventId
import com.daml.lf.transaction.Node.NodeCreate
import com.daml.lf.transaction.{Transaction => Tx}
import com.daml.lf.transaction.VersionedTransaction
import com.daml.platform.db.migration.translation.TransactionSerializer
import com.daml.platform.store.Conversions._
import org.flywaydb.core.api.migration.{BaseJavaMigration, Context}
Expand All @@ -25,10 +25,10 @@ private[migration] class V10_1__Populate_Event_Data extends BaseJavaMigration {
val statement = conn.createStatement()
val rows = statement.executeQuery(SELECT_TRANSACTIONS)

new Iterator[(Ref.LedgerString, Tx.Transaction)] {
new Iterator[(Ref.LedgerString, VersionedTransaction)] {
var hasNext: Boolean = rows.next()

def next(): (Ref.LedgerString, Tx.Transaction) = {
def next(): (Ref.LedgerString, VersionedTransaction) = {
val transactionId = Ref.LedgerString.assertFromString(rows.getString("transaction_id"))
val transaction = TransactionSerializer
.deserializeTransaction(transactionId, rows.getBinaryStream("transaction"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.sql.{Connection, ResultSet}

import anorm.{BatchSql, NamedParameter}
import com.daml.lf.data.Ref
import com.daml.lf.transaction.{Transaction => Tx}
import com.daml.lf.transaction.VersionedTransaction
import com.daml.lf.transaction.Node.{
NodeRollback,
NodeCreate,
Expand All @@ -35,7 +35,7 @@ private[migration] class V4_1__Collect_Parties extends BaseJavaMigration {

private def loadTransactions(implicit
connection: Connection
): Iterator[(Long, Tx.Transaction)] = {
): Iterator[(Long, VersionedTransaction)] = {

val SQL_SELECT_LEDGER_ENTRIES =
"""SELECT
Expand All @@ -50,11 +50,11 @@ private[migration] class V4_1__Collect_Parties extends BaseJavaMigration {
statement.setFetchSize(batchSize)
val rows: ResultSet = statement.executeQuery(SQL_SELECT_LEDGER_ENTRIES)

new Iterator[(Long, Tx.Transaction)] {
new Iterator[(Long, VersionedTransaction)] {

var hasNext: Boolean = rows.next()

def next(): (Long, Tx.Transaction) = {
def next(): (Long, VersionedTransaction) = {
val ledgerOffset = rows.getLong("ledger_offset")
val transactionId = Ref.LedgerString.assertFromString(rows.getString("transaction_id"))
val transaction = TransactionSerializer
Expand All @@ -72,7 +72,7 @@ private[migration] class V4_1__Collect_Parties extends BaseJavaMigration {
}

private def updateParties(
transactions: Iterator[(Long, Tx.Transaction)]
transactions: Iterator[(Long, VersionedTransaction)]
)(implicit conn: Connection): Unit = {

val SQL_INSERT_PARTY =
Expand Down Expand Up @@ -102,7 +102,7 @@ private[migration] class V4_1__Collect_Parties extends BaseJavaMigration {
}
}

private def getParties(transaction: Tx.Transaction): Set[Ref.Party] = {
private def getParties(transaction: VersionedTransaction): Set[Ref.Party] = {
transaction
.fold[Set[Ref.Party]](Set.empty) { case (parties, (_, node)) =>
node match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package object v25_backfill_participant_events {

import com.daml.lf.{transaction => lftx}
private[migration] type NodeId = lftx.NodeId
private[migration] type Transaction = lftx.Transaction.Transaction
private[migration] type Transaction = lftx.VersionedTransaction
private[migration] type Create = lftx.Node.NodeCreate
private[migration] type Exercise = lftx.Node.NodeExercises

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package object v29_fix_participant_events {

import com.daml.lf.{transaction => lftx}
private[migration] type NodeId = lftx.NodeId
private[migration] type Transaction = lftx.Transaction.Transaction
private[migration] type Transaction = lftx.VersionedTransaction
private[migration] type Create = lftx.Node.NodeCreate
private[migration] type Exercise = lftx.Node.NodeExercises

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ private[state] object Conversions {
private def assertEncode[X](context: => String, x: Either[ValueCoder.EncodeError, X]): X =
x.fold(err => throw Err.EncodeError(context, err.errorMessage), identity)

def encodeTransaction(tx: Transaction.Transaction): TransactionOuterClass.Transaction =
def encodeTransaction(tx: VersionedTransaction): TransactionOuterClass.Transaction =
assertEncode(
"Transaction",
TransactionCoder.encodeTransaction(TransactionCoder.NidEncoder, ValueCoder.CidEncoder, tx),
)

def decodeTransaction(tx: TransactionOuterClass.Transaction): Transaction.Transaction =
def decodeTransaction(tx: TransactionOuterClass.Transaction): VersionedTransaction =
assertDecode(
"Transaction",
TransactionCoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.daml.ledger.participant.state.kvutils

import com.daml.lf.data.BackStack
import com.daml.lf.data.Ref.Party
import com.daml.lf.transaction.{BlindingInfo, NodeId, Transaction}
import com.daml.lf.transaction.{BlindingInfo, NodeId, VersionedTransaction}

final case class ProjectionRoots(
party: Party,
Expand All @@ -24,7 +24,7 @@ object Projections {
* we keep an explicit list of roots for each party.
*/
def computePerPartyProjectionRoots(
tx: Transaction.Transaction,
tx: VersionedTransaction,
blindingInfo: BlindingInfo,
): List[ProjectionRoots] = {

Expand Down
Loading

0 comments on commit f81d880

Please sign in to comment.