diff --git a/libraries/fabric-shim/protos/common/collection.proto b/libraries/fabric-shim/protos/common/collection.proto index 77283d56..a09e815f 100644 --- a/libraries/fabric-shim/protos/common/collection.proto +++ b/libraries/fabric-shim/protos/common/collection.proto @@ -15,6 +15,7 @@ import "common/policies.proto"; // messages; the extra struct is required because repeated oneof is // forbidden by the protobuf syntax message CollectionConfigPackage { + option deprecated = true; repeated CollectionConfig config = 1; } @@ -22,6 +23,7 @@ message CollectionConfigPackage { // it currently contains a single, static type. // Dynamic collections are deferred. message CollectionConfig { + option deprecated = true; oneof payload { StaticCollectionConfig static_collection_config = 1; } @@ -33,6 +35,7 @@ message CollectionConfig { // known at chaincode instantiation time, and that cannot be changed. // Dynamic collections are deferred. message StaticCollectionConfig { + option deprecated = true; // the name of the collection inside the denoted chaincode string name = 1; // a reference to a policy residing / managed in the config block @@ -59,6 +62,9 @@ message StaticCollectionConfig { // write the data (if set to false, for example if you want to implement more granular // access logic in the chaincode) bool member_only_write = 7; + // a reference to a policy residing / managed in the config block + // to define the endorsement policy for this collection + ApplicationPolicy endorsement_policy= 8; } @@ -67,6 +73,7 @@ message StaticCollectionConfig { // more general Policy. Instead of containing the actual policy, the // configuration may in the future contain a string reference to a policy. message CollectionPolicyConfig { + option deprecated = true; oneof payload { // Initially, only a signature policy is supported. SignaturePolicyEnvelope signature_policy = 1; @@ -76,13 +83,3 @@ message CollectionPolicyConfig { // string reference = 2; } } - - -// CollectionCriteria defines an element of a private data that corresponds -// to a certain transaction and collection -message CollectionCriteria { - string channel = 1; - string tx_id = 2; - string collection = 3; - string namespace = 4; -} diff --git a/libraries/fabric-shim/protos/common/common.proto b/libraries/fabric-shim/protos/common/common.proto index ca18f4a6..24cbe1a3 100644 --- a/libraries/fabric-shim/protos/common/common.proto +++ b/libraries/fabric-shim/protos/common/common.proto @@ -40,13 +40,13 @@ enum HeaderType { // This enum enlists indexes of the block metadata array enum BlockMetadataIndex { - SIGNATURES = 0; // Block metadata array position for block signatures - LAST_CONFIG = 1; // Block metadata array position to store last configuration block sequence number - TRANSACTIONS_FILTER = 2; // Block metadata array position to store serialized bit array filter of invalid transactions - ORDERER = 3 [deprecated=true]; /* Block metadata array position to store operational metadata for orderers - e.g. For Kafka, this is where we store the last offset written to the local ledger */ - COMMIT_HASH = 4; /* Block metadata array position to store the hash of TRANSACTIONS_FILTER, State Updates, - and the COMMIT_HASH of the previous block */ + SIGNATURES = 0; // Block metadata array position for block signatures + LAST_CONFIG = 1 [deprecated=true]; // Block metadata array position to store last configuration block sequence number + TRANSACTIONS_FILTER = 2; // Block metadata array position to store serialized bit array filter of invalid transactions + ORDERER = 3 [deprecated=true]; /* Block metadata array position to store operational metadata for orderers + e.g. For Kafka, this is where we store the last offset written to the local ledger */ + COMMIT_HASH = 4; /* Block metadata array position to store the hash of TRANSACTIONS_FILTER, State Updates, + and the COMMIT_HASH of the previous block */ } // LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index diff --git a/libraries/fabric-shim/protos/common/configtx.proto b/libraries/fabric-shim/protos/common/configtx.proto index 188848e6..f60e1548 100644 --- a/libraries/fabric-shim/protos/common/configtx.proto +++ b/libraries/fabric-shim/protos/common/configtx.proto @@ -39,16 +39,6 @@ message ConfigEnvelope { // Note that CONFIG_UPDATE has a Payload.Data of a Marshaled ConfigUpdate } -message ConfigGroupSchema { - map groups = 1; - map values = 2; - map policies = 3; -} - -message ConfigValueSchema {} - -message ConfigPolicySchema {} - // Config represents the config for a particular channel message Config { // Prevent removed tag re-use diff --git a/libraries/fabric-shim/protos/common/policies.proto b/libraries/fabric-shim/protos/common/policies.proto index 8ac81d09..9afaa10a 100644 --- a/libraries/fabric-shim/protos/common/policies.proto +++ b/libraries/fabric-shim/protos/common/policies.proto @@ -65,3 +65,20 @@ message ImplicitMetaPolicy { string sub_policy = 1; Rule rule = 2; } + +// ApplicationPolicy captures the diffenrent policy types that +// are set and evaluted at the application level. +message ApplicationPolicy { + option deprecated = true; + oneof Type { + // SignaturePolicy type is used if the policy is specified as + // a combination (using threshold gates) of signatures from MSP + // principals + SignaturePolicyEnvelope signature_policy = 1; + + // ChannelConfigPolicyReference is used when the policy is + // specified as a string that references a policy defined in + // the configuration of the channel + string channel_config_policy_reference = 2; + } +} diff --git a/libraries/fabric-shim/protos/discovery/protocol.proto b/libraries/fabric-shim/protos/discovery/protocol.proto index d2b29bdc..dec159a1 100644 --- a/libraries/fabric-shim/protos/discovery/protocol.proto +++ b/libraries/fabric-shim/protos/discovery/protocol.proto @@ -156,6 +156,8 @@ message ChaincodeInterest { message ChaincodeCall { string name = 1; repeated string collection_names = 2; + bool no_private_reads = 3; // Indicates we do not need to read from private data + bool no_public_writes = 4; // Indicates we do not need to write to the chaincode namespace } // ChaincodeQueryResult contains EndorsementDescriptors for diff --git a/libraries/fabric-shim/protos/gossip/message.proto b/libraries/fabric-shim/protos/gossip/message.proto index f567db5c..bd2560fa 100644 --- a/libraries/fabric-shim/protos/gossip/message.proto +++ b/libraries/fabric-shim/protos/gossip/message.proto @@ -9,7 +9,7 @@ option java_package = "org.hyperledger.fabric.protos.gossip"; package gossip; -import "common/collection.proto"; +import "peer/collection.proto"; // Gossip service Gossip { @@ -175,6 +175,7 @@ message ConnEstablish { bytes pki_id = 1; bytes identity = 2; bytes tls_cert_hash = 3; + bool probe = 4; } // PeerIdentity defines the identity of the peer @@ -257,7 +258,7 @@ message PrivatePayload { string tx_id = 3; bytes private_rwset = 4; uint64 private_sim_height = 5; - common.CollectionConfigPackage collection_configs = 6; + protos.CollectionConfigPackage collection_configs = 6; } // Membership messages diff --git a/libraries/fabric-shim/protos/peer/chaincode_shim.proto b/libraries/fabric-shim/protos/peer/chaincode_shim.proto index 48afbdb3..4b0ccca0 100644 --- a/libraries/fabric-shim/protos/peer/chaincode_shim.proto +++ b/libraries/fabric-shim/protos/peer/chaincode_shim.proto @@ -177,3 +177,9 @@ message StateMetadataResult { service ChaincodeSupport { rpc Register(stream ChaincodeMessage) returns (stream ChaincodeMessage); } + +// Chaincode as a server - peer establishes a connection to the chaincode as a client +// Currently only supports a stream connection. +service Chaincode { + rpc Connect(stream ChaincodeMessage) returns (stream ChaincodeMessage); +} diff --git a/libraries/fabric-shim/protos/peer/collection.proto b/libraries/fabric-shim/protos/peer/collection.proto new file mode 100644 index 00000000..dad26d81 --- /dev/null +++ b/libraries/fabric-shim/protos/peer/collection.proto @@ -0,0 +1,82 @@ +// Copyright the Hyperledger Fabric contributors. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 + +syntax = "proto3"; + +option go_package = "github.com/hyperledger/fabric-protos-go/peer"; +option java_package = "org.hyperledger.fabric.protos.peer"; + +package protos; + +import "common/policies.proto"; +import "peer/policy.proto"; + +// CollectionConfigPackage represents an array of CollectionConfig +// messages; the extra struct is required because repeated oneof is +// forbidden by the protobuf syntax +message CollectionConfigPackage { + repeated CollectionConfig config = 1; +} + +// CollectionConfig defines the configuration of a collection object; +// it currently contains a single, static type. +// Dynamic collections are deferred. +message CollectionConfig { + oneof payload { + StaticCollectionConfig static_collection_config = 1; + } +} + + +// StaticCollectionConfig constitutes the configuration parameters of a +// static collection object. Static collections are collections that are +// known at chaincode instantiation time, and that cannot be changed. +// Dynamic collections are deferred. +message StaticCollectionConfig { + // the name of the collection inside the denoted chaincode + string name = 1; + // a reference to a policy residing / managed in the config block + // to define which orgs have access to this collection’s private data + CollectionPolicyConfig member_orgs_policy = 2; + // The minimum number of peers private data will be sent to upon + // endorsement. The endorsement would fail if dissemination to at least + // this number of peers is not achieved. + int32 required_peer_count = 3; + // The maximum number of peers that private data will be sent to + // upon endorsement. This number has to be bigger than required_peer_count. + int32 maximum_peer_count = 4; + // The number of blocks after which the collection data expires. + // For instance if the value is set to 10, a key last modified by block number 100 + // will be purged at block number 111. A zero value is treated same as MaxUint64 + uint64 block_to_live = 5; + // The member only read access denotes whether only collection member clients + // can read the private data (if set to true), or even non members can + // read the data (if set to false, for example if you want to implement more granular + // access logic in the chaincode) + bool member_only_read = 6; + // The member only write access denotes whether only collection member clients + // can write the private data (if set to true), or even non members can + // write the data (if set to false, for example if you want to implement more granular + // access logic in the chaincode) + bool member_only_write = 7; + // a reference to a policy residing / managed in the config block + // to define the endorsement policy for this collection + ApplicationPolicy endorsement_policy= 8; +} + + +// Collection policy configuration. Initially, the configuration can only +// contain a SignaturePolicy. In the future, the SignaturePolicy may be a +// more general Policy. Instead of containing the actual policy, the +// configuration may in the future contain a string reference to a policy. +message CollectionPolicyConfig { + oneof payload { + // Initially, only a signature policy is supported. + common.SignaturePolicyEnvelope signature_policy = 1; + // Later, the SignaturePolicy will be replaced by a Policy. + // Policy policy = 1; + // A reference to a Policy is planned to be added later. +// string reference = 2; + } +} diff --git a/libraries/fabric-shim/protos/peer/lifecycle/lifecycle.proto b/libraries/fabric-shim/protos/peer/lifecycle/lifecycle.proto index 4e48e687..f1889be7 100644 --- a/libraries/fabric-shim/protos/peer/lifecycle/lifecycle.proto +++ b/libraries/fabric-shim/protos/peer/lifecycle/lifecycle.proto @@ -9,7 +9,7 @@ option go_package = "github.com/hyperledger/fabric-protos-go/peer/lifecycle"; package lifecycle; -import "common/collection.proto"; +import "peer/collection.proto"; // InstallChaincodeArgs is the message used as the argument to // '_lifecycle.InstallChaincode'. @@ -97,7 +97,7 @@ message ApproveChaincodeDefinitionForMyOrgArgs { string endorsement_plugin = 4; string validation_plugin = 5; bytes validation_parameter = 6; - common.CollectionConfigPackage collections = 7; + protos.CollectionConfigPackage collections = 7; bool init_required = 8; ChaincodeSource source = 9; } @@ -130,7 +130,7 @@ message CommitChaincodeDefinitionArgs { string endorsement_plugin = 4; string validation_plugin = 5; bytes validation_parameter = 6; - common.CollectionConfigPackage collections = 7; + protos.CollectionConfigPackage collections = 7; bool init_required = 8; } @@ -149,7 +149,7 @@ message CheckCommitReadinessArgs { string endorsement_plugin = 4; string validation_plugin = 5; bytes validation_parameter = 6; - common.CollectionConfigPackage collections = 7; + protos.CollectionConfigPackage collections = 7; bool init_required = 8; } @@ -161,6 +161,26 @@ message CheckCommitReadinessResult{ map approvals = 1; } +// QueryApprovedChaincodeDefinitionArgs is the message used as arguments to +// `_lifecycle.QueryApprovedChaincodeDefinition`. +message QueryApprovedChaincodeDefinitionArgs { + string name = 1; + int64 sequence = 2; +} + +// QueryApprovedChaincodeDefinitionResult is the message returned by +// `_lifecycle.QueryApprovedChaincodeDefinition`. +message QueryApprovedChaincodeDefinitionResult { + int64 sequence = 1; + string version = 2; + string endorsement_plugin = 3; + string validation_plugin = 4; + bytes validation_parameter = 5; + protos.CollectionConfigPackage collections = 6; + bool init_required = 7; + ChaincodeSource source = 8; +} + // QueryChaincodeDefinitionArgs is the message used as arguments to // `_lifecycle.QueryChaincodeDefinition`. message QueryChaincodeDefinitionArgs { @@ -175,7 +195,7 @@ message QueryChaincodeDefinitionResult { string endorsement_plugin = 3; string validation_plugin = 4; bytes validation_parameter = 5; - common.CollectionConfigPackage collections = 6; + protos.CollectionConfigPackage collections = 6; bool init_required = 7; map approvals = 8; } @@ -194,7 +214,7 @@ message QueryChaincodeDefinitionsResult { string endorsement_plugin = 4; string validation_plugin = 5; bytes validation_parameter = 6; - common.CollectionConfigPackage collections = 7; + protos.CollectionConfigPackage collections = 7; bool init_required = 8; } repeated ChaincodeDefinition chaincode_definitions = 1; diff --git a/libraries/fabric-shim/protos/peer/transaction.proto b/libraries/fabric-shim/protos/peer/transaction.proto index fdffba33..93ef234e 100644 --- a/libraries/fabric-shim/protos/peer/transaction.proto +++ b/libraries/fabric-shim/protos/peer/transaction.proto @@ -13,20 +13,6 @@ package protos; import "peer/proposal_response.proto"; import "common/common.proto"; -// This message is necessary to facilitate the verification of the signature -// (in the signature field) over the bytes of the transaction (in the -// transactionBytes field). -message SignedTransaction { - // The bytes of the Transaction. NDD - bytes transaction_bytes = 1; - - // Signature of the transactionBytes The public key of the signature is in - // the header field of TransactionAction There might be multiple - // TransactionAction, so multiple headers, but there should be same - // transactor identity (cert) in all headers - bytes signature = 2; -} - // ProcessedTransaction wraps an Envelope that includes a transaction along with an indication // of whether the transaction was validated or invalidated by committing peer. // The use case is that GetTransactionByID API needs to retrieve the transaction Envelope diff --git a/libraries/fabric-shim/protos/transientstore/transientstore.proto b/libraries/fabric-shim/protos/transientstore/transientstore.proto index 1b6d577e..745ee9e7 100644 --- a/libraries/fabric-shim/protos/transientstore/transientstore.proto +++ b/libraries/fabric-shim/protos/transientstore/transientstore.proto @@ -10,7 +10,7 @@ option go_package = "github.com/hyperledger/fabric-protos-go/transientstore"; option java_package = "org.hyperledger.fabric.protos.transientstore"; import "ledger/rwset/rwset.proto"; -import "common/collection.proto"; +import "peer/collection.proto"; // TxPvtReadWriteSetWithConfigInfo encapsulates the transaction's private // read-write set and additional information about the configurations such as @@ -18,5 +18,5 @@ import "common/collection.proto"; message TxPvtReadWriteSetWithConfigInfo { uint64 endorsed_at = 1; rwset.TxPvtReadWriteSet pvt_rwset = 2; - map collection_configs = 3; + map collection_configs = 3; }