HyperLedger Fabric

TOC

Tools

IBMBlockchain.ibm-blockchain-platform

Topics

Hyperledger Fabric Operator

Cloud native deployment support

FAB-13582 Peer and Chaincode cloud native deployment support - Hyperledger JIRA

The current runtime model of a chaincode is that it has to be in a sandbox (Docker container) since it is co-located in the hosting peer's environment. To sandbox, the hosting peer builds the chaincode Docker image and launches the container during the instantiate transaction.

在Kubernetes上运行区块链服务(BaaS) - 知乎

由于该过程是独立于Kubernetes体系之外运行的,难以对chaincode容器进行生命周期管理。无法基于Kubernetes的namaspace隔离、NetworkPolicy等机制实现对chaincode容器的安全管理。

生成 Google Protocol Buffers 文件

hyperledger/fabric-protos

git clone https://github.com/hyperledger/fabric-protos.git /tmp/src/hlf-protos
bash tc.sh --gen-proto-doc /tmp/src/hlf-protos /tmp/output.md

Generated Date:2019-09-12T14:31:57+08:00

Protocol Documentation

Table of Contents

Top

peer/transaction.proto

ChaincodeActionPayload

ChaincodeActionPayload is the message to be used for the TransactionAction's payload when the Header's type is set to CHAINCODE. It carries the chaincodeProposalPayload and an endorsed action to apply to the ledger.

FieldTypeLabelDescription
chaincode_proposal_payloadbytesThis field contains the bytes of the ChaincodeProposalPayload message from the original invocation (essentially the arguments) after the application of the visibility function. The main visibility modes are "full" (the entire ChaincodeProposalPayload message is included here), "hash" (only the hash of the ChaincodeProposalPayload message is included) or "nothing". This field will be used to check the consistency of ProposalResponsePayload.proposalHash. For the CHAINCODE type, ProposalResponsePayload.proposalHash is supposed to be H(ProposalHeader
actionChaincodeEndorsedActionThe list of actions to apply to the ledger

ChaincodeEndorsedAction

ChaincodeEndorsedAction carries information about the endorsement of a specific proposal

FieldTypeLabelDescription
proposal_response_payloadbytesThis is the bytes of the ProposalResponsePayload message signed by the endorsers. Recall that for the CHAINCODE type, the ProposalResponsePayload's extenstion field carries a ChaincodeAction
endorsementsEndorsementrepeatedThe endorsement of the proposal, basically the endorser's signature over proposalResponsePayload

ProcessedTransaction

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 from block storage, and return it to a client, and indicate whether the transaction was validated or invalidated by committing peer. So that the originally submitted transaction Envelope is not modified, the ProcessedTransaction wrapper is returned.

FieldTypeLabelDescription
transactionEnvelopecommon.EnvelopeAn Envelope which includes a processed transaction
validationCodeint32An indication of whether the transaction was validated or invalidated by committing peer

SignedTransaction

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).

FieldTypeLabelDescription
transaction_bytesbytesThe bytes of the Transaction. NDD
signaturebytesSignature 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

Transaction

The transaction to be sent to the ordering service. A transaction contains one or more TransactionAction. Each TransactionAction binds a proposal to potentially multiple actions. The transaction is atomic meaning that either all actions in the transaction will be committed or none will. Note that while a Transaction might include more than one Header, the Header.creator field must be the same in each. A single client is free to issue a number of independent Proposal, each with their header (Header) and request payload (ChaincodeProposalPayload). Each proposal is independently endorsed generating an action (ProposalResponsePayload) with one signature per Endorser. Any number of independent proposals (and their action) might be included in a transaction to ensure that they are treated atomically.

FieldTypeLabelDescription
actionsTransactionActionrepeatedThe payload is an array of TransactionAction. An array is necessary to accommodate multiple actions per transaction

TransactionAction

TransactionAction binds a proposal to its action. The type field in the header dictates the type of action to be applied to the ledger.

FieldTypeLabelDescription
headerbytesThe header of the proposal action, which is the proposal header
payloadbytesThe payload of the action as defined by the type in the header For chaincode, it's the bytes of ChaincodeActionPayload

MetaDataKeys

Reserved entries in the key-level metadata map

NameNumberDescription
VALIDATION_PARAMETER0
VALIDATION_PARAMETER_V21

TxValidationCode

NameNumberDescription
VALID0
NIL_ENVELOPE1
BAD_PAYLOAD2
BAD_COMMON_HEADER3
BAD_CREATOR_SIGNATURE4
INVALID_ENDORSER_TRANSACTION5
INVALID_CONFIG_TRANSACTION6
UNSUPPORTED_TX_PAYLOAD7
BAD_PROPOSAL_TXID8
DUPLICATE_TXID9
ENDORSEMENT_POLICY_FAILURE10
MVCC_READ_CONFLICT11
PHANTOM_READ_CONFLICT12
UNKNOWN_TX_TYPE13
TARGET_CHAIN_NOT_FOUND14
MARSHAL_TX_ERROR15
NIL_TXACTION16
EXPIRED_CHAINCODE17
CHAINCODE_VERSION_CONFLICT18
BAD_HEADER_EXTENSION19
BAD_CHANNEL_HEADER20
BAD_RESPONSE_PAYLOAD21
BAD_RWSET22
ILLEGAL_WRITESET23
INVALID_WRITESET24
INVALID_CHAINCODE25
NOT_VALIDATED254
INVALID_OTHER_REASON255

Top

peer/configuration.proto

ACLs

ACLs provides mappings for resources in a channel. APIResource encapsulates reference to a policy used to determine ACL for the resource

FieldTypeLabelDescription
aclsACLs.AclsEntryrepeated

ACLs.AclsEntry

FieldTypeLabelDescription
keystring
valueAPIResource

APIResource

APIResource represents an API resource in the peer whose ACL is determined by the policy_ref field

FieldTypeLabelDescription
policy_refstringThe policy name to use for this API

AnchorPeer

AnchorPeer message structure which provides information about anchor peer, it includes host name, port number and peer certificate.

FieldTypeLabelDescription
hoststringDNS host name of the anchor peer
portint32The port number

AnchorPeers

AnchorPeers simply represents list of anchor peers which is used in ConfigurationItem

FieldTypeLabelDescription
anchor_peersAnchorPeerrepeated

Top

peer/signed_cc_dep_spec.proto

SignedChaincodeDeploymentSpec

SignedChaincodeDeploymentSpec carries the CDS along with endorsements

FieldTypeLabelDescription
chaincode_deployment_specbytesThis is the bytes of the ChaincodeDeploymentSpec
instantiation_policybytesThis is the instantiation policy which is identical in structure to endorsement policy. This policy is checked by the VSCC at commit time on the instantiation (all peers will get the same policy as it will be part of the LSCC instantation record and will be part of the hash as well)
owner_endorsementsEndorsementrepeatedThe endorsements of the above deployment spec, the owner's signature over chaincode_deployment_spec and Endorsement.endorser.

Top

peer/chaincode.proto

CDSData

CDSData is data stored in the LSCC on instantiation of a CC for CDSPackage. This needs to be serialized for ChaincodeData hence the protobuf format

FieldTypeLabelDescription
hashbyteshash of ChaincodeDeploymentSpec.code_package
metadatahashbyteshash of ChaincodeID.name + ChaincodeID.version

ChaincodeData

ChaincodeData defines the datastructure for chaincodes to be serialized by proto Type provides an additional check by directing to use a specific package after instantiation Data is Type specific (see CDSPackage and SignedCDSPackage)

FieldTypeLabelDescription
namestringName of the chaincode
versionstringVersion of the chaincode
esccstringEscc for the chaincode instance
vsccstringVscc for the chaincode instance
policycommon.SignaturePolicyEnvelopePolicy endorsement policy for the chaincode instance
databytesData data specific to the package
idbytesId of the chaincode that's the unique fingerprint for the CC This is not currently used anywhere but serves as a good eyecatcher
instantiation_policycommon.SignaturePolicyEnvelopeInstantiationPolicy for the chaincode

ChaincodeDeploymentSpec

Specify the deployment of a chaincode. TODO: Define codePackage.

FieldTypeLabelDescription
chaincode_specChaincodeSpec
code_packagebytes

ChaincodeID

ChaincodeID contains the path as specified by the deploy transaction that created it as well as the hashCode that is generated by the system for the path. From the user level (ie, CLI, REST API and so on) deploy transaction is expected to provide the path and other requests are expected to provide the hashCode. The other value will be ignored. Internally, the structure could contain both values. For instance, the hashCode will be set when first generated using the path

FieldTypeLabelDescription
pathstringdeploy transaction will use the path
namestringall other requests will use the name (really a hashcode) generated by the deploy transaction
versionstringuser friendly version name for the chaincode

ChaincodeInput

Carries the chaincode function and its arguments. UnmarshalJSON in transaction.go converts the string-based REST/JSON input to the []byte-based current ChaincodeInput structure.

FieldTypeLabelDescription
argsbytesrepeated
decorationsChaincodeInput.DecorationsEntryrepeated
is_initboolis_init is used for the application to signal that an invocation is to be routed to the legacy 'Init' function for compatibility with chaincodes which handled Init in the old way. New applications should manage their initialized state themselves.

ChaincodeInput.DecorationsEntry

FieldTypeLabelDescription
keystring
valuebytes

ChaincodeInvocationSpec

Carries the chaincode function and its arguments.

FieldTypeLabelDescription
chaincode_specChaincodeSpec

ChaincodeSpec

Carries the chaincode specification. This is the actual metadata required for defining a chaincode.

FieldTypeLabelDescription
typeChaincodeSpec.Type
chaincode_idChaincodeID
inputChaincodeInput
timeoutint32

LifecycleEvent

LifecycleEvent is used as the payload of the chaincode event emitted by LSCC

FieldTypeLabelDescription
chaincode_namestring

ChaincodeSpec.Type

NameNumberDescription
UNDEFINED0
GOLANG1
NODE2
CAR3
JAVA4

Top

peer/proposal_response.proto

Endorsement

An endorsement is a signature of an endorser over a proposal response. By producing an endorsement message, an endorser implicitly "approves" that proposal response and the actions contained therein. When enough endorsements have been collected, a transaction can be generated out of a set of proposal responses. Note that this message only contains an identity and a signature but no signed payload. This is intentional because endorsements are supposed to be collected in a transaction, and they are all expected to endorse a single proposal response/action (many endorsements over a single proposal response)

FieldTypeLabelDescription
endorserbytesIdentity of the endorser (e.g. its certificate)
signaturebytesSignature of the payload included in ProposalResponse concatenated with the endorser's certificate; ie, sign(ProposalResponse.payload + endorser)

ProposalResponse

A ProposalResponse is returned from an endorser to the proposal submitter. The idea is that this message contains the endorser's response to the request of a client to perform an action over a chaincode (or more generically on the ledger); the response might be success/error (conveyed in the Response field) together with a description of the action and a signature over it by that endorser. If a sufficient number of distinct endorsers agree on the same action and produce signature to that effect, a transaction can be generated and sent for ordering.

FieldTypeLabelDescription
versionint32Version indicates message protocol version
timestampgoogle.protobuf.TimestampTimestamp is the time that the message was created as defined by the sender
responseResponseA response message indicating whether the endorsement of the action was successful
payloadbytesThe payload of response. It is the bytes of ProposalResponsePayload
endorsementEndorsementThe endorsement of the proposal, basically the endorser's signature over the payload

ProposalResponsePayload

ProposalResponsePayload is the payload of a proposal response. This message is the "bridge" between the client's request and the endorser's action in response to that request. Concretely, for chaincodes, it contains a hashed representation of the proposal (proposalHash) and a representation of the chaincode state changes and events inside the extension field.

FieldTypeLabelDescription
proposal_hashbytesHash of the proposal that triggered this response. The hash is used to link a response with its proposal, both for bookeeping purposes on an asynchronous system and for security reasons (accountability, non-repudiation). The hash usually covers the entire Proposal message (byte-by-byte).
extensionbytesExtension should be unmarshaled to a type-specific message. The type of the extension in any proposal response depends on the type of the proposal that the client selected when the proposal was initially sent out. In particular, this information is stored in the type field of a Header. For chaincode, it's a ChaincodeAction message

Response

A response with a representation similar to an HTTP response that can be used within another message.

FieldTypeLabelDescription
statusint32A status code that should follow the HTTP status codes.
messagestringA message associated with the response code.
payloadbytesA payload that can be used to include metadata with this response.

Top

peer/query.proto

ChaincodeInfo

ChaincodeInfo contains general information about an installed/instantiated chaincode

FieldTypeLabelDescription
namestring
versionstring
pathstringthe path as specified by the install/instantiate transaction
inputstringthe chaincode function upon instantiation and its arguments. This will be blank if the query is returning information about installed chaincodes.
esccstringthe name of the ESCC for this chaincode. This will be blank if the query is returning information about installed chaincodes.
vsccstringthe name of the VSCC for this chaincode. This will be blank if the query is returning information about installed chaincodes.
idbytesthe chaincode unique id. computed as: H( H(name

ChaincodeQueryResponse

ChaincodeQueryResponse returns information about each chaincode that pertains to a query in lscc.go, such as GetChaincodes (returns all chaincodes instantiated on a channel), and GetInstalledChaincodes (returns all chaincodes installed on a peer)

FieldTypeLabelDescription
chaincodesChaincodeInforepeated

ChannelInfo

ChannelInfo contains general information about channels

FieldTypeLabelDescription
channel_idstring

ChannelQueryResponse

ChannelQueryResponse returns information about each channel that pertains to a query in lscc.go, such as GetChannels (returns all channels for a given peer)

FieldTypeLabelDescription
channelsChannelInforepeated

Top

peer/resources.proto

ChaincodeEndorsement

ChaincodeEndorsement instructs the peer how transactions should be endorsed. The only endorsement mechanism which ships with the fabric today is the standard 'escc' mechanism. This code simply simulates the proposal to generate a RW set, then signs the result using the peer's local signing identity.

FieldTypeLabelDescription
namestringSpecifies what code to run for endorsements, defaults 'escc'

ChaincodeIdentifier

ChaincodeIdentifier identifies a piece of chaincode. For a peer to accept invocations of this chaincode, the hash of the installed code must match, as must the version string included with the install command.

FieldTypeLabelDescription
hashbytesThe hash of the chaincode bytes
versionstringA user friendly human readable name corresponding to the ID

ChaincodeValidation

ChaincodeValidation instructs the peer how transactions for this chaincode should be validated. The only validation mechanism which ships with fabric today is the standard 'vscc' validation mechanism. This built in validation method utilizes an endorsement policy which checks that a sufficient number of signatures have been included. The 'arguement' field encodes any parameters required by the validation implementation.

FieldTypeLabelDescription
namestringSpecifies which code to run to validate transactions, defaults to 'vscc'
argumentbytesWhen 'vscc' a marshaled VSCCArgs

ConfigTree

ConfigTree encapsulates channel and resources configuration of a channel. Both configurations are represented as common.Config

FieldTypeLabelDescription
channel_configcommon.Config
resources_configcommon.Config

VSCCArgs

VSCCArgs is passed (marshaled) as a parameter to the VSCC imlementation via the argument field of the ChaincodeValidation message.

FieldTypeLabelDescription
endorsement_policy_refstringA named reference to an endorsement policy,

Top

peer/events.proto

BlockAndPrivateData

BlockAndPrivateData contains Block and a map from tx_seq_in_block to rwset.TxPvtReadWriteSet

FieldTypeLabelDescription
blockcommon.Block
private_data_mapBlockAndPrivateData.PrivateDataMapEntryrepeatedmap from tx_seq_in_block to rwset.TxPvtReadWriteSet

BlockAndPrivateData.PrivateDataMapEntry

FieldTypeLabelDescription
keyuint64
valuerwset.TxPvtReadWriteSet

DeliverResponse

DeliverResponse

FieldTypeLabelDescription
statuscommon.Status
blockcommon.Block
filtered_blockFilteredBlock
block_and_private_dataBlockAndPrivateData

FilteredBlock

FilteredBlock is a minimal set of information about a block

FieldTypeLabelDescription
channel_idstring
numberuint64The position in the blockchain
filtered_transactionsFilteredTransactionrepeated

FilteredChaincodeAction

FilteredChaincodeAction is a minimal set of information about an action within a transaction

FieldTypeLabelDescription
chaincode_eventChaincodeEvent

FilteredTransaction

FilteredTransaction is a minimal set of information about a transaction within a block

FieldTypeLabelDescription
txidstring
typecommon.HeaderType
tx_validation_codeTxValidationCode
transaction_actionsFilteredTransactionActions

FilteredTransactionActions

FilteredTransactionActions is a wrapper for array of TransactionAction message from regular block

FieldTypeLabelDescription
chaincode_actionsFilteredChaincodeActionrepeated

Deliver

Method NameRequest TypeResponse TypeDescription
Deliver.common.Envelope streamDeliverResponse streamDeliver first requires an Envelope of type ab.DELIVER_SEEK_INFO with Payload data as a marshaled orderer.SeekInfo message, then a stream of block replies is received
DeliverFiltered.common.Envelope streamDeliverResponse streamDeliverFiltered first requires an Envelope of type ab.DELIVER_SEEK_INFO with Payload data as a marshaled orderer.SeekInfo message, then a stream of filtered block replies is received
DeliverWithPrivateData.common.Envelope streamDeliverResponse streamDeliverWithPrivateData first requires an Envelope of type ab.DELIVER_SEEK_INFO with Payload data as a marshaled orderer.SeekInfo message, then a stream of block and private data replies is received

Top

peer/proposal.proto

ChaincodeAction

ChaincodeAction contains the actions the events generated by the execution of the chaincode.

FieldTypeLabelDescription
resultsbytesThis field contains the read set and the write set produced by the chaincode executing this invocation.
eventsbytesThis field contains the events generated by the chaincode executing this invocation.
responseResponseThis field contains the result of executing this invocation.
chaincode_idChaincodeIDThis field contains the ChaincodeID of executing this invocation. Endorser will set it with the ChaincodeID called by endorser while simulating proposal. Committer will validate the version matching with latest chaincode version. Adding ChaincodeID to keep version opens up the possibility of multiple ChaincodeAction per transaction.

ChaincodeHeaderExtension

ChaincodeHeaderExtension is the Header's extentions message to be used when the Header's type is CHAINCODE. This extensions is used to specify which chaincode to invoke and what should appear on the ledger.

FieldTypeLabelDescription
chaincode_idChaincodeIDThe ID of the chaincode to target.

ChaincodeProposalPayload

ChaincodeProposalPayload is the Proposal's payload message to be used when the Header's type is CHAINCODE. It contains the arguments for this invocation.

FieldTypeLabelDescription
inputbytesInput contains the arguments for this invocation. If this invocation deploys a new chaincode, ESCC/VSCC are part of this field. This is usually a marshaled ChaincodeInvocationSpec
TransientMapChaincodeProposalPayload.TransientMapEntryrepeatedTransientMap contains data (e.g. cryptographic material) that might be used to implement some form of application-level confidentiality. The contents of this field are supposed to always be omitted from the transaction and excluded from the ledger.

ChaincodeProposalPayload.TransientMapEntry

FieldTypeLabelDescription
keystring
valuebytes

Proposal

A Proposal is sent to an endorser for endorsement. The proposal contains:

  1. A header which should be unmarshaled to a Header message. Note that Header is both the header of a Proposal and of a Transaction, in that i) both headers should be unmarshaled to this message; and ii) it is used to compute cryptographic hashes and signatures. The header has fields common to all proposals/transactions. In addition it has a type field for additional customization. An example of this is the ChaincodeHeaderExtension message used to extend the Header for type CHAINCODE.
  2. A payload whose type depends on the header's type field.
  3. An extension whose type depends on the header's type field.

Let us see an example. For type CHAINCODE (see the Header message), we have the following:

  1. The header is a Header message whose extensions field is a ChaincodeHeaderExtension message.
  2. The payload is a ChaincodeProposalPayload message.
  3. The extension is a ChaincodeAction that might be used to ask the endorsers to endorse a specific ChaincodeAction, thus emulating the submitting peer model.
FieldTypeLabelDescription
headerbytesThe header of the proposal. It is the bytes of the Header
payloadbytesThe payload of the proposal as defined by the type in the proposal header.
extensionbytesOptional extensions to the proposal. Its content depends on the Header's type field. For the type CHAINCODE, it might be the bytes of a ChaincodeAction message.

SignedProposal

This structure is necessary to sign the proposal which contains the header and the payload. Without this structure, we would have to concatenate the header and the payload to verify the signature, which could be expensive with large payload

When an endorser receives a SignedProposal message, it should verify the signature over the proposal bytes. This verification requires the following steps:

  1. Verification of the validity of the certificate that was used to produce the signature. The certificate will be available once proposalBytes has been unmarshalled to a Proposal message, and Proposal.header has been unmarshalled to a Header message. While this unmarshalling-before-verifying might not be ideal, it is unavoidable because i) the signature needs to also protect the signing certificate; ii) it is desirable that Header is created once by the client and never changed (for the sake of accountability and non-repudiation). Note also that it is actually impossible to conclusively verify the validity of the certificate included in a Proposal, because the proposal needs to first be endorsed and ordered with respect to certificate expiration transactions. Still, it is useful to pre-filter expired certificates at this stage.
  2. Verification that the certificate is trusted (signed by a trusted CA) and that it is allowed to transact with us (with respect to some ACLs);
  3. Verification that the signature on proposalBytes is valid;
  4. Detect replay attacks;
FieldTypeLabelDescription
proposal_bytesbytesThe bytes of Proposal
signaturebytesSignaure over proposalBytes; this signature is to be verified against the creator identity contained in the header of the Proposal message marshaled as proposalBytes

Top

peer/policy.proto

ApplicationPolicy

ApplicationPolicy captures the diffenrent policy types that are set and evaluted at the application level.

FieldTypeLabelDescription
signature_policycommon.SignaturePolicyEnvelopeSignaturePolicy type is used if the policy is specified as a combination (using threshold gates) of signatures from MSP principals
channel_config_policy_referencestringChannelConfigPolicyReference is used when the policy is specified as a string that references a policy defined in the configuration of the channel

Top

peer/lifecycle/chaincode_definition.proto

ChaincodeEndorsementInfo

ChaincodeEndorsementInfo is (most) everything the peer needs to know in order to execute a chaincode

FieldTypeLabelDescription
versionstring
init_requiredbool
endorsement_pluginstring

ChaincodeValidationInfo

ValidationInfo is (most) everything the peer needs to know in order to validate a transaction

FieldTypeLabelDescription
validation_pluginstring
validation_parameterbytes

Top

peer/lifecycle/lifecycle.proto

ApproveChaincodeDefinitionForMyOrgArgs

ApproveChaincodeDefinitionForMyOrgArgs is the message used as arguments to _lifecycle.ApproveChaincodeDefinitionForMyOrg.

FieldTypeLabelDescription
sequenceint64
namestring
versionstring
endorsement_pluginstring
validation_pluginstring
validation_parameterbytes
collectionscommon.CollectionConfigPackage
init_requiredbool
sourceChaincodeSource

ApproveChaincodeDefinitionForMyOrgResult

ApproveChaincodeDefinitionForMyOrgResult is the message returned by _lifecycle.ApproveChaincodeDefinitionForMyOrg. Currently it returns nothing, but may be extended in the future.

ChaincodeSource

FieldTypeLabelDescription
unavailableChaincodeSource.Unavailable
local_packageChaincodeSource.Local

ChaincodeSource.Local

FieldTypeLabelDescription
package_idstring

ChaincodeSource.Unavailable

CheckCommitReadinessArgs

CheckCommitReadinessArgs is the message used as arguments to _lifecycle.CheckCommitReadiness.

FieldTypeLabelDescription
sequenceint64
namestring
versionstring
endorsement_pluginstring
validation_pluginstring
validation_parameterbytes
collectionscommon.CollectionConfigPackage
init_requiredbool

CheckCommitReadinessResult

CheckCommitReadinessResult is the message returned by _lifecycle.CheckCommitReadiness. It returns a map of orgs to their approval (true/false) for the definition supplied as args.

FieldTypeLabelDescription
approvalsCheckCommitReadinessResult.ApprovalsEntryrepeated

CheckCommitReadinessResult.ApprovalsEntry

FieldTypeLabelDescription
keystring
valuebool

CommitChaincodeDefinitionArgs

CommitChaincodeDefinitionArgs is the message used as arguments to _lifecycle.CommitChaincodeDefinition.

