mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-09 15:37:05 +03:00
Remove localDisclosures from BlindingInfo entirely (#6509)
* Address https://github.com/digital-asset/daml/pull/6507#discussion_r446113575 * drop blindinginfo.proto changelog_begin changelog_end * drop BlindingCoder * Remove blindinginfo Protobuf definition JAR changelog_begin [DAML-LF] The blindinginfo Protobuf definition JAR, which was previously unused, has been pulled from the artifacts released on Maven changelog_end Co-authored-by: Remy Haemmerle <Remy.Haemmerle@daml.com>
This commit is contained in:
parent
95213c4e74
commit
36a9042594
@ -51,9 +51,6 @@ object Blinding {
|
||||
Right(
|
||||
BlindingInfo(
|
||||
disclosure = enrichedTx.explicitDisclosure,
|
||||
// NOTE(MH): Local divulgences are a thing of the past and are not
|
||||
// produced by the current implementation anymore.
|
||||
localDivulgence = Map.empty,
|
||||
globalDivulgence = enrichedTx.globalImplicitDisclosure,
|
||||
))
|
||||
} else {
|
||||
|
@ -953,7 +953,7 @@ class EngineTest extends WordSpec with Matchers with EitherValues with BazelRunf
|
||||
"blinded correctly" in {
|
||||
|
||||
// Bob sees both the archive and the create
|
||||
val bobView = Blinding.divulgedTransaction(blindingInfo.localDisclosure, bob, tx.transaction)
|
||||
val bobView = Blinding.divulgedTransaction(blindingInfo.disclosure, bob, tx.transaction)
|
||||
bobView.nodes.size shouldBe 2
|
||||
findNodeByIdx(bobView.nodes, 0).getOrElse(fail("node not found")) match {
|
||||
case NodeExercises(
|
||||
@ -987,7 +987,7 @@ class EngineTest extends WordSpec with Matchers with EitherValues with BazelRunf
|
||||
|
||||
// clara only sees create
|
||||
val claraView =
|
||||
Blinding.divulgedTransaction(blindingInfo.localDisclosure, clara, tx.transaction)
|
||||
Blinding.divulgedTransaction(blindingInfo.disclosure, clara, tx.transaction)
|
||||
|
||||
claraView.nodes.size shouldBe 1
|
||||
findNodeByIdx(claraView.nodes, 1).getOrElse(fail("node not found")) match {
|
||||
|
@ -437,11 +437,10 @@ object ValueGenerators {
|
||||
.map(NodeId(_))
|
||||
.flatMap(n => genMaybeEmptyParties.map(ps => (n, ps))))
|
||||
for {
|
||||
disclosed1 <- nodePartiesGen
|
||||
disclosed2 <- nodePartiesGen
|
||||
disclosed <- nodePartiesGen
|
||||
divulged <- Gen.mapOf(
|
||||
cidV0Gen.flatMap(c => genMaybeEmptyParties.map(ps => (c: ContractId) -> ps)))
|
||||
} yield BlindingInfo(disclosed1, disclosed2, divulged)
|
||||
} yield BlindingInfo(disclosed, divulged)
|
||||
}
|
||||
|
||||
def stringVersionGen: Gen[String] = {
|
||||
|
@ -43,19 +43,6 @@ da_java_proto_library(
|
||||
deps = [":transaction_proto"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "blindinginfo_proto",
|
||||
srcs = ["src/main/protobuf/com/daml/lf/blindinginfo.proto"],
|
||||
strip_import_prefix = "src/main/protobuf/",
|
||||
)
|
||||
|
||||
da_java_proto_library(
|
||||
name = "blindinginfo_java_proto",
|
||||
tags = ["maven_coordinates=com.daml:daml-lf-blindinginfo-java-proto:__VERSION__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":blindinginfo_proto"],
|
||||
)
|
||||
|
||||
#
|
||||
# Transaction library providing a high-level scala transaction
|
||||
# data structure and associated utilities.
|
||||
@ -68,7 +55,6 @@ da_scala_library(
|
||||
tags = ["maven_coordinates=com.daml:daml-lf-transaction:__VERSION__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":blindinginfo_java_proto",
|
||||
":transaction_java_proto",
|
||||
":value_java_proto",
|
||||
"//daml-lf/data",
|
||||
@ -87,7 +73,6 @@ da_scala_test(
|
||||
],
|
||||
scalacopts = lf_scalacopts,
|
||||
deps = [
|
||||
":blindinginfo_java_proto",
|
||||
":transaction",
|
||||
":transaction_java_proto",
|
||||
":value_java_proto",
|
||||
|
@ -1,31 +0,0 @@
|
||||
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package com.daml.lf.blinding;
|
||||
|
||||
option java_package = "com.daml.lf.blinding";
|
||||
|
||||
// a relation between a node and a set of parties
|
||||
message NodeParties {
|
||||
string node_id = 1;
|
||||
repeated string parties = 2;
|
||||
}
|
||||
|
||||
// a relation between a contract and a set of parties
|
||||
message ContractParties {
|
||||
string contract_id = 1;
|
||||
repeated string parties = 2;
|
||||
}
|
||||
|
||||
// Blinding info always contains information with respect to a specific transaction
|
||||
// nodes are the nodes of that transaction for
|
||||
message BlindingInfo {
|
||||
// also known as simple 'disclosure' describes which nodes are shown to which parties
|
||||
repeated NodeParties explicit_disclosure = 1;
|
||||
// also known as 'divulgence' additional nodes sent to participants enabling post-commit validation
|
||||
repeated NodeParties local_implicit_disclosure = 2;
|
||||
// 'divulgence' contracts outside this the transaction revealed to participants making validation possible
|
||||
repeated ContractParties global_implicit_disclosure = 3;
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package com.daml.lf.transaction
|
||||
|
||||
import com.daml.lf.data.Ref._
|
||||
import com.daml.lf.value.Value.ContractId
|
||||
import com.daml.lf.value.ValueCoder.DecodeError
|
||||
import com.daml.lf.{blinding => proto}
|
||||
import com.google.protobuf.ProtocolStringList
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object BlindingCoder {
|
||||
|
||||
def decode(
|
||||
p: proto.Blindinginfo.BlindingInfo,
|
||||
nodeIdReader: TransactionCoder.DecodeNid[Transaction.NodeId],
|
||||
): Either[DecodeError, BlindingInfo] = {
|
||||
|
||||
val explicitDisclosure =
|
||||
p.getExplicitDisclosureList.asScala.map(n =>
|
||||
for {
|
||||
ni <- nodeIdReader.fromString(n.getNodeId)
|
||||
parties <- toPartySet(n.getPartiesList)
|
||||
} yield ni -> parties)
|
||||
|
||||
val implicitLocal =
|
||||
p.getLocalImplicitDisclosureList.asScala.map(n =>
|
||||
for {
|
||||
ni <- nodeIdReader.fromString(n.getNodeId)
|
||||
parties <- toPartySet(n.getPartiesList)
|
||||
} yield ni -> parties)
|
||||
|
||||
val globalDisclosure =
|
||||
p.getGlobalImplicitDisclosureList.asScala.map(n =>
|
||||
for {
|
||||
parties <- toPartySet(n.getPartiesList)
|
||||
coid <- toContractId(n.getContractId)
|
||||
} yield coid -> parties)
|
||||
|
||||
for {
|
||||
explicit <- sequence(explicitDisclosure)
|
||||
local <- sequence(implicitLocal)
|
||||
global <- sequence(globalDisclosure)
|
||||
} yield BlindingInfo(explicit.toMap, local.toMap, global.toMap)
|
||||
|
||||
}
|
||||
|
||||
def encode(
|
||||
blindingInfo: BlindingInfo,
|
||||
nodeIdWriter: TransactionCoder.EncodeNid[Transaction.NodeId],
|
||||
): proto.Blindinginfo.BlindingInfo = {
|
||||
val builder = proto.Blindinginfo.BlindingInfo.newBuilder()
|
||||
|
||||
val localImplicit = blindingInfo.localDivulgence.map(nodeParties => {
|
||||
val b1 = proto.Blindinginfo.NodeParties.newBuilder()
|
||||
b1.setNodeId(nodeIdWriter.asString(nodeParties._1))
|
||||
b1.addAllParties(nodeParties._2.toSet[String].asJava)
|
||||
b1.build()
|
||||
})
|
||||
|
||||
val explicit = blindingInfo.disclosure.map(nodeParties => {
|
||||
val b1 = proto.Blindinginfo.NodeParties.newBuilder()
|
||||
b1.setNodeId(nodeIdWriter.asString(nodeParties._1))
|
||||
b1.addAllParties(nodeParties._2.toSet[String].asJava)
|
||||
b1.build()
|
||||
})
|
||||
|
||||
val global = blindingInfo.globalDivulgence.map(contractParties => {
|
||||
val b1 = proto.Blindinginfo.ContractParties.newBuilder()
|
||||
b1.setContractId(contractParties._1.coid)
|
||||
b1.addAllParties(contractParties._2.toSet[String].asJava)
|
||||
b1.build()
|
||||
})
|
||||
|
||||
builder.addAllExplicitDisclosure(explicit.asJava)
|
||||
builder.addAllGlobalImplicitDisclosure(global.asJava)
|
||||
builder.addAllLocalImplicitDisclosure(localImplicit.asJava)
|
||||
builder.build()
|
||||
}
|
||||
|
||||
private def toPartySet(strList: ProtocolStringList): Either[DecodeError, Set[Party]] = {
|
||||
val parties = strList
|
||||
.asByteStringList()
|
||||
.asScala
|
||||
.map(bs => Party.fromString(bs.toStringUtf8))
|
||||
|
||||
sequence(parties) match {
|
||||
case Left(err) => Left(DecodeError(s"Cannot decode party: $err"))
|
||||
case Right(l) => Right(l.toSet)
|
||||
}
|
||||
}
|
||||
|
||||
private def toContractId(s: String): Either[DecodeError, ContractId] =
|
||||
ContractId.fromString(s).left.map(err => DecodeError(s"Cannot decode contractId: $err"))
|
||||
|
||||
}
|
@ -19,11 +19,9 @@ import com.daml.lf.value.Value.ContractId
|
||||
* _outside_ this transaction.
|
||||
* See also https://docs.daml.com/concepts/ledger-model/ledger-privacy.html#divulgence-when-non-stakeholders-see-contracts
|
||||
*/
|
||||
case class BlindingInfo(
|
||||
final case class BlindingInfo(
|
||||
/** Disclosure, specified in terms of local node IDs */
|
||||
disclosure: Relation[Transaction.NodeId, Party],
|
||||
/** Divulgence, specified in terms of local node IDs */
|
||||
localDivulgence: Relation[Transaction.NodeId, Party],
|
||||
/**
|
||||
* Divulgence, specified in terms of contract IDs.
|
||||
* Note that if this info was produced by blinding a transaction
|
||||
@ -31,7 +29,4 @@ case class BlindingInfo(
|
||||
* contain contracts produced in the same transaction.
|
||||
*/
|
||||
globalDivulgence: Relation[ContractId, Party],
|
||||
) {
|
||||
def localDisclosure: Relation[Transaction.NodeId, Party] =
|
||||
Relation.union(disclosure, localDivulgence)
|
||||
}
|
||||
)
|
||||
|
@ -290,15 +290,6 @@ class TransactionCoderSpec
|
||||
}
|
||||
}
|
||||
|
||||
"do transaction blinding" in {
|
||||
forAll(genBlindingInfo) { bi: BlindingInfo =>
|
||||
Right(bi) shouldEqual BlindingCoder.decode(
|
||||
BlindingCoder.encode(bi, TransactionCoder.NidEncoder),
|
||||
TransactionCoder.NidDecoder,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
"do tx with a lot of root nodes" in {
|
||||
val node =
|
||||
Node.NodeCreate[Value.ContractId, Value.VersionedValue[Value.ContractId]](
|
||||
|
@ -361,7 +361,7 @@ private[kvutils] class TransactionCommitter(
|
||||
val cs = DamlContractState.newBuilder
|
||||
cs.setActiveAt(buildTimestamp(transactionEntry.ledgerEffectiveTime))
|
||||
val localDisclosure =
|
||||
blindingInfo.localDisclosure(cid2nid(decodeContractId(key.getContractId)))
|
||||
blindingInfo.disclosure(cid2nid(decodeContractId(key.getContractId)))
|
||||
cs.addAllLocallyDisclosedTo((localDisclosure: Iterable[String]).asJava)
|
||||
cs.setContractInstance(
|
||||
Conversions.encodeContractInstance(createNode.coinst)
|
||||
|
@ -65,12 +65,6 @@ object Ledger {
|
||||
// here we just need to align the type for blinding
|
||||
val blindingInfo = Blinding.blind(committedTransaction)
|
||||
|
||||
// At this point there should be no local-divulgences
|
||||
assert(
|
||||
blindingInfo.localDivulgence.isEmpty,
|
||||
s"Encountered non-empty local divulgence. This is a bug! [transactionId={$transactionId}, blindingInfo={${blindingInfo.localDivulgence}}"
|
||||
)
|
||||
|
||||
// convert LF NodeId to Index EventId
|
||||
val disclosureForIndex = blindingInfo.disclosure
|
||||
|
||||
|
@ -31,8 +31,6 @@
|
||||
type: jar-scala
|
||||
- target: //daml-lf/scenario-interpreter:scenario-interpreter
|
||||
type: jar-scala
|
||||
- target: //daml-lf/transaction:blindinginfo_java_proto
|
||||
type: jar-proto
|
||||
- target: //daml-lf/transaction:transaction
|
||||
type: jar-scala
|
||||
- target: //daml-lf/transaction:transaction_java_proto
|
||||
|
Loading…
Reference in New Issue
Block a user