mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-11 04:45:57 +03:00
Fix badly versioned empty tx (#10596)
* build correctly versioned empty tx * dont call normalizeTx from Engine.validate * dont recalc the tx-version in normalizeTx; just assume it is correct CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
d92440471c
commit
aec601f929
@ -222,7 +222,7 @@ class Engine(val config: EngineConfig = new EngineConfig(LanguageVersion.StableV
|
||||
(rtx, _) = result
|
||||
validationResult <-
|
||||
transaction.Validation
|
||||
.isReplayedBy(transaction.Normalization.normalizeTx(tx), rtx)
|
||||
.isReplayedBy(tx, rtx)
|
||||
.fold(
|
||||
e => ResultError(Error.Validation.ReplayMismatch(e)),
|
||||
_ => ResultDone.Unit,
|
||||
|
@ -274,7 +274,7 @@ object TransactionBuilder {
|
||||
// not valid transactions.
|
||||
val Empty: Tx.Transaction =
|
||||
VersionedTransaction(
|
||||
TransactionVersion.minNodeVersion,
|
||||
TransactionVersion.minVersion, // A normalized empty tx is V10
|
||||
HashMap.empty,
|
||||
ImmArray.empty,
|
||||
)
|
||||
|
@ -45,17 +45,9 @@ class Normalization[Nid, Cid] {
|
||||
|
||||
def normalizeTx(vtx: VTX): VTX = {
|
||||
vtx match {
|
||||
case VersionedTransaction(_, nodes, roots) =>
|
||||
// TODO: Normalized version calc should be shared with code in asVersionedTransaction
|
||||
val version = roots.iterator.foldLeft(TransactionVersion.minVersion) { (acc, nodeId) =>
|
||||
import scala.Ordering.Implicits.infixOrderingOps
|
||||
nodes(nodeId).optVersion match {
|
||||
case Some(version) => acc max version
|
||||
case None => acc max TransactionVersion.minExceptions
|
||||
}
|
||||
}
|
||||
case VersionedTransaction(_, nodes, _) =>
|
||||
VersionedTransaction(
|
||||
version,
|
||||
vtx.version,
|
||||
nodes.map { case (k, v) =>
|
||||
(k, normNode(v))
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user