FieldTypeLabelDescription
sequenceint64
namestring
versionstring
endorsement_pluginstring
validation_pluginstring
validation_parameterbytes
collectionscommon.CollectionConfigPackage
init_requiredbool

CommitChaincodeDefinitionResult

CommitChaincodeDefinitionResult is the message returned by _lifecycle.CommitChaincodeDefinition. Currently it returns nothing, but may be extended in the future.

GetInstalledChaincodePackageArgs

GetInstalledChaincodePackageArgs is the message used as the argument to '_lifecycle.GetInstalledChaincodePackage'.

FieldTypeLabelDescription
package_idstring

GetInstalledChaincodePackageResult

GetInstalledChaincodePackageResult is the message returned by '_lifecycle.GetInstalledChaincodePackage'.

FieldTypeLabelDescription
chaincode_install_packagebytes

InstallChaincodeArgs

InstallChaincodeArgs is the message used as the argument to '_lifecycle.InstallChaincode'.

FieldTypeLabelDescription
chaincode_install_packagebytesThis should be a marshaled lifecycle.ChaincodePackage

InstallChaincodeResult

InstallChaincodeArgs is the message returned by '_lifecycle.InstallChaincode'.

FieldTypeLabelDescription
package_idstring
labelstring

QueryChaincodeDefinitionArgs

QueryChaincodeDefinitionArgs is the message used as arguments to _lifecycle.QueryChaincodeDefinition.

FieldTypeLabelDescription
namestring

QueryChaincodeDefinitionResult

QueryChaincodeDefinitionResult is the message returned by _lifecycle.QueryChaincodeDefinition.

FieldTypeLabelDescription
sequenceint64
versionstring
endorsement_pluginstring
validation_pluginstring
validation_parameterbytes
collectionscommon.CollectionConfigPackage
init_requiredbool
approvalsQueryChaincodeDefinitionResult.ApprovalsEntryrepeated

QueryChaincodeDefinitionResult.ApprovalsEntry

FieldTypeLabelDescription
keystring
valuebool

QueryChaincodeDefinitionsArgs

QueryChaincodeDefinitionsArgs is the message used as arguments to _lifecycle.QueryChaincodeDefinitions.

QueryChaincodeDefinitionsResult

QueryChaincodeDefinitionsResult is the message returned by _lifecycle.QueryChaincodeDefinitions.

FieldTypeLabelDescription
chaincode_definitionsQueryChaincodeDefinitionsResult.ChaincodeDefinitionrepeated

QueryChaincodeDefinitionsResult.ChaincodeDefinition

FieldTypeLabelDescription
namestring
sequenceint64
versionstring
endorsement_pluginstring
validation_pluginstring
validation_parameterbytes
collectionscommon.CollectionConfigPackage
init_requiredbool

QueryInstalledChaincodeArgs

QueryInstalledChaincodeArgs is the message used as arguments '_lifecycle.QueryInstalledChaincode'

FieldTypeLabelDescription
package_idstring

QueryInstalledChaincodeResult

QueryInstalledChaincodeResult is the message returned by '_lifecycle.QueryInstalledChaincode'

FieldTypeLabelDescription
package_idstring
labelstring
referencesQueryInstalledChaincodeResult.ReferencesEntryrepeated

QueryInstalledChaincodeResult.Chaincode

FieldTypeLabelDescription
namestring
versionstring

QueryInstalledChaincodeResult.References

FieldTypeLabelDescription
chaincodesQueryInstalledChaincodeResult.Chaincoderepeated

QueryInstalledChaincodeResult.ReferencesEntry

FieldTypeLabelDescription
keystring
valueQueryInstalledChaincodeResult.References

QueryInstalledChaincodesArgs

QueryInstalledChaincodesArgs currently is an empty argument to '_lifecycle.QueryInstalledChaincodes'. In the future, it may be extended to have parameters.

QueryInstalledChaincodesResult

QueryInstalledChaincodesResult is the message returned by '_lifecycle.QueryInstalledChaincodes'. It returns a list of installed chaincodes, including a map of channel name to chaincode name and version pairs of chaincode definitions that reference this chaincode package.

FieldTypeLabelDescription
installed_chaincodesQueryInstalledChaincodesResult.InstalledChaincoderepeated

QueryInstalledChaincodesResult.Chaincode

FieldTypeLabelDescription
namestring
versionstring

QueryInstalledChaincodesResult.InstalledChaincode

FieldTypeLabelDescription
package_idstring
labelstring
referencesQueryInstalledChaincodesResult.InstalledChaincode.ReferencesEntryrepeated

QueryInstalledChaincodesResult.InstalledChaincode.ReferencesEntry

FieldTypeLabelDescription
keystring
valueQueryInstalledChaincodesResult.References

QueryInstalledChaincodesResult.References

FieldTypeLabelDescription
chaincodesQueryInstalledChaincodesResult.Chaincoderepeated

Top

peer/lifecycle/db.proto

StateData

StateData encodes a particular field of a datatype

FieldTypeLabelDescription
Int64int64
Bytesbytes
Stringstring

StateMetadata

StateMetadata describes the keys in a namespace. It is necessary because in collections, range scans are not possible during transactions which write. Therefore we must track the keys in our namespace ourselves.

FieldTypeLabelDescription
datatypestring
fieldsstringrepeated

Top

peer/chaincode_event.proto

ChaincodeEvent

ChaincodeEvent is used for events and registrations that are specific to chaincode string type - "chaincode"

FieldTypeLabelDescription
chaincode_idstring
tx_idstring
event_namestring
payloadbytes

Top

peer/chaincode_shim.proto

ChaincodeMessage

FieldTypeLabelDescription
typeChaincodeMessage.Type
timestampgoogle.protobuf.Timestamp
payloadbytes
txidstring
proposalSignedProposal
chaincode_eventChaincodeEventevent emitted by chaincode. Used only with Init or Invoke. This event is then stored (currently) with Block.NonHashData.TransactionResult
channel_idstringchannel id

DelState

DelState is the payload of a ChaincodeMessage. It contains a key which needs to be recorded in the transaction's write set as a delete operation. If the collection is specified, the key needs to be recorded in the transaction's private write set as a delete operation.

FieldTypeLabelDescription
keystring
collectionstring

GetHistoryForKey

GetHistoryForKey is the payload of a ChaincodeMessage. It contains a key for which the historical values need to be retrieved.

FieldTypeLabelDescription
keystring

GetQueryResult

GetQueryResult is the payload of a ChaincodeMessage. It contains a query string in the form that is supported by the underlying state database. If the collection is specified, the query needs to be executed on the private data. The metadata hold the byte representation of QueryMetadata.

FieldTypeLabelDescription
querystring
collectionstring
metadatabytes

GetState

GetState is the payload of a ChaincodeMessage. It contains a key which is to be fetched from the ledger. If the collection is specified, the key would be fetched from the collection (i.e., private state)

FieldTypeLabelDescription
keystring
collectionstring

GetStateByRange

GetStateByRange is the payload of a ChaincodeMessage. It contains a start key and a end key required to execute range query. If the collection is specified, the range query needs to be executed on the private data. The metadata hold the byte representation of QueryMetadata.

FieldTypeLabelDescription
startKeystring
endKeystring
collectionstring
metadatabytes

GetStateMetadata

FieldTypeLabelDescription
keystring
collectionstring

PutState

PutState is the payload of a ChaincodeMessage. It contains a key and value which needs to be written to the transaction's write set. If the collection is specified, the key and value would be written to the transaction's private write set.

FieldTypeLabelDescription
keystring
valuebytes
collectionstring

PutStateMetadata

FieldTypeLabelDescription
keystring
collectionstring
metadataStateMetadata

QueryMetadata

QueryMetadata is the metadata of a GetStateByRange and GetQueryResult. It contains a pageSize which denotes the number of records to be fetched and a bookmark.

FieldTypeLabelDescription
pageSizeint32
bookmarkstring

QueryResponse

QueryResponse is returned by the peer as a result of a GetStateByRange, GetQueryResult, and GetHistoryForKey. It holds a bunch of records in results field, a flag to denote whether more results need to be fetched from the peer in has_more field, transaction id in id field, and a QueryResponseMetadata in metadata field.

FieldTypeLabelDescription
resultsQueryResultBytesrepeated
has_morebool
idstring
metadatabytes

QueryResponseMetadata

QueryResponseMetadata is the metadata of a QueryResponse. It contains a count which denotes the number of records fetched from the ledger and a bookmark.

FieldTypeLabelDescription
fetched_records_countint32
bookmarkstring

QueryResultBytes

QueryResultBytes hold the byte representation of a record returned by the peer.

FieldTypeLabelDescription
resultBytesbytes

QueryStateClose

FieldTypeLabelDescription
idstring

QueryStateNext

FieldTypeLabelDescription
idstring

StateMetadata

FieldTypeLabelDescription
metakeystring
valuebytes

StateMetadataResult

FieldTypeLabelDescription
entriesStateMetadatarepeated

ChaincodeMessage.Type

NameNumberDescription
UNDEFINED0
REGISTER1
REGISTERED2
INIT3
READY4
TRANSACTION5
COMPLETED6
ERROR7
GET_STATE8
PUT_STATE9
DEL_STATE10
INVOKE_CHAINCODE11
RESPONSE13
GET_STATE_BY_RANGE14
GET_QUERY_RESULT15
QUERY_STATE_NEXT16
QUERY_STATE_CLOSE17
KEEPALIVE18
GET_HISTORY_FOR_KEY19
GET_STATE_METADATA20
PUT_STATE_METADATA21
GET_PRIVATE_DATA_HASH22

ChaincodeSupport

Interface that provides support to chaincode execution. ChaincodeContext provides the context necessary for the server to respond appropriately.

Method NameRequest TypeResponse TypeDescription
RegisterChaincodeMessage streamChaincodeMessage stream

Top

peer/peer.proto

Endorser

Method NameRequest TypeResponse TypeDescription
ProcessProposalSignedProposalProposalResponse

Top

msp/msp_config.proto

FabricCryptoConfig

FabricCryptoConfig contains configuration parameters for the cryptographic algorithms used by the MSP this configuration refers to

FieldTypeLabelDescription
signature_hash_familystringSignatureHashFamily is a string representing the hash family to be used during sign and verify operations. Allowed values are "SHA2" and "SHA3".
identity_identifier_hash_functionstringIdentityIdentifierHashFunction is a string representing the hash function to be used during the computation of the identity identifier of an MSP identity. Allowed values are "SHA256", "SHA384" and "SHA3_256", "SHA3_384".

FabricMSPConfig

FabricMSPConfig collects all the configuration information for a Fabric MSP. Here we assume a default certificate validation policy, where any certificate signed by any of the listed rootCA certs would be considered as valid under this MSP. This MSP may or may not come with a signing identity. If it does, it can also issue signing identities. If it does not, it can only be used to validate and verify certificates.

FieldTypeLabelDescription
namestringName holds the identifier of the MSP; MSP identifier is chosen by the application that governs this MSP. For example, and assuming the default implementation of MSP, that is X.509-based and considers a single Issuer, this can refer to the Subject OU field or the Issuer OU field.
root_certsbytesrepeatedList of root certificates trusted by this MSP they are used upon certificate validation (see comment for IntermediateCerts below)
intermediate_certsbytesrepeatedList of intermediate certificates trusted by this MSP; they are used upon certificate validation as follows: validation attempts to build a path from the certificate to be validated (which is at one end of the path) and one of the certs in the RootCerts field (which is at the other end of the path). If the path is longer than 2, certificates in the middle are searched within the IntermediateCerts pool
adminsbytesrepeatedIdentity denoting the administrator of this MSP
revocation_listbytesrepeatedIdentity revocation list
signing_identitySigningIdentityInfoSigningIdentity holds information on the signing identity this peer is to use, and which is to be imported by the MSP defined before
organizational_unit_identifiersFabricOUIdentifierrepeatedOrganizationalUnitIdentifiers holds one or more fabric organizational unit identifiers that belong to this MSP configuration
crypto_configFabricCryptoConfigFabricCryptoConfig contains the configuration parameters for the cryptographic algorithms used by this MSP
tls_root_certsbytesrepeatedList of TLS root certificates trusted by this MSP. They are returned by GetTLSRootCerts.
tls_intermediate_certsbytesrepeatedList of TLS intermediate certificates trusted by this MSP; They are returned by GetTLSIntermediateCerts.
fabric_node_ousFabricNodeOUsfabric_node_ous contains the configuration to distinguish clients from peers from orderers based on the OUs.

FabricNodeOUs

FabricNodeOUs contains configuration to tell apart clients from peers from orderers based on OUs. If NodeOUs recognition is enabled then an msp identity that does not contain any of the specified OU will be considered invalid.

FieldTypeLabelDescription
enableboolIf true then an msp identity that does not contain any of the specified OU will be considered invalid.
client_ou_identifierFabricOUIdentifierOU Identifier of the clients
peer_ou_identifierFabricOUIdentifierOU Identifier of the peers
admin_ou_identifierFabricOUIdentifierOU Identifier of the admins
orderer_ou_identifierFabricOUIdentifierOU Identifier of the orderers

FabricOUIdentifier

FabricOUIdentifier represents an organizational unit and its related chain of trust identifier.

FieldTypeLabelDescription
certificatebytesCertificate represents the second certificate in a certification chain. (Notice that the first certificate in a certification chain is supposed to be the certificate of an identity). It must correspond to the certificate of root or intermediate CA recognized by the MSP this message belongs to. Starting from this certificate, a certification chain is computed and bound to the OrganizationUnitIdentifier specified
organizational_unit_identifierstringOrganizationUnitIdentifier defines the organizational unit under the MSP identified with MSPIdentifier

IdemixMSPConfig

IdemixMSPConfig collects all the configuration information for an Idemix MSP.

FieldTypeLabelDescription
namestringName holds the identifier of the MSP
ipkbytesipk represents the (serialized) issuer public key
signerIdemixMSPSignerConfigsigner may contain crypto material to configure a default signer
revocation_pkbytesrevocation_pk is the public key used for revocation of credentials
epochint64epoch represents the current epoch (time interval) used for revocation

IdemixMSPSignerConfig

IdemixMSPSIgnerConfig contains the crypto material to set up an idemix signing identity

FieldTypeLabelDescription
credbytescred represents the serialized idemix credential of the default signer
skbytessk is the secret key of the default signer, corresponding to credential Cred
organizational_unit_identifierstringorganizational_unit_identifier defines the organizational unit the default signer is in
roleint32role defines whether the default signer is admin, peer, member or client
enrollment_idstringenrollment_id contains the enrollment id of this signer
credential_revocation_informationbytescredential_revocation_information contains a serialized CredentialRevocationInformation

KeyInfo

KeyInfo represents a (secret) key that is either already stored in the bccsp/keystore or key material to be imported to the bccsp key-store. In later versions it may contain also a keystore identifier

FieldTypeLabelDescription
key_identifierstringIdentifier of the key inside the default keystore; this for the case of Software BCCSP as well as the HSM BCCSP would be the SKI of the key
key_materialbytesKeyMaterial (optional) for the key to be imported; this is properly encoded key bytes, prefixed by the type of the key

MSPConfig

MSPConfig collects all the configuration information for an MSP. The Config field should be unmarshalled in a way that depends on the Type

FieldTypeLabelDescription
typeint32Type holds the type of the MSP; the default one would be of type FABRIC implementing an X.509 based provider
configbytesConfig is MSP dependent configuration info

SigningIdentityInfo

SigningIdentityInfo represents the configuration information related to the signing identity the peer is to use for generating endorsements

FieldTypeLabelDescription
public_signerbytesPublicSigner carries the public information of the signing identity. For an X.509 provider this would be represented by an X.509 certificate
private_signerKeyInfoPrivateSigner denotes a reference to the private key of the peer's signing identity

Top

msp/msp_principal.proto

CombinedPrincipal

CombinedPrincipal governs the organization of the Principal field of a policy principal when principal_classification has indicated that a combined form of principals is required

FieldTypeLabelDescription
principalsMSPPrincipalrepeatedPrincipals refer to combined principals

MSPIdentityAnonymity

MSPIdentityAnonymity can be used to enforce an identity to be anonymous or nominal.

FieldTypeLabelDescription
anonymity_typeMSPIdentityAnonymity.MSPIdentityAnonymityType

MSPPrincipal

MSPPrincipal aims to represent an MSP-centric set of identities. In particular, this structure allows for definition of

  • a group of identities that are member of the same MSP
  • a group of identities that are member of the same organization unit in the same MSP
  • a group of identities that are administering a specific MSP
  • a specific identity Expressing these groups is done given two fields of the fields below
  • Classification, that defines the type of classification of identities in an MSP this principal would be defined on; Classification can take three values: (i) ByMSPRole: that represents a classification of identities within MSP based on one of the two pre-defined MSP rules, "member" and "admin" (ii) ByOrganizationUnit: that represents a classification of identities within MSP based on the organization unit an identity belongs to (iii)ByIdentity that denotes that MSPPrincipal is mapped to a single identity/certificate; this would mean that the Principal bytes message
FieldTypeLabelDescription
principal_classificationMSPPrincipal.ClassificationClassification describes the way that one should process Principal. An Classification value of "ByOrganizationUnit" reflects that "Principal" contains the name of an organization this MSP handles. A Classification value "ByIdentity" means that "Principal" contains a specific identity. Default value denotes that Principal contains one of the groups by default supported by all MSPs ("admin" or "member").
principalbytesPrincipal completes the policy principal definition. For the default principal types, Principal can be either "Admin" or "Member". For the ByOrganizationUnit/ByIdentity values of Classification, PolicyPrincipal acquires its value from an organization unit or identity, respectively. For the Combined Classification type, the Principal is a marshalled CombinedPrincipal.

MSPRole

MSPRole governs the organization of the Principal field of an MSPPrincipal when it aims to define one of the two dedicated roles within an MSP: Admin and Members.

FieldTypeLabelDescription
msp_identifierstringMSPIdentifier represents the identifier of the MSP this principal refers to
roleMSPRole.MSPRoleTypeMSPRoleType defines which of the available, pre-defined MSP-roles an identiy should posess inside the MSP with identifier MSPidentifier

OrganizationUnit

OrganizationUnit governs the organization of the Principal field of a policy principal when a specific organization unity members are to be defined within a policy principal.

FieldTypeLabelDescription
msp_identifierstringMSPIdentifier represents the identifier of the MSP this organization unit refers to
organizational_unit_identifierstringOrganizationUnitIdentifier defines the organizational unit under the MSP identified with MSPIdentifier
certifiers_identifierbytesCertifiersIdentifier is the hash of certificates chain of trust related to this organizational unit

MSPIdentityAnonymity.MSPIdentityAnonymityType

NameNumberDescription
NOMINAL0Represents a nominal MSP Identity
ANONYMOUS1Represents an anonymous MSP Identity

MSPPrincipal.Classification

NameNumberDescription
ROLE0Represents the one of the dedicated MSP roles, the
ORGANIZATION_UNIT1one of a member of MSP network, and the one of an administrator of an MSP network

Denotes a finer grained (affiliation-based) | | IDENTITY | 2 | groupping of entities, per MSP affiliation E.g., this can well be represented by an MSP's Organization unit

Denotes a principal that consists of a single | | ANONYMITY | 3 | identity

Denotes a principal that can be used to enforce | | COMBINED | 4 | an identity to be anonymous or nominal.

Denotes a combined principal |

MSPRole.MSPRoleType

NameNumberDescription
MEMBER0Represents an MSP Member
ADMIN1Represents an MSP Admin
CLIENT2Represents an MSP Client
PEER3Represents an MSP Peer
ORDERER4Represents an MSP Orderer

Top

msp/identities.proto

SerializedIdemixIdentity

This struct represents an Idemix Identity to be used to serialize it and deserialize it. The IdemixMSP will first serialize an idemix identity to bytes using this proto, and then uses these bytes as id_bytes in SerializedIdentity

FieldTypeLabelDescription
nym_xbytesnym_x is the X-component of the pseudonym elliptic curve point. It is a []byte representation of an amcl.BIG The pseudonym can be seen as a public key of the identity, it is used to verify signatures.
nym_ybytesnym_y is the Y-component of the pseudonym elliptic curve point. It is a []byte representation of an amcl.BIG The pseudonym can be seen as a public key of the identity, it is used to verify signatures.
oubytesou contains the organizational unit of the idemix identity
rolebytesrole contains the role of this identity (e.g., ADMIN or MEMBER)
proofbytesproof contains the cryptographic evidence that this identity is valid

SerializedIdentity

This struct represents an Identity (with its MSP identifier) to be used to serialize it and deserialize it

FieldTypeLabelDescription
mspidstringThe identifier of the associated membership service provider
id_bytesbytesthe Identity, serialized according to the rules of its MPS

Top

ledger/rwset/rwset.proto

CollectionHashedReadWriteSet

CollectionHashedReadWriteSet encapsulate the hashed representation for the private read-write set for a collection

FieldTypeLabelDescription
collection_namestring
hashed_rwsetbytesData model specific serialized proto message (e.g., kvrwset.HashedRWSet for KV and Document data models)
pvt_rwset_hashbytesHash of entire private read-write set for a specific collection. This helps in authenticating the private read-write set efficiently

CollectionPvtReadWriteSet

CollectionPvtReadWriteSet encapsulates the private read-write set for a collection

FieldTypeLabelDescription
collection_namestring
rwsetbytesData model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)

NsPvtReadWriteSet

NsPvtReadWriteSet encapsulates the private read-write set for a chaincode

FieldTypeLabelDescription
namespacestring
collection_pvt_rwsetCollectionPvtReadWriteSetrepeated

NsReadWriteSet

NsReadWriteSet encapsulates the read-write set for a chaincode

FieldTypeLabelDescription
namespacestring
rwsetbytesData model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)
collection_hashed_rwsetCollectionHashedReadWriteSetrepeated

TxPvtReadWriteSet

TxPvtReadWriteSet encapsulate the private read-write set for a transaction

FieldTypeLabelDescription
data_modelTxReadWriteSet.DataModel
ns_pvt_rwsetNsPvtReadWriteSetrepeated

TxReadWriteSet

TxReadWriteSet encapsulates a read-write set for a transaction DataModel specifies the enum value of the data model ns_rwset field specifies a list of chaincode specific read-write set (one for each chaincode)

FieldTypeLabelDescription
data_modelTxReadWriteSet.DataModel
ns_rwsetNsReadWriteSetrepeated

TxReadWriteSet.DataModel

NameNumberDescription
KV0

Top

ledger/rwset/kvrwset/kv_rwset.proto

HashedRWSet

HashedRWSet encapsulates hashed representation of a private read-write set for KV or Document data model

FieldTypeLabelDescription
hashed_readsKVReadHashrepeated
hashed_writesKVWriteHashrepeated
metadata_writesKVMetadataWriteHashrepeated

KVMetadataEntry

KVMetadataEntry captures a 'name'ed entry in the metadata of a key/key-hash.

FieldTypeLabelDescription
namestring
valuebytes

KVMetadataWrite

KVMetadataWrite captures all the entries in the metadata associated with a key

FieldTypeLabelDescription
keystring
entriesKVMetadataEntryrepeated

KVMetadataWriteHash

KVMetadataWriteHash captures all the upserts to the metadata associated with a key hash

FieldTypeLabelDescription
key_hashbytes
entriesKVMetadataEntryrepeated

KVRWSet

KVRWSet encapsulates the read-write set for a chaincode that operates upon a KV or Document data model This structure is used for both the public data and the private data

FieldTypeLabelDescription
readsKVReadrepeated
range_queries_infoRangeQueryInforepeated
writesKVWriterepeated
metadata_writesKVMetadataWriterepeated

KVRead

KVRead captures a read operation performed during transaction simulation A 'nil' version indicates a non-existing key read by the transaction

FieldTypeLabelDescription
keystring
versionVersion

KVReadHash

KVReadHash is similar to the KVRead in spirit. However, it captures the hash of the key instead of the key itself version is kept as is for now. However, if the version also needs to be privacy-protected, it would need to be the hash of the version and hence of 'bytes' type

FieldTypeLabelDescription
key_hashbytes
versionVersion

KVWrite

KVWrite captures a write (update/delete) operation performed during transaction simulation

FieldTypeLabelDescription
keystring
is_deletebool
valuebytes

KVWriteHash

KVWriteHash is similar to the KVWrite. It captures a write (update/delete) operation performed during transaction simulation

FieldTypeLabelDescription
key_hashbytes
is_deletebool
value_hashbytes

