github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/protos/peer/proposal.proto (about) 1 /* 2 Copyright IBM Corp. 2016 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 syntax = "proto3"; 18 19 option go_package = "github.com/hyperledger/fabric/protos/peer"; 20 21 package protos; 22 23 import "peer/chaincode.proto"; 24 import "peer/proposal_response.proto"; 25 26 /* 27 The flow to get a generic transaction approved goes as follows: 28 29 1. client sends proposal to endorser 30 ==================================== 31 32 The proposal is basically a request to do something that will result on some 33 action with impact on the ledger; a proposal contains a header (with some 34 metadata describing it, such as the type, the identity of the invoker, the 35 time, the ID of the chain, a cryptographic nonce..) and an opaque payload that 36 depends on the type specified in the header. A proposal contains the following 37 messages: 38 39 SignedProposal 40 |\_ Signature (signature on the Proposal message by the creator specified in the header) 41 \_ Proposal 42 |\_ Header (the header for this proposal) 43 \_ Payload (the payload for this proposal) 44 45 2. endorser sends proposal response back to client 46 ================================================== 47 48 The proposal response contains an endorser's response to a client's proposal. A 49 proposal response contains a success/error code, a response payload and a 50 signature (also referred to as endorsement) over the response payload. The 51 response payload contains a hash of the proposal (to securely link this 52 response to the corresponding proposal) and an opaque extension field that 53 depends on the type specified in the header of the corresponding proposal. A 54 proposal response contains the following messages: 55 56 ProposalResponse 57 |\_ Endorsement (the endorser's signature over the whole response payload) 58 \_ ProposalResponsePayload (the payload of the proposal response) 59 60 3. client assembles endorsements into a transaction 61 =================================================== 62 63 A transaction message assembles one or more proposals and corresponding 64 responses into a message to be sent to orderers. After ordering, (batches of) 65 transactions are delivered to committing peers for validation and final 66 delivery into the ledger. A transaction contains one or more actions. Each of 67 them contains a header (same as that of the proposal that requested it) and an 68 opaque payload that depends on the type specified in the header. 69 70 SignedTransaction 71 |\_ Signature (signature on the Transaction message by the creator specified in the header) 72 \_ Transaction 73 \_ TransactionAction (1...n) 74 |\_ Header (1) (the header of the proposal that requested this action) 75 \_ Payload (1) (the payload for this action) 76 */ 77 78 // This structure is necessary to sign the proposal which contains the header 79 // and the payload. Without this structure, we would have to concatenate the 80 // header and the payload to verify the signature, which could be expensive 81 // with large payload 82 // 83 // When an endorser receives a SignedProposal message, it should verify the 84 // signature over the proposal bytes. This verification requires the following 85 // steps: 86 // 1. Verification of the validity of the certificate that was used to produce 87 // the signature. The certificate will be available once proposalBytes has 88 // been unmarshalled to a Proposal message, and Proposal.header has been 89 // unmarshalled to a Header message. While this unmarshalling-before-verifying 90 // might not be ideal, it is unavoidable because i) the signature needs to also 91 // protect the signing certificate; ii) it is desirable that Header is created 92 // once by the client and never changed (for the sake of accountability and 93 // non-repudiation). Note also that it is actually impossible to conclusively 94 // verify the validity of the certificate included in a Proposal, because the 95 // proposal needs to first be endorsed and ordered with respect to certificate 96 // expiration transactions. Still, it is useful to pre-filter expired 97 // certificates at this stage. 98 // 2. Verification that the certificate is trusted (signed by a trusted CA) and 99 // that it is allowed to transact with us (with respect to some ACLs); 100 // 3. Verification that the signature on proposalBytes is valid; 101 // 4. Detect replay attacks; 102 message SignedProposal { 103 104 // The bytes of Proposal 105 bytes proposal_bytes = 1; 106 107 // Signaure over proposalBytes; this signature is to be verified against 108 // the creator identity contained in the header of the Proposal message 109 // marshaled as proposalBytes 110 bytes signature = 2; 111 } 112 113 // A Proposal is sent to an endorser for endorsement. The proposal contains: 114 // 1. A header which should be unmarshaled to a Header message. Note that 115 // Header is both the header of a Proposal and of a Transaction, in that i) 116 // both headers should be unmarshaled to this message; and ii) it is used to 117 // compute cryptographic hashes and signatures. The header has fields common 118 // to all proposals/transactions. In addition it has a type field for 119 // additional customization. An example of this is the ChaincodeHeaderExtension 120 // message used to extend the Header for type CHAINCODE. 121 // 2. A payload whose type depends on the header's type field. 122 // 3. An extension whose type depends on the header's type field. 123 // 124 // Let us see an example. For type CHAINCODE (see the Header message), 125 // we have the following: 126 // 1. The header is a Header message whose extensions field is a 127 // ChaincodeHeaderExtension message. 128 // 2. The payload is a ChaincodeProposalPayload message. 129 // 3. The extension is a ChaincodeAction that might be used to ask the 130 // endorsers to endorse a specific ChaincodeAction, thus emulating the 131 // submitting peer model. 132 message Proposal { 133 134 // The header of the proposal. It is the bytes of the Header 135 bytes header = 1; 136 137 // The payload of the proposal as defined by the type in the proposal 138 // header. 139 bytes payload = 2; 140 141 // Optional extensions to the proposal. Its content depends on the Header's 142 // type field. For the type CHAINCODE, it might be the bytes of a 143 // ChaincodeAction message. 144 bytes extension = 3; 145 } 146 147 //-------- the Chaincode Proposal ----------- 148 149 /* 150 The flow to get a CHAINCODE transaction approved goes as follows: 151 152 1. client sends proposal to endorser 153 ==================================== 154 155 The proposal is basically a request to do something on a chaincode, that will 156 result on some action - some change in the state of a chaincode and/or some 157 data to be committed to the ledger; a proposal in general contains a header 158 (with some metadata describing it, such as the type, the identity of the 159 invoker, the time, the ID of the chain, a cryptographic nonce..) and a payload 160 (the chaincode ID, invocation arguments..). Optionally, it may contain actions 161 that the endorser may be asked to endorse, to emulate a submitting peer. A 162 chaincode proposal contains the following messages: 163 164 SignedProposal 165 |\_ Signature (signature on the Proposal message by the creator specified in the header) 166 \_ Proposal 167 |\_ Header (the header for this proposal) 168 |\_ ChaincodeProposalPayload (the payload for this proposal) 169 \_ ChaincodeAction (the actions for this proposal - optional for a proposal) 170 171 2. endorser sends proposal response back to client 172 ================================================== 173 174 The proposal response contains an endorser's response to a client's proposal. A 175 proposal response contains a success/error code, a response payload and a 176 signature (also referred to as endorsement) over the response payload. The 177 response payload contains a hash of the proposal (to securely link this 178 response to the corresponding proposal), a description of the action resulting 179 from the proposal and the endorser's signature over its payload. Formally, a 180 chaincode proposal response contains the following messages: 181 182 ProposalResponse 183 |\_ Endorsement (the endorser's signature over the whole response payload) 184 \_ ProposalResponsePayload 185 \_ ChaincodeAction (the actions for this proposal) 186 187 3. client assembles endorsements into a transaction 188 =================================================== 189 190 A transaction message assembles one or more proposals and corresponding 191 responses into a message to be sent to orderers. After ordering, (batches of) 192 transactions are delivered to committing peers for validation and final 193 delivery into the ledger. A transaction contains one or more actions. Each of 194 them contains a header (same as that of the proposal that requested it), a 195 proposal payload (same as that of the proposal that requested it), a 196 description of the resulting action and signatures from each of the endorsers 197 that endorsed the action. 198 199 SignedTransaction 200 |\_ Signature (signature on the Transaction message by the creator specified in the header) 201 \_ Transaction 202 \_ TransactionAction (1...n) 203 |\_ Header (1) (the header of the proposal that requested this action) 204 \_ ChaincodeActionPayload (1) 205 |\_ ChaincodeProposalPayload (1) (payload of the proposal that requested this action) 206 \_ ChaincodeEndorsedAction (1) 207 |\_ Endorsement (1...n) (endorsers' signatures over the whole response payload) 208 \_ ProposalResponsePayload 209 \_ ChaincodeAction (the actions for this proposal) 210 */ 211 212 // ChaincodeHeaderExtension is the Header's extentions message to be used when 213 // the Header's type is CHAINCODE. This extensions is used to specify which 214 // chaincode to invoke and what should appear on the ledger. 215 message ChaincodeHeaderExtension { 216 217 // The PayloadVisibility field controls to what extent the Proposal's payload 218 // (recall that for the type CHAINCODE, it is ChaincodeProposalPayload 219 // message) field will be visible in the final transaction and in the ledger. 220 // Ideally, it would be configurable, supporting at least 3 main visibility 221 // modes: 222 // 1. all bytes of the payload are visible; 223 // 2. only a hash of the payload is visible; 224 // 3. nothing is visible. 225 // Notice that the visibility function may be potentially part of the ESCC. 226 // In that case it overrides PayloadVisibility field. Finally notice that 227 // this field impacts the content of ProposalResponsePayload.proposalHash. 228 bytes payload_visibility = 1; 229 230 // The ID of the chaincode to target. 231 ChaincodeID chaincode_id = 2; 232 } 233 234 // ChaincodeProposalPayload is the Proposal's payload message to be used when 235 // the Header's type is CHAINCODE. It contains the arguments for this 236 // invocation. 237 message ChaincodeProposalPayload { 238 239 // Input contains the arguments for this invocation. If this invocation 240 // deploys a new chaincode, ESCC/VSCC are part of this field. 241 bytes input = 1; 242 243 // TransientMap contains data (e.g. cryptographic material) that might be used 244 // to implement some form of application-level confidentiality. The contents 245 // of this field are supposed to always be omitted from the transaction and 246 // excluded from the ledger. 247 map<string, bytes> TransientMap = 2; 248 } 249 250 // ChaincodeAction contains the actions the events generated by the execution 251 // of the chaincode. 252 message ChaincodeAction { 253 254 // This field contains the read set and the write set produced by the 255 // chaincode executing this invocation. 256 bytes results = 1; 257 258 // This field contains the events generated by the chaincode executing this 259 // invocation. 260 bytes events = 2; 261 262 // This field contains the result of executing this invocation. 263 Response response = 3; 264 }