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