QueryReads

QueryReads encapsulates the KVReads for the items read by a transaction as a result of a query execution

FieldTypeLabelDescription
kv_readsKVReadrepeated

QueryReadsMerkleSummary

QueryReadsMerkleSummary encapsulates the Merkle-tree hashes for the QueryReads This allows to reduce the size of RWSet in the presence of query results by storing certain hashes instead of actual results. maxDegree field refers to the maximum number of children in the tree at any level maxLevel field contains the lowest level which has lesser nodes than maxDegree (starting from leaf level)

FieldTypeLabelDescription
max_degreeuint32
max_leveluint32
max_level_hashesbytesrepeated

RangeQueryInfo

RangeQueryInfo encapsulates the details of a range query performed by a transaction during simulation. This helps protect transactions from phantom reads by varifying during validation whether any new items got committed within the given range between transaction simuation and validation (in addition to regular checks for updates/deletes of the existing items). readInfo field contains either the KVReads (for the items read by the range query) or a merkle-tree hash if the KVReads exceeds a pre-configured numbers

FieldTypeLabelDescription
start_keystring
end_keystring
itr_exhaustedbool
raw_readsQueryReads
reads_merkle_hashesQueryReadsMerkleSummary

Version

Version encapsulates the version of a Key A version of a committed key is maintained as the height of the transaction that committed the key. The height is represenetd as a tuple <blockNum, txNum> where the txNum is the position of the transaction (starting with 0) within block

FieldTypeLabelDescription
block_numuint64
tx_numuint64

Top

ledger/queryresult/kv_query_result.proto

KV

KV -- QueryResult for range/execute query. Holds a key and corresponding value.

FieldTypeLabelDescription
namespacestring
keystring
valuebytes

KeyModification

KeyModification -- QueryResult for history query. Holds a transaction ID, value, timestamp, and delete marker which resulted from a history query.

FieldTypeLabelDescription
tx_idstring
valuebytes
timestampgoogle.protobuf.Timestamp
is_deletebool

Top

discovery/protocol.proto

AuthInfo

AuthInfo aggregates authentication information that the server uses to authenticate the client

FieldTypeLabelDescription
client_identitybytesThis is the identity of the client that is used to verify the signature on the SignedRequest's payload. It is a msp.SerializedIdentity in bytes form
client_tls_cert_hashbytesThis is the hash of the client's TLS cert. When the network is running with TLS, clients that don't include a certificate will be denied access to the service. Since the Request is encapsulated with a SignedRequest (which is signed), this binds the TLS session to the enrollement identity of the client and therefore both authenticates the client to the server, and also prevents the server from relaying the request message to another server.

ChaincodeCall

ChaincodeCall defines a call to a chaincode. It may have collections that are related to the chaincode

FieldTypeLabelDescription
namestring
collection_namesstringrepeated

ChaincodeInterest

ChaincodeInterest defines an interest about an endorsement for a specific single chaincode invocation. Multiple chaincodes indicate chaincode to chaincode invocations.

FieldTypeLabelDescription
chaincodesChaincodeCallrepeated

ChaincodeQuery

ChaincodeQuery requests ChaincodeQueryResults for a given list of chaincode invocations. Each invocation is a separate one, and the endorsement policy is evaluated independantly for each given interest.

FieldTypeLabelDescription
interestsChaincodeInterestrepeated

ChaincodeQueryResult

ChaincodeQueryResult contains EndorsementDescriptors for chaincodes

FieldTypeLabelDescription
contentEndorsementDescriptorrepeated

ConfigQuery

ConfigQuery requests a ConfigResult

ConfigResult

FieldTypeLabelDescription
mspsConfigResult.MspsEntryrepeatedmsps is a map from MSP_ID to FabricMSPConfig
orderersConfigResult.OrderersEntryrepeatedorderers is a map from MSP_ID to endpoint lists of orderers

ConfigResult.MspsEntry

FieldTypeLabelDescription
keystring
valuemsp.FabricMSPConfig

ConfigResult.OrderersEntry

FieldTypeLabelDescription
keystring
valueEndpoints

EndorsementDescriptor

EndorsementDescriptor contains information about which peers can be used to request endorsement from, such that the endorsement policy would be fulfilled. Here is how to compute a set of peers to ask an endorsement from, given an EndorsementDescriptor: Let e: G --> P be the endorsers_by_groups field that maps a group to a set of peers. Note that applying e on a group g yields a set of peers.

  1. Select a layout l: G --> N out of the layouts given. l is the quantities_by_group field of a Layout, and it maps a group to an integer.
  2. R = {} (an empty set of peers)
  3. For each group g in the layout l, compute n = l(g) 3.1) Denote P_g as a set of n random peers {p0, p1, ... p_n} selected from e(g) 3.2) R = R U P_g (add P_g to R)
  4. The set of peers R is the peers the client needs to request endorsements from
FieldTypeLabelDescription
chaincodestring
endorsers_by_groupsEndorsementDescriptor.EndorsersByGroupsEntryrepeatedSpecifies the endorsers, separated to groups.
layoutsLayoutrepeatedSpecifies options of fulfulling the endorsement policy. Each option lists the group names, and the amount of signatures needed from each group.

EndorsementDescriptor.EndorsersByGroupsEntry

FieldTypeLabelDescription
keystring
valuePeers

Endpoint

Endpoint is a combination of a host and a port

FieldTypeLabelDescription
hoststring
portuint32

Endpoints

Endpoints is a list of Endpoint(s)

FieldTypeLabelDescription
endpointEndpointrepeated

Error

Error denotes that something went wrong and contains the error message

FieldTypeLabelDescription
contentstring

Layout

Layout contains a mapping from a group name to number of peers that are needed for fulfilling an endorsement policy

FieldTypeLabelDescription
quantities_by_groupLayout.QuantitiesByGroupEntryrepeatedSpecifies how many non repeated signatures of each group are needed for endorsement

Layout.QuantitiesByGroupEntry

FieldTypeLabelDescription
keystring
valueuint32

LocalPeerQuery

LocalPeerQuery queries for peers in a non channel context

Peer

Peer contains information about the peer such as its channel specific state, and membership information.

FieldTypeLabelDescription
state_infogossip.EnvelopeThis is an Envelope of a GossipMessage with a gossip.StateInfo message
membership_infogossip.EnvelopeThis is an Envelope of a GossipMessage with a gossip.AliveMessage message
identitybytesThis is the msp.SerializedIdentity of the peer, represented in bytes.

PeerMembershipQuery

PeerMembershipQuery requests PeerMembershipResult. The filter field may be optionally populated in order for the peer membership to be filtered according to chaincodes that are installed on peers and collection access control policies.

FieldTypeLabelDescription
filterChaincodeInterest

PeerMembershipResult

PeerMembershipResult contains peers mapped by their organizations (MSP_ID)

FieldTypeLabelDescription
peers_by_orgPeerMembershipResult.PeersByOrgEntryrepeated

PeerMembershipResult.PeersByOrgEntry

FieldTypeLabelDescription
keystring
valuePeers

Peers

Peers contains a list of Peer(s)

FieldTypeLabelDescription
peersPeerrepeated

Query

Query asks for information in the context of a specific channel

FieldTypeLabelDescription
channelstring
config_queryConfigQueryConfigQuery is used to query for the configuration of the channel, such as FabricMSPConfig, and rorderer endpoints. The client has to query a peer it trusts as it doesn't have means to self-verify the authenticity of the returned result. The result is returned in the form of ConfigResult.
peer_queryPeerMembershipQueryPeerMembershipQuery queries for peers in a channel context, and returns PeerMembershipResult
cc_queryChaincodeQueryChaincodeQuery queries for chaincodes by their name and version. An empty version means any version can by returned.
local_peersLocalPeerQueryLocalPeerQuery queries for peers in a non channel context, and returns PeerMembershipResult

QueryResult

QueryResult contains a result for a given Query. The corresponding Query can be inferred by the index of the QueryResult from its enclosing Response message. QueryResults are ordered in the same order as the Queries are ordered in their enclosing Request.

FieldTypeLabelDescription
errorErrorError indicates failure or refusal to process the query
config_resultConfigResultConfigResult contains the configuration of the channel, such as FabricMSPConfig and orderer endpoints
cc_query_resChaincodeQueryResultChaincodeQueryResult contains information about chaincodes, and their corresponding endorsers
membersPeerMembershipResultPeerMembershipResult contains information about peers, such as their identity, endpoints, and channel related state.

Request

Request contains authentication info about the client that sent the request and the queries it wishes to query the service

FieldTypeLabelDescription
authenticationAuthInfoauthentication contains information that the service uses to check the client's eligibility for the queries.
queriesQueryrepeatedqueries

Response

FieldTypeLabelDescription
resultsQueryResultrepeatedThe results are returned in the same order of the queries

SignedRequest

SignedRequest contains a serialized Request in the payload field and a signature. The identity that is used to verify the signature can be extracted from the authentication field of type AuthInfo in the Request itself after deserializing it.

FieldTypeLabelDescription
payloadbytes
signaturebytes

Discovery

Discovery defines a service that serves information about the fabric network like which peers, orderers, chaincodes, etc.

Method NameRequest TypeResponse TypeDescription
DiscoverSignedRequestResponseDiscover receives a signed request, and returns a response.

Top

orderer/configuration.proto

BatchSize

FieldTypeLabelDescription
max_message_countuint32Simply specified as number of messages for now, in the future we may want to allow this to be specified by size in bytes
absolute_max_bytesuint32The byte count of the serialized messages in a batch cannot exceed this value.
preferred_max_bytesuint32The byte count of the serialized messages in a batch should not exceed this value.

BatchTimeout

FieldTypeLabelDescription
timeoutstringAny duration string parseable by ParseDuration(): https://golang.org/pkg/time/#ParseDuration

ChannelRestrictions

ChannelRestrictions is the mssage which conveys restrictions on channel creation for an orderer

FieldTypeLabelDescription
max_countuint64The max count of channels to allow to be created, a value of 0 indicates no limit

ConsensusType

FieldTypeLabelDescription
typestringThe consensus type: "solo", "kafka" or "etcdraft".
metadatabytesOpaque metadata, dependent on the consensus type.
stateConsensusType.StateThe state signals the ordering service to go into maintenance mode, typically for consensus-type migration.

KafkaBrokers

Carries a list of bootstrap brokers, i.e. this is not the exclusive set of brokers an ordering service

FieldTypeLabelDescription
brokersstringrepeatedEach broker here should be identified using the (IP

ConsensusType.State

State defines the orderer mode of operation, typically for consensus-type migration. NORMAL is during normal operation, when consensus-type migration is not, and can not, take place. MAINTENANCE is when the consensus-type can be changed.

NameNumberDescription
STATE_NORMAL0
STATE_MAINTENANCE1

Top

orderer/kafka.proto

KafkaMessage

KafkaMessage is a wrapper type for the messages that the Kafka-based orderer deals with.

FieldTypeLabelDescription
regularKafkaMessageRegular
time_to_cutKafkaMessageTimeToCut
connectKafkaMessageConnect

KafkaMessageConnect

KafkaMessageConnect is posted by an orderer upon booting up. It is used to prevent the panic that would be caused if we were to consume an empty partition. It is ignored by all orderers when processing the partition.

FieldTypeLabelDescription
payloadbytes

KafkaMessageRegular

KafkaMessageRegular wraps a marshalled envelope.

FieldTypeLabelDescription
payloadbytes
config_sequint64
classKafkaMessageRegular.Class
original_offsetint64

KafkaMessageTimeToCut

KafkaMessageTimeToCut is used to signal to the orderers that it is time to cut block <block_number>.

FieldTypeLabelDescription
block_numberuint64

KafkaMetadata

KafkaMetadata is encoded into the ORDERER block to keep track of Kafka-related metadata associated with this block.

FieldTypeLabelDescription
last_offset_persistedint64LastOffsetPersisted is the encoded value for the Metadata message which is encoded in the ORDERER block metadata index for the case of the Kafka-based orderer.
last_original_offset_processedint64LastOriginalOffsetProcessed is used to keep track of the newest offset processed if a message is re-validated and re-ordered. This value is used to deduplicate re-submitted messages from multiple orderer so that we don't bother re-processing it again.
last_resubmitted_config_offsetint64LastResubmittedConfigOffset is used to capture the newest offset of CONFIG kafka message, which is revalidated and resubmitted. By comparing this with LastOriginalOffsetProcessed, we could detemine whether there are still CONFIG messages that have been resubmitted but NOT processed yet. It's used as condition to block ingress messages, so we could reduce the overhead of repeatedly resubmitting messages as config seq keeps advancing.

KafkaMessageRegular.Class

NameNumberDescription
UNKNOWN0
NORMAL1
CONFIG2

Top

orderer/ab.proto

BroadcastResponse

FieldTypeLabelDescription
statuscommon.StatusStatus code, which may be used to programatically respond to success/failure
infostringInfo string which may contain additional information about the status returned

DeliverResponse

FieldTypeLabelDescription
statuscommon.Status
blockcommon.Block

SeekInfo

SeekInfo specifies the range of requested blocks to return If the start position is not found, an error is immediately returned Otherwise, blocks are returned until a missing block is encountered, then behavior is dictated by the SeekBehavior specified.

FieldTypeLabelDescription
startSeekPositionThe position to start the deliver from
stopSeekPositionThe position to stop the deliver
behaviorSeekInfo.SeekBehaviorThe behavior when a missing block is encountered
error_responseSeekInfo.SeekErrorResponseHow to respond to errors reported to the deliver service

SeekNewest

SeekOldest

SeekPosition

FieldTypeLabelDescription
newestSeekNewest
oldestSeekOldest
specifiedSeekSpecified

SeekSpecified

FieldTypeLabelDescription
numberuint64

SeekInfo.SeekBehavior

If BLOCK_UNTIL_READY is specified, the reply will block until the requested blocks are available, if FAIL_IF_NOT_READY is specified, the reply will return an error indicating that the block is not found. To request that all blocks be returned indefinitely as they are created, behavior should be set to BLOCK_UNTIL_READY and the stop should be set to specified with a number of MAX_UINT64

NameNumberDescription
BLOCK_UNTIL_READY0
FAIL_IF_NOT_READY1

SeekInfo.SeekErrorResponse

SeekErrorTolerance indicates to the server how block provider errors should be tolerated. By default, if the deliver service detects a problem in the underlying block source (typically, in the orderer, a consenter error), it will begin to reject deliver requests. This is to prevent a client from waiting for blocks from an orderer which is stuck in an errored state. This is almost always the desired behavior and clients should stick with the default STRICT checking behavior. However, in some scenarios, particularly when attempting to recover from a crash or other corruption, it's desirable to force an orderer to respond with blocks on a best effort basis, even if the backing consensus implementation is in an errored state. In this case, set the SeekErrorResponse to BEST_EFFORT to ignore the consenter errors.

NameNumberDescription
STRICT0
BEST_EFFORT1

AtomicBroadcast

Method NameRequest TypeResponse TypeDescription
Broadcast.common.Envelope streamBroadcastResponse streambroadcast receives a reply of Acknowledgement for each common.Envelope in order, indicating success or type of failure
Deliver.common.Envelope streamDeliverResponse streamdeliver first requires an Envelope of type DELIVER_SEEK_INFO with Payload data as a mashaled SeekInfo message, then a stream of block replies is received.

Top

orderer/cluster.proto

ConsensusRequest

ConsensusRequest is a consensus specific message sent to a cluster member.

FieldTypeLabelDescription
channelstring
payloadbytes
metadatabytes

StepRequest

StepRequest wraps a message that is sent to a cluster member.

FieldTypeLabelDescription
consensus_requestConsensusRequestconsensus_request is a consensus specific message.
submit_requestSubmitRequestsubmit_request is a relay of a transaction.

StepResponse

StepResponse is a message received from a cluster member.

FieldTypeLabelDescription
submit_resSubmitResponse

SubmitRequest

SubmitRequest wraps a transaction to be sent for ordering.

FieldTypeLabelDescription
channelstring
last_validation_sequint64last_validation_seq denotes the last configuration sequence at which the sender validated this message.
payloadcommon.Envelopecontent is the fabric transaction that is forwarded to the cluster member.

SubmitResponse

SubmitResponse returns a success or failure status to the sender.

FieldTypeLabelDescription
channelstring
statuscommon.StatusStatus code, which may be used to programatically respond to success/failure.
infostringInfo string which may contain additional information about the returned status.

Cluster

Cluster defines communication between cluster members.

Method NameRequest TypeResponse TypeDescription
StepStepRequest streamStepResponse streamStep passes an implementation-specific message to another cluster member.

Top

orderer/etcdraft/configuration.proto

ConfigMetadata

ConfigMetadata is serialized and set as the value of ConsensusType.Metadata in a channel configuration when the ConsensusType.Type is set "etcdraft".

FieldTypeLabelDescription
consentersConsenterrepeated
optionsOptions

Consenter

Consenter represents a consenting node (i.e. replica).

FieldTypeLabelDescription
hoststring
portuint32
client_tls_certbytes
server_tls_certbytes

Options

Options to be specified for all the etcd/raft nodes. These can be modified on a per-channel basis.

FieldTypeLabelDescription
tick_intervalstringtime duration format, e.g. 500ms
election_tickuint32
heartbeat_tickuint32
max_inflight_blocksuint32
snapshot_interval_sizeuint32Take snapshot when cumulative data exceeds certain size in bytes.

Top

orderer/etcdraft/metadata.proto

BlockMetadata

BlockMetadata stores data used by the Raft OSNs when coordinating with each other, to be serialized into block meta dta field and used after failres and restarts.

FieldTypeLabelDescription
consenter_idsuint64repeatedMaintains a mapping between the cluster's OSNs and their Raft IDs.
next_consenter_iduint64Carries the Raft ID value that will be assigned to the next OSN that will join this cluster.
raft_indexuint64Index of etcd/raft entry for current block.

ClusterMetadata

ClusterMetadata encapsulates metadata that is exchanged among cluster nodes

FieldTypeLabelDescription
active_nodesuint64repeatedIndicates active nodes in cluster that are reacheable by Raft leader

Top

gossip/message.proto

Acknowledgement

FieldTypeLabelDescription
errorstring

AliveMessage

AliveMessage is sent to inform remote peers of a peer's existence and activity

FieldTypeLabelDescription
membershipMember
timestampPeerTime
identitybytes

Chaincode

Chaincode represents a Chaincode that is installed on a peer

FieldTypeLabelDescription
namestring
versionstring
metadatabytes

ConnEstablish

ConnEstablish is the message used for the gossip handshake Whenever a peer connects to another peer, it handshakes with it by sending this message that proves its identity

FieldTypeLabelDescription
pki_idbytes
identitybytes
tls_cert_hashbytes

DataDigest

DataDigest is the message sent from the receiver peer to the initator peer and contains the data items it has

FieldTypeLabelDescription
nonceuint64
digestsbytesrepeatedMaybe change this to bitmap later on
msg_typePullMsgType

DataMessage

DataMessage is the message that contains a block

FieldTypeLabelDescription
payloadPayload

DataRequest

DataRequest is a message used for a peer to request certain data blocks from a remote peer

FieldTypeLabelDescription
nonceuint64
digestsbytesrepeated
msg_typePullMsgType

DataUpdate

DataUpdate is the final message in the pull phase sent from the receiver to the initiator

FieldTypeLabelDescription
nonceuint64
dataEnveloperepeated
msg_typePullMsgType

Empty

Empty is used for pinging and in tests

Envelope

Envelope contains a marshalled GossipMessage and a signature over it. It may also contain a SecretEnvelope which is a marshalled Secret

FieldTypeLabelDescription
payloadbytes
signaturebytes
secret_envelopeSecretEnvelope

GossipHello

GossipHello is the message that is used for the peer to initiate a pull round with another peer

FieldTypeLabelDescription
nonceuint64
metadatabytes
msg_typePullMsgType

GossipMessage

GossipMessage defines the message sent in a gossip network

FieldTypeLabelDescription
nonceuint64used mainly for testing, but will might be used in the future for ensuring message delivery by acking
channelbytesThe channel of the message. Some GossipMessages may set this to nil, because they are cross-channels but some may not
tagGossipMessage.Tagdetermines to which peers it is allowed to forward the message
alive_msgAliveMessageMembership
mem_reqMembershipRequest
mem_resMembershipResponse
data_msgDataMessageContains a ledger block
helloGossipHelloUsed for push&pull
data_digDataDigest
data_reqDataRequest
data_updateDataUpdate
emptyEmptyEmpty message, used for pinging
connConnEstablishConnEstablish, used for establishing a connection
state_infoStateInfoUsed for relaying information about state
state_snapshotStateInfoSnapshotUsed for sending sets of StateInfo messages
state_info_pull_reqStateInfoPullRequestUsed for asking for StateInfoSnapshots
state_requestRemoteStateRequestUsed to ask from a remote peer a set of blocks
state_responseRemoteStateResponseUsed to send a set of blocks to a remote peer
leadership_msgLeadershipMessageUsed to indicate intent of peer to become leader
peer_identityPeerIdentityUsed to learn of a peer's certificate
ackAcknowledgement
privateReqRemotePvtDataRequestUsed to request private data
privateResRemotePvtDataResponseUsed to respond to private data requests
private_dataPrivateDataMessageEncapsulates private data used to distribute private rwset after the endorsement

LeadershipMessage

Leadership Message is sent during leader election to inform remote peers about intent of peer to proclaim itself as leader

FieldTypeLabelDescription
pki_idbytes
timestampPeerTime
is_declarationbool

Member

Member holds membership-related information about a peer

FieldTypeLabelDescription
endpointstring
metadatabytes
pki_idbytes

MembershipRequest

MembershipRequest is used to ask membership information from a remote peer

FieldTypeLabelDescription
self_informationEnvelope
knownbytesrepeated

MembershipResponse

MembershipResponse is used for replying to MembershipRequests

FieldTypeLabelDescription
aliveEnveloperepeated
deadEnveloperepeated

Payload

Payload contains a block

FieldTypeLabelDescription
seq_numuint64
databytes
private_databytesrepeated

PeerIdentity

PeerIdentity defines the identity of the peer Used to make other peers learn of the identity of a certain peer

FieldTypeLabelDescription
pki_idbytes
certbytes
metadatabytes

PeerTime

PeerTime defines the logical time of a peer's life

FieldTypeLabelDescription
inc_numuint64
seq_numuint64

PrivateDataMessage

PrivateDataMessage message which includes private data information to distributed once transaction has been endorsed

FieldTypeLabelDescription
payloadPrivatePayload

PrivatePayload

PrivatePayload payload to encapsulate private data with collection name to enable routing based on collection partitioning

FieldTypeLabelDescription
collection_namestring
namespacestring
tx_idstring
private_rwsetbytes
private_sim_heightuint64
collection_configscommon.CollectionConfigPackage

Properties

FieldTypeLabelDescription
ledger_heightuint64
left_channelbool
chaincodesChaincoderepeated

PvtDataDigest

PvtDataDigest defines a digest of private data

FieldTypeLabelDescription
tx_idstring
namespacestring
collectionstring
block_sequint64
seq_in_blockuint64

PvtDataElement

FieldTypeLabelDescription
digestPvtDataDigest
payloadbytesrepeatedthe payload is a marshaled kvrwset.KVRWSet

PvtDataPayload

PvtPayload augments private rwset data and tx index inside the block

FieldTypeLabelDescription
tx_seq_in_blockuint64
payloadbytesEncodes marhslaed bytes of rwset.TxPvtReadWriteSet defined in rwset.proto

RemotePvtDataRequest

RemotePrivateDataRequest message used to request missing private rwset

FieldTypeLabelDescription
digestsPvtDataDigestrepeated

RemotePvtDataResponse

RemotePrivateData message to response on private data replication request

FieldTypeLabelDescription
elementsPvtDataElementrepeated

RemoteStateRequest

RemoteStateRequest is used to ask a set of blocks from a remote peer

FieldTypeLabelDescription
start_seq_numuint64
end_seq_numuint64

RemoteStateResponse

RemoteStateResponse is used to send a set of blocks to a remote peer

FieldTypeLabelDescription
payloadsPayloadrepeated

Secret

Secret is an entity that might be omitted from an Envelope when the remote peer that is receiving the Envelope shouldn't know the secret's content.

FieldTypeLabelDescription
internalEndpointstring

SecretEnvelope

SecretEnvelope is a marshalled Secret and a signature over it. The signature should be validated by the peer that signed the Envelope the SecretEnvelope came with

FieldTypeLabelDescription
payloadbytes
signaturebytes

StateInfo

StateInfo is used for a peer to relay its state information to other peers

FieldTypeLabelDescription
timestampPeerTime
pki_idbytes
channel_MACbyteschannel_MAC is an authentication code that proves that the peer that sent this message knows the name of the channel.
propertiesProperties

StateInfoPullRequest

StateInfoPullRequest is used to fetch a StateInfoSnapshot from a remote peer

FieldTypeLabelDescription
channel_MACbyteschannel_MAC is an authentication code that proves that the peer that sent this message knows the name of the channel.

StateInfoSnapshot

StateInfoSnapshot is an aggregation of StateInfo messages

FieldTypeLabelDescription
elementsEnveloperepeated

GossipMessage.Tag

NameNumberDescription
UNDEFINED0
EMPTY1
ORG_ONLY2
CHAN_ONLY3
CHAN_AND_ORG4
CHAN_OR_ORG5

PullMsgType

NameNumberDescription
UNDEFINED0
BLOCK_MSG1
IDENTITY_MSG2

Gossip

Gossip

Method NameRequest TypeResponse TypeDescription
GossipStreamEnvelope streamEnvelope streamGossipStream is the gRPC stream used for sending and receiving messages
PingEmptyEmptyPing is used to probe a remote peer's aliveness

Top

transientstore/transientstore.proto

TxPvtReadWriteSetWithConfigInfo

TxPvtReadWriteSetWithConfigInfo encapsulates the transaction's private read-write set and additional information about the configurations such as the latest collection config when the transaction is simulated

FieldTypeLabelDescription
endorsed_atuint64
pvt_rwsetrwset.TxPvtReadWriteSet
collection_configsTxPvtReadWriteSetWithConfigInfo.CollectionConfigsEntryrepeated

TxPvtReadWriteSetWithConfigInfo.CollectionConfigsEntry

FieldTypeLabelDescription
keystring
valuecommon.CollectionConfigPackage

Top

common/configuration.proto

BlockDataHashingStructure

BlockDataHashingStructure is encoded into the configuration transaction as a configuration item of type Chain with a Key of "BlockDataHashingStructure" and a Value of HashingAlgorithm as marshaled protobuf bytes

FieldTypeLabelDescription
widthuint32width specifies the width of the Merkle tree to use when computing the BlockDataHash in order to replicate flat hashing, set this width to MAX_UINT32

Capabilities

Capabilities message defines the capabilities a particular binary must implement for that binary to be able to safely participate in the channel. The capabilities message is defined at the /Channel level, the /Channel/Application level, and the /Channel/Orderer level.

The /Channel level capabilties define capabilities which both the orderer and peer binaries must satisfy. These capabilties might be things like a new MSP type, or a new policy type.

The /Channel/Orderer level capabilties define capabilities which must be supported by the orderer, but which have no bearing on the behavior of the peer. For instance if the orderer changes the logic for how it constructs new channels, only all orderers must agree on the new logic. The peers do not need to be aware of this change as they only interact with the channel after it has been constructed.

Finally, the /Channel/Application level capabilities define capabilities which the peer binary must satisfy, but which have no bearing on the orderer. For instance, if the peer adds a new UTXO transaction type, or changes the chaincode lifecycle requirements, all peers must agree on the new logic. However, orderers never inspect transactions this deeply, and therefore have no need to be aware of the change.

The capabilities strings defined in these messages typically correspond to release binary versions (e.g. "V1.1"), and are used primarilly as a mechanism for a fully upgraded network to switch from one set of logic to a new one.

Although for V1.1, the orderers must be upgraded to V1.1 prior to the rest of the network, going forward, because of the split between the /Channel, /Channel/Orderer and /Channel/Application capabilities. It should be possible for the orderer and application networks to upgrade themselves independently (with the exception of any new capabilities defined at the /Channel level).

FieldTypeLabelDescription
capabilitiesCapabilities.CapabilitiesEntryrepeated

Capabilities.CapabilitiesEntry

FieldTypeLabelDescription
keystring
valueCapability

Capability

Capability is an empty message for the time being. It is defined as a protobuf message rather than a constant, so that we may extend capabilities with other fields if the need arises in the future. For the time being, a capability being in the capabilities map requires that that capability be supported.

Consortium

Consortium represents the consortium context in which the channel was created

FieldTypeLabelDescription
namestring

HashingAlgorithm

HashingAlgorithm is encoded into the configuration transaction as a configuration item of type Chain with a Key of "HashingAlgorithm" and a Value of HashingAlgorithm as marshaled protobuf bytes

FieldTypeLabelDescription
namestringCurrently supported algorithms are: SHAKE256

OrdererAddresses

OrdererAddresses is encoded into the configuration transaction as a configuration item of type Chain with a Key of "OrdererAddresses" and a Value of OrdererAddresses as marshaled protobuf bytes

FieldTypeLabelDescription
addressesstringrepeated

Top

common/ledger.proto

BlockchainInfo

Contains information about the blockchain ledger such as height, current block hash, and previous block hash.

FieldTypeLabelDescription
heightuint64
currentBlockHashbytes
previousBlockHashbytes

Top

common/policies.proto

ImplicitMetaPolicy

ImplicitMetaPolicy is a policy type which depends on the hierarchical nature of the configuration It is implicit because the rule is generate implicitly based on the number of sub policies It is meta because it depends only on the result of other policies When evaluated, this policy iterates over all immediate child sub-groups, retrieves the policy of name sub_policy, evaluates the collection and applies the rule. For example, with 4 sub-groups, and a policy name of "foo", ImplicitMetaPolicy retrieves each sub-group, retrieves policy "foo" for each subgroup, evaluates it, and, in the case of ANY 1 satisfied is sufficient, ALL would require 4 signatures, and MAJORITY would require 3 signatures.

FieldTypeLabelDescription
sub_policystring
ruleImplicitMetaPolicy.Rule

Policy

Policy expresses a policy which the orderer can evaluate, because there has been some desire expressed to support multiple policy engines, this is typed as a oneof for now

FieldTypeLabelDescription
typeint32For outside implementors, consider the first 1000 types reserved, otherwise one of PolicyType
valuebytes

SignaturePolicy

SignaturePolicy is a recursive message structure which defines a featherweight DSL for describing policies which are more complicated than 'exactly this signature'. The NOutOf operator is sufficent to express AND as well as OR, as well as of course N out of the following M policies SignedBy implies that the signature is from a valid certificate which is signed by the trusted authority specified in the bytes. This will be the certificate itself for a self-signed certificate and will be the CA for more traditional certificates

FieldTypeLabelDescription
signed_byint32
n_out_ofSignaturePolicy.NOutOf

SignaturePolicy.NOutOf

FieldTypeLabelDescription
nint32
rulesSignaturePolicyrepeated

SignaturePolicyEnvelope

SignaturePolicyEnvelope wraps a SignaturePolicy and includes a version for future enhancements

FieldTypeLabelDescription
versionint32
ruleSignaturePolicy
identitiesMSPPrincipalrepeated

ImplicitMetaPolicy.Rule

NameNumberDescription
ANY0Requires any of the sub-policies be satisfied, if no sub-policies exist, always returns true
ALL1Requires all of the sub-policies be satisfied
MAJORITY2Requires a strict majority (greater than half) of the sub-policies be satisfied

Policy.PolicyType

NameNumberDescription
UNKNOWN0Reserved to check for proper initialization
SIGNATURE1
MSP2
IMPLICIT_META3

Top

common/configtx.proto

Config

Config represents the config for a particular channel

FieldTypeLabelDescription
sequenceuint64
channel_groupConfigGroupchannel_group is a bad name for this, it should be changed to root when API breakage is allowed

ConfigEnvelope

ConfigEnvelope is designed to contain all configuration for a chain with no dependency on previous configuration transactions.

It is generated with the following scheme:

  1. Retrieve the existing configuration
  2. Note the config properties (ConfigValue, ConfigPolicy, ConfigGroup) to be modified
  3. Add any intermediate ConfigGroups to the ConfigUpdate.read_set (sparsely)
  4. Add any additional desired dependencies to ConfigUpdate.read_set (sparsely)
  5. Modify the config properties, incrementing each version by 1, set them in the ConfigUpdate.write_set Note: any element not modified but specified should already be in the read_set, so may be specified sparsely
  6. Create ConfigUpdate message and marshal it into ConfigUpdateEnvelope.update and encode the required signatures a) Each signature is of type ConfigSignature b) The ConfigSignature signature is over the concatenation of signature_header and the ConfigUpdate bytes (which includes a ChainHeader)
  7. Submit new Config for ordering in Envelope signed by submitter a) The Envelope Payload has data set to the marshaled ConfigEnvelope b) The Envelope Payload has a header of type Header.Type.CONFIG_UPDATE

The configuration manager will verify:

  1. All items in the read_set exist at the read versions
  2. All items in the write_set at a different version than, or not in, the read_set have been appropriately signed according to their mod_policy
  3. The new configuration satisfies the ConfigSchema
FieldTypeLabelDescription
configConfigA marshaled Config structure
last_updateEnvelopeThe last CONFIG_UPDATE message which generated this current configuration

ConfigGroup

ConfigGroup is the hierarchical data structure for holding config

FieldTypeLabelDescription
versionuint64
groupsConfigGroup.GroupsEntryrepeated
valuesConfigGroup.ValuesEntryrepeated
policiesConfigGroup.PoliciesEntryrepeated
mod_policystring

ConfigGroup.GroupsEntry

FieldTypeLabelDescription
keystring
valueConfigGroup

ConfigGroup.PoliciesEntry

FieldTypeLabelDescription
keystring
valueConfigPolicy

ConfigGroup.ValuesEntry

FieldTypeLabelDescription
keystring
valueConfigValue

ConfigGroupSchema

FieldTypeLabelDescription
groupsConfigGroupSchema.GroupsEntryrepeated
valuesConfigGroupSchema.ValuesEntryrepeated
policiesConfigGroupSchema.PoliciesEntryrepeated

ConfigGroupSchema.GroupsEntry

FieldTypeLabelDescription
keystring
valueConfigGroupSchema

ConfigGroupSchema.PoliciesEntry

FieldTypeLabelDescription
keystring
valueConfigPolicySchema

ConfigGroupSchema.ValuesEntry

FieldTypeLabelDescription
keystring
valueConfigValueSchema

ConfigPolicy

FieldTypeLabelDescription
versionuint64
policyPolicy
mod_policystring

ConfigPolicySchema

ConfigSignature

FieldTypeLabelDescription
signature_headerbytesA marshaled SignatureHeader
signaturebytesSignature over the concatenation signatureHeader bytes and config bytes

ConfigUpdate

ConfigUpdate is used to submit a subset of config and to have the orderer apply to Config it is always submitted inside a ConfigUpdateEnvelope which allows the addition of signatures resulting in a new total configuration. The update is applied as follows:

  1. The versions from all of the elements in the read_set is verified against the versions in the existing config. If there is a mismatch in the read versions, then the config update fails and is rejected.
  2. Any elements in the write_set with the same version as the read_set are ignored.
  3. The corresponding mod_policy for every remaining element in the write_set is collected.
  4. Each policy is checked against the signatures from the ConfigUpdateEnvelope, any failing to verify are rejected
  5. The write_set is applied to the Config and the ConfigGroupSchema verifies that the updates were legal
FieldTypeLabelDescription
channel_idstringWhich channel this config update is for
read_setConfigGroupReadSet explicitly lists the portion of the config which was read, this should be sparse with only Version set
write_setConfigGroupWriteSet lists the portion of the config which was written, this should included updated Versions
isolated_dataConfigUpdate.IsolatedDataEntryrepeatedData which is not to be reflected in the resulting Config, but is still needed for some other purpose. For instance, rscc_seed_data

ConfigUpdate.IsolatedDataEntry

FieldTypeLabelDescription
keystring
valuebytes

ConfigUpdateEnvelope

FieldTypeLabelDescription
config_updatebytesA marshaled ConfigUpdate structure
signaturesConfigSignaturerepeatedSignatures over the config_update

ConfigValue

ConfigValue represents an individual piece of config data

FieldTypeLabelDescription
versionuint64
valuebytes
mod_policystring

ConfigValueSchema

Top

common/common.proto

Block

This is finalized block structure to be shared among the orderer and peer Note that the BlockHeader chains to the previous BlockHeader, and the BlockData hash is embedded in the BlockHeader. This makes it natural and obvious that the Data is included in the hash, but the Metadata is not.

FieldTypeLabelDescription
headerBlockHeader
dataBlockData
metadataBlockMetadata

BlockData

FieldTypeLabelDescription
databytesrepeated

BlockHeader

BlockHeader is the element of the block which forms the block chain The block header is hashed using the configured chain hashing algorithm over the ASN.1 encoding of the BlockHeader

FieldTypeLabelDescription
numberuint64The position in the blockchain
previous_hashbytesThe hash of the previous block header
data_hashbytesThe hash of the BlockData, by MerkleTree

BlockMetadata

FieldTypeLabelDescription
metadatabytesrepeated

ChannelHeader

Header is a generic replay prevention and identity message to include in a signed payload

FieldTypeLabelDescription
typeint32Header types 0-10000 are reserved and defined by HeaderType
versionint32Version indicates message protocol version
timestampgoogle.protobuf.TimestampTimestamp is the local time when the message was created by the sender
channel_idstringIdentifier of the channel this message is bound for
tx_idstringAn unique identifier that is used end-to-end. - set by higher layers such as end user or SDK - passed to the endorser (which will check for uniqueness) - as the header is passed along unchanged, it will be be retrieved by the committer (uniqueness check here as well) - to be stored in the ledger
epochuint64The epoch in which this header was generated, where epoch is defined based on block height Epoch in which the response has been generated. This field identifies a logical window of time. A proposal response is accepted by a peer only if two conditions hold: 1. the epoch specified in the message is the current epoch 2. this message has been only seen once during this epoch (i.e. it hasn't been replayed)
extensionbytesExtension that may be attached based on the header type
tls_cert_hashbytesIf mutual TLS is employed, this represents the hash of the client's TLS certificate

Envelope

Envelope wraps a Payload with a signature so that the message may be authenticated

FieldTypeLabelDescription
payloadbytesA marshaled Payload
signaturebytesA signature by the creator specified in the Payload header

Header

FieldTypeLabelDescription
channel_headerbytes
signature_headerbytes

LastConfig

LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index

FieldTypeLabelDescription
indexuint64

Metadata

Metadata is a common structure to be used to encode block metadata

FieldTypeLabelDescription
valuebytes
signaturesMetadataSignaturerepeated

MetadataSignature

FieldTypeLabelDescription
signature_headerbytesAn encoded SignatureHeader
signaturebytesThe signature over the concatenation of the Metadata value bytes, signatureHeader, and block header

OrdererBlockMetadata

OrdererBlockMetadata defines metadata that is set by the ordering service.

FieldTypeLabelDescription
last_configLastConfig
consenter_metadatabytes

Payload

Payload is the message contents (and header to allow for signing)

FieldTypeLabelDescription
headerHeaderHeader is included to provide identity and prevent replay
databytesData, the encoding of which is defined by the type in the header

SignatureHeader

FieldTypeLabelDescription
creatorbytesCreator of the message, a marshaled msp.SerializedIdentity
noncebytesArbitrary number that may only be used once. Can be used to detect replay attacks.

BlockMetadataIndex

This enum enlists indexes of the block metadata array

NameNumberDescription
SIGNATURES0Block metadata array position for block signatures
LAST_CONFIG1Block metadata array position to store last configuration block sequence number
TRANSACTIONS_FILTER2Block metadata array position to store serialized bit array filter of invalid transactions
ORDERER3Block 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_HASH4Block metadata array position to store the hash of TRANSACTIONS_FILTER, State Updates, and the COMMIT_HASH of the previous block

HeaderType

NameNumberDescription
MESSAGE0Used for messages which are signed but opaque
CONFIG1Used for messages which express the channel config
CONFIG_UPDATE2Used for transactions which update the channel config
ENDORSER_TRANSACTION3Used by the SDK to submit endorser based transactions
ORDERER_TRANSACTION4Used internally by the orderer for management
DELIVER_SEEK_INFO5Used as the type for Envelope messages submitted to instruct the Deliver API to seek
CHAINCODE_PACKAGE6Used for packaging chaincode artifacts for install
PEER_ADMIN_OPERATION8Used for invoking an administrative operation on a peer

Status

These status codes are intended to resemble selected HTTP status codes

NameNumberDescription
UNKNOWN0
SUCCESS200
BAD_REQUEST400
FORBIDDEN403
NOT_FOUND404
REQUEST_ENTITY_TOO_LARGE413
INTERNAL_SERVER_ERROR500
NOT_IMPLEMENTED501
SERVICE_UNAVAILABLE503

Top

common/collection.proto

CollectionConfig

CollectionConfig defines the configuration of a collection object; it currently contains a single, static type. Dynamic collections are deferred.

FieldTypeLabelDescription
static_collection_configStaticCollectionConfig

CollectionConfigPackage

CollectionConfigPackage represents an array of CollectionConfig messages; the extra struct is required because repeated oneof is forbidden by the protobuf syntax

FieldTypeLabelDescription
configCollectionConfigrepeated

CollectionCriteria

CollectionCriteria defines an element of a private data that corresponds to a certain transaction and collection

FieldTypeLabelDescription
channelstring
tx_idstring
collectionstring
namespacestring

CollectionPolicyConfig

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.

FieldTypeLabelDescription
signature_policySignaturePolicyEnvelopeInitially, only a signature policy is supported.

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; |

StaticCollectionConfig

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.

FieldTypeLabelDescription
namestringthe name of the collection inside the denoted chaincode
member_orgs_policyCollectionPolicyConfiga reference to a policy residing / managed in the config block to define which orgs have access to this collection’s private data
required_peer_countint32The 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.
maximum_peer_countint32The maximum number of peers that private data will be sent to upon endorsement. This number has to be bigger than required_peer_count.
block_to_liveuint64The 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
member_only_readboolThe 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)
member_only_writeboolThe 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)

Scalar Value Types

.proto TypeNotesC++ TypeJava TypePython Type
doubledoubledoublefloat
floatfloatfloatfloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intint
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/long
uint32Uses variable-length encoding.uint32intint/long
uint64Uses variable-length encoding.uint64longint/long
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intint
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/long
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intint
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/long
sfixed32Always four bytes.int32intint
sfixed64Always eight bytes.int64longint/long
boolboolbooleanboolean
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicode
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr

Protos File Tree


.
├── ci
├── common
│   ├── collection.proto
│   ├── common.proto
│   ├── configtx.proto
│   ├── configuration.proto
│   ├── ledger.proto
│   └── policies.proto
├── discovery
│   └── protocol.proto
├── gossip
│   └── message.proto
├── ledger
│   ├── queryresult
│   │   └── kv_query_result.proto
│   └── rwset
│       ├── kvrwset
│       │   └── kv_rwset.proto
│       └── rwset.proto
├── msp
│   ├── identities.proto
│   ├── msp_config.proto
│   └── msp_principal.proto
├── orderer
│   ├── ab.proto
│   ├── cluster.proto
│   ├── configuration.proto
│   ├── etcdraft
│   │   ├── configuration.proto
│   │   └── metadata.proto
│   └── kafka.proto
├── peer
│   ├── chaincode_event.proto
│   ├── chaincode.proto
│   ├── chaincode_shim.proto
│   ├── configuration.proto
│   ├── events.proto
│   ├── lifecycle
│   │   ├── chaincode_definition.proto
│   │   ├── db.proto
│   │   └── lifecycle.proto
│   ├── peer.proto
│   ├── policy.proto
│   ├── proposal.proto
│   ├── proposal_response.proto
│   ├── query.proto
│   ├── resources.proto
│   ├── signed_cc_dep_spec.proto
│   └── transaction.proto
└── transientstore
    └── transientstore.proto

14 directories, 37 files

Protobuf sources

src:./peer/transaction.proto


// 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";
option java_outer_classname = "TransactionPackage";

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
// from block storage, and return it to a client, and indicate whether the transaction
// was validated or invalidated by committing peer. So that the originally submitted
// transaction Envelope is not modified, the ProcessedTransaction wrapper is returned.
message ProcessedTransaction {
    // An Envelope which includes a processed transaction
    common.Envelope transactionEnvelope = 1;

    // An indication of whether the transaction was validated or invalidated by committing peer
    int32 validationCode = 2;
}

// The transaction to be sent to the ordering service. A transaction contains
// one or more TransactionAction. Each TransactionAction binds a proposal to
// potentially multiple actions. The transaction is atomic meaning that either
// all actions in the transaction will be committed or none will.  Note that
// while a Transaction might include more than one Header, the Header.creator
// field must be the same in each.
// A single client is free to issue a number of independent Proposal, each with
// their header (Header) and request payload (ChaincodeProposalPayload).  Each
// proposal is independently endorsed generating an action
// (ProposalResponsePayload) with one signature per Endorser. Any number of
// independent proposals (and their action) might be included in a transaction
// to ensure that they are treated atomically.
message Transaction {

    // The payload is an array of TransactionAction. An array is necessary to
    // accommodate multiple actions per transaction
    repeated TransactionAction actions = 1;
}

// TransactionAction binds a proposal to its action.  The type field in the
// header dictates the type of action to be applied to the ledger.
message TransactionAction {

    // The header of the proposal action, which is the proposal header
    bytes header = 1;

    // The payload of the action as defined by the type in the header For
    // chaincode, it's the bytes of ChaincodeActionPayload
    bytes payload = 2;
}

//---------- Chaincode Transaction ------------

// ChaincodeActionPayload is the message to be used for the TransactionAction's
// payload when the Header's type is set to CHAINCODE.  It carries the
// chaincodeProposalPayload and an endorsed action to apply to the ledger.
message ChaincodeActionPayload {
    // This field contains the bytes of the ChaincodeProposalPayload message from
    // the original invocation (essentially the arguments) after the application
    // of the visibility function. The main visibility modes are "full" (the
    // entire ChaincodeProposalPayload message is included here), "hash" (only
    // the hash of the ChaincodeProposalPayload message is included) or
    // "nothing".  This field will be used to check the consistency of
    // ProposalResponsePayload.proposalHash.  For the CHAINCODE type,
    // ProposalResponsePayload.proposalHash is supposed to be H(ProposalHeader ||
    // f(ChaincodeProposalPayload)) where f is the visibility function.
    bytes chaincode_proposal_payload = 1;

    // The list of actions to apply to the ledger
    ChaincodeEndorsedAction action = 2;
}

// ChaincodeEndorsedAction carries information about the endorsement of a
// specific proposal
message ChaincodeEndorsedAction {
    // This is the bytes of the ProposalResponsePayload message signed by the
    // endorsers.  Recall that for the CHAINCODE type, the
    // ProposalResponsePayload's extenstion field carries a ChaincodeAction
    bytes proposal_response_payload = 1;

    // The endorsement of the proposal, basically the endorser's signature over
    // proposalResponsePayload
    repeated Endorsement endorsements = 2;
}

enum TxValidationCode {
    VALID = 0;
    NIL_ENVELOPE = 1;
    BAD_PAYLOAD = 2;
    BAD_COMMON_HEADER = 3;
    BAD_CREATOR_SIGNATURE = 4;
    INVALID_ENDORSER_TRANSACTION = 5;
    INVALID_CONFIG_TRANSACTION = 6;
    UNSUPPORTED_TX_PAYLOAD = 7;
    BAD_PROPOSAL_TXID = 8;
    DUPLICATE_TXID = 9;
    ENDORSEMENT_POLICY_FAILURE = 10;
    MVCC_READ_CONFLICT = 11;
    PHANTOM_READ_CONFLICT = 12;
    UNKNOWN_TX_TYPE = 13;
    TARGET_CHAIN_NOT_FOUND = 14;
    MARSHAL_TX_ERROR = 15;
    NIL_TXACTION = 16;
    EXPIRED_CHAINCODE = 17;
    CHAINCODE_VERSION_CONFLICT = 18;
    BAD_HEADER_EXTENSION = 19;
    BAD_CHANNEL_HEADER = 20;
    BAD_RESPONSE_PAYLOAD = 21;
    BAD_RWSET = 22;
    ILLEGAL_WRITESET = 23;
    INVALID_WRITESET = 24;
    INVALID_CHAINCODE = 25;
    NOT_VALIDATED = 254;
    INVALID_OTHER_REASON = 255;
}

// Reserved entries in the key-level metadata map
enum MetaDataKeys {
    VALIDATION_PARAMETER = 0;
    VALIDATION_PARAMETER_V2 = 1;
}

src:./peer/configuration.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

// AnchorPeers simply represents list of anchor peers which is used in ConfigurationItem
message AnchorPeers {
    repeated AnchorPeer anchor_peers = 1;
}

// AnchorPeer message structure which provides information about anchor peer, it includes host name,
// port number and peer certificate.
message AnchorPeer {
    string host = 1; // DNS host name of the anchor peer
    int32 port  = 2; // The port number
}

// APIResource represents an API resource in the peer whose ACL
// is determined by the policy_ref field
message APIResource {
    string policy_ref = 1; // The policy name to use for this API
}

// ACLs provides mappings for resources in a channel. APIResource encapsulates
// reference to a policy used to determine ACL for the resource
message ACLs {
    map<string, APIResource> acls = 1;
}

src:./peer/signed_cc_dep_spec.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "peer/proposal_response.proto";

// SignedChaincodeDeploymentSpec carries the CDS along with endorsements
message SignedChaincodeDeploymentSpec {
    // This is the bytes of the ChaincodeDeploymentSpec
    bytes chaincode_deployment_spec = 1;

    // This is the instantiation policy which is identical in structure
    // to endorsement policy.  This policy is checked by the VSCC at commit
    // time on the instantiation (all peers will get the same policy as it
    // will be part of the LSCC instantation record and will be part of the
    // hash as well)
    bytes instantiation_policy = 2;

    // The endorsements of the above deployment spec, the owner's signature over
    // chaincode_deployment_spec and Endorsement.endorser.
    repeated Endorsement owner_endorsements = 3;
}


src:./peer/chaincode.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "common/policies.proto";

//ChaincodeID contains the path as specified by the deploy transaction
//that created it as well as the hashCode that is generated by the
//system for the path. From the user level (ie, CLI, REST API and so on)
//deploy transaction is expected to provide the path and other requests
//are expected to provide the hashCode. The other value will be ignored.
//Internally, the structure could contain both values. For instance, the
//hashCode will be set when first generated using the path
message ChaincodeID {
    //deploy transaction will use the path
    string path = 1;

    //all other requests will use the name (really a hashcode) generated by
    //the deploy transaction
    string name = 2;

    //user friendly version name for the chaincode
    string version = 3;
}

// Carries the chaincode function and its arguments.
// UnmarshalJSON in transaction.go converts the string-based REST/JSON input to
// the []byte-based current ChaincodeInput structure.
message ChaincodeInput {
    repeated bytes args  = 1;
    map<string, bytes> decorations = 2;

    // is_init is used for the application to signal that an invocation is to be routed
    // to the legacy 'Init' function for compatibility with chaincodes which handled
    // Init in the old way.  New applications should manage their initialized state
    // themselves.
    bool is_init = 3;
}

// Carries the chaincode specification. This is the actual metadata required for
// defining a chaincode.
message ChaincodeSpec {

    enum Type {
        UNDEFINED = 0;
        GOLANG = 1;
        NODE = 2;
        CAR = 3;
        JAVA = 4;
    }

    Type type = 1;
    ChaincodeID chaincode_id = 2;
    ChaincodeInput input = 3;
    int32 timeout = 4;
}

// Specify the deployment of a chaincode.
// TODO: Define `codePackage`.
message ChaincodeDeploymentSpec {
    // Prevent removed tag re-use
    reserved 2, 4;
    reserved "effective_date", "exec_env";

    ChaincodeSpec chaincode_spec = 1;
    bytes code_package = 3;

}

// Carries the chaincode function and its arguments.
message ChaincodeInvocationSpec {
    // Prevent removed tag re-use
    reserved 2;
    reserved "id_generation_alg";

    ChaincodeSpec chaincode_spec = 1;
}

// LifecycleEvent is used as the payload of the chaincode event emitted by LSCC
message LifecycleEvent {
    string chaincode_name = 1;
}

// CDSData is data stored in the LSCC on instantiation of a CC
// for CDSPackage.  This needs to be serialized for ChaincodeData
// hence the protobuf format
message CDSData {
    bytes hash = 1; // hash of ChaincodeDeploymentSpec.code_package
    bytes metadatahash = 2; // hash of ChaincodeID.name + ChaincodeID.version
}

// ChaincodeData defines the datastructure for chaincodes to be serialized by proto
// Type provides an additional check by directing to use a specific package after instantiation
// Data is Type specific (see CDSPackage and SignedCDSPackage)
message ChaincodeData {

    // Name of the chaincode
    string name = 1;

    // Version of the chaincode
    string version = 2;

    // Escc for the chaincode instance
    string escc = 3;

    // Vscc for the chaincode instance
    string vscc = 4;

    // Policy endorsement policy for the chaincode instance
    common.SignaturePolicyEnvelope policy = 5;

    // Data data specific to the package
    bytes data = 6;

    // Id of the chaincode that's the unique fingerprint for the CC This is not
    // currently used anywhere but serves as a good eyecatcher
    bytes id = 7;

    // InstantiationPolicy for the chaincode
    common.SignaturePolicyEnvelope instantiation_policy = 8;
}

src:./peer/proposal_response.proto


// 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";
option java_outer_classname = "ProposalResponsePackage";

package protos;

import "google/protobuf/timestamp.proto";

// A ProposalResponse is returned from an endorser to the proposal submitter.
// The idea is that this message contains the endorser's response to the
// request of a client to perform an action over a chaincode (or more
// generically on the ledger); the response might be success/error (conveyed in
// the Response field) together with a description of the action and a
// signature over it by that endorser.  If a sufficient number of distinct
// endorsers agree on the same action and produce signature to that effect, a
// transaction can be generated and sent for ordering.
message ProposalResponse {
    // Version indicates message protocol version
    int32 version = 1;

    // Timestamp is the time that the message
    // was created as  defined by the sender
    google.protobuf.Timestamp timestamp = 2;

    // A response message indicating whether the
    // endorsement of the action was successful
    Response response = 4;

    // The payload of response. It is the bytes of ProposalResponsePayload
    bytes payload = 5;

    // The endorsement of the proposal, basically
    // the endorser's signature over the payload
    Endorsement endorsement = 6;
}

// A response with a representation similar to an HTTP response that can
// be used within another message.
message Response {
    // A status code that should follow the HTTP status codes.
    int32 status = 1;

    // A message associated with the response code.
    string message = 2;

    // A payload that can be used to include metadata with this response.
    bytes payload = 3;
}

// ProposalResponsePayload is the payload of a proposal response.  This message
// is the "bridge" between the client's request and the endorser's action in
// response to that request. Concretely, for chaincodes, it contains a hashed
// representation of the proposal (proposalHash) and a representation of the
// chaincode state changes and events inside the extension field.
message ProposalResponsePayload {
    // Hash of the proposal that triggered this response. The hash is used to
    // link a response with its proposal, both for bookeeping purposes on an
    // asynchronous system and for security reasons (accountability,
    // non-repudiation). The hash usually covers the entire Proposal message
    // (byte-by-byte).
    bytes proposal_hash = 1;

    // Extension should be unmarshaled to a type-specific message. The type of
    // the extension in any proposal response depends on the type of the proposal
    // that the client selected when the proposal was initially sent out.  In
    // particular, this information is stored in the type field of a Header.  For
    // chaincode, it's a ChaincodeAction message
    bytes extension = 2;
}

// An endorsement is a signature of an endorser over a proposal response.  By
// producing an endorsement message, an endorser implicitly "approves" that
// proposal response and the actions contained therein. When enough
// endorsements have been collected, a transaction can be generated out of a
// set of proposal responses.  Note that this message only contains an identity
// and a signature but no signed payload. This is intentional because
// endorsements are supposed to be collected in a transaction, and they are all
// expected to endorse a single proposal response/action (many endorsements
// over a single proposal response)
message Endorsement {
    // Identity of the endorser (e.g. its certificate)
    bytes endorser = 1;

    // Signature of the payload included in ProposalResponse concatenated with
    // the endorser's certificate; ie, sign(ProposalResponse.payload + endorser)
    bytes signature = 2;
}

src:./peer/query.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

// ChaincodeQueryResponse returns information about each chaincode that pertains
// to a query in lscc.go, such as GetChaincodes (returns all chaincodes
// instantiated on a channel), and GetInstalledChaincodes (returns all chaincodes
// installed on a peer)
message ChaincodeQueryResponse {
    repeated ChaincodeInfo chaincodes = 1;
}

// ChaincodeInfo contains general information about an installed/instantiated
// chaincode
message ChaincodeInfo {
    string name = 1;
    string version = 2;
    // the path as specified by the install/instantiate transaction
    string path = 3;
    // the chaincode function upon instantiation and its arguments. This will be
    // blank if the query is returning information about installed chaincodes.
    string input = 4;
    // the name of the ESCC for this chaincode. This will be
    // blank if the query is returning information about installed chaincodes.
    string escc = 5;
    // the name of the VSCC for this chaincode. This will be
    // blank if the query is returning information about installed chaincodes.
    string vscc = 6;
    // the chaincode unique id.
    // computed as: H(
    //                H(name || version) ||
    //                H(CodePackage)
    //              )
    bytes id = 7;
}

// ChannelQueryResponse returns information about each channel that pertains
// to a query in lscc.go, such as GetChannels (returns all channels for a
// given peer)
message ChannelQueryResponse {
    repeated ChannelInfo channels = 1;
}

// ChannelInfo contains general information about channels
message ChannelInfo {
    string channel_id = 1;
}

src:./peer/resources.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "common/configtx.proto";

// ChaincodeIdentifier identifies a piece of chaincode.  For a peer to accept invocations of
// this chaincode, the hash of the installed code must match, as must the version string
// included with the install command.
message ChaincodeIdentifier {
    bytes hash = 1;     // The hash of the chaincode bytes
    string version = 2; // A user friendly human readable name corresponding to the ID
}

// ChaincodeValidation instructs the peer how transactions for this chaincode should be
// validated.  The only validation mechanism which ships with fabric today is the standard
// 'vscc' validation mechanism.  This built in validation method utilizes an endorsement policy
// which checks that a sufficient number of signatures have been included.  The 'arguement'
// field encodes any parameters required by the validation implementation.
message ChaincodeValidation {
    string name = 1;    // Specifies which code to run to validate transactions, defaults to 'vscc'
    bytes argument = 2; // When 'vscc' a marshaled VSCCArgs
}

// VSCCArgs is passed (marshaled) as a parameter to the VSCC imlementation via the
// argument field of the ChaincodeValidation message.
message VSCCArgs {
    string endorsement_policy_ref = 1;  // A named reference to an endorsement policy,
                                        // for instance /Channel/Application/Writers
}

// ChaincodeEndorsement instructs the peer how transactions should be endorsed.  The only
// endorsement mechanism which ships with the fabric today is the standard 'escc' mechanism.
// This code simply simulates the proposal to generate a RW set, then signs the result
// using the peer's local signing identity.
message ChaincodeEndorsement {
    string name = 1; // Specifies what code to run for endorsements, defaults 'escc'
    // Eventually we may wish add an arg here, just like the ChaincodeValidation message, but
    // omitting now until there is a need for it.
}

// ConfigTree encapsulates channel and resources configuration of a channel.
// Both configurations are represented as common.Config
message ConfigTree {
    common.Config channel_config = 1;
    common.Config resources_config = 2;
}

src:./peer/events.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option java_outer_classname = "EventsPackage";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "common/common.proto";
import "ledger/rwset/rwset.proto";
import "peer/chaincode_event.proto";
import "peer/transaction.proto";

// FilteredBlock is a minimal set of information about a block
message FilteredBlock {
    string channel_id = 1;
    uint64 number = 2; // The position in the blockchain
    repeated FilteredTransaction filtered_transactions = 4;
}

// FilteredTransaction is a minimal set of information about a transaction
// within a block
message FilteredTransaction {
    string txid = 1;
    common.HeaderType type = 2;
    TxValidationCode tx_validation_code = 3;
    oneof Data {
        FilteredTransactionActions transaction_actions = 4;
    }
}

// FilteredTransactionActions is a wrapper for array of TransactionAction
// message from regular block
message FilteredTransactionActions {
    repeated FilteredChaincodeAction chaincode_actions = 1;
}

// FilteredChaincodeAction is a minimal set of information about an action
// within a transaction
message FilteredChaincodeAction {
    ChaincodeEvent chaincode_event = 1;
}

// BlockAndPrivateData contains Block and a map from tx_seq_in_block to rwset.TxPvtReadWriteSet
message BlockAndPrivateData {
    common.Block block = 1;
    // map from tx_seq_in_block to rwset.TxPvtReadWriteSet
    map<uint64, rwset.TxPvtReadWriteSet> private_data_map = 2;
}

// DeliverResponse
message DeliverResponse {
    oneof Type {
        common.Status status = 1;
        common.Block block = 2;
        FilteredBlock filtered_block = 3;
        BlockAndPrivateData block_and_private_data = 4;
    }
}

service Deliver {
    // Deliver first requires an Envelope of type ab.DELIVER_SEEK_INFO with
    // Payload data as a marshaled orderer.SeekInfo message,
    // then a stream of block replies is received
    rpc Deliver (stream common.Envelope) returns (stream DeliverResponse) {
    }
    // DeliverFiltered first requires an Envelope of type ab.DELIVER_SEEK_INFO with
    // Payload data as a marshaled orderer.SeekInfo message,
    // then a stream of **filtered** block replies is received
    rpc DeliverFiltered (stream common.Envelope) returns (stream DeliverResponse) {
    }
    // DeliverWithPrivateData first requires an Envelope of type ab.DELIVER_SEEK_INFO with
    // Payload data as a marshaled orderer.SeekInfo message,
    // then a stream of block and private data replies is received
    rpc DeliverWithPrivateData (stream common.Envelope) returns (stream DeliverResponse) {
    }
}

src:./peer/proposal.proto


// 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";
option java_outer_classname = "ProposalPackage";

package protos;

import "peer/chaincode.proto";
import "peer/proposal_response.proto";

/*
The flow to get a generic transaction approved goes as follows:

1. client sends proposal to endorser
====================================

The proposal is basically a request to do something that will result on some
action with impact on the ledger; a proposal contains a header (with some
metadata describing it, such as the type, the identity of the invoker, the
time, the ID of the chain, a cryptographic nonce..) and an opaque payload that
depends on the type specified in the header. A proposal contains the following
messages:

SignedProposal
|\_ Signature                                    (signature on the Proposal message by the creator specified in the header)
 \_ Proposal
    |\_ Header                                   (the header for this proposal)
     \_ Payload                                  (the payload for this proposal)

2. endorser sends proposal response back to client
==================================================

The proposal response contains an endorser's response to a client's proposal. A
proposal response contains a success/error code, a response payload and a
signature (also referred to as endorsement) over the response payload. The
response payload contains a hash of the proposal (to securely link this
response to the corresponding proposal) and an opaque extension field that
depends on the type specified in the header of the corresponding proposal. A
proposal response contains the following messages:

ProposalResponse
|\_ Endorsement                                  (the endorser's signature over the whole response payload)
 \_ ProposalResponsePayload                      (the payload of the proposal response)

3. client assembles endorsements into a transaction
===================================================

A transaction message assembles one or more proposals and corresponding
responses into a message to be sent to orderers. After ordering, (batches of)
transactions are delivered to committing peers for validation and final
delivery into the ledger. A transaction contains one or more actions. Each of
them contains a header (same as that of the proposal that requested it) and an
opaque payload that depends on the type specified in the header.

SignedTransaction
|\_ Signature                                    (signature on the Transaction message by the creator specified in the header)
 \_ Transaction
     \_ TransactionAction (1...n)
        |\_ Header (1)                           (the header of the proposal that requested this action)
         \_ Payload (1)                          (the payload for this action)
*/

// This structure is necessary to sign the proposal which contains the header
// and the payload. Without this structure, we would have to concatenate the
// header and the payload to verify the signature, which could be expensive
// with large payload
//
// When an endorser receives a SignedProposal message, it should verify the
// signature over the proposal bytes. This verification requires the following
// steps:
// 1. Verification of the validity of the certificate that was used to produce
//    the signature.  The certificate will be available once proposalBytes has
//    been unmarshalled to a Proposal message, and Proposal.header has been
//    unmarshalled to a Header message. While this unmarshalling-before-verifying
//    might not be ideal, it is unavoidable because i) the signature needs to also
//    protect the signing certificate; ii) it is desirable that Header is created
//    once by the client and never changed (for the sake of accountability and
//    non-repudiation). Note also that it is actually impossible to conclusively
//    verify the validity of the certificate included in a Proposal, because the
//    proposal needs to first be endorsed and ordered with respect to certificate
//    expiration transactions. Still, it is useful to pre-filter expired
//    certificates at this stage.
// 2. Verification that the certificate is trusted (signed by a trusted CA) and
//    that it is allowed to transact with us (with respect to some ACLs);
// 3. Verification that the signature on proposalBytes is valid;
// 4. Detect replay attacks;
message SignedProposal {

    // The bytes of Proposal
    bytes proposal_bytes = 1;

  // Signaure over proposalBytes; this signature is to be verified against
  // the creator identity contained in the header of the Proposal message
  // marshaled as proposalBytes
    bytes signature = 2;
}

// A Proposal is sent to an endorser for endorsement.  The proposal contains:
// 1. A header which should be unmarshaled to a Header message.  Note that
//    Header is both the header of a Proposal and of a Transaction, in that i)
//    both headers should be unmarshaled to this message; and ii) it is used to
//    compute cryptographic hashes and signatures.  The header has fields common
//    to all proposals/transactions.  In addition it has a type field for
//    additional customization. An example of this is the ChaincodeHeaderExtension
//    message used to extend the Header for type CHAINCODE.
// 2. A payload whose type depends on the header's type field.
// 3. An extension whose type depends on the header's type field.
//
// Let us see an example. For type CHAINCODE (see the Header message),
// we have the following:
// 1. The header is a Header message whose extensions field is a
//    ChaincodeHeaderExtension message.
// 2. The payload is a ChaincodeProposalPayload message.
// 3. The extension is a ChaincodeAction that might be used to ask the
//    endorsers to endorse a specific ChaincodeAction, thus emulating the
//    submitting peer model.
message Proposal {

    // The header of the proposal. It is the bytes of the Header
    bytes header = 1;

    // The payload of the proposal as defined by the type in the proposal
    // header.
    bytes payload = 2;

    // Optional extensions to the proposal. Its content depends on the Header's
    // type field.  For the type CHAINCODE, it might be the bytes of a
    // ChaincodeAction message.
    bytes extension = 3;
}

//-------- the Chaincode Proposal -----------

/*
The flow to get a CHAINCODE transaction approved goes as follows:

1. client sends proposal to endorser
====================================

The proposal is basically a request to do something on a chaincode, that will
result on some action - some change in the state of a chaincode and/or some
data to be committed to the ledger; a proposal in general contains a header
(with some metadata describing it, such as the type, the identity of the
invoker, the time, the ID of the chain, a cryptographic nonce..) and a payload
(the chaincode ID, invocation arguments..). Optionally, it may contain actions
that the endorser may be asked to endorse, to emulate a submitting peer. A
chaincode proposal contains the following messages:

SignedProposal
|\_ Signature                                    (signature on the Proposal message by the creator specified in the header)
 \_ Proposal
    |\_ Header                                   (the header for this proposal)
    |\_ ChaincodeProposalPayload                 (the payload for this proposal)
     \_ ChaincodeAction                          (the actions for this proposal - optional for a proposal)

2. endorser sends proposal response back to client
==================================================

The proposal response contains an endorser's response to a client's proposal. A
proposal response contains a success/error code, a response payload and a
signature (also referred to as endorsement) over the response payload. The
response payload contains a hash of the proposal (to securely link this
response to the corresponding proposal), a description of the action resulting
from the proposal and the endorser's signature over its payload. Formally, a
chaincode proposal response contains the following messages:

ProposalResponse
|\_ Endorsement                                  (the endorser's signature over the whole response payload)
 \_ ProposalResponsePayload
     \_ ChaincodeAction                          (the actions for this proposal)

3. client assembles endorsements into a transaction
===================================================

A transaction message assembles one or more proposals and corresponding
responses into a message to be sent to orderers. After ordering, (batches of)
transactions are delivered to committing peers for validation and final
delivery into the ledger. A transaction contains one or more actions. Each of
them contains a header (same as that of the proposal that requested it), a
proposal payload (same as that of the proposal that requested it), a
description of the resulting action and signatures from each of the endorsers
that endorsed the action.

SignedTransaction
|\_ Signature                                    (signature on the Transaction message by the creator specified in the header)
 \_ Transaction
     \_ TransactionAction (1...n)
        |\_ Header (1)                           (the header of the proposal that requested this action)
         \_ ChaincodeActionPayload (1)
            |\_ ChaincodeProposalPayload (1)     (payload of the proposal that requested this action)
             \_ ChaincodeEndorsedAction (1)
                |\_ Endorsement (1...n)          (endorsers' signatures over the whole response payload)
                 \_ ProposalResponsePayload
                     \_ ChaincodeAction          (the actions for this proposal)
*/

// ChaincodeHeaderExtension is the Header's extentions message to be used when
// the Header's type is CHAINCODE.  This extensions is used to specify which
// chaincode to invoke and what should appear on the ledger.
message ChaincodeHeaderExtension {

    reserved 1;
    reserved "payload_visbility";

    // The ID of the chaincode to target.
    ChaincodeID chaincode_id = 2;
}

// ChaincodeProposalPayload is the Proposal's payload message to be used when
// the Header's type is CHAINCODE.  It contains the arguments for this
// invocation.
message ChaincodeProposalPayload {

    // Input contains the arguments for this invocation. If this invocation
    // deploys a new chaincode, ESCC/VSCC are part of this field.
    // This is usually a marshaled ChaincodeInvocationSpec
    bytes input  = 1;

    // TransientMap contains data (e.g. cryptographic material) that might be used
    // to implement some form of application-level confidentiality. The contents
    // of this field are supposed to always be omitted from the transaction and
    // excluded from the ledger.
    map<string, bytes> TransientMap = 2;
}

// ChaincodeAction contains the actions the events generated by the execution
// of the chaincode.
message ChaincodeAction {
    reserved 5;
    reserved "token_operations";

    // This field contains the read set and the write set produced by the
    // chaincode executing this invocation.
    bytes results = 1;

    // This field contains the events generated by the chaincode executing this
    // invocation.
    bytes events = 2;

    // This field contains the result of executing this invocation.
    Response response = 3;

    // This field contains the ChaincodeID of executing this invocation. Endorser
    // will set it with the ChaincodeID called by endorser while simulating proposal.
    // Committer will validate the version matching with latest chaincode version.
    // Adding ChaincodeID to keep version opens up the possibility of multiple
    // ChaincodeAction per transaction.
    ChaincodeID chaincode_id = 4;
}

src:./peer/policy.proto


// 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";

// ApplicationPolicy captures the diffenrent policy types that
// are set and evaluted at the application level.
message ApplicationPolicy {
    oneof Type {
        // SignaturePolicy type is used if the policy is specified as
        // a combination (using threshold gates) of signatures from MSP
        // principals
        common.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;
    }
}

src:./peer/lifecycle/chaincode_definition.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer.lifecycle";
option go_package = "github.com/hyperledger/fabric-protos-go/peer/lifecycle";

package lifecycle;

// These protos are used for encoding chaincode definitions into the statedb
// in general, it should not be necessary for clients to utilize them.

// ChaincodeEndorsementInfo is (most) everything the peer needs to know in order
// to execute a chaincode
message ChaincodeEndorsementInfo {
    string version = 1;
    bool init_required = 2;
    string endorsement_plugin = 3;
}

// ValidationInfo is (most) everything the peer needs to know in order
// to validate a transaction
message ChaincodeValidationInfo {
    string validation_plugin = 1;
    bytes validation_parameter = 2;
}

// The notable omission in this file is the collection configuration info.
// It should be moved to this package, but... defering for now.

src:./peer/lifecycle/lifecycle.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer.lifecycle";
option go_package = "github.com/hyperledger/fabric-protos-go/peer/lifecycle";

package lifecycle;

import "common/collection.proto";

// InstallChaincodeArgs is the message used as the argument to
// '_lifecycle.InstallChaincode'.
message InstallChaincodeArgs {
    bytes chaincode_install_package = 1; // This should be a marshaled lifecycle.ChaincodePackage
}

// InstallChaincodeArgs is the message returned by
// '_lifecycle.InstallChaincode'.
message InstallChaincodeResult {
    string package_id = 1;
    string label = 2;
}

// QueryInstalledChaincodeArgs is the message used as arguments
// '_lifecycle.QueryInstalledChaincode'
message QueryInstalledChaincodeArgs {
    string package_id = 1;
}

// QueryInstalledChaincodeResult is the message returned by
// '_lifecycle.QueryInstalledChaincode'
message QueryInstalledChaincodeResult {
    string package_id = 1;
    string label = 2;
    map<string, References> references = 3;

    message References {
        repeated Chaincode chaincodes = 1;
    }

    message Chaincode {
        string name = 1;
        string version = 2;
    }
}

// GetInstalledChaincodePackageArgs is the message used as the argument to
// '_lifecycle.GetInstalledChaincodePackage'.
message GetInstalledChaincodePackageArgs {
    string package_id = 1;
}

// GetInstalledChaincodePackageResult is the message returned by
// '_lifecycle.GetInstalledChaincodePackage'.
message GetInstalledChaincodePackageResult {
    bytes chaincode_install_package = 1;
}

// QueryInstalledChaincodesArgs currently is an empty argument to
// '_lifecycle.QueryInstalledChaincodes'.   In the future, it may be
// extended to have parameters.
message QueryInstalledChaincodesArgs {
}

// QueryInstalledChaincodesResult is the message returned by
// '_lifecycle.QueryInstalledChaincodes'.  It returns a list of installed
// chaincodes, including a map of channel name to chaincode name and version
// pairs of chaincode definitions that reference this chaincode package.
message QueryInstalledChaincodesResult {
    message InstalledChaincode {
        string package_id = 1;
        string label = 2;
        map<string, References> references = 3;
    }

    message References {
        repeated Chaincode chaincodes = 1;
    }

    message Chaincode {
        string name = 1;
        string version = 2;
    }

    repeated InstalledChaincode installed_chaincodes = 1;
}

// ApproveChaincodeDefinitionForMyOrgArgs is the message used as arguments to
// `_lifecycle.ApproveChaincodeDefinitionForMyOrg`.
message ApproveChaincodeDefinitionForMyOrgArgs {
    int64 sequence = 1;
    string name = 2;
    string version = 3;
    string endorsement_plugin = 4;
    string validation_plugin = 5;
    bytes validation_parameter = 6;
    common.CollectionConfigPackage collections = 7;
    bool init_required = 8;
    ChaincodeSource source = 9;
}

message ChaincodeSource {
    message Unavailable {}

    message Local {
        string package_id = 1;
    }

    oneof Type {
        Unavailable unavailable = 1;
        Local local_package = 2;
    }
}

// ApproveChaincodeDefinitionForMyOrgResult is the message returned by
// `_lifecycle.ApproveChaincodeDefinitionForMyOrg`. Currently it returns
// nothing, but may be extended in the future.
message ApproveChaincodeDefinitionForMyOrgResult {
}

// CommitChaincodeDefinitionArgs is the message used as arguments to
// `_lifecycle.CommitChaincodeDefinition`.
message CommitChaincodeDefinitionArgs {
    int64 sequence = 1;
    string name = 2;
    string version = 3;
    string endorsement_plugin = 4;
    string validation_plugin = 5;
    bytes validation_parameter = 6;
    common.CollectionConfigPackage collections = 7;
    bool init_required = 8;
}

// CommitChaincodeDefinitionResult is the message returned by
// `_lifecycle.CommitChaincodeDefinition`. Currently it returns
// nothing, but may be extended in the future.
message CommitChaincodeDefinitionResult {
}

// CheckCommitReadinessArgs is the message used as arguments to
// `_lifecycle.CheckCommitReadiness`.
message CheckCommitReadinessArgs {
    int64 sequence = 1;
    string name = 2;
    string version = 3;
    string endorsement_plugin = 4;
    string validation_plugin = 5;
    bytes validation_parameter = 6;
    common.CollectionConfigPackage collections = 7;
    bool init_required = 8;
}

// CheckCommitReadinessResult is the message returned by
// `_lifecycle.CheckCommitReadiness`. It returns a map of
// orgs to their approval (true/false) for the definition 
// supplied as args.
message CheckCommitReadinessResult{
    map<string, bool> approvals = 1;
}

// QueryChaincodeDefinitionArgs is the message used as arguments to
// `_lifecycle.QueryChaincodeDefinition`.
message QueryChaincodeDefinitionArgs {
    string name = 1;
}

// QueryChaincodeDefinitionResult is the message returned by
// `_lifecycle.QueryChaincodeDefinition`.
message QueryChaincodeDefinitionResult {
    int64 sequence = 1;
    string version = 2;
    string endorsement_plugin = 3;
    string validation_plugin = 4;
    bytes validation_parameter = 5;
    common.CollectionConfigPackage collections = 6;
    bool init_required = 7;
    map<string,bool> approvals = 8;
}

// QueryChaincodeDefinitionsArgs is the message used as arguments to
// `_lifecycle.QueryChaincodeDefinitions`.
message QueryChaincodeDefinitionsArgs { }

// QueryChaincodeDefinitionsResult is the message returned by
// `_lifecycle.QueryChaincodeDefinitions`.
message QueryChaincodeDefinitionsResult {
    message ChaincodeDefinition {
        string name = 1;
        int64 sequence = 2;
        string version = 3;
        string endorsement_plugin = 4;
        string validation_plugin = 5;
        bytes validation_parameter = 6;
        common.CollectionConfigPackage collections = 7;
        bool init_required = 8;
    }
    repeated ChaincodeDefinition chaincode_definitions = 1;
}

src:./peer/lifecycle/db.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer.lifecycle";
option go_package = "github.com/hyperledger/fabric-protos-go/peer/lifecycle";

package lifecycle;

// These protos are used for encoding data into the statedb
// in general, it should not be necessary for clients to utilize them.

// StateMetadata describes the keys in a namespace.  It is necessary because
// in collections, range scans are not possible during transactions which
// write.  Therefore we must track the keys in our namespace ourselves.
message StateMetadata {
    string datatype = 1;
    repeated string fields = 2;
}

// StateData encodes a particular field of a datatype
message StateData {
    oneof Type {
        int64 Int64 = 1;
        bytes Bytes = 2;
        string String = 3;
    }
}

src:./peer/chaincode_event.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option java_outer_classname = "ChaincodeEventPackage";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

//ChaincodeEvent is used for events and registrations that are specific to chaincode
//string type - "chaincode"
message ChaincodeEvent {
    string chaincode_id = 1;
    string tx_id = 2;
    string event_name = 3;
    bytes payload = 4;
}

src:./peer/chaincode_shim.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "peer/chaincode_event.proto";
import "peer/proposal.proto";
import "google/protobuf/timestamp.proto";

message ChaincodeMessage {
    enum Type {
        UNDEFINED = 0;
        REGISTER = 1;
        REGISTERED = 2;
        INIT = 3;
        READY = 4;
        TRANSACTION = 5;
        COMPLETED = 6;
        ERROR = 7;
        GET_STATE = 8;
        PUT_STATE = 9;
        DEL_STATE = 10;
        INVOKE_CHAINCODE = 11;
        RESPONSE = 13;
        GET_STATE_BY_RANGE = 14;
        GET_QUERY_RESULT = 15;
        QUERY_STATE_NEXT = 16;
        QUERY_STATE_CLOSE = 17;
        KEEPALIVE = 18;
        GET_HISTORY_FOR_KEY = 19;
        GET_STATE_METADATA = 20;
        PUT_STATE_METADATA = 21;
        GET_PRIVATE_DATA_HASH = 22;
    }

    Type type = 1;
    google.protobuf.Timestamp timestamp = 2;
    bytes payload = 3;
    string txid = 4;

    SignedProposal proposal = 5;

    //event emitted by chaincode. Used only with Init or Invoke.
    // This event is then stored (currently)
    //with Block.NonHashData.TransactionResult
    ChaincodeEvent chaincode_event = 6;

    //channel id
    string channel_id = 7;
}

// TODO: We need to finalize the design on chaincode container
// compatibility upon upgrade, see FAB-5777.

// GetState is the payload of a ChaincodeMessage. It contains a key which
// is to be fetched from the ledger. If the collection is specified, the key
// would be fetched from the collection (i.e., private state)
message GetState {
    string key = 1;
    string collection = 2;
}

message GetStateMetadata {
    string key = 1;
    string collection = 2;
}

// PutState is the payload of a ChaincodeMessage. It contains a key and value
// which needs to be written to the transaction's write set. If the collection is
// specified, the key and value would be written to the transaction's private
// write set.
message PutState {
    string key = 1;
    bytes value = 2;
    string collection = 3;
}

message PutStateMetadata {
    string key = 1;
    string collection = 3;
    StateMetadata metadata = 4;
}

// DelState is the payload of a ChaincodeMessage. It contains a key which
// needs to be recorded in the transaction's write set as a delete operation.
// If the collection is specified, the key needs to be recorded in the
// transaction's private write set as a delete operation.
message DelState {
    string key = 1;
    string collection = 2;
}

// GetStateByRange is the payload of a ChaincodeMessage. It contains a start key and
// a end key required to execute range query. If the collection is specified,
// the range query needs to be executed on the private data. The metadata hold
// the byte representation of QueryMetadata.
message GetStateByRange {
    string startKey = 1;
    string endKey = 2;
    string collection = 3;
    bytes metadata = 4;
}

// GetQueryResult is the payload of a ChaincodeMessage. It contains a query
// string in the form that is supported by the underlying state database.
// If the collection is specified, the query needs to be executed on the
// private data.  The metadata hold the byte representation of QueryMetadata.
message GetQueryResult {
    string query = 1;
    string collection = 2;
    bytes metadata = 3;
}

// QueryMetadata is the metadata of a GetStateByRange and GetQueryResult.
// It contains a pageSize which denotes the number of records to be fetched
// and a bookmark.
message QueryMetadata {
    int32 pageSize = 1;
    string bookmark = 2;
}

// GetHistoryForKey is the payload of a ChaincodeMessage. It contains a key
// for which the historical values need to be retrieved.
message GetHistoryForKey {
    string key = 1;
}

message QueryStateNext {
    string id = 1;
}

message QueryStateClose {
    string id = 1;
}

// QueryResultBytes hold the byte representation of a record returned by the peer.
message QueryResultBytes {
    bytes resultBytes = 1;
}

// QueryResponse is returned by the peer as a result of a GetStateByRange,
// GetQueryResult, and GetHistoryForKey. It holds a bunch of records in
// results field, a flag to denote whether more results need to be fetched from
// the peer in has_more field, transaction id in id field, and a QueryResponseMetadata
// in metadata field.
message QueryResponse {
    repeated QueryResultBytes results = 1;
    bool has_more = 2;
    string id = 3;
    bytes metadata = 4;
}

// QueryResponseMetadata is the metadata of a QueryResponse. It contains a count
// which denotes the number of records fetched from the ledger and a bookmark.
message QueryResponseMetadata {
    int32 fetched_records_count = 1;
    string bookmark = 2;
}

message StateMetadata {
    string metakey = 1;
    bytes value = 2;
}

message StateMetadataResult {
    repeated StateMetadata entries = 1;
}

// Interface that provides support to chaincode execution. ChaincodeContext
// provides the context necessary for the server to respond appropriately.
service ChaincodeSupport {
    rpc Register(stream ChaincodeMessage) returns (stream ChaincodeMessage);
}

src:./peer/peer.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "peer/proposal.proto";
import "peer/proposal_response.proto";

service Endorser {
    rpc ProcessProposal(SignedProposal) returns (ProposalResponse);
}

src:./msp/msp_config.proto


// 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/msp";
option java_package = "org.hyperledger.fabric.protos.msp";
option java_outer_classname = "MspConfigPackage";

package msp;

// MSPConfig collects all the configuration information for
// an MSP. The Config field should be unmarshalled in a way
// that depends on the Type
message MSPConfig {
    // Type holds the type of the MSP; the default one would
    // be of type FABRIC implementing an X.509 based provider
    int32 type = 1;

    // Config is MSP dependent configuration info
    bytes config = 2;
}

// FabricMSPConfig collects all the configuration information for
// a Fabric MSP.
// Here we assume a default certificate validation policy, where
// any certificate signed by any of the listed rootCA certs would
// be considered as valid under this MSP.
// This MSP may or may not come with a signing identity. If it does,
// it can also issue signing identities. If it does not, it can only
// be used to validate and verify certificates.
message FabricMSPConfig {
    // Name holds the identifier of the MSP; MSP identifier
    // is chosen by the application that governs this MSP.
    // For example, and assuming the default implementation of MSP,
    // that is X.509-based and considers a single Issuer,
    // this can refer to the Subject OU field or the Issuer OU field.
    string name = 1;

    // List of root certificates trusted by this MSP
    // they are used upon certificate validation (see
    // comment for IntermediateCerts below)
    repeated bytes root_certs = 2;

    // List of intermediate certificates trusted by this MSP;
    // they are used upon certificate validation as follows:
    // validation attempts to build a path from the certificate
    // to be validated (which is at one end of the path) and
    // one of the certs in the RootCerts field (which is at
    // the other end of the path). If the path is longer than
    // 2, certificates in the middle are searched within the
    // IntermediateCerts pool
    repeated bytes intermediate_certs = 3;

    // Identity denoting the administrator of this MSP
    repeated bytes admins = 4;

    // Identity revocation list
    repeated bytes revocation_list = 5;

    // SigningIdentity holds information on the signing identity
    // this peer is to use, and which is to be imported by the
    // MSP defined before
    SigningIdentityInfo signing_identity = 6;

    // OrganizationalUnitIdentifiers holds one or more
    // fabric organizational unit identifiers that belong to
    // this MSP configuration
    repeated FabricOUIdentifier organizational_unit_identifiers = 7;

    // FabricCryptoConfig contains the configuration parameters
    // for the cryptographic algorithms used by this MSP
    FabricCryptoConfig crypto_config = 8;

    // List of TLS root certificates trusted by this MSP.
    // They are returned by GetTLSRootCerts.
    repeated bytes tls_root_certs = 9;

    // List of TLS intermediate certificates trusted by this MSP;
    // They are returned by GetTLSIntermediateCerts.
    repeated bytes tls_intermediate_certs = 10;

    // fabric_node_ous contains the configuration to distinguish clients from peers from orderers
    // based on the OUs.
    FabricNodeOUs fabric_node_ous = 11;
}

// FabricCryptoConfig contains configuration parameters
// for the cryptographic algorithms used by the MSP
// this configuration refers to
message FabricCryptoConfig {

    // SignatureHashFamily is a string representing the hash family to be used
    // during sign and verify operations.
    // Allowed values are "SHA2" and "SHA3".
    string signature_hash_family = 1;

    // IdentityIdentifierHashFunction is a string representing the hash function
    // to be used during the computation of the identity identifier of an MSP identity.
    // Allowed values are "SHA256", "SHA384" and "SHA3_256", "SHA3_384".
    string identity_identifier_hash_function = 2;

}

// IdemixMSPConfig collects all the configuration information for
// an Idemix MSP.
message IdemixMSPConfig {
    // Name holds the identifier of the MSP
    string name = 1;

    // ipk represents the (serialized) issuer public key
    bytes ipk = 2;

    // signer may contain crypto material to configure a default signer
    IdemixMSPSignerConfig signer = 3;

    // revocation_pk is the public key used for revocation of credentials
    bytes revocation_pk = 4;

    // epoch represents the current epoch (time interval) used for revocation
    int64 epoch = 5;
}

// IdemixMSPSIgnerConfig contains the crypto material to set up an idemix signing identity
message IdemixMSPSignerConfig {
    // cred represents the serialized idemix credential of the default signer
    bytes cred = 1;

    // sk is the secret key of the default signer, corresponding to credential Cred
    bytes sk = 2;

    // organizational_unit_identifier defines the organizational unit the default signer is in
    string organizational_unit_identifier = 3;

    // role defines whether the default signer is admin, peer, member or client
    int32 role = 4;

    // enrollment_id contains the enrollment id of this signer
    string enrollment_id = 5;

    // credential_revocation_information contains a serialized CredentialRevocationInformation
    bytes credential_revocation_information = 6;
}

// SigningIdentityInfo represents the configuration information
// related to the signing identity the peer is to use for generating
// endorsements
message SigningIdentityInfo {
    // PublicSigner carries the public information of the signing
    // identity. For an X.509 provider this would be represented by
    // an X.509 certificate
    bytes public_signer = 1;

    // PrivateSigner denotes a reference to the private key of the
    // peer's signing identity
    KeyInfo private_signer = 2;
}

// KeyInfo represents a (secret) key that is either already stored
// in the bccsp/keystore or key material to be imported to the
// bccsp key-store. In later versions it may contain also a
// keystore identifier
message KeyInfo {
    // Identifier of the key inside the default keystore; this for
    // the case of Software BCCSP as well as the HSM BCCSP would be
    // the SKI of the key
    string key_identifier = 1;

    // KeyMaterial (optional) for the key to be imported; this is
    // properly encoded key bytes, prefixed by the type of the key
    bytes key_material = 2;
}

// FabricOUIdentifier represents an organizational unit and
// its related chain of trust identifier.
message FabricOUIdentifier {

    // Certificate represents the second certificate in a certification chain.
    // (Notice that the first certificate in a certification chain is supposed
    // to be the certificate of an identity).
    // It must correspond to the certificate of root or intermediate CA
    // recognized by the MSP this message belongs to.
    // Starting from this certificate, a certification chain is computed
    // and bound to the OrganizationUnitIdentifier specified
    bytes certificate = 1;

    // OrganizationUnitIdentifier defines the organizational unit under the
    // MSP identified with MSPIdentifier
    string organizational_unit_identifier = 2;
}

// FabricNodeOUs contains configuration to tell apart clients from peers from orderers
// based on OUs. If NodeOUs recognition is enabled then an msp identity
// that does not contain any of the specified OU will be considered invalid.
message FabricNodeOUs {
    // If true then an msp identity that does not contain any of the specified OU will be considered invalid.
    bool   enable = 1;

    // OU Identifier of the clients
    FabricOUIdentifier client_ou_identifier = 2;

    // OU Identifier of the peers
    FabricOUIdentifier peer_ou_identifier = 3;

    // OU Identifier of the admins
    FabricOUIdentifier admin_ou_identifier = 4;

    // OU Identifier of the orderers
    FabricOUIdentifier orderer_ou_identifier = 5;
}

src:./msp/msp_principal.proto


// 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/msp";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

// msp_principal.proto contains proto messages defining the generalized
// MSP notion of identity called an MSPPrincipal.  It is used as part of
// the chain configuration, in particular as the identity parameters to
// the configuration.proto file.  This does not represent the MSP
// configuration for a chain, but is understood by MSPs

// MSPPrincipal aims to represent an MSP-centric set of identities.
// In particular, this structure allows for definition of
//  - a group of identities that are member of the same MSP
//  - a group of identities that are member of the same organization unit
//    in the same MSP
//  - a group of identities that are administering a specific MSP
//  - a specific identity
// Expressing these groups is done given two fields of the fields below
//  - Classification, that defines the type of classification of identities
//    in an MSP this principal would be defined on; Classification can take
//    three values:
//     (i)  ByMSPRole: that represents a classification of identities within
//          MSP based on one of the two pre-defined MSP rules, "member" and "admin"
//     (ii) ByOrganizationUnit: that represents a classification of identities
//          within MSP based on the organization unit an identity belongs to
//     (iii)ByIdentity that denotes that MSPPrincipal is mapped to a single
//          identity/certificate; this would mean that the Principal bytes
//          message
message MSPPrincipal {
    enum Classification {
        ROLE = 0;  // Represents the one of the dedicated MSP roles, the
        // one of a member of MSP network, and the one of an
        // administrator of an MSP network
        ORGANIZATION_UNIT = 1; // Denotes a finer grained (affiliation-based)
        // groupping of entities, per MSP affiliation
        // E.g., this can well be represented by an MSP's
        // Organization unit
        IDENTITY  = 2;    // Denotes a principal that consists of a single
        // identity
        ANONYMITY = 3; // Denotes a principal that can be used to enforce
        // an identity to be anonymous or nominal.
        COMBINED = 4; // Denotes a combined principal
    }

    // Classification describes the way that one should process
    // Principal. An Classification value of "ByOrganizationUnit" reflects
    // that "Principal" contains the name of an organization this MSP
    // handles. A Classification value "ByIdentity" means that
    // "Principal" contains a specific identity. Default value
    // denotes that Principal contains one of the groups by
    // default supported by all MSPs ("admin" or "member").
    Classification principal_classification = 1;

    // Principal completes the policy principal definition. For the default
    // principal types, Principal can be either "Admin" or "Member".
    // For the ByOrganizationUnit/ByIdentity values of Classification,
    // PolicyPrincipal acquires its value from an organization unit or
    // identity, respectively.
    // For the Combined Classification type, the Principal is a marshalled
    // CombinedPrincipal.
    bytes principal = 2;
}


// OrganizationUnit governs the organization of the Principal
// field of a policy principal when a specific organization unity members
// are to be defined within a policy principal.
message OrganizationUnit {

    // MSPIdentifier represents the identifier of the MSP this organization unit
    // refers to
    string msp_identifier = 1;

    // OrganizationUnitIdentifier defines the organizational unit under the
    // MSP identified with MSPIdentifier
    string organizational_unit_identifier = 2;

    // CertifiersIdentifier is the hash of certificates chain of trust
    // related to this organizational unit
    bytes certifiers_identifier = 3;
}

// MSPRole governs the organization of the Principal
// field of an MSPPrincipal when it aims to define one of the
// two dedicated roles within an MSP: Admin and Members.
message MSPRole {
    // MSPIdentifier represents the identifier of the MSP this principal
    // refers to
    string msp_identifier = 1;

    enum MSPRoleType {
        MEMBER = 0; // Represents an MSP Member
        ADMIN  = 1; // Represents an MSP Admin
        CLIENT = 2; // Represents an MSP Client
        PEER = 3; // Represents an MSP Peer
        ORDERER = 4; // Represents an MSP Orderer
    }

    // MSPRoleType defines which of the available, pre-defined MSP-roles
    // an identiy should posess inside the MSP with identifier MSPidentifier
    MSPRoleType role = 2;
}

// MSPIdentityAnonymity can be used to enforce an identity to be anonymous or nominal.
message MSPIdentityAnonymity {
    enum MSPIdentityAnonymityType {
        NOMINAL = 0; // Represents a nominal MSP Identity
        ANONYMOUS = 1; // Represents an anonymous MSP Identity
    }

    MSPIdentityAnonymityType anonymity_type = 1;
}

// CombinedPrincipal governs the organization of the Principal
// field of a policy principal when principal_classification has
// indicated that a combined form of principals is required
message CombinedPrincipal {
    // Principals refer to combined principals
    repeated MSPPrincipal principals = 1;
}

// TODO: Bring msp.SerializedIdentity from fabric/msp/identities.proto here. Reason below.
// SerializedIdentity represents an serialized version of an identity;
// this consists of an MSP-identifier this identity would correspond to
// and the bytes of the actual identity. A serialized form of
// SerializedIdentity would govern "Principal" field of a PolicyPrincipal
// of classification "ByIdentity".

src:./msp/identities.proto


// 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/msp";
option java_package = "org.hyperledger.fabric.protos.msp";

package msp;

// This struct represents an Identity
// (with its MSP identifier) to be used
// to serialize it and deserialize it
message SerializedIdentity {
    // The identifier of the associated membership service provider
    string mspid = 1;

    // the Identity, serialized according to the rules of its MPS
    bytes id_bytes = 2;
}

// This struct represents an Idemix Identity
// to be used to serialize it and deserialize it.
// The IdemixMSP will first serialize an idemix identity to bytes using
// this proto, and then uses these bytes as id_bytes in SerializedIdentity
message SerializedIdemixIdentity {
    // nym_x is the X-component of the pseudonym elliptic curve point.
    // It is a []byte representation of an amcl.BIG
    // The pseudonym can be seen as a public key of the identity, it is used to verify signatures.
    bytes nym_x = 1;

    // nym_y is the Y-component of the pseudonym elliptic curve point.
    // It is a []byte representation of an amcl.BIG
    // The pseudonym can be seen as a public key of the identity, it is used to verify signatures.
    bytes nym_y = 2;

    // ou contains the organizational unit of the idemix identity
    bytes ou = 3;

    // role contains the role of this identity (e.g., ADMIN or MEMBER)
    bytes role = 4;

    // proof contains the cryptographic evidence that this identity is valid
    bytes proof = 5;
}

src:./ledger/rwset/rwset.proto


// 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/ledger/rwset";
option java_package = "org.hyperledger.fabric.protos.ledger.rwset";

package rwset;

// TxReadWriteSet encapsulates a read-write set for a transaction
// DataModel specifies the enum value of the data model
// ns_rwset field specifies a list of chaincode specific read-write set (one for each chaincode)
message TxReadWriteSet {
    enum DataModel {
        KV = 0;
    }
    DataModel data_model = 1;
    repeated NsReadWriteSet ns_rwset = 2;
}

// NsReadWriteSet encapsulates the read-write set for a chaincode
message NsReadWriteSet {
   string namespace = 1;
   bytes rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)
   repeated CollectionHashedReadWriteSet collection_hashed_rwset = 3;
}

// CollectionHashedReadWriteSet encapsulate the hashed representation for the private read-write set for a collection
message CollectionHashedReadWriteSet {
    string collection_name = 1;
    bytes hashed_rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.HashedRWSet for KV and Document data models)
    bytes pvt_rwset_hash = 3; // Hash of entire private read-write set for a specific collection. This helps in authenticating the private read-write set efficiently
}

// TxPvtReadWriteSet encapsulate the private read-write set for a transaction
message TxPvtReadWriteSet {
    TxReadWriteSet.DataModel data_model = 1;
    repeated NsPvtReadWriteSet ns_pvt_rwset = 2;
}

// NsPvtReadWriteSet encapsulates the private read-write set for a chaincode
message NsPvtReadWriteSet {
   string namespace = 1;
   repeated CollectionPvtReadWriteSet collection_pvt_rwset = 2;
}

// CollectionPvtReadWriteSet encapsulates the private read-write set for a collection
message CollectionPvtReadWriteSet {
    string collection_name = 1;
    bytes rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)
}

src:./ledger/rwset/kvrwset/kv_rwset.proto


// 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/ledger/rwset/kvrwset";
option java_package = "org.hyperledger.fabric.protos.ledger.rwset.kvrwset";

package kvrwset;

// KVRWSet encapsulates the read-write set for a chaincode that operates upon a KV or Document data model
// This structure is used for both the public data and the private data
message KVRWSet {
    repeated KVRead reads = 1;
    repeated RangeQueryInfo range_queries_info = 2;
    repeated KVWrite writes = 3;
    repeated KVMetadataWrite metadata_writes = 4;
}

// HashedRWSet encapsulates hashed representation of a private read-write set for KV or Document data model
message HashedRWSet {
    repeated KVReadHash hashed_reads = 1;
    repeated KVWriteHash hashed_writes = 2;
    repeated KVMetadataWriteHash metadata_writes = 3;
}

// KVRead captures a read operation performed during transaction simulation
// A 'nil' version indicates a non-existing key read by the transaction
message KVRead {
    string key = 1;
    Version version = 2;
}

// KVWrite captures a write (update/delete) operation performed during transaction simulation
message KVWrite {
    string key = 1;
    bool is_delete = 2;
    bytes value = 3;
}

// KVMetadataWrite captures all the entries in the metadata associated with a key
message KVMetadataWrite {
    string key = 1;
    repeated KVMetadataEntry entries = 2;
}

// KVReadHash is similar to the KVRead in spirit. However, it captures the hash of the key instead of the key itself
// version is kept as is for now. However, if the version also needs to be privacy-protected, it would need to be the
// hash of the version and hence of 'bytes' type
message KVReadHash {
    bytes key_hash = 1;
    Version version = 2;
}

// KVWriteHash is similar to the KVWrite. It captures a write (update/delete) operation performed during transaction simulation
message KVWriteHash {
    bytes key_hash = 1;
    bool is_delete = 2;
    bytes value_hash = 3;
}

// KVMetadataWriteHash captures all the upserts to the metadata associated with a key hash
message KVMetadataWriteHash {
    bytes key_hash = 1;
    repeated KVMetadataEntry entries = 2;
}

// KVMetadataEntry captures a 'name'ed entry in the metadata of a key/key-hash.
message KVMetadataEntry {
    string name = 1;
    bytes value = 2;
}

// Version encapsulates the version of a Key
// A version of a committed key is maintained as the height of the transaction that committed the key.
// The height is represenetd as a tuple <blockNum, txNum> where the txNum is the position of the transaction
// (starting with 0) within block
message Version {
    uint64 block_num = 1;
    uint64 tx_num = 2;
}

// RangeQueryInfo encapsulates the details of a range query performed by a transaction during simulation.
// This helps protect transactions from phantom reads by varifying during validation whether any new items
// got committed within the given range between transaction simuation and validation
// (in addition to regular checks for updates/deletes of the existing items).
// readInfo field contains either the KVReads (for the items read by the range query) or a merkle-tree hash
// if the KVReads exceeds a pre-configured numbers
message RangeQueryInfo {
    string start_key = 1;
    string end_key = 2;
    bool itr_exhausted = 3;
    oneof reads_info {
        QueryReads raw_reads = 4;
        QueryReadsMerkleSummary reads_merkle_hashes = 5;
    }
}

// QueryReads encapsulates the KVReads for the items read by a transaction as a result of a query execution
message QueryReads {
    repeated KVRead kv_reads = 1;
}

// QueryReadsMerkleSummary encapsulates the Merkle-tree hashes for the QueryReads
// This allows to reduce the size of RWSet in the presence of query results
// by storing certain hashes instead of actual results.
// maxDegree field refers to the maximum number of children in the tree at any level
// maxLevel field contains the lowest level which has lesser nodes than maxDegree (starting from leaf level)
message QueryReadsMerkleSummary {
    uint32 max_degree = 1;
    uint32 max_level = 2;
    repeated bytes max_level_hashes = 3;
}

src:./ledger/queryresult/kv_query_result.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

package queryresult;

option go_package = "github.com/hyperledger/fabric-protos-go/ledger/queryresult";
option java_package = "org.hyperledger.fabric.protos.ledger.queryresult";

import "google/protobuf/timestamp.proto";


// KV -- QueryResult for range/execute query. Holds a key and corresponding value.
message KV {
    string namespace = 1;
    string key = 2;
    bytes value = 3;
}

// KeyModification -- QueryResult for history query. Holds a transaction ID, value,
// timestamp, and delete marker which resulted from a history query.
message KeyModification {
    string tx_id = 1;
    bytes value = 2;
    google.protobuf.Timestamp timestamp = 3;
    bool is_delete = 4;
}

src:./discovery/protocol.proto


// 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/discovery";
option java_package = "org.hyperledger.fabric.protos.discovery";

package discovery;

import "gossip/message.proto";
import "msp/msp_config.proto";

// Discovery defines a service that serves information about the fabric network
// like which peers, orderers, chaincodes, etc.
service Discovery {
    // Discover receives a signed request, and returns a response.
    rpc Discover (SignedRequest) returns (Response);
}

// SignedRequest contains a serialized Request in the payload field
// and a signature.
// The identity that is used to verify the signature
// can be extracted from the authentication field of type AuthInfo
// in the Request itself after deserializing it.
message SignedRequest {
    bytes payload   = 1;
    bytes signature = 2;
}

// Request contains authentication info about the client that sent the request
// and the queries it wishes to query the service
message Request {
    // authentication contains information that the service uses to check
    // the client's eligibility for the queries.
    AuthInfo authentication = 1;
    // queries
    repeated Query queries = 2;
}

message Response {
    // The results are returned in the same order of the queries
    repeated QueryResult results = 1;
}

// AuthInfo aggregates authentication information that the server uses
// to authenticate the client
message AuthInfo {
    // This is the identity of the client that is used to verify the signature
    // on the SignedRequest's payload.
    // It is a msp.SerializedIdentity in bytes form
    bytes client_identity = 1;

    // This is the hash of the client's TLS cert.
    // When the network is running with TLS, clients that don't include a certificate
    // will be denied access to the service.
    // Since the Request is encapsulated with a SignedRequest (which is signed),
    // this binds the TLS session to the enrollement identity of the client and
    // therefore both authenticates the client to the server,
    // and also prevents the server from relaying the request message to another server.
    bytes client_tls_cert_hash = 2;
}

// Query asks for information in the context of a specific channel
message Query {
    string channel = 1;
    oneof query {
        // ConfigQuery is used to query for the configuration of the channel,
        // such as FabricMSPConfig, and rorderer endpoints.
        // The client has to query a peer it trusts as it doesn't have means to self-verify
        // the authenticity of the returned result.
        // The result is returned in the form of ConfigResult.
        ConfigQuery config_query = 2;

        // PeerMembershipQuery queries for peers in a channel context,
        // and returns PeerMembershipResult
        PeerMembershipQuery peer_query = 3;

        // ChaincodeQuery queries for chaincodes by their name and version.
        // An empty version means any version can by returned.
        ChaincodeQuery cc_query = 4;

        // LocalPeerQuery queries for peers in a non channel context,
        // and returns PeerMembershipResult
        LocalPeerQuery local_peers = 5;
    }
}

// QueryResult contains a result for a given Query.
// The corresponding Query can be inferred by the index of the QueryResult from
// its enclosing Response message.
// QueryResults are ordered in the same order as the Queries are ordered in their enclosing Request.
message QueryResult {
    oneof result {
        // Error indicates failure or refusal to process the query
        Error error = 1;

        // ConfigResult contains the configuration of the channel,
        // such as FabricMSPConfig and orderer endpoints
        ConfigResult config_result = 2;

        // ChaincodeQueryResult contains information about chaincodes,
        // and their corresponding endorsers
        ChaincodeQueryResult cc_query_res = 3;

        // PeerMembershipResult contains information about peers,
        // such as their identity, endpoints, and channel related state.
        PeerMembershipResult members = 4;
    }
}

// ConfigQuery requests a ConfigResult
message ConfigQuery {

}

message ConfigResult {
    // msps is a map from MSP_ID to FabricMSPConfig
    map<string, msp.FabricMSPConfig> msps = 1;
    // orderers is a map from MSP_ID to endpoint lists of orderers
    map<string, Endpoints> orderers = 2;
}

// PeerMembershipQuery requests PeerMembershipResult.
// The filter field may be optionally populated in order
// for the peer membership to be filtered according to
// chaincodes that are installed on peers and collection
// access control policies.
message PeerMembershipQuery {
    ChaincodeInterest filter = 1;
}

// PeerMembershipResult contains peers mapped by their organizations (MSP_ID)
message PeerMembershipResult {
    map<string, Peers> peers_by_org = 1;
}

// ChaincodeQuery requests ChaincodeQueryResults for a given
// list of chaincode invocations.
// Each invocation is a separate one, and the endorsement policy
// is evaluated independantly for each given interest.
message ChaincodeQuery {
    repeated ChaincodeInterest interests = 1;
}

// ChaincodeInterest defines an interest about an endorsement
// for a specific single chaincode invocation.
// Multiple chaincodes indicate chaincode to chaincode invocations.
message ChaincodeInterest {
    repeated ChaincodeCall chaincodes = 1;
}

// ChaincodeCall defines a call to a chaincode.
// It may have collections that are related to the chaincode
message ChaincodeCall {
    string name = 1;
    repeated string collection_names = 2;
}

// ChaincodeQueryResult contains EndorsementDescriptors for
// chaincodes
message ChaincodeQueryResult {
    repeated EndorsementDescriptor content = 1;
}

// LocalPeerQuery queries for peers in a non channel context
message LocalPeerQuery {
}

// EndorsementDescriptor contains information about which peers can be used
// to request endorsement from, such that the endorsement policy would be fulfilled.
// Here is how to compute a set of peers to ask an endorsement from, given an EndorsementDescriptor:
// Let e: G --> P be the endorsers_by_groups field that maps a group to a set of peers.
// Note that applying e on a group g yields a set of peers.
// 1) Select a layout l: G --> N out of the layouts given.
//    l is the quantities_by_group field of a Layout, and it maps a group to an integer.
// 2) R = {}  (an empty set of peers)
// 3) For each group g in the layout l, compute n = l(g)
//    3.1) Denote P_g as a set of n random peers {p0, p1, ... p_n} selected from e(g)
//    3.2) R = R U P_g  (add P_g to R)
// 4) The set of peers R is the peers the client needs to request endorsements from
message EndorsementDescriptor {
    string chaincode = 1;
    // Specifies the endorsers, separated to groups.
    map<string, Peers> endorsers_by_groups = 2;

    // Specifies options of fulfulling the endorsement policy.
    // Each option lists the group names, and the amount of signatures needed
    // from each group.
    repeated Layout layouts = 3;
}

// Layout contains a mapping from a group name to number of peers
// that are needed for fulfilling an endorsement policy
message Layout {
    // Specifies how many non repeated signatures of each group
    // are needed for endorsement
    map<string, uint32> quantities_by_group = 1;
}

// Peers contains a list of Peer(s)
message Peers {
    repeated Peer peers = 1;
}

// Peer contains information about the peer such as its channel specific
// state, and membership information.
message Peer {
    // This is an Envelope of a GossipMessage with a gossip.StateInfo message
    gossip.Envelope state_info = 1;
    // This is an Envelope of a GossipMessage with a gossip.AliveMessage message
    gossip.Envelope membership_info = 2;

    // This is the msp.SerializedIdentity of the peer, represented in bytes.
    bytes identity = 3;
}

// Error denotes that something went wrong and contains the error message
message Error {
    string content = 1;
}

// Endpoints is a list of Endpoint(s)
message Endpoints {
    repeated Endpoint endpoint = 1;
}

// Endpoint is a combination of a host and a port
message Endpoint {
    string host = 1;
    uint32 port = 2;
}

src:./orderer/configuration.proto


// 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/orderer";
option java_package = "org.hyperledger.fabric.protos.orderer";

package orderer;

// The orderer config is specified by the following convention:
//   For a configuration item with key "Key"
//   the encoded value is a a proto message of type "Key"
//   For example, for the configuration item of name "ConsensusType"
//   the encoded value is the proto message "ConsensusType"

message ConsensusType {
    // The consensus type: "solo", "kafka" or "etcdraft".
    string type = 1;
    // Opaque metadata, dependent on the consensus type.
    bytes metadata = 2;

    // State defines the orderer mode of operation, typically for consensus-type migration.
    // NORMAL is during normal operation, when consensus-type migration is not, and can not, take place.
    // MAINTENANCE is when the consensus-type can be changed.
    enum State {
        STATE_NORMAL = 0;
        STATE_MAINTENANCE = 1;
    }
    // The state signals the ordering service to go into maintenance mode, typically for consensus-type migration.
    State state = 3;
}

message BatchSize {
    // Simply specified as number of messages for now, in the future
    // we may want to allow this to be specified by size in bytes
    uint32 max_message_count = 1;
    // The byte count of the serialized messages in a batch cannot
    // exceed this value.
    uint32 absolute_max_bytes = 2;
    // The byte count of the serialized messages in a batch should not
    // exceed this value.
    uint32 preferred_max_bytes = 3;
}

message BatchTimeout {
    // Any duration string parseable by ParseDuration():
    // https://golang.org/pkg/time/#ParseDuration
    string timeout = 1;
}

// Carries a list of bootstrap brokers, i.e. this is not the exclusive set of
// brokers an ordering service
message KafkaBrokers {
    // Each broker here should be identified using the (IP|host):port notation,
    // e.g. 127.0.0.1:7050, or localhost:7050 are valid entries
    repeated string brokers = 1;
}

// ChannelRestrictions is the mssage which conveys restrictions on channel creation for an orderer
message ChannelRestrictions {
    uint64 max_count = 1; // The max count of channels to allow to be created, a value of 0 indicates no limit
}

src:./orderer/kafka.proto


// 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/orderer";
option java_package = "org.hyperledger.fabric.protos.orderer";

package orderer;

// KafkaMessage is a wrapper type for the messages
// that the Kafka-based orderer deals with.
message KafkaMessage {
    oneof Type {
        KafkaMessageRegular regular = 1;
        KafkaMessageTimeToCut time_to_cut = 2;
        KafkaMessageConnect connect = 3;
    }
}

// KafkaMessageRegular wraps a marshalled envelope.
message KafkaMessageRegular {
    enum Class {
        UNKNOWN = 0;
        NORMAL = 1;
        CONFIG = 2;
    }
    bytes payload = 1;
    uint64 config_seq = 2;
    Class class = 3;
    int64 original_offset = 4;
}

// KafkaMessageTimeToCut is used to signal to the orderers
// that it is time to cut block <block_number>.
message KafkaMessageTimeToCut {
    uint64 block_number = 1;
}

// KafkaMessageConnect is posted by an orderer upon booting up.
// It is used to prevent the panic that would be caused if we
// were to consume an empty partition. It is ignored by all
// orderers when processing the partition.
message KafkaMessageConnect {
    bytes payload = 1;
}

// KafkaMetadata is encoded into the ORDERER block to keep track of
// Kafka-related metadata associated with this block.
message KafkaMetadata {
    // LastOffsetPersisted is the encoded value for the Metadata message
    // which is encoded in the ORDERER block metadata index for the case
    // of the Kafka-based orderer.
    int64 last_offset_persisted = 1;

    // LastOriginalOffsetProcessed is used to keep track of the newest
    // offset processed if a message is re-validated and re-ordered.
    // This value is used to deduplicate re-submitted messages from
    // multiple orderer so that we don't bother re-processing it again.
    int64 last_original_offset_processed = 2;

    // LastResubmittedConfigOffset is used to capture the newest offset of
    // CONFIG kafka message, which is revalidated and resubmitted. By comparing
    // this with LastOriginalOffsetProcessed, we could detemine whether there
    // are still CONFIG messages that have been resubmitted but NOT processed
    // yet. It's used as condition to block ingress messages, so we could reduce
    // the overhead of repeatedly resubmitting messages as config seq keeps
    // advancing.
    int64 last_resubmitted_config_offset = 3;
}

src:./orderer/ab.proto


// 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/orderer";
option java_package = "org.hyperledger.fabric.protos.orderer";

package orderer;

import "common/common.proto";

message BroadcastResponse {
    // Status code, which may be used to programatically respond to success/failure
    common.Status status = 1;
    // Info string which may contain additional information about the status returned
    string info = 2;
}

message SeekNewest { }

message SeekOldest { }

message SeekSpecified {
    uint64 number = 1;
}

message SeekPosition {
    oneof Type {
        SeekNewest newest = 1;
        SeekOldest oldest = 2;
        SeekSpecified specified = 3;
    }
}

// SeekInfo specifies the range of requested blocks to return
// If the start position is not found, an error is immediately returned
// Otherwise, blocks are returned until a missing block is encountered, then behavior is dictated
// by the SeekBehavior specified.
message SeekInfo {
   // If BLOCK_UNTIL_READY is specified, the reply will block until the requested blocks are available,
   // if FAIL_IF_NOT_READY is specified, the reply will return an error indicating that the block is not
   // found.  To request that all blocks be returned indefinitely as they are created, behavior should be
   // set to BLOCK_UNTIL_READY and the stop should be set to specified with a number of MAX_UINT64
    enum SeekBehavior {
        BLOCK_UNTIL_READY = 0;
        FAIL_IF_NOT_READY = 1;
    }

    // SeekErrorTolerance indicates to the server how block provider errors should be tolerated.  By default,
    // if the deliver service detects a problem in the underlying block source (typically, in the orderer,
    // a consenter error), it will begin to reject deliver requests.  This is to prevent a client from waiting
    // for blocks from an orderer which is stuck in an errored state.  This is almost always the desired behavior
    // and clients should stick with the default STRICT checking behavior.  However, in some scenarios, particularly
    // when attempting to recover from a crash or other corruption, it's desirable to force an orderer to respond
    // with blocks on a best effort basis, even if the backing consensus implementation is in an errored state.
    // In this case, set the SeekErrorResponse to BEST_EFFORT to ignore the consenter errors.
    enum SeekErrorResponse {
        STRICT = 0;
        BEST_EFFORT = 1;
    }
    SeekPosition start = 1;               // The position to start the deliver from
    SeekPosition stop = 2;                // The position to stop the deliver
    SeekBehavior behavior = 3;            // The behavior when a missing block is encountered
    SeekErrorResponse error_response = 4; // How to respond to errors reported to the deliver service
}

message DeliverResponse {
    oneof Type {
        common.Status status = 1;
        common.Block block = 2;
    }
}

service AtomicBroadcast {
    // broadcast receives a reply of Acknowledgement for each common.Envelope in order, indicating success or type of failure
    rpc Broadcast(stream common.Envelope) returns (stream BroadcastResponse);

    // deliver first requires an Envelope of type DELIVER_SEEK_INFO with Payload data as a mashaled SeekInfo message, then a stream of block replies is received.
    rpc Deliver(stream common.Envelope) returns (stream DeliverResponse);
}

src:./orderer/cluster.proto


// 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/orderer";
option java_package = "org.hyperledger.fabric.protos.orderer";

package orderer;

import "common/common.proto";

// Cluster defines communication between cluster members.
service Cluster {
    // Step passes an implementation-specific message to another cluster member.
    rpc Step(stream StepRequest) returns (stream StepResponse);
}

// StepRequest wraps a message that is sent to a cluster member.
message StepRequest {
    oneof payload {
        // consensus_request is a consensus specific message.
        ConsensusRequest consensus_request = 1;
        // submit_request is a relay of a transaction.
        SubmitRequest submit_request = 2;
    }
}

// StepResponse is a message received from a cluster member.
message StepResponse {
    oneof payload {
        SubmitResponse submit_res = 1;
    }
}

// ConsensusRequest is a consensus specific message sent to a cluster member.
message ConsensusRequest {
    string channel = 1;
    bytes payload = 2;
    bytes metadata = 3;
}

// SubmitRequest wraps a transaction to be sent for ordering.
message SubmitRequest {
    string channel = 1;
    // last_validation_seq denotes the last
    // configuration sequence at which the
    // sender validated this message.
    uint64 last_validation_seq = 2;
    // content is the fabric transaction
    // that is forwarded to the cluster member.
    common.Envelope payload = 3;
}

// SubmitResponse returns a success
// or failure status to the sender.
message SubmitResponse {
    string channel = 1;
    // Status code, which may be used to programatically respond to success/failure.
    common.Status status = 2;
    // Info string which may contain additional information about the returned status.
    string info = 3;
}

src:./orderer/etcdraft/configuration.proto


// 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/orderer/etcdraft";
option java_package = "org.hyperledger.fabric.protos.orderer.etcdraft";

package etcdraft;

// ConfigMetadata is serialized and set as the value of ConsensusType.Metadata in
// a channel configuration when the ConsensusType.Type is set "etcdraft".
message ConfigMetadata {
    repeated Consenter consenters = 1;
    Options options = 2;
}

// Consenter represents a consenting node (i.e. replica).
message Consenter {
    string host = 1;
    uint32 port = 2;
    bytes client_tls_cert = 3;
    bytes server_tls_cert = 4;
}

// Options to be specified for all the etcd/raft nodes. These can be modified on a
// per-channel basis.
message Options {
    string tick_interval = 1; // time duration format, e.g. 500ms
    uint32 election_tick = 2;
    uint32 heartbeat_tick = 3;
    uint32 max_inflight_blocks = 4;
    // Take snapshot when cumulative data exceeds certain size in bytes.
    uint32 snapshot_interval_size = 5;
}

src:./orderer/etcdraft/metadata.proto


// 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/orderer/etcdraft";
option java_package = "org.hyperledger.fabric.protos.orderer.etcdraft";

package etcdraft;

// BlockMetadata stores data used by the Raft OSNs when
// coordinating with each other, to be serialized into
// block meta dta field and used after failres and restarts.
message BlockMetadata {
    // Maintains a mapping between the cluster's OSNs
    // and their Raft IDs.
    repeated uint64 consenter_ids = 1;
    // Carries the Raft ID value that will be assigned
    // to the next OSN that will join this cluster.
    uint64 next_consenter_id = 2;
    // Index of etcd/raft entry for current block.
    uint64 raft_index = 3;
}

// ClusterMetadata encapsulates metadata that is exchanged among cluster nodes
message ClusterMetadata {
    // Indicates active nodes in cluster that are reacheable by Raft leader
    repeated uint64 active_nodes = 1;
}

src:./gossip/message.proto


// 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/gossip";
option java_package = "org.hyperledger.fabric.protos.gossip";

package gossip;

import "common/collection.proto";

// Gossip
service Gossip {

    // GossipStream is the gRPC stream used for sending and receiving messages
    rpc GossipStream (stream Envelope) returns (stream Envelope);

    // Ping is used to probe a remote peer's aliveness
    rpc Ping (Empty) returns (Empty);
}


// Envelope contains a marshalled
// GossipMessage and a signature over it.
// It may also contain a SecretEnvelope
// which is a marshalled Secret
message Envelope {
    bytes payload   = 1;
    bytes signature = 2;
    SecretEnvelope secret_envelope = 3;
}

// SecretEnvelope is a marshalled Secret
// and a signature over it.
// The signature should be validated by the peer
// that signed the Envelope the SecretEnvelope
// came with
message SecretEnvelope {
    bytes payload   = 1;
    bytes signature = 2;
}

// Secret is an entity that might be omitted
// from an Envelope when the remote peer that is receiving
// the Envelope shouldn't know the secret's content.
message Secret {
    oneof content {
        string internalEndpoint = 1;
    }
}

// GossipMessage defines the message sent in a gossip network
message GossipMessage {

    // used mainly for testing, but will might be used in the future
    // for ensuring message delivery by acking
    uint64 nonce  = 1;

    // The channel of the message.
    // Some GossipMessages may set this to nil, because
    // they are cross-channels but some may not
    bytes channel = 2;


    enum Tag {
        UNDEFINED    = 0;
        EMPTY        = 1;
        ORG_ONLY     = 2;
        CHAN_ONLY    = 3;
        CHAN_AND_ORG = 4;
        CHAN_OR_ORG  = 5;
    }

    // determines to which peers it is allowed
    // to forward the message
    Tag tag = 3;

    oneof content {
        // Membership
        AliveMessage alive_msg = 5;
        MembershipRequest mem_req = 6;
        MembershipResponse mem_res = 7;

        // Contains a ledger block
        DataMessage data_msg = 8;

        // Used for push&pull
        GossipHello hello = 9;
        DataDigest  data_dig = 10;
        DataRequest data_req = 11;
        DataUpdate  data_update = 12;

        // Empty message, used for pinging
        Empty empty = 13;

        // ConnEstablish, used for establishing a connection
        ConnEstablish conn = 14;

        // Used for relaying information
        // about state
        StateInfo state_info = 15;

        // Used for sending sets of StateInfo messages
        StateInfoSnapshot state_snapshot = 16;

        // Used for asking for StateInfoSnapshots
        StateInfoPullRequest state_info_pull_req = 17;

        //  Used to ask from a remote peer a set of blocks
        RemoteStateRequest state_request = 18;

        // Used to send a set of blocks to a remote peer
        RemoteStateResponse state_response = 19;

        // Used to indicate intent of peer to become leader
        LeadershipMessage leadership_msg = 20;

        // Used to learn of a peer's certificate
        PeerIdentity peer_identity = 21;

        Acknowledgement ack = 22;

        // Used to request private data
        RemotePvtDataRequest privateReq = 23;

        // Used to respond to private data requests
        RemotePvtDataResponse privateRes = 24;

        // Encapsulates private data used to distribute
        // private rwset after the endorsement
        PrivateDataMessage private_data = 25;
    }
}

// StateInfo is used for a peer to relay its state information
// to other peers
message StateInfo {
    PeerTime timestamp = 2;
    bytes pki_id       = 3;

    // channel_MAC is an authentication code that proves
    // that the peer that sent this message knows
    // the name of the channel.
    bytes channel_MAC  = 4;

    Properties properties = 5;
}

message Properties {
    uint64 ledger_height = 1;
    bool left_channel = 2;
    repeated Chaincode chaincodes = 3;
}

// StateInfoSnapshot is an aggregation of StateInfo messages
message StateInfoSnapshot {
    repeated Envelope elements = 1;
}

// StateInfoPullRequest is used to fetch a StateInfoSnapshot
// from a remote peer
message StateInfoPullRequest {
    // channel_MAC is an authentication code that proves
    // that the peer that sent this message knows
    // the name of the channel.
    bytes channel_MAC  = 1;
}

// ConnEstablish is the message used for the gossip handshake
// Whenever a peer connects to another peer, it handshakes
// with it by sending this message that proves its identity
message ConnEstablish {
    bytes pki_id          = 1;
    bytes identity        = 2;
    bytes tls_cert_hash   = 3;
}

// PeerIdentity defines the identity of the peer
// Used to make other peers learn of the identity
// of a certain peer
message PeerIdentity {
    bytes pki_id    = 1;
    bytes cert      = 2;
    bytes metadata  = 3;
}

// Messages related to pull mechanism

enum PullMsgType {
    UNDEFINED     = 0;
    BLOCK_MSG     = 1;
    IDENTITY_MSG  = 2;
}

// DataRequest is a message used for a peer to request
// certain data blocks from a remote peer
message DataRequest {
    uint64 nonce             = 1;
    repeated bytes digests  = 2;
    PullMsgType msg_type     = 3;
}

// GossipHello is the message that is used for the peer to initiate
// a pull round with another peer
message GossipHello {
    uint64 nonce         = 1;
    bytes metadata       = 2;
    PullMsgType msg_type = 3;
}

// DataUpdate is the final message in the pull phase
// sent from the receiver to the initiator
message DataUpdate {
    uint64 nonce                = 1;
    repeated Envelope data      = 2;
    PullMsgType msg_type        = 3;
}

// DataDigest is the message sent from the receiver peer
// to the initator peer and contains the data items it has
message DataDigest {
    uint64 nonce             = 1;
    repeated bytes digests  = 2; // Maybe change this to bitmap later on
    PullMsgType msg_type     = 3;
}


// Ledger block messages

// DataMessage is the message that contains a block
message DataMessage {
    Payload payload = 1;
}

// PrivateDataMessage message which includes private
// data information to distributed once transaction
// has been endorsed
message PrivateDataMessage {
    PrivatePayload payload = 1;
}

// Payload contains a block
message Payload {
    uint64 seq_num              = 1;
    bytes data                  = 2;
    repeated bytes private_data = 3;
}

// PrivatePayload payload to encapsulate private
// data with collection name to enable routing
// based on collection partitioning
message PrivatePayload {
    string collection_name      = 1;
    string namespace            = 2;
    string tx_id                = 3;
    bytes private_rwset         = 4;
    uint64 private_sim_height  = 5;
    common.CollectionConfigPackage collection_configs = 6;
}

// Membership messages

// AliveMessage is sent to inform remote peers
// of a peer's existence and activity
message AliveMessage {
    Member membership  = 1;
    PeerTime timestamp = 2;
    bytes identity     = 4;
}

// Leadership Message is sent during leader election to inform
// remote peers about intent of peer to proclaim itself as leader
message LeadershipMessage {
    bytes pki_id        = 1;
    PeerTime timestamp = 2;
    bool is_declaration = 3;
}

// PeerTime defines the logical time of a peer's life
message PeerTime {
    uint64 inc_num = 1;
    uint64 seq_num = 2;
}

// MembershipRequest is used to ask membership information
// from a remote peer
message MembershipRequest {
    Envelope self_information = 1;
    repeated bytes known         = 2;
}

// MembershipResponse is used for replying to MembershipRequests
message MembershipResponse {
    repeated Envelope alive = 1;
    repeated Envelope dead  = 2;
}

// Member holds membership-related information
// about a peer
message Member {
    string endpoint = 1;
    bytes  metadata = 2;
    bytes  pki_id    = 3;
}

// Empty is used for pinging and in tests
message Empty {}


// State transfer

// RemoteStateRequest is used to ask a set of blocks
// from a remote peer
message RemoteStateRequest {
    uint64 start_seq_num = 1;
    uint64 end_seq_num = 2;
}

// RemoteStateResponse is used to send a set of blocks
// to a remote peer
message RemoteStateResponse {
    repeated Payload payloads = 1;
}

// RemotePrivateDataRequest message used to request
// missing private rwset
message RemotePvtDataRequest {
    repeated PvtDataDigest digests = 1;
}

// PvtDataDigest defines a digest of private data
message PvtDataDigest {
    string tx_id = 1;
    string namespace = 2;
    string collection = 3;
    uint64 block_seq = 4;
    uint64 seq_in_block = 5;
}

// RemotePrivateData message to response on private
// data replication request
message RemotePvtDataResponse {
    repeated PvtDataElement elements = 1;
}

message PvtDataElement {
    PvtDataDigest digest = 1;
    // the payload is a marshaled kvrwset.KVRWSet
    repeated bytes payload = 2;
}

// PvtPayload augments private rwset data and tx index
// inside the block
message PvtDataPayload {
    uint64 tx_seq_in_block = 1;
    // Encodes marhslaed bytes of rwset.TxPvtReadWriteSet
    // defined in rwset.proto
    bytes payload = 2;
}

message Acknowledgement {
    string error = 1;
}

// Chaincode represents a Chaincode that is installed
// on a peer
message Chaincode {
    string name = 1;
    string version = 2;
    bytes metadata = 3;
}

src:./transientstore/transientstore.proto


// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

package transientstore;

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";

// TxPvtReadWriteSetWithConfigInfo encapsulates the transaction's private
// read-write set and additional information about the configurations such as
// the latest collection config when the transaction is simulated
message TxPvtReadWriteSetWithConfigInfo {
    uint64 endorsed_at = 1;
    rwset.TxPvtReadWriteSet pvt_rwset = 2;
    map<string, common.CollectionConfigPackage> collection_configs = 3;
}

src:./common/configuration.proto


// 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/common";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

// HashingAlgorithm is encoded into the configuration transaction as  a configuration item of type Chain
// with a Key of "HashingAlgorithm" and a Value of  HashingAlgorithm as marshaled protobuf bytes
message HashingAlgorithm {
    // Currently supported algorithms are: SHAKE256
    string name = 1;
}

// BlockDataHashingStructure is encoded into the configuration transaction as a configuration item of
// type Chain with a Key of "BlockDataHashingStructure" and a Value of HashingAlgorithm as marshaled protobuf bytes
message BlockDataHashingStructure {
    // width specifies the width of the Merkle tree to use when computing the BlockDataHash
    // in order to replicate flat hashing, set this width to MAX_UINT32
    uint32 width  = 1;
}

// OrdererAddresses is encoded into the configuration transaction as a configuration item of type Chain
// with a Key of "OrdererAddresses" and a Value of OrdererAddresses as marshaled protobuf bytes
message OrdererAddresses {
    repeated string addresses = 1;
}

// Consortium represents the consortium context in which the channel was created
message Consortium {
    string name = 1;
}


// Capabilities message defines the capabilities a particular binary must implement
// for that binary to be able to safely participate in the channel.  The capabilities
// message is defined at the /Channel level, the /Channel/Application level, and the
// /Channel/Orderer level.
//
// The /Channel level capabilties define capabilities which both the orderer and peer
// binaries must satisfy.  These capabilties might be things like a new MSP type,
// or a new policy type.
//
// The /Channel/Orderer level capabilties define capabilities which must be supported
// by the orderer, but which have no bearing on the behavior of the peer.  For instance
// if the orderer changes the logic for how it constructs new channels, only all orderers
// must agree on the new logic.  The peers do not need to be aware of this change as
// they only interact with the channel after it has been constructed.
//
// Finally, the /Channel/Application level capabilities define capabilities which the peer
// binary must satisfy, but which have no bearing on the orderer.  For instance, if the
// peer adds a new UTXO transaction type, or changes the chaincode lifecycle requirements,
// all peers must agree on the new logic.  However, orderers never inspect transactions
// this deeply, and therefore have no need to be aware of the change.
//
// The capabilities strings defined in these messages typically correspond to release
// binary versions (e.g. "V1.1"), and are used primarilly as a mechanism for a fully
// upgraded network to switch from one set of logic to a new one.
//
// Although for V1.1, the orderers must be upgraded to V1.1 prior to the rest of the
// network, going forward, because of the split between the /Channel, /Channel/Orderer
// and /Channel/Application capabilities.  It should be possible for the orderer and
// application networks to upgrade themselves independently (with the exception of any
// new capabilities defined at the /Channel level).
message Capabilities {
    map<string, Capability> capabilities = 1;
}

// Capability is an empty message for the time being.  It is defined as a protobuf
// message rather than a constant, so that we may extend capabilities with other fields
// if the need arises in the future.  For the time being, a capability being in the
// capabilities map requires that that capability be supported.
message Capability { }

src:./common/ledger.proto


// 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/common";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

// Contains information about the blockchain ledger such as height, current
// block hash, and previous block hash.
message BlockchainInfo {
    uint64 height = 1;
    bytes currentBlockHash = 2;
    bytes previousBlockHash = 3;
}

src:./common/policies.proto


// 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/common";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

import "msp/msp_principal.proto";

// Policy expresses a policy which the orderer can evaluate, because there has been some desire expressed to support
// multiple policy engines, this is typed as a oneof for now
message Policy {
    enum PolicyType {
        UNKNOWN = 0; // Reserved to check for proper initialization
        SIGNATURE = 1;
        MSP = 2;
        IMPLICIT_META = 3;
    }
    int32 type = 1; // For outside implementors, consider the first 1000 types reserved, otherwise one of PolicyType
    bytes value = 2;
}

// SignaturePolicyEnvelope wraps a SignaturePolicy and includes a version for future enhancements
message SignaturePolicyEnvelope {
    int32 version = 1;
    SignaturePolicy rule = 2;
    repeated MSPPrincipal identities = 3;
}

// SignaturePolicy is a recursive message structure which defines a featherweight DSL for describing
// policies which are more complicated than 'exactly this signature'.  The NOutOf operator is sufficent
// to express AND as well as OR, as well as of course N out of the following M policies
// SignedBy implies that the signature is from a valid certificate which is signed by the trusted
// authority specified in the bytes.  This will be the certificate itself for a self-signed certificate
// and will be the CA for more traditional certificates
message SignaturePolicy {
    message NOutOf {
        int32 n = 1;
        repeated SignaturePolicy rules = 2;
    }
    oneof Type {
        int32 signed_by = 1;
        NOutOf n_out_of = 2;
    }
}

// ImplicitMetaPolicy is a policy type which depends on the hierarchical nature of the configuration
// It is implicit because the rule is generate implicitly based on the number of sub policies
// It is meta because it depends only on the result of other policies
// When evaluated, this policy iterates over all immediate child sub-groups, retrieves the policy
// of name sub_policy, evaluates the collection and applies the rule.
// For example, with 4 sub-groups, and a policy name of "foo", ImplicitMetaPolicy retrieves
// each sub-group, retrieves policy "foo" for each subgroup, evaluates it, and, in the case of ANY
// 1 satisfied is sufficient, ALL would require 4 signatures, and MAJORITY would require 3 signatures.
message ImplicitMetaPolicy {
    enum Rule {
        ANY = 0;      // Requires any of the sub-policies be satisfied, if no sub-policies exist, always returns true
        ALL = 1;      // Requires all of the sub-policies be satisfied
        MAJORITY = 2; // Requires a strict majority (greater than half) of the sub-policies be satisfied
    }
    string sub_policy = 1;
    Rule rule = 2;
}

src:./common/configtx.proto


// 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/common";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

import "common/common.proto";
import "common/policies.proto";

// ConfigEnvelope is designed to contain _all_ configuration for a chain with no dependency
// on previous configuration transactions.
//
// It is generated with the following scheme:
//   1. Retrieve the existing configuration
//   2. Note the config properties (ConfigValue, ConfigPolicy, ConfigGroup) to be modified
//   3. Add any intermediate ConfigGroups to the ConfigUpdate.read_set (sparsely)
//   4. Add any additional desired dependencies to ConfigUpdate.read_set (sparsely)
//   5. Modify the config properties, incrementing each version by 1, set them in the ConfigUpdate.write_set
//      Note: any element not modified but specified should already be in the read_set, so may be specified sparsely
//   6. Create ConfigUpdate message and marshal it into ConfigUpdateEnvelope.update and encode the required signatures
//     a) Each signature is of type ConfigSignature
//     b) The ConfigSignature signature is over the concatenation of signature_header and the ConfigUpdate bytes (which includes a ChainHeader)
//   5. Submit new Config for ordering in Envelope signed by submitter
//     a) The Envelope Payload has data set to the marshaled ConfigEnvelope
//     b) The Envelope Payload has a header of type Header.Type.CONFIG_UPDATE
//
// The configuration manager will verify:
//   1. All items in the read_set exist at the read versions
//   2. All items in the write_set at a different version than, or not in, the read_set have been appropriately signed according to their mod_policy
//   3. The new configuration satisfies the ConfigSchema
message ConfigEnvelope {
    Config config = 1;        // A marshaled Config structure
    Envelope last_update = 2; // The last CONFIG_UPDATE message which generated this current configuration
                              // Note that CONFIG_UPDATE has a Payload.Data of a Marshaled ConfigUpdate
}

message ConfigGroupSchema {
    map<string, ConfigGroupSchema> groups = 1;
    map<string, ConfigValueSchema> values = 2;
    map<string, ConfigPolicySchema> policies = 3;
}

message ConfigValueSchema {}

message ConfigPolicySchema {}

// Config represents the config for a particular channel
message Config {
    // Prevent removed tag re-use
    reserved 3;
    reserved "type";

    uint64 sequence = 1;
    ConfigGroup channel_group = 2; // channel_group is a bad name for this, it should be changed to root when API breakage is allowed
}

message ConfigUpdateEnvelope {
    bytes config_update = 1;                 // A marshaled ConfigUpdate structure
    repeated ConfigSignature signatures = 2; // Signatures over the config_update
}

// ConfigUpdate is used to submit a subset of config and to have the orderer apply to Config
// it is always submitted inside a ConfigUpdateEnvelope which allows the addition of signatures
// resulting in a new total configuration.  The update is applied as follows:
// 1. The versions from all of the elements in the read_set is verified against the versions in the existing config.
//    If there is a mismatch in the read versions, then the config update fails and is rejected.
// 2. Any elements in the write_set with the same version as the read_set are ignored.
// 3. The corresponding mod_policy for every remaining element in the write_set is collected.
// 4. Each policy is checked against the signatures from the ConfigUpdateEnvelope, any failing to verify are rejected
// 5. The write_set is applied to the Config and the ConfigGroupSchema verifies that the updates were legal
message ConfigUpdate {
    // Prevent removed tag re-use
    reserved 4;
    reserved "type";

    string channel_id = 1;                // Which channel this config update is for
    ConfigGroup read_set = 2;             // ReadSet explicitly lists the portion of the config which was read, this should be sparse with only Version set
    ConfigGroup write_set = 3;            // WriteSet lists the portion of the config which was written, this should included updated Versions
    map<string, bytes> isolated_data = 5; // Data which is not to be reflected in the resulting Config, but is still needed for some other purpose.  For instance, rscc_seed_data
}

// ConfigGroup is the hierarchical data structure for holding config
message ConfigGroup {
    uint64 version = 1;
    map<string,ConfigGroup> groups = 2;
    map<string,ConfigValue> values = 3;
    map<string,ConfigPolicy> policies = 4;
    string mod_policy = 5;
}

// ConfigValue represents an individual piece of config data
message ConfigValue {
    uint64 version = 1;
    bytes value = 2;
    string mod_policy = 3;
}

message ConfigPolicy {
    uint64 version = 1;
    Policy policy = 2;
    string mod_policy = 3;
}

message ConfigSignature {
    bytes signature_header = 1; // A marshaled SignatureHeader
    bytes signature = 2;        // Signature over the concatenation signatureHeader bytes and config bytes
}

src:./common/common.proto


// 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/common";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

import "google/protobuf/timestamp.proto";

// These status codes are intended to resemble selected HTTP status codes
enum Status {
    UNKNOWN = 0;
    SUCCESS = 200;
    BAD_REQUEST = 400;
    FORBIDDEN = 403;
    NOT_FOUND = 404;
    REQUEST_ENTITY_TOO_LARGE = 413;
    INTERNAL_SERVER_ERROR = 500;
    NOT_IMPLEMENTED = 501;
    SERVICE_UNAVAILABLE = 503;
}

enum HeaderType {
    reserved 7, 9;
    reserved "PEER_RESOURCE_UPDATE", "TOKEN_TRANSACTION";

    MESSAGE = 0;                     // Used for messages which are signed but opaque
    CONFIG = 1;                      // Used for messages which express the channel config
    CONFIG_UPDATE = 2;               // Used for transactions which update the channel config
    ENDORSER_TRANSACTION = 3;        // Used by the SDK to submit endorser based transactions
    ORDERER_TRANSACTION = 4;         // Used internally by the orderer for management
    DELIVER_SEEK_INFO = 5;           // Used as the type for Envelope messages submitted to instruct the Deliver API to seek
    CHAINCODE_PACKAGE = 6;           // Used for packaging chaincode artifacts for install
    PEER_ADMIN_OPERATION = 8;        // Used for invoking an administrative operation on a peer
}

// 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 */
}

// LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index
message LastConfig {
    uint64 index  = 1;
}

// Metadata is a common structure to be used to encode block metadata
message Metadata {
    bytes value = 1;
    repeated MetadataSignature signatures = 2;
}

message MetadataSignature {
    bytes signature_header = 1; // An encoded SignatureHeader
    bytes signature = 2;       // The signature over the concatenation of the Metadata value bytes, signatureHeader, and block header
}

message Header {
    bytes channel_header = 1;
    bytes signature_header = 2;
}

// Header is a generic replay prevention and identity message to include in a signed payload
message ChannelHeader {
    int32 type = 1; // Header types 0-10000 are reserved and defined by HeaderType

    // Version indicates message protocol version
    int32 version = 2;

    // Timestamp is the local time when the message was created
    // by the sender
    google.protobuf.Timestamp timestamp = 3;

    // Identifier of the channel this message is bound for
    string channel_id = 4;

    // An unique identifier that is used end-to-end.
    //  -  set by higher layers such as end user or SDK
    //  -  passed to the endorser (which will check for uniqueness)
    //  -  as the header is passed along unchanged, it will be
    //     be retrieved by the committer (uniqueness check here as well)
    //  -  to be stored in the ledger
    string tx_id = 5;

    // The epoch in which this header was generated, where epoch is defined based on block height
    // Epoch in which the response has been generated. This field identifies a
    // logical window of time. A proposal response is accepted by a peer only if
    // two conditions hold:
    // 1. the epoch specified in the message is the current epoch
    // 2. this message has been only seen once during this epoch (i.e. it hasn't
    //    been replayed)
    uint64 epoch = 6;

    // Extension that may be attached based on the header type
    bytes extension = 7;

    // If mutual TLS is employed, this represents
    // the hash of the client's TLS certificate
    bytes tls_cert_hash = 8;
}

message SignatureHeader {
    // Creator of the message, a marshaled msp.SerializedIdentity
    bytes creator = 1;

    // Arbitrary number that may only be used once. Can be used to detect replay attacks.
    bytes nonce = 2;
}

// Payload is the message contents (and header to allow for signing)
message Payload {

    // Header is included to provide identity and prevent replay
    Header header = 1;

    // Data, the encoding of which is defined by the type in the header
    bytes data = 2;
}

// Envelope wraps a Payload with a signature so that the message may be authenticated
message Envelope {
    // A marshaled Payload
    bytes payload = 1;

    // A signature by the creator specified in the Payload header
    bytes signature = 2;
}

// This is finalized block structure to be shared among the orderer and peer
// Note that the BlockHeader chains to the previous BlockHeader, and the BlockData hash is embedded
// in the BlockHeader.  This makes it natural and obvious that the Data is included in the hash, but
// the Metadata is not.
message Block {
    BlockHeader header = 1;
    BlockData data = 2;
    BlockMetadata metadata = 3;
}

// BlockHeader is the element of the block which forms the block chain
// The block header is hashed using the configured chain hashing algorithm
// over the ASN.1 encoding of the BlockHeader
message BlockHeader {
    uint64 number = 1; // The position in the blockchain
    bytes previous_hash = 2; // The hash of the previous block header
    bytes data_hash = 3; // The hash of the BlockData, by MerkleTree
}

message BlockData {
    repeated bytes data = 1;
}

message BlockMetadata {
    repeated bytes metadata = 1;
}

// OrdererBlockMetadata defines metadata that is set by the ordering service.
message OrdererBlockMetadata {
    LastConfig last_config = 1;
    bytes consenter_metadata = 2;
}

src:./common/collection.proto


// 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/common";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

import "common/policies.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;
}


// 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.
        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;
    }
}


// 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;
}