diff --git a/accesscontrol/crypto/attr/attr_support.go b/accesscontrol/crypto/attr/attr_support.go index 8803e47933a..54fd1878e54 100644 --- a/accesscontrol/crypto/attr/attr_support.go +++ b/accesscontrol/crypto/attr/attr_support.go @@ -28,8 +28,8 @@ import ( // chaincodeHolder is the struct that hold the certificate and the metadata. An implementation is ChaincodeStub type chaincodeHolder interface { - // GetCallerCertificate returns caller certificate - GetCallerCertificate() ([]byte, error) + // GetCreator returns caller certificate + GetCreator() ([]byte, error) // GetCallerMetadata returns caller metadata /* @@ -82,8 +82,8 @@ type chaincodeHolderImpl struct { Certificate []byte } -// GetCallerCertificate returns caller certificate -func (holderImpl *chaincodeHolderImpl) GetCallerCertificate() ([]byte, error) { +// GetCreator returns caller certificate +func (holderImpl *chaincodeHolderImpl) GetCreator() ([]byte, error) { return holderImpl.Certificate, nil } @@ -99,7 +99,7 @@ func GetValueFrom(attributeName string, cert []byte) ([]byte, error) { //NewAttributesHandlerImpl creates a new AttributesHandlerImpl from a pb.ChaincodeSecurityContext object. func NewAttributesHandlerImpl(holder chaincodeHolder) (*AttributesHandlerImpl, error) { // Getting certificate - certRaw, err := holder.GetCallerCertificate() + certRaw, err := holder.GetCreator() if err != nil { return nil, err } diff --git a/accesscontrol/crypto/attr/attr_support_test.go b/accesscontrol/crypto/attr/attr_support_test.go index 268b2dfbfa1..01b72caef67 100644 --- a/accesscontrol/crypto/attr/attr_support_test.go +++ b/accesscontrol/crypto/attr/attr_support_test.go @@ -40,8 +40,8 @@ type chaincodeStubMock struct { */ } -// GetCallerCertificate returns caller certificate -func (shim *chaincodeStubMock) GetCallerCertificate() ([]byte, error) { +// GetCreator returns caller certificate +func (shim *chaincodeStubMock) GetCreator() ([]byte, error) { return shim.callerCert, nil } @@ -60,9 +60,9 @@ type certErrorMock struct { */ } -// GetCallerCertificate returns caller certificate -func (shim *certErrorMock) GetCallerCertificate() ([]byte, error) { - return nil, errors.New("GetCallerCertificate error") +// GetCreator returns caller certificate +func (shim *certErrorMock) GetCreator() ([]byte, error) { + return nil, errors.New("GetCreator error") } /* @@ -76,8 +76,8 @@ type metadataErrorMock struct { callerCert []byte } -// GetCallerCertificate returns caller certificate -func (shim *metadataErrorMock) GetCallerCertificate() ([]byte, error) { +// GetCreator returns caller certificate +func (shim *metadataErrorMock) GetCreator() ([]byte, error) { return shim.callerCert, nil } @@ -85,7 +85,7 @@ func (shim *metadataErrorMock) GetCallerCertificate() ([]byte, error) { TODO: ##attributes-keys-pending This code have be redefined to avoid use of metadata field. // GetCallerMetadata returns caller metadata func (shim *metadataErrorMock) GetCallerMetadata() ([]byte, error) { - return nil, errors.New("GetCallerCertificate error") + return nil, errors.New("GetCreator error") }*/ func TestVerifyAttribute(t *testing.T) { diff --git a/core/chaincode/handler.go b/core/chaincode/handler.go index 5e6262284c8..343141c5cff 100644 --- a/core/chaincode/handler.go +++ b/core/chaincode/handler.go @@ -31,7 +31,6 @@ import ( "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/peer" pb "github.com/hyperledger/fabric/protos/peer" - "github.com/hyperledger/fabric/protos/utils" "github.com/looplab/fsm" logging "github.com/op/go-logging" "golang.org/x/net/context" @@ -1379,13 +1378,7 @@ func (handler *Handler) setChaincodeProposal(prop *pb.Proposal, msg *pb.Chaincod if prop != nil { chaincodeLogger.Debug("Proposal different from nil. Creating chaincode proposal context...") - proposalContext, err := utils.GetChaincodeProposalContext(prop) - if err != nil { - chaincodeLogger.Debug("Failed getting proposal context from proposal [%s]", err) - return fmt.Errorf("Failed getting proposal context from proposal [%s]", err) - } - - msg.ProposalContext = proposalContext + msg.Proposal = prop } return nil } @@ -1400,7 +1393,6 @@ func (handler *Handler) ready(ctxt context.Context, chainID string, txid string, chaincodeLogger.Debug("sending READY") ccMsg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_READY, Txid: txid} - //if security is disabled the context elements will just be nil if err := handler.setChaincodeProposal(prop, ccMsg); err != nil { return nil, err } @@ -1465,7 +1457,6 @@ func (handler *Handler) sendExecuteMessage(ctxt context.Context, chainID string, chaincodeLogger.Debugf("[%s]Inside sendExecuteMessage. Message %s", shorttxid(msg.Txid), msg.Type.String()) } - //if security is disabled the context elements will just be nil if err = handler.setChaincodeProposal(prop, msg); err != nil { return nil, err } diff --git a/core/chaincode/shim/chaincode.go b/core/chaincode/shim/chaincode.go index 12d0aed7832..7a8fa0b180a 100644 --- a/core/chaincode/shim/chaincode.go +++ b/core/chaincode/shim/chaincode.go @@ -29,9 +29,9 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/timestamp" - "github.com/hyperledger/fabric/common/util" "github.com/hyperledger/fabric/core/comm" pb "github.com/hyperledger/fabric/protos/peer" + "github.com/hyperledger/fabric/protos/utils" "github.com/op/go-logging" "github.com/spf13/viper" "golang.org/x/net/context" @@ -49,11 +49,16 @@ const ( // ChaincodeStub is an object passed to chaincode for shim side handling of // APIs. type ChaincodeStub struct { - TxID string - proposalContext *pb.ChaincodeProposalContext - chaincodeEvent *pb.ChaincodeEvent - args [][]byte - handler *Handler + TxID string + chaincodeEvent *pb.ChaincodeEvent + args [][]byte + handler *Handler + proposal *pb.Proposal + + // Additional fields extracted from the proposal + creator []byte + transient map[string][]byte + binding []byte } // Peer address derived from command line or env var @@ -270,20 +275,32 @@ func chatWithPeer(chaincodename string, stream PeerChaincodeStream, cc Chaincode // -- init stub --- // ChaincodeInvocation functionality -func (stub *ChaincodeStub) init(handler *Handler, txid string, input *pb.ChaincodeInput, proposalContext *pb.ChaincodeProposalContext) { +func (stub *ChaincodeStub) init(handler *Handler, txid string, input *pb.ChaincodeInput, proposal *pb.Proposal) error { stub.TxID = txid stub.args = input.Args stub.handler = handler - stub.proposalContext = proposalContext -} + stub.proposal = proposal + + // TODO: sanity check: verify that every call to init with a nil + // proposal is a legitimate one, meaning it is an internal call + // to system chaincodes. + if proposal != nil { + // Extract creator, transient, binding... + var err error + stub.creator, stub.transient, err = utils.GetChaincodeProposalContext(proposal) + if err != nil { + return fmt.Errorf("Failed extracting proposal fields. [%s]", err) + } -// InitTestStub initializes an appropriate stub for testing chaincode -func InitTestStub(funargs ...string) *ChaincodeStub { - stub := ChaincodeStub{} - allargs := util.ToChaincodeArgs(funargs...) - newCI := &pb.ChaincodeInput{Args: allargs} - stub.init(&Handler{}, "TEST-txid", newCI, nil) // TODO: add msg.ProposalContext - return &stub + // TODO: txid must uniquely identity the transaction. + // Remove this comment once replay attack protection will be in place + stub.binding, err = utils.ComputeProposalBinding(proposal) + if err != nil { + return fmt.Errorf("Failed computing binding from proposal. [%s]", err) + } + } + + return nil } // GetTxID returns the transaction ID @@ -505,33 +522,34 @@ func (stub *ChaincodeStub) GetFunctionAndParameters() (function string, params [ return } -// GetCallerCertificate returns caller certificate -func (stub *ChaincodeStub) GetCallerCertificate() ([]byte, error) { - if stub.proposalContext != nil { - return stub.proposalContext.Transient, nil - } - - return nil, errors.New("Creator field not set.") +// GetCreator returns SignatureHeader.Creator of the proposal +// this Stub refers to. +func (stub *ChaincodeStub) GetCreator() ([]byte, error) { + return stub.creator, nil } -// GetCallerMetadata returns caller metadata -func (stub *ChaincodeStub) GetCallerMetadata() ([]byte, error) { - if stub.proposalContext != nil { - return stub.proposalContext.Transient, nil - } - - return nil, errors.New("Transient field not set.") +// GetTransient returns the ChaincodeProposalPayload.transient field. +// It is a map that contains data (e.g. cryptographic material) +// that might be used to implement some form of application-level confidentiality. The contents +// of this field, as prescribed by ChaincodeProposalPayload, are supposed to always +// be omitted from the transaction and excluded from the ledger. +func (stub *ChaincodeStub) GetTransient() (map[string][]byte, error) { + return stub.transient, nil } // GetBinding returns the transaction binding func (stub *ChaincodeStub) GetBinding() ([]byte, error) { - return nil, nil + return stub.binding, nil } -// GetPayload returns transaction payload, which is a `ChaincodeSpec` defined -// in fabric/protos/chaincode.proto -func (stub *ChaincodeStub) GetPayload() ([]byte, error) { - return nil, nil +// GetArgsSlice returns the arguments to the stub call as a byte array +func (stub *ChaincodeStub) GetArgsSlice() ([]byte, error) { + args := stub.GetArgs() + res := []byte{} + for _, barg := range args { + res = append(res, barg...) + } + return res, nil } // GetTxTimestamp returns transaction created timestamp, which is currently diff --git a/core/chaincode/shim/handler.go b/core/chaincode/shim/handler.go index 330cf51f3f1..c891639fe39 100644 --- a/core/chaincode/shim/handler.go +++ b/core/chaincode/shim/handler.go @@ -227,7 +227,12 @@ func (handler *Handler) handleInit(msg *pb.ChaincodeMessage) { // Call chaincode's Run // Create the ChaincodeStub which the chaincode can use to callback stub := new(ChaincodeStub) - stub.init(handler, msg.Txid, input, msg.ProposalContext) + err := stub.init(handler, msg.Txid, input, msg.Proposal) + if err != nil { + chaincodeLogger.Errorf("[%s]Init get error response [%s]. Sending %s", shorttxid(msg.Txid), err.Error(), pb.ChaincodeMessage_ERROR) + nextStateMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: []byte(err.Error()), Txid: msg.Txid, ChaincodeEvent: stub.chaincodeEvent} + return + } res := handler.cc.Init(stub) chaincodeLogger.Debugf("[%s]Init get response status: %d", shorttxid(msg.Txid), res.Status) @@ -296,7 +301,14 @@ func (handler *Handler) handleTransaction(msg *pb.ChaincodeMessage) { // Call chaincode's Run // Create the ChaincodeStub which the chaincode can use to callback stub := new(ChaincodeStub) - stub.init(handler, msg.Txid, input, msg.ProposalContext) + err := stub.init(handler, msg.Txid, input, msg.Proposal) + if err != nil { + payload := []byte(err.Error()) + // Send ERROR message to chaincode support and change state + chaincodeLogger.Errorf("[%s]Transaction execution failed. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_ERROR) + nextStateMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: payload, Txid: msg.Txid, ChaincodeEvent: stub.chaincodeEvent} + return + } res := handler.cc.Invoke(stub) // Endorser will handle error contained in Response. diff --git a/core/chaincode/shim/interfaces.go b/core/chaincode/shim/interfaces.go index e7ef5bd9748..92b743ce18c 100644 --- a/core/chaincode/shim/interfaces.go +++ b/core/chaincode/shim/interfaces.go @@ -101,18 +101,22 @@ type ChaincodeStubInterface interface { // key values across time. GetHistoryForKey is intended to be used for read-only queries. GetHistoryForKey(key string) (StateQueryIteratorInterface, error) - // GetCallerCertificate returns caller certificate - GetCallerCertificate() ([]byte, error) + // GetCreator returns SignatureHeader.Creator of the proposal + // this Stub refers to. + GetCreator() ([]byte, error) - // GetCallerMetadata returns caller metadata - GetCallerMetadata() ([]byte, error) + // GetTransient returns the ChaincodeProposalPayload.transient field. + // It is a map that contains data (e.g. cryptographic material) + // that might be used to implement some form of application-level confidentiality. The contents + // of this field, as prescribed by ChaincodeProposalPayload, are supposed to always + // be omitted from the transaction and excluded from the ledger. + GetTransient() (map[string][]byte, error) // GetBinding returns the transaction binding GetBinding() ([]byte, error) - // GetPayload returns transaction payload, which is a `ChaincodeSpec` defined - // in fabric/protos/chaincode.proto - GetPayload() ([]byte, error) + // GetArgsSlice returns the arguments to the stub call as a byte array + GetArgsSlice() ([]byte, error) // GetTxTimestamp returns transaction created timestamp, which is currently // taken from the peer receiving the transaction. Note that this timestamp diff --git a/core/chaincode/shim/java/build.gradle b/core/chaincode/shim/java/build.gradle index 72d71f0d37d..6d2c0146ba6 100644 --- a/core/chaincode/shim/java/build.gradle +++ b/core/chaincode/shim/java/build.gradle @@ -93,6 +93,9 @@ task copyProtos(type:Copy){ from ("${rootDir}/protos/peer"){ include '**/chaincodeevent.proto' include '**/chaincode.proto' + include '**/chaincodeshim.proto' + include '**/proposal.proto' + include '**/proposal_response.proto' } into "${projectDir}/src/main/proto/peer" diff --git a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeBase.java b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeBase.java index a0d70110c28..ed2bf8ca484 100644 --- a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeBase.java +++ b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeBase.java @@ -29,8 +29,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hyperledger.protos.Chaincode.ChaincodeID; -import org.hyperledger.protos.Chaincode.ChaincodeMessage; -import org.hyperledger.protos.Chaincode.ChaincodeMessage.Type; +import org.hyperledger.protos.Chaincodeshim.ChaincodeMessage; +import org.hyperledger.protos.Chaincodeshim.ChaincodeMessage.Type; import org.hyperledger.protos.ChaincodeSupportGrpc; import org.hyperledger.protos.ChaincodeSupportGrpc.ChaincodeSupportStub; diff --git a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeStub.java b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeStub.java index 0389c6886ff..49f6a2f0816 100644 --- a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeStub.java +++ b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeStub.java @@ -20,7 +20,7 @@ import com.google.protobuf.InvalidProtocolBufferException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hyperledger.protos.Chaincode; +import org.hyperledger.protos.Chaincodeshim; import java.util.ArrayList; import java.util.HashMap; @@ -102,7 +102,7 @@ public Map getStateByRange(String startKey, String endKey) { */ public Map getStateByRangeRaw(String startKey, String endKey) { Map map = new HashMap<>(); - for (Chaincode.QueryStateKeyValue mapping : handler.handleGetStateByRange( + for (Chaincodeshim.QueryStateKeyValue mapping : handler.handleGetStateByRange( startKey, endKey, uuid).getKeysAndValuesList()) { map.put(mapping.getKey(), mapping.getValue()); } diff --git a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java index 800fa60263f..61c84727c7e 100644 --- a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java +++ b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java @@ -28,14 +28,15 @@ import org.hyperledger.java.fsm.exceptions.NoTransitionException; import org.hyperledger.java.helper.Channel; import org.hyperledger.protos.Chaincode.*; -import org.hyperledger.protos.Chaincode.ChaincodeMessage.Builder; +import org.hyperledger.protos.Chaincodeshim.*; +import org.hyperledger.protos.Chaincodeshim.ChaincodeMessage.Builder; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.hyperledger.java.fsm.CallbackType.*; -import static org.hyperledger.protos.Chaincode.ChaincodeMessage.Type.*; +import static org.hyperledger.protos.Chaincodeshim.ChaincodeMessage.Type.*; public class Handler { diff --git a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/NextStateInfo.java b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/NextStateInfo.java index 3745a79e57c..16fde9b80dc 100644 --- a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/NextStateInfo.java +++ b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/NextStateInfo.java @@ -16,7 +16,7 @@ package org.hyperledger.java.shim; -import org.hyperledger.protos.Chaincode.ChaincodeMessage; +import org.hyperledger.protos.Chaincodeshim.ChaincodeMessage; public class NextStateInfo { diff --git a/core/chaincode/shim/mockstub.go b/core/chaincode/shim/mockstub.go index 4ac397db832..fd37177fff2 100644 --- a/core/chaincode/shim/mockstub.go +++ b/core/chaincode/shim/mockstub.go @@ -251,12 +251,12 @@ func (stub *MockStub) InvokeChaincode(chaincodeName string, args [][]byte, chann } // Not implemented -func (stub *MockStub) GetCallerCertificate() ([]byte, error) { +func (stub *MockStub) GetCreator() ([]byte, error) { return nil, nil } // Not implemented -func (stub *MockStub) GetCallerMetadata() ([]byte, error) { +func (stub *MockStub) GetTransient() (map[string][]byte, error) { return nil, nil } @@ -266,7 +266,7 @@ func (stub *MockStub) GetBinding() ([]byte, error) { } // Not implemented -func (stub *MockStub) GetPayload() ([]byte, error) { +func (stub *MockStub) GetArgsSlice() ([]byte, error) { return nil, nil } diff --git a/examples/chaincode/go/asset_management/asset_management.go b/examples/chaincode/go/asset_management/asset_management.go index 925ea7528df..ccc6b54afd5 100644 --- a/examples/chaincode/go/asset_management/asset_management.go +++ b/examples/chaincode/go/asset_management/asset_management.go @@ -173,7 +173,7 @@ func (t *AssetManagementChaincode) isCaller(stub shim.ChaincodeStubInterface, ce if err != nil { return false, errors.New("Failed getting metadata") } - payload, err := stub.GetPayload() + payload, err := stub.GetArgsSlice() if err != nil { return false, errors.New("Failed getting payload") } diff --git a/examples/chaincode/go/asset_management_interactive/asset_management.go b/examples/chaincode/go/asset_management_interactive/asset_management.go index e69fef99a01..c1c2ba5d86d 100644 --- a/examples/chaincode/go/asset_management_interactive/asset_management.go +++ b/examples/chaincode/go/asset_management_interactive/asset_management.go @@ -210,7 +210,7 @@ func (t *AssetManagementChaincode) isCaller(stub shim.ChaincodeStubInterface, ce if err != nil { return false, errors.New("Failed getting metadata") } - payload, err := stub.GetPayload() + payload, err := stub.GetArgsSlice() if err != nil { return false, errors.New("Failed getting payload") } diff --git a/examples/chaincode/go/rbac_tcerts_no_attrs/rbac.go b/examples/chaincode/go/rbac_tcerts_no_attrs/rbac.go index db31bf063f9..7ede6eb6903 100644 --- a/examples/chaincode/go/rbac_tcerts_no_attrs/rbac.go +++ b/examples/chaincode/go/rbac_tcerts_no_attrs/rbac.go @@ -242,7 +242,7 @@ func (t *RBACChaincode) hasInvokerRole(stub shim.ChaincodeStubInterface, role st } // Verify signature - payload, err := stub.GetPayload() + payload, err := stub.GetArgsSlice() if err != nil { return false, nil, errors.New("Failed getting payload") } diff --git a/protos/peer/admin.pb.go b/protos/peer/admin.pb.go index a719623c1e2..550e549ecbd 100644 --- a/protos/peer/admin.pb.go +++ b/protos/peer/admin.pb.go @@ -9,6 +9,7 @@ It is generated from these files: peer/admin.proto peer/chaincode.proto peer/chaincodeevent.proto + peer/chaincodeshim.proto peer/configuration.proto peer/events.proto peer/peer.proto @@ -25,7 +26,7 @@ It has these top-level messages: ChaincodeSpec ChaincodeDeploymentSpec ChaincodeInvocationSpec - ChaincodeProposalContext + ChaincodeEvent ChaincodeMessage PutStateInfo GetStateByRange @@ -35,7 +36,6 @@ It has these top-level messages: QueryStateClose QueryStateKeyValue QueryStateResponse - ChaincodeEvent AnchorPeers AnchorPeer ChaincodeReg diff --git a/protos/peer/chaincode.pb.go b/protos/peer/chaincode.pb.go index 830cb42bac2..05b5959ef37 100644 --- a/protos/peer/chaincode.pb.go +++ b/protos/peer/chaincode.pb.go @@ -9,11 +9,6 @@ import fmt "fmt" import math "math" import google_protobuf1 "github.com/golang/protobuf/ptypes/timestamp" -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf @@ -94,78 +89,6 @@ func (ChaincodeDeploymentSpec_ExecutionEnvironment) EnumDescriptor() ([]byte, [] return fileDescriptor1, []int{3, 0} } -type ChaincodeMessage_Type int32 - -const ( - ChaincodeMessage_UNDEFINED ChaincodeMessage_Type = 0 - ChaincodeMessage_REGISTER ChaincodeMessage_Type = 1 - ChaincodeMessage_REGISTERED ChaincodeMessage_Type = 2 - ChaincodeMessage_INIT ChaincodeMessage_Type = 3 - ChaincodeMessage_READY ChaincodeMessage_Type = 4 - ChaincodeMessage_TRANSACTION ChaincodeMessage_Type = 5 - ChaincodeMessage_COMPLETED ChaincodeMessage_Type = 6 - ChaincodeMessage_ERROR ChaincodeMessage_Type = 7 - ChaincodeMessage_GET_STATE ChaincodeMessage_Type = 8 - ChaincodeMessage_PUT_STATE ChaincodeMessage_Type = 9 - ChaincodeMessage_DEL_STATE ChaincodeMessage_Type = 10 - ChaincodeMessage_INVOKE_CHAINCODE ChaincodeMessage_Type = 11 - ChaincodeMessage_RESPONSE ChaincodeMessage_Type = 13 - ChaincodeMessage_GET_STATE_BY_RANGE ChaincodeMessage_Type = 14 - ChaincodeMessage_GET_QUERY_RESULT ChaincodeMessage_Type = 15 - ChaincodeMessage_QUERY_STATE_NEXT ChaincodeMessage_Type = 16 - ChaincodeMessage_QUERY_STATE_CLOSE ChaincodeMessage_Type = 17 - ChaincodeMessage_KEEPALIVE ChaincodeMessage_Type = 18 - ChaincodeMessage_GET_HISTORY_FOR_KEY ChaincodeMessage_Type = 19 -) - -var ChaincodeMessage_Type_name = map[int32]string{ - 0: "UNDEFINED", - 1: "REGISTER", - 2: "REGISTERED", - 3: "INIT", - 4: "READY", - 5: "TRANSACTION", - 6: "COMPLETED", - 7: "ERROR", - 8: "GET_STATE", - 9: "PUT_STATE", - 10: "DEL_STATE", - 11: "INVOKE_CHAINCODE", - 13: "RESPONSE", - 14: "GET_STATE_BY_RANGE", - 15: "GET_QUERY_RESULT", - 16: "QUERY_STATE_NEXT", - 17: "QUERY_STATE_CLOSE", - 18: "KEEPALIVE", - 19: "GET_HISTORY_FOR_KEY", -} -var ChaincodeMessage_Type_value = map[string]int32{ - "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, -} - -func (x ChaincodeMessage_Type) String() string { - return proto.EnumName(ChaincodeMessage_Type_name, int32(x)) -} -func (ChaincodeMessage_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{6, 0} } - // 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) @@ -282,348 +205,56 @@ func (m *ChaincodeInvocationSpec) GetChaincodeSpec() *ChaincodeSpec { return nil } -// ChaincodeProposalContext contains proposal data that we send to the chaincode -// container shim and allow the chaincode to access through the shim interface. -type ChaincodeProposalContext struct { - // Creator corresponds to SignatureHeader.Creator - Creator []byte `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - // Transient corresponds to ChaincodeProposalPayload.Transient - // TODO: The transient field is supposed to carry application-specific - // data. They might be realted to access-control, encryption and so on. - // To simply access to this data, replacing bytes with a map - // is the next step to be carried. - Transient []byte `protobuf:"bytes,2,opt,name=transient,proto3" json:"transient,omitempty"` -} - -func (m *ChaincodeProposalContext) Reset() { *m = ChaincodeProposalContext{} } -func (m *ChaincodeProposalContext) String() string { return proto.CompactTextString(m) } -func (*ChaincodeProposalContext) ProtoMessage() {} -func (*ChaincodeProposalContext) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} } - -type ChaincodeMessage struct { - Type ChaincodeMessage_Type `protobuf:"varint,1,opt,name=type,enum=protos.ChaincodeMessage_Type" json:"type,omitempty"` - Timestamp *google_protobuf1.Timestamp `protobuf:"bytes,2,opt,name=timestamp" json:"timestamp,omitempty"` - Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` - Txid string `protobuf:"bytes,4,opt,name=txid" json:"txid,omitempty"` - ProposalContext *ChaincodeProposalContext `protobuf:"bytes,5,opt,name=proposal_context,json=proposalContext" json:"proposal_context,omitempty"` - // event emmited by chaincode. Used only with Init or Invoke. - // This event is then stored (currently) - // with Block.NonHashData.TransactionResult - ChaincodeEvent *ChaincodeEvent `protobuf:"bytes,6,opt,name=chaincode_event,json=chaincodeEvent" json:"chaincode_event,omitempty"` -} - -func (m *ChaincodeMessage) Reset() { *m = ChaincodeMessage{} } -func (m *ChaincodeMessage) String() string { return proto.CompactTextString(m) } -func (*ChaincodeMessage) ProtoMessage() {} -func (*ChaincodeMessage) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} } - -func (m *ChaincodeMessage) GetTimestamp() *google_protobuf1.Timestamp { - if m != nil { - return m.Timestamp - } - return nil -} - -func (m *ChaincodeMessage) GetProposalContext() *ChaincodeProposalContext { - if m != nil { - return m.ProposalContext - } - return nil -} - -func (m *ChaincodeMessage) GetChaincodeEvent() *ChaincodeEvent { - if m != nil { - return m.ChaincodeEvent - } - return nil -} - -type PutStateInfo struct { - Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (m *PutStateInfo) Reset() { *m = PutStateInfo{} } -func (m *PutStateInfo) String() string { return proto.CompactTextString(m) } -func (*PutStateInfo) ProtoMessage() {} -func (*PutStateInfo) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} } - -type GetStateByRange struct { - StartKey string `protobuf:"bytes,1,opt,name=startKey" json:"startKey,omitempty"` - EndKey string `protobuf:"bytes,2,opt,name=endKey" json:"endKey,omitempty"` -} - -func (m *GetStateByRange) Reset() { *m = GetStateByRange{} } -func (m *GetStateByRange) String() string { return proto.CompactTextString(m) } -func (*GetStateByRange) ProtoMessage() {} -func (*GetStateByRange) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{8} } - -type GetQueryResult struct { - Query string `protobuf:"bytes,1,opt,name=query" json:"query,omitempty"` -} - -func (m *GetQueryResult) Reset() { *m = GetQueryResult{} } -func (m *GetQueryResult) String() string { return proto.CompactTextString(m) } -func (*GetQueryResult) ProtoMessage() {} -func (*GetQueryResult) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{9} } - -type GetHistoryForKey struct { - Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` -} - -func (m *GetHistoryForKey) Reset() { *m = GetHistoryForKey{} } -func (m *GetHistoryForKey) String() string { return proto.CompactTextString(m) } -func (*GetHistoryForKey) ProtoMessage() {} -func (*GetHistoryForKey) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{10} } - -type QueryStateNext struct { - Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` -} - -func (m *QueryStateNext) Reset() { *m = QueryStateNext{} } -func (m *QueryStateNext) String() string { return proto.CompactTextString(m) } -func (*QueryStateNext) ProtoMessage() {} -func (*QueryStateNext) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{11} } - -type QueryStateClose struct { - Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` -} - -func (m *QueryStateClose) Reset() { *m = QueryStateClose{} } -func (m *QueryStateClose) String() string { return proto.CompactTextString(m) } -func (*QueryStateClose) ProtoMessage() {} -func (*QueryStateClose) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{12} } - -type QueryStateKeyValue struct { - Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (m *QueryStateKeyValue) Reset() { *m = QueryStateKeyValue{} } -func (m *QueryStateKeyValue) String() string { return proto.CompactTextString(m) } -func (*QueryStateKeyValue) ProtoMessage() {} -func (*QueryStateKeyValue) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{13} } - -type QueryStateResponse struct { - KeysAndValues []*QueryStateKeyValue `protobuf:"bytes,1,rep,name=keys_and_values,json=keysAndValues" json:"keys_and_values,omitempty"` - HasMore bool `protobuf:"varint,2,opt,name=has_more,json=hasMore" json:"has_more,omitempty"` - Id string `protobuf:"bytes,3,opt,name=id" json:"id,omitempty"` -} - -func (m *QueryStateResponse) Reset() { *m = QueryStateResponse{} } -func (m *QueryStateResponse) String() string { return proto.CompactTextString(m) } -func (*QueryStateResponse) ProtoMessage() {} -func (*QueryStateResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{14} } - -func (m *QueryStateResponse) GetKeysAndValues() []*QueryStateKeyValue { - if m != nil { - return m.KeysAndValues - } - return nil -} - func init() { proto.RegisterType((*ChaincodeID)(nil), "protos.ChaincodeID") proto.RegisterType((*ChaincodeInput)(nil), "protos.ChaincodeInput") proto.RegisterType((*ChaincodeSpec)(nil), "protos.ChaincodeSpec") proto.RegisterType((*ChaincodeDeploymentSpec)(nil), "protos.ChaincodeDeploymentSpec") proto.RegisterType((*ChaincodeInvocationSpec)(nil), "protos.ChaincodeInvocationSpec") - proto.RegisterType((*ChaincodeProposalContext)(nil), "protos.ChaincodeProposalContext") - proto.RegisterType((*ChaincodeMessage)(nil), "protos.ChaincodeMessage") - proto.RegisterType((*PutStateInfo)(nil), "protos.PutStateInfo") - proto.RegisterType((*GetStateByRange)(nil), "protos.GetStateByRange") - proto.RegisterType((*GetQueryResult)(nil), "protos.GetQueryResult") - proto.RegisterType((*GetHistoryForKey)(nil), "protos.GetHistoryForKey") - proto.RegisterType((*QueryStateNext)(nil), "protos.QueryStateNext") - proto.RegisterType((*QueryStateClose)(nil), "protos.QueryStateClose") - proto.RegisterType((*QueryStateKeyValue)(nil), "protos.QueryStateKeyValue") - proto.RegisterType((*QueryStateResponse)(nil), "protos.QueryStateResponse") proto.RegisterEnum("protos.ConfidentialityLevel", ConfidentialityLevel_name, ConfidentialityLevel_value) proto.RegisterEnum("protos.ChaincodeSpec_Type", ChaincodeSpec_Type_name, ChaincodeSpec_Type_value) proto.RegisterEnum("protos.ChaincodeDeploymentSpec_ExecutionEnvironment", ChaincodeDeploymentSpec_ExecutionEnvironment_name, ChaincodeDeploymentSpec_ExecutionEnvironment_value) - proto.RegisterEnum("protos.ChaincodeMessage_Type", ChaincodeMessage_Type_name, ChaincodeMessage_Type_value) -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion3 - -// Client API for ChaincodeSupport service - -type ChaincodeSupportClient interface { - Register(ctx context.Context, opts ...grpc.CallOption) (ChaincodeSupport_RegisterClient, error) -} - -type chaincodeSupportClient struct { - cc *grpc.ClientConn -} - -func NewChaincodeSupportClient(cc *grpc.ClientConn) ChaincodeSupportClient { - return &chaincodeSupportClient{cc} -} - -func (c *chaincodeSupportClient) Register(ctx context.Context, opts ...grpc.CallOption) (ChaincodeSupport_RegisterClient, error) { - stream, err := grpc.NewClientStream(ctx, &_ChaincodeSupport_serviceDesc.Streams[0], c.cc, "/protos.ChaincodeSupport/Register", opts...) - if err != nil { - return nil, err - } - x := &chaincodeSupportRegisterClient{stream} - return x, nil -} - -type ChaincodeSupport_RegisterClient interface { - Send(*ChaincodeMessage) error - Recv() (*ChaincodeMessage, error) - grpc.ClientStream -} - -type chaincodeSupportRegisterClient struct { - grpc.ClientStream -} - -func (x *chaincodeSupportRegisterClient) Send(m *ChaincodeMessage) error { - return x.ClientStream.SendMsg(m) -} - -func (x *chaincodeSupportRegisterClient) Recv() (*ChaincodeMessage, error) { - m := new(ChaincodeMessage) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// Server API for ChaincodeSupport service - -type ChaincodeSupportServer interface { - Register(ChaincodeSupport_RegisterServer) error -} - -func RegisterChaincodeSupportServer(s *grpc.Server, srv ChaincodeSupportServer) { - s.RegisterService(&_ChaincodeSupport_serviceDesc, srv) -} - -func _ChaincodeSupport_Register_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ChaincodeSupportServer).Register(&chaincodeSupportRegisterServer{stream}) -} - -type ChaincodeSupport_RegisterServer interface { - Send(*ChaincodeMessage) error - Recv() (*ChaincodeMessage, error) - grpc.ServerStream -} - -type chaincodeSupportRegisterServer struct { - grpc.ServerStream -} - -func (x *chaincodeSupportRegisterServer) Send(m *ChaincodeMessage) error { - return x.ServerStream.SendMsg(m) -} - -func (x *chaincodeSupportRegisterServer) Recv() (*ChaincodeMessage, error) { - m := new(ChaincodeMessage) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -var _ChaincodeSupport_serviceDesc = grpc.ServiceDesc{ - ServiceName: "protos.ChaincodeSupport", - HandlerType: (*ChaincodeSupportServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "Register", - Handler: _ChaincodeSupport_Register_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: fileDescriptor1, } func init() { proto.RegisterFile("peer/chaincode.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 1184 bytes of a gzipped FileDescriptorPro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c, 0x7b, 0x92, 0x86, 0x93, 0x34, 0x4d, 0x32, 0x41, 0x4d, 0xa8, 0x72, 0x1c, - 0x45, 0xb9, 0xc0, 0x8c, 0xb6, 0xbf, 0xf6, 0x20, 0xed, 0x7f, 0x75, 0x47, 0x7b, 0x74, 0x58, 0xfa, - 0xae, 0x74, 0x62, 0xc0, 0x5e, 0x92, 0x8d, 0x3a, 0x37, 0xb3, 0x14, 0xb3, 0x31, 0x86, 0x23, 0xcc, - 0xe6, 0x0e, 0xbf, 0xfe, 0x6f, 0x14, 0x89, 0x9b, 0xc9, 0x55, 0x27, 0x48, 0x6e, 0x8f, 0xee, 0x6d, - 0x1f, 0x5d, 0xfb, 0x57, 0x59, 0x14, 0x14, 0xdf, 0x34, 0xf9, 0x91, 0xfc, 0xf8, 0xb9, 0x2a, 0x3e, - 0x85, 0x7e, 0xf8, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x51, 0xfa, 0x66, 0xd7, 0x29, 0x09, 0x00, 0x00, + // 585 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x53, 0x5d, 0x6f, 0xd3, 0x30, + 0x14, 0x5d, 0xd6, 0xee, 0xeb, 0xf6, 0x83, 0x60, 0xc6, 0xa8, 0xf6, 0xc2, 0x88, 0x78, 0x18, 0x13, + 0x4a, 0xa5, 0x32, 0xf1, 0x84, 0x90, 0xb2, 0x24, 0x9b, 0x02, 0xa5, 0x9d, 0xb2, 0x0e, 0x09, 0x5e, + 0x2a, 0x37, 0xb9, 0x4d, 0x2d, 0x52, 0x3b, 0x4a, 0xdc, 0x68, 0x7d, 0xe6, 0x7f, 0xf1, 0xd7, 0x40, + 0x76, 0xd6, 0x6e, 0xd3, 0xf6, 0xc8, 0x93, 0xed, 0xe3, 0x73, 0xec, 0x73, 0x8f, 0xee, 0x85, 0xfd, + 0x0c, 0x31, 0xef, 0x46, 0x33, 0xca, 0x78, 0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 0xee, 0x05, 0x18, 0xf0, 0x52, 0x44, 0x54, 0x49, 0xff, 0x43, 0x80, + 0x27, 0xf0, 0x9c, 0xc5, 0xe3, 0x04, 0x39, 0xe6, 0xfa, 0xc9, 0x31, 0x4d, 0x93, 0xdb, 0xee, 0x7f, + 0xc6, 0xe2, 0x8b, 0x35, 0xee, 0xa4, 0xc9, 0xc9, 0x29, 0xec, 0xbb, 0x82, 0x4f, 0x59, 0x8c, 0x5c, + 0x32, 0x9a, 0x32, 0xb9, 0xec, 0x63, 0x89, 0xa9, 0x72, 0x7a, 0x79, 0x7d, 0xd6, 0x0f, 0x5c, 0x73, + 0x83, 0x98, 0xd0, 0x74, 0x87, 0x83, 0xf3, 0xc0, 0xf3, 0x07, 0xa3, 0xc0, 0xe9, 0x9b, 0xc6, 0x99, + 0x0b, 0x07, 0x22, 0x4f, 0xec, 0xd9, 0x32, 0xc3, 0x3c, 0xc5, 0x38, 0xc1, 0xfc, 0xd6, 0xd8, 0xcf, + 0x77, 0x09, 0x93, 0xb3, 0xc5, 0xc4, 0x8e, 0xc4, 0xbc, 0x7b, 0xef, 0xba, 0x3b, 0xa5, 0x93, 0x9c, + 0x45, 0xd5, 0x1c, 0x17, 0x5d, 0x35, 0xf3, 0x93, 0x6a, 0xc6, 0x3f, 0xfc, 0x0b, 0x00, 0x00, 0xff, + 0xff, 0xd7, 0xce, 0x97, 0x9a, 0x02, 0x04, 0x00, 0x00, } diff --git a/protos/peer/chaincode.proto b/protos/peer/chaincode.proto index e84759e8a1e..38c55878e60 100644 --- a/protos/peer/chaincode.proto +++ b/protos/peer/chaincode.proto @@ -19,7 +19,6 @@ syntax = "proto3"; package protos; option java_package = "org.hyperledger.protos"; option go_package = "github.com/hyperledger/fabric/protos/peer"; -import "peer/chaincodeevent.proto"; import "google/protobuf/timestamp.proto"; @@ -103,102 +102,4 @@ message ChaincodeInvocationSpec { // 2, a decoding used to decode user (string) input to bytes // Currently, SHA256 with BASE64 is supported (e.g. idGenerationAlg='sha256base64') string id_generation_alg = 2; -} - -// ChaincodeProposalContext contains proposal data that we send to the chaincode -// container shim and allow the chaincode to access through the shim interface. -message ChaincodeProposalContext { - - // Creator corresponds to SignatureHeader.Creator - bytes creator = 1; - - // Transient corresponds to ChaincodeProposalPayload.Transient - // TODO: The transient field is supposed to carry application-specific - // data. They might be realted to access-control, encryption and so on. - // To simply access to this data, replacing bytes with a map - // is the next step to be carried. - bytes transient = 2; -} - -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; - } - - Type type = 1; - google.protobuf.Timestamp timestamp = 2; - bytes payload = 3; - string txid = 4; - - ChaincodeProposalContext proposal_context = 5; - - //event emmited by chaincode. Used only with Init or Invoke. - // This event is then stored (currently) - //with Block.NonHashData.TransactionResult - ChaincodeEvent chaincode_event = 6; -} - -message PutStateInfo { - string key = 1; - bytes value = 2; -} - -message GetStateByRange { - string startKey = 1; - string endKey = 2; -} - -message GetQueryResult { - string query = 1; -} - -message GetHistoryForKey { - string key = 1; -} - -message QueryStateNext { - string id = 1; -} - -message QueryStateClose { - string id = 1; -} - -message QueryStateKeyValue { - string key = 1; - bytes value = 2; -} - -message QueryStateResponse { - repeated QueryStateKeyValue keys_and_values = 1; - bool has_more = 2; - string id = 3; -} - -// 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) {} - - -} +} \ No newline at end of file diff --git a/protos/peer/chaincodeshim.pb.go b/protos/peer/chaincodeshim.pb.go new file mode 100644 index 00000000000..9aae6dc8822 --- /dev/null +++ b/protos/peer/chaincodeshim.pb.go @@ -0,0 +1,386 @@ +// Code generated by protoc-gen-go. +// source: peer/chaincodeshim.proto +// DO NOT EDIT! + +package peer + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf1 "github.com/golang/protobuf/ptypes/timestamp" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type ChaincodeMessage_Type int32 + +const ( + ChaincodeMessage_UNDEFINED ChaincodeMessage_Type = 0 + ChaincodeMessage_REGISTER ChaincodeMessage_Type = 1 + ChaincodeMessage_REGISTERED ChaincodeMessage_Type = 2 + ChaincodeMessage_INIT ChaincodeMessage_Type = 3 + ChaincodeMessage_READY ChaincodeMessage_Type = 4 + ChaincodeMessage_TRANSACTION ChaincodeMessage_Type = 5 + ChaincodeMessage_COMPLETED ChaincodeMessage_Type = 6 + ChaincodeMessage_ERROR ChaincodeMessage_Type = 7 + ChaincodeMessage_GET_STATE ChaincodeMessage_Type = 8 + ChaincodeMessage_PUT_STATE ChaincodeMessage_Type = 9 + ChaincodeMessage_DEL_STATE ChaincodeMessage_Type = 10 + ChaincodeMessage_INVOKE_CHAINCODE ChaincodeMessage_Type = 11 + ChaincodeMessage_RESPONSE ChaincodeMessage_Type = 13 + ChaincodeMessage_GET_STATE_BY_RANGE ChaincodeMessage_Type = 14 + ChaincodeMessage_GET_QUERY_RESULT ChaincodeMessage_Type = 15 + ChaincodeMessage_QUERY_STATE_NEXT ChaincodeMessage_Type = 16 + ChaincodeMessage_QUERY_STATE_CLOSE ChaincodeMessage_Type = 17 + ChaincodeMessage_KEEPALIVE ChaincodeMessage_Type = 18 + ChaincodeMessage_GET_HISTORY_FOR_KEY ChaincodeMessage_Type = 19 +) + +var ChaincodeMessage_Type_name = map[int32]string{ + 0: "UNDEFINED", + 1: "REGISTER", + 2: "REGISTERED", + 3: "INIT", + 4: "READY", + 5: "TRANSACTION", + 6: "COMPLETED", + 7: "ERROR", + 8: "GET_STATE", + 9: "PUT_STATE", + 10: "DEL_STATE", + 11: "INVOKE_CHAINCODE", + 13: "RESPONSE", + 14: "GET_STATE_BY_RANGE", + 15: "GET_QUERY_RESULT", + 16: "QUERY_STATE_NEXT", + 17: "QUERY_STATE_CLOSE", + 18: "KEEPALIVE", + 19: "GET_HISTORY_FOR_KEY", +} +var ChaincodeMessage_Type_value = map[string]int32{ + "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, +} + +func (x ChaincodeMessage_Type) String() string { + return proto.EnumName(ChaincodeMessage_Type_name, int32(x)) +} +func (ChaincodeMessage_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{0, 0} } + +type ChaincodeMessage struct { + Type ChaincodeMessage_Type `protobuf:"varint,1,opt,name=type,enum=protos.ChaincodeMessage_Type" json:"type,omitempty"` + Timestamp *google_protobuf1.Timestamp `protobuf:"bytes,2,opt,name=timestamp" json:"timestamp,omitempty"` + Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` + Txid string `protobuf:"bytes,4,opt,name=txid" json:"txid,omitempty"` + Proposal *Proposal `protobuf:"bytes,5,opt,name=proposal" json:"proposal,omitempty"` + // event emmited by chaincode. Used only with Init or Invoke. + // This event is then stored (currently) + // with Block.NonHashData.TransactionResult + ChaincodeEvent *ChaincodeEvent `protobuf:"bytes,6,opt,name=chaincode_event,json=chaincodeEvent" json:"chaincode_event,omitempty"` +} + +func (m *ChaincodeMessage) Reset() { *m = ChaincodeMessage{} } +func (m *ChaincodeMessage) String() string { return proto.CompactTextString(m) } +func (*ChaincodeMessage) ProtoMessage() {} +func (*ChaincodeMessage) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } + +func (m *ChaincodeMessage) GetTimestamp() *google_protobuf1.Timestamp { + if m != nil { + return m.Timestamp + } + return nil +} + +func (m *ChaincodeMessage) GetProposal() *Proposal { + if m != nil { + return m.Proposal + } + return nil +} + +func (m *ChaincodeMessage) GetChaincodeEvent() *ChaincodeEvent { + if m != nil { + return m.ChaincodeEvent + } + return nil +} + +type PutStateInfo struct { + Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *PutStateInfo) Reset() { *m = PutStateInfo{} } +func (m *PutStateInfo) String() string { return proto.CompactTextString(m) } +func (*PutStateInfo) ProtoMessage() {} +func (*PutStateInfo) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} } + +type GetStateByRange struct { + StartKey string `protobuf:"bytes,1,opt,name=startKey" json:"startKey,omitempty"` + EndKey string `protobuf:"bytes,2,opt,name=endKey" json:"endKey,omitempty"` +} + +func (m *GetStateByRange) Reset() { *m = GetStateByRange{} } +func (m *GetStateByRange) String() string { return proto.CompactTextString(m) } +func (*GetStateByRange) ProtoMessage() {} +func (*GetStateByRange) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{2} } + +type GetQueryResult struct { + Query string `protobuf:"bytes,1,opt,name=query" json:"query,omitempty"` +} + +func (m *GetQueryResult) Reset() { *m = GetQueryResult{} } +func (m *GetQueryResult) String() string { return proto.CompactTextString(m) } +func (*GetQueryResult) ProtoMessage() {} +func (*GetQueryResult) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{3} } + +type GetHistoryForKey struct { + Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` +} + +func (m *GetHistoryForKey) Reset() { *m = GetHistoryForKey{} } +func (m *GetHistoryForKey) String() string { return proto.CompactTextString(m) } +func (*GetHistoryForKey) ProtoMessage() {} +func (*GetHistoryForKey) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{4} } + +type QueryStateNext struct { + Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` +} + +func (m *QueryStateNext) Reset() { *m = QueryStateNext{} } +func (m *QueryStateNext) String() string { return proto.CompactTextString(m) } +func (*QueryStateNext) ProtoMessage() {} +func (*QueryStateNext) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{5} } + +type QueryStateClose struct { + Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` +} + +func (m *QueryStateClose) Reset() { *m = QueryStateClose{} } +func (m *QueryStateClose) String() string { return proto.CompactTextString(m) } +func (*QueryStateClose) ProtoMessage() {} +func (*QueryStateClose) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{6} } + +type QueryStateKeyValue struct { + Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *QueryStateKeyValue) Reset() { *m = QueryStateKeyValue{} } +func (m *QueryStateKeyValue) String() string { return proto.CompactTextString(m) } +func (*QueryStateKeyValue) ProtoMessage() {} +func (*QueryStateKeyValue) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{7} } + +type QueryStateResponse struct { + KeysAndValues []*QueryStateKeyValue `protobuf:"bytes,1,rep,name=keys_and_values,json=keysAndValues" json:"keys_and_values,omitempty"` + HasMore bool `protobuf:"varint,2,opt,name=has_more,json=hasMore" json:"has_more,omitempty"` + Id string `protobuf:"bytes,3,opt,name=id" json:"id,omitempty"` +} + +func (m *QueryStateResponse) Reset() { *m = QueryStateResponse{} } +func (m *QueryStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStateResponse) ProtoMessage() {} +func (*QueryStateResponse) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{8} } + +func (m *QueryStateResponse) GetKeysAndValues() []*QueryStateKeyValue { + if m != nil { + return m.KeysAndValues + } + return nil +} + +func init() { + proto.RegisterType((*ChaincodeMessage)(nil), "protos.ChaincodeMessage") + proto.RegisterType((*PutStateInfo)(nil), "protos.PutStateInfo") + proto.RegisterType((*GetStateByRange)(nil), "protos.GetStateByRange") + proto.RegisterType((*GetQueryResult)(nil), "protos.GetQueryResult") + proto.RegisterType((*GetHistoryForKey)(nil), "protos.GetHistoryForKey") + proto.RegisterType((*QueryStateNext)(nil), "protos.QueryStateNext") + proto.RegisterType((*QueryStateClose)(nil), "protos.QueryStateClose") + proto.RegisterType((*QueryStateKeyValue)(nil), "protos.QueryStateKeyValue") + proto.RegisterType((*QueryStateResponse)(nil), "protos.QueryStateResponse") + proto.RegisterEnum("protos.ChaincodeMessage_Type", ChaincodeMessage_Type_name, ChaincodeMessage_Type_value) +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion3 + +// Client API for ChaincodeSupport service + +type ChaincodeSupportClient interface { + Register(ctx context.Context, opts ...grpc.CallOption) (ChaincodeSupport_RegisterClient, error) +} + +type chaincodeSupportClient struct { + cc *grpc.ClientConn +} + +func NewChaincodeSupportClient(cc *grpc.ClientConn) ChaincodeSupportClient { + return &chaincodeSupportClient{cc} +} + +func (c *chaincodeSupportClient) Register(ctx context.Context, opts ...grpc.CallOption) (ChaincodeSupport_RegisterClient, error) { + stream, err := grpc.NewClientStream(ctx, &_ChaincodeSupport_serviceDesc.Streams[0], c.cc, "/protos.ChaincodeSupport/Register", opts...) + if err != nil { + return nil, err + } + x := &chaincodeSupportRegisterClient{stream} + return x, nil +} + +type ChaincodeSupport_RegisterClient interface { + Send(*ChaincodeMessage) error + Recv() (*ChaincodeMessage, error) + grpc.ClientStream +} + +type chaincodeSupportRegisterClient struct { + grpc.ClientStream +} + +func (x *chaincodeSupportRegisterClient) Send(m *ChaincodeMessage) error { + return x.ClientStream.SendMsg(m) +} + +func (x *chaincodeSupportRegisterClient) Recv() (*ChaincodeMessage, error) { + m := new(ChaincodeMessage) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Server API for ChaincodeSupport service + +type ChaincodeSupportServer interface { + Register(ChaincodeSupport_RegisterServer) error +} + +func RegisterChaincodeSupportServer(s *grpc.Server, srv ChaincodeSupportServer) { + s.RegisterService(&_ChaincodeSupport_serviceDesc, srv) +} + +func _ChaincodeSupport_Register_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(ChaincodeSupportServer).Register(&chaincodeSupportRegisterServer{stream}) +} + +type ChaincodeSupport_RegisterServer interface { + Send(*ChaincodeMessage) error + Recv() (*ChaincodeMessage, error) + grpc.ServerStream +} + +type chaincodeSupportRegisterServer struct { + grpc.ServerStream +} + +func (x *chaincodeSupportRegisterServer) Send(m *ChaincodeMessage) error { + return x.ServerStream.SendMsg(m) +} + +func (x *chaincodeSupportRegisterServer) Recv() (*ChaincodeMessage, error) { + m := new(ChaincodeMessage) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _ChaincodeSupport_serviceDesc = grpc.ServiceDesc{ + ServiceName: "protos.ChaincodeSupport", + HandlerType: (*ChaincodeSupportServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Register", + Handler: _ChaincodeSupport_Register_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: fileDescriptor3, +} + +func init() { proto.RegisterFile("peer/chaincodeshim.proto", fileDescriptor3) } + +var fileDescriptor3 = []byte{ + // 777 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x94, 0xdd, 0x6e, 0xe2, 0x46, + 0x14, 0xc7,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0xc5, 0x7b, 0x7e, 0x49, 0xd0, 0x47, 0x18, 0x9b, + 0x70, 0x94, 0x84, 0xd9, 0x9a, 0x87, 0x91, 0x59, 0xed, 0x18, 0xdd, 0x13, 0x5a, 0x4a, 0x8c, 0xa1, + 0x26, 0x3f, 0xc5, 0x91, 0x59, 0xeb, 0x18, 0xdd, 0x06, 0xd5, 0x67, 0xfc, 0x03, 0xd4, 0xcb, 0x11, + 0xcd, 0x03, 0x5d, 0x06, 0x95, 0xed, 0xcd, 0x0a, 0x3b, 0xdd, 0x13, 0xf8, 0x77, 0x68, 0xed, 0xef, + 0x2a, 0xd0, 0x97, 0x65, 0x1e, 0xea, 0xa0, 0xf3, 0x67, 0x33, 0x11, 0xe5, 0xa5, 0xcd, 0xc5, 0x67, + 0xda, 0xfa, 0xbb, 0x02, 0x35, 0x35, 0x25, 0x3e, 0x85, 0xc6, 0xad, 0x33, 0x22, 0x57, 0xb6, 0x43, + 0x46, 0xe8, 0x15, 0x3e, 0x81, 0x3a, 0x25, 0x63, 0xdb, 0xf3, 0x09, 0x45, 0x06, 0x6e, 0x02, 0x94, + 0x8a, 0x8c, 0x50, 0x05, 0xd7, 0xa1, 0x66, 0x3b, 0xb6, 0x8f, 0xaa, 0xb8, 0x01, 0x07, 0x94, 0x0c, + 0x46, 0x73, 0x54, 0xc3, 0x2d, 0x38, 0xf6, 0xe9, 0xc0, 0xf1, 0x06, 0x43, 0xdf, 0x76, 0x1d, 0x74, + 0xa0, 0x52, 0x0e, 0xdd, 0x9b, 0xd9, 0x94, 0xf8, 0x64, 0x84, 0x0e, 0x15, 0x4a, 0x28, 0x75, 0x29, + 0x3a, 0x52, 0x9e, 0x31, 0xf1, 0x03, 0xcf, 0x1f, 0xf8, 0x04, 0xd5, 0x95, 0x9c, 0xdd, 0x96, 0xb2, + 0xa1, 0xe4, 0x88, 0x4c, 0x0b, 0x09, 0xf8, 0x0d, 0x20, 0xdb, 0xb9, 0x73, 0x27, 0x24, 0x18, 0x5e, + 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xdd, 0x7f, 0x08, 0xef, 0xd3, 0x78, + 0x91, 0xaf, 0x3a, 0xd1, 0x57, 0xdb, 0xf0, 0x3e, 0x5f, 0x9b, 0x3f, 0xff, 0x1b, 0x00, 0x00, 0xff, + 0xff, 0xfb, 0x9f, 0x18, 0xb2, 0x59, 0x05, 0x00, 0x00, +} diff --git a/protos/peer/chaincodeshim.proto b/protos/peer/chaincodeshim.proto new file mode 100644 index 00000000000..67111b0b6ff --- /dev/null +++ b/protos/peer/chaincodeshim.proto @@ -0,0 +1,108 @@ +/* +Copyright IBM Corp. 2016 All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +syntax = "proto3"; + +package protos; +option java_package = "org.hyperledger.protos"; +option go_package = "github.com/hyperledger/fabric/protos/peer"; +import "peer/chaincodeevent.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; + } + + Type type = 1; + google.protobuf.Timestamp timestamp = 2; + bytes payload = 3; + string txid = 4; + + Proposal proposal = 5; + + //event emmited by chaincode. Used only with Init or Invoke. + // This event is then stored (currently) + //with Block.NonHashData.TransactionResult + ChaincodeEvent chaincode_event = 6; +} + +message PutStateInfo { + string key = 1; + bytes value = 2; +} + +message GetStateByRange { + string startKey = 1; + string endKey = 2; +} + +message GetQueryResult { + string query = 1; +} + +message GetHistoryForKey { + string key = 1; +} + +message QueryStateNext { + string id = 1; +} + +message QueryStateClose { + string id = 1; +} + +message QueryStateKeyValue { + string key = 1; + bytes value = 2; +} + +message QueryStateResponse { + repeated QueryStateKeyValue keys_and_values = 1; + bool has_more = 2; + string id = 3; +} + +// 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) {} + + +} diff --git a/protos/peer/configuration.pb.go b/protos/peer/configuration.pb.go index 0df2f5b59fc..69f2bfa6bc5 100644 --- a/protos/peer/configuration.pb.go +++ b/protos/peer/configuration.pb.go @@ -21,7 +21,7 @@ type AnchorPeers struct { func (m *AnchorPeers) Reset() { *m = AnchorPeers{} } func (m *AnchorPeers) String() string { return proto.CompactTextString(m) } func (*AnchorPeers) ProtoMessage() {} -func (*AnchorPeers) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } +func (*AnchorPeers) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{0} } func (m *AnchorPeers) GetAnchorPeers() []*AnchorPeer { if m != nil { @@ -45,16 +45,16 @@ type AnchorPeer struct { func (m *AnchorPeer) Reset() { *m = AnchorPeer{} } func (m *AnchorPeer) String() string { return proto.CompactTextString(m) } func (*AnchorPeer) ProtoMessage() {} -func (*AnchorPeer) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} } +func (*AnchorPeer) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{1} } func init() { proto.RegisterType((*AnchorPeers)(nil), "protos.AnchorPeers") proto.RegisterType((*AnchorPeer)(nil), "protos.AnchorPeer") } -func init() { proto.RegisterFile("peer/configuration.proto", fileDescriptor3) } +func init() { proto.RegisterFile("peer/configuration.proto", fileDescriptor4) } -var fileDescriptor3 = []byte{ +var fileDescriptor4 = []byte{ // 191 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x44, 0x8f, 0x31, 0x4f, 0xc6, 0x20, 0x10, 0x86, 0x83, 0x55, 0x13, 0x69, 0x27, 0x26, 0x46, 0xd2, 0x09, 0x63, 0x52, 0x12, 0x8d, 0x3f, diff --git a/protos/peer/events.pb.go b/protos/peer/events.pb.go index c5190b38da3..3bde7f63bb3 100644 --- a/protos/peer/events.pb.go +++ b/protos/peer/events.pb.go @@ -44,7 +44,7 @@ var EventType_value = map[string]int32{ func (x EventType) String() string { return proto.EnumName(EventType_name, int32(x)) } -func (EventType) EnumDescriptor() ([]byte, []int) { return fileDescriptor4, []int{0} } +func (EventType) EnumDescriptor() ([]byte, []int) { return fileDescriptor5, []int{0} } // ChaincodeReg is used for registering chaincode Interests // when EventType is CHAINCODE @@ -56,7 +56,7 @@ type ChaincodeReg struct { func (m *ChaincodeReg) Reset() { *m = ChaincodeReg{} } func (m *ChaincodeReg) String() string { return proto.CompactTextString(m) } func (*ChaincodeReg) ProtoMessage() {} -func (*ChaincodeReg) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{0} } +func (*ChaincodeReg) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} } type Interest struct { EventType EventType `protobuf:"varint,1,opt,name=event_type,json=eventType,enum=protos.EventType" json:"event_type,omitempty"` @@ -74,7 +74,7 @@ type Interest struct { func (m *Interest) Reset() { *m = Interest{} } func (m *Interest) String() string { return proto.CompactTextString(m) } func (*Interest) ProtoMessage() {} -func (*Interest) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{1} } +func (*Interest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{1} } type isInterest_RegInfo interface { isInterest_RegInfo() @@ -165,7 +165,7 @@ type Register struct { func (m *Register) Reset() { *m = Register{} } func (m *Register) String() string { return proto.CompactTextString(m) } func (*Register) ProtoMessage() {} -func (*Register) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{2} } +func (*Register) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{2} } func (m *Register) GetEvents() []*Interest { if m != nil { @@ -184,7 +184,7 @@ type Rejection struct { func (m *Rejection) Reset() { *m = Rejection{} } func (m *Rejection) String() string { return proto.CompactTextString(m) } func (*Rejection) ProtoMessage() {} -func (*Rejection) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{3} } +func (*Rejection) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{3} } func (m *Rejection) GetTx() *Transaction { if m != nil { @@ -201,7 +201,7 @@ type Unregister struct { func (m *Unregister) Reset() { *m = Unregister{} } func (m *Unregister) String() string { return proto.CompactTextString(m) } func (*Unregister) ProtoMessage() {} -func (*Unregister) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{4} } +func (*Unregister) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{4} } func (m *Unregister) GetEvents() []*Interest { if m != nil { @@ -221,7 +221,7 @@ type SignedEvent struct { func (m *SignedEvent) Reset() { *m = SignedEvent{} } func (m *SignedEvent) String() string { return proto.CompactTextString(m) } func (*SignedEvent) ProtoMessage() {} -func (*SignedEvent) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{5} } +func (*SignedEvent) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{5} } // Event is used by // - consumers (adapters) to send Register @@ -241,7 +241,7 @@ type Event struct { func (m *Event) Reset() { *m = Event{} } func (m *Event) String() string { return proto.CompactTextString(m) } func (*Event) ProtoMessage() {} -func (*Event) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{6} } +func (*Event) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{6} } type isEvent_Event interface { isEvent_Event() @@ -556,12 +556,12 @@ var _Events_serviceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: fileDescriptor4, + Metadata: fileDescriptor5, } -func init() { proto.RegisterFile("peer/events.proto", fileDescriptor4) } +func init() { proto.RegisterFile("peer/events.proto", fileDescriptor5) } -var fileDescriptor4 = []byte{ +var fileDescriptor5 = []byte{ // 587 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6f, 0xd3, 0x4e, 0x10, 0xb5, 0xd3, 0x26, 0x8d, 0x27, 0x69, 0x7f, 0xe9, 0xf6, 0xa7, 0xca, 0x94, 0x3f, 0x2a, 0x46, diff --git a/protos/peer/peer.pb.go b/protos/peer/peer.pb.go index 79eda2cb37e..4f91d91edc4 100644 --- a/protos/peer/peer.pb.go +++ b/protos/peer/peer.pb.go @@ -25,7 +25,7 @@ type PeerID struct { func (m *PeerID) Reset() { *m = PeerID{} } func (m *PeerID) String() string { return proto.CompactTextString(m) } func (*PeerID) ProtoMessage() {} -func (*PeerID) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} } +func (*PeerID) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{0} } type PeerEndpoint struct { Id *PeerID `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` @@ -35,7 +35,7 @@ type PeerEndpoint struct { func (m *PeerEndpoint) Reset() { *m = PeerEndpoint{} } func (m *PeerEndpoint) String() string { return proto.CompactTextString(m) } func (*PeerEndpoint) ProtoMessage() {} -func (*PeerEndpoint) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{1} } +func (*PeerEndpoint) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{1} } func (m *PeerEndpoint) GetId() *PeerID { if m != nil { @@ -118,12 +118,12 @@ var _Endorser_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: fileDescriptor5, + Metadata: fileDescriptor6, } -func init() { proto.RegisterFile("peer/peer.proto", fileDescriptor5) } +func init() { proto.RegisterFile("peer/peer.proto", fileDescriptor6) } -var fileDescriptor5 = []byte{ +var fileDescriptor6 = []byte{ // 234 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x54, 0x90, 0x4f, 0x4b, 0xc3, 0x40, 0x10, 0xc5, 0x6d, 0x90, 0xaa, 0xa3, 0x58, 0x58, 0x41, 0x42, 0x28, 0x22, 0x39, 0x29, 0x42, 0x02, diff --git a/protos/peer/proposal.pb.go b/protos/peer/proposal.pb.go index 1a56d52f858..50de3b46049 100644 --- a/protos/peer/proposal.pb.go +++ b/protos/peer/proposal.pb.go @@ -49,7 +49,7 @@ type SignedProposal struct { func (m *SignedProposal) Reset() { *m = SignedProposal{} } func (m *SignedProposal) String() string { return proto.CompactTextString(m) } func (*SignedProposal) ProtoMessage() {} -func (*SignedProposal) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{0} } +func (*SignedProposal) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{0} } // 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 @@ -85,7 +85,7 @@ type Proposal struct { func (m *Proposal) Reset() { *m = Proposal{} } func (m *Proposal) String() string { return proto.CompactTextString(m) } func (*Proposal) ProtoMessage() {} -func (*Proposal) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{1} } +func (*Proposal) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{1} } // ChaincodeHeaderExtension is the Header's extentions message to be used when // the Header's type is CHAINCODE. This extensions is used to specify which @@ -94,8 +94,8 @@ type ChaincodeHeaderExtension struct { // The PayloadVisibility field controls to what extent the Proposal's payload // (recall that for the type CHAINCODE, it is ChaincodeProposalPayload // message) field will be visible in the final transaction and in the ledger. - // Ideally, it would be configurable, supporting at least 3 main “visibility - // modes”: + // Ideally, it would be configurable, supporting at least 3 main visibility + // modes: // 1. all bytes of the payload are visible; // 2. only a hash of the payload is visible; // 3. nothing is visible. @@ -110,7 +110,7 @@ type ChaincodeHeaderExtension struct { func (m *ChaincodeHeaderExtension) Reset() { *m = ChaincodeHeaderExtension{} } func (m *ChaincodeHeaderExtension) String() string { return proto.CompactTextString(m) } func (*ChaincodeHeaderExtension) ProtoMessage() {} -func (*ChaincodeHeaderExtension) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{2} } +func (*ChaincodeHeaderExtension) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{2} } func (m *ChaincodeHeaderExtension) GetChaincodeId() *ChaincodeID { if m != nil { @@ -126,17 +126,24 @@ type ChaincodeProposalPayload struct { // Input contains the arguments for this invocation. If this invocation // deploys a new chaincode, ESCC/VSCC are part of this field. Input []byte `protobuf:"bytes,1,opt,name=input,proto3" json:"input,omitempty"` - // Transient contains data (e.g. cryptographic material) that might be used + // 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. - Transient []byte `protobuf:"bytes,2,opt,name=transient,proto3" json:"transient,omitempty"` + TransientMap map[string][]byte `protobuf:"bytes,2,rep,name=TransientMap" json:"TransientMap,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *ChaincodeProposalPayload) Reset() { *m = ChaincodeProposalPayload{} } func (m *ChaincodeProposalPayload) String() string { return proto.CompactTextString(m) } func (*ChaincodeProposalPayload) ProtoMessage() {} -func (*ChaincodeProposalPayload) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{3} } +func (*ChaincodeProposalPayload) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{3} } + +func (m *ChaincodeProposalPayload) GetTransientMap() map[string][]byte { + if m != nil { + return m.TransientMap + } + return nil +} // ChaincodeAction contains the actions the events generated by the execution // of the chaincode. @@ -154,7 +161,7 @@ type ChaincodeAction struct { func (m *ChaincodeAction) Reset() { *m = ChaincodeAction{} } func (m *ChaincodeAction) String() string { return proto.CompactTextString(m) } func (*ChaincodeAction) ProtoMessage() {} -func (*ChaincodeAction) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{4} } +func (*ChaincodeAction) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{4} } func (m *ChaincodeAction) GetResponse() *Response { if m != nil { @@ -171,31 +178,35 @@ func init() { proto.RegisterType((*ChaincodeAction)(nil), "protos.ChaincodeAction") } -func init() { proto.RegisterFile("peer/proposal.proto", fileDescriptor6) } - -var fileDescriptor6 = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x54, 0x52, 0xcf, 0x4b, 0xf3, 0x40, - 0x10, 0xa5, 0xdf, 0xc7, 0xd7, 0xf6, 0xdb, 0xd6, 0xaa, 0xdb, 0x22, 0xa1, 0xf4, 0x20, 0x01, 0x41, - 0x51, 0x1b, 0xa8, 0xe0, 0xdd, 0xaa, 0x60, 0x2f, 0x52, 0x22, 0x7a, 0xe8, 0xa5, 0x6c, 0x92, 0x31, - 0x59, 0x88, 0xbb, 0xeb, 0xee, 0xa6, 0x98, 0xa3, 0xff, 0xb9, 0x24, 0xfb, 0x43, 0x3d, 0x85, 0x79, - 0x6f, 0xe6, 0xcd, 0xbc, 0x97, 0x45, 0x63, 0x01, 0x20, 0x23, 0x21, 0xb9, 0xe0, 0x8a, 0x94, 0x73, - 0x21, 0xb9, 0xe6, 0xb8, 0xdb, 0x7e, 0xd4, 0x74, 0xd2, 0x92, 0x69, 0x41, 0x28, 0x4b, 0x79, 0x06, - 0x86, 0x9d, 0xce, 0x7e, 0x8d, 0x6c, 0x25, 0x28, 0xc1, 0x99, 0xb2, 0x6c, 0xf8, 0x8c, 0x46, 0x4f, - 0x34, 0x67, 0x90, 0xad, 0x6d, 0x03, 0x3e, 0x41, 0x23, 0xdf, 0x9c, 0xd4, 0x1a, 0x54, 0xd0, 0x39, - 0xee, 0x9c, 0x0e, 0xe3, 0x3d, 0x87, 0x2e, 0x1b, 0x10, 0xcf, 0xd0, 0x7f, 0x45, 0x73, 0x46, 0x74, - 0x25, 0x21, 0xf8, 0xd3, 0x76, 0x7c, 0x03, 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2b, 0x49, - 0x24, 0x4d, 0x23, 0x33, 0x1a, 0x35, 0xcf, 0x27, 0x31, 0x4f, 0xec, 0xea, 0x2b, 0x00, 0x00, 0xff, - 0xff, 0x1d, 0xd7, 0x36, 0x09, 0x80, 0x02, 0x00, 0x00, +func init() { proto.RegisterFile("peer/proposal.proto", fileDescriptor7) } + +var fileDescriptor7 = []byte{ + // 419 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x64, 0x52, 0xdf, 0x6b, 0xd4, 0x40, + 0x10, 0xe6, 0xee, 0xb0, 0x3f, 0x26, 0x67, 0x6d, 0xb7, 0x45, 0xc2, 0xd1, 0x87, 0x12, 0x10, 0x2a, + 0x6a, 0x02, 0x11, 0x44, 0x7c, 0x11, 0xab, 0x05, 0xfb, 0x20, 0x94, 0xa8, 0x7d, 0xe8, 0xcb, 0xb1, + 0x49, 0xc6, 0x64, 0x31, 0xee, 0xae, 0xbb, 0x9b, 0xc3, 0x3c, 0xfa, 0xe7, 0xf9, 0x5f, 0x49, 0xb2, + 0x3f, 0x6c, 0xbd, 0xa7, 0xe4, 0x9b, 0xef, 0x9b, 0x6f, 0x66, 0x76, 0x06, 0x8e, 0x25, 0xa2, 0xca, + 0xa4, 0x12, 0x52, 0x68, 0xda, 0xa5, 0x52, 0x09, 0x23, 0xc8, 0xce, 0xf4, 0xd1, 0xab, 0x93, 0x89, + 0xac, 0x5a, 0xca, 0x78, 0x25, 0x6a, 0xb4, 0xec, 0xea, 0xf4, 0x5e, 0xca, 0x5a, 0xa1, 0x96, 0x82, + 0x6b, 0xc7, 0x26, 0x5f, 0xe1, 0xe0, 0x33, 0x6b, 0x38, 0xd6, 0xd7, 0x4e, 0x40, 0x9e, 0xc0, 0x41, + 0x10, 0x97, 0x83, 0x41, 0x1d, 0xcf, 0xce, 0x66, 0xe7, 0xcb, 0xe2, 0xa1, 0x8f, 0x5e, 0x8c, 0x41, + 0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5, 0x2c, 0xf9, 0x09, 0x8f, 0x42, 0xf1, 0x77, 0x95, 0x19, 0x5f, + 0x31, 0x86, 0x5d, 0x85, 0xba, 0xef, 0x8c, 0x5f, 0xbe, 0x87, 0xe3, 0x32, 0x71, 0x83, 0xdc, 0x68, + 0xe7, 0xe3, 0x10, 0x79, 0x0e, 0x7b, 0xfe, 0xb2, 0xa6, 0x8d, 0x45, 0xf9, 0xa1, 0x9f, 0xac, 0x70, + 0xf1, 0x22, 0x28, 0x2e, 0x9e, 0xdd, 0x3e, 0x6d, 0x98, 0x69, 0xfb, 0x32, 0xad, 0xc4, 0x8f, 0xac, + 0x1d, 0x24, 0xaa, 0x0e, 0xeb, 0x06, 0x55, 0xf6, 0x8d, 0x96, 0x8a, 0x55, 0x99, 0x4d, 0xcd, 0xc6, + 0xd3, 0x2d, 0xed, 0x79, 0xbf, 0xfc, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x28, 0x14, 0xac, 0x8e, 0xfc, + 0x02, 0x00, 0x00, } diff --git a/protos/peer/proposal.proto b/protos/peer/proposal.proto index 421a021ef01..b6882884d02 100644 --- a/protos/peer/proposal.proto +++ b/protos/peer/proposal.proto @@ -217,8 +217,8 @@ message ChaincodeHeaderExtension { // The PayloadVisibility field controls to what extent the Proposal's payload // (recall that for the type CHAINCODE, it is ChaincodeProposalPayload // message) field will be visible in the final transaction and in the ledger. - // Ideally, it would be configurable, supporting at least 3 main “visibility - // modes”: + // Ideally, it would be configurable, supporting at least 3 main visibility + // modes: // 1. all bytes of the payload are visible; // 2. only a hash of the payload is visible; // 3. nothing is visible. @@ -240,11 +240,11 @@ message ChaincodeProposalPayload { // deploys a new chaincode, ESCC/VSCC are part of this field. bytes input = 1; - // Transient contains data (e.g. cryptographic material) that might be used + // 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. - bytes transient = 2; + map TransientMap = 2; } // ChaincodeAction contains the actions the events generated by the execution diff --git a/protos/peer/proposal_response.pb.go b/protos/peer/proposal_response.pb.go index ab6f1f54657..131820903c9 100644 --- a/protos/peer/proposal_response.pb.go +++ b/protos/peer/proposal_response.pb.go @@ -41,7 +41,7 @@ type ProposalResponse struct { func (m *ProposalResponse) Reset() { *m = ProposalResponse{} } func (m *ProposalResponse) String() string { return proto.CompactTextString(m) } func (*ProposalResponse) ProtoMessage() {} -func (*ProposalResponse) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{0} } +func (*ProposalResponse) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{0} } func (m *ProposalResponse) GetTimestamp() *google_protobuf1.Timestamp { if m != nil { @@ -78,7 +78,7 @@ type Response struct { func (m *Response) Reset() { *m = Response{} } func (m *Response) String() string { return proto.CompactTextString(m) } func (*Response) ProtoMessage() {} -func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{1} } +func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{1} } // ProposalResponsePayload is the payload of a proposal response. This message // is the "bridge" between the client's request and the endorser's action in @@ -113,7 +113,7 @@ type ProposalResponsePayload struct { func (m *ProposalResponsePayload) Reset() { *m = ProposalResponsePayload{} } func (m *ProposalResponsePayload) String() string { return proto.CompactTextString(m) } func (*ProposalResponsePayload) ProtoMessage() {} -func (*ProposalResponsePayload) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{2} } +func (*ProposalResponsePayload) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{2} } // An endorsement is a signature of an endorser over a proposal response. By // producing an endorsement message, an endorser implicitly "approves" that @@ -135,7 +135,7 @@ type Endorsement struct { func (m *Endorsement) Reset() { *m = Endorsement{} } func (m *Endorsement) String() string { return proto.CompactTextString(m) } func (*Endorsement) ProtoMessage() {} -func (*Endorsement) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{3} } +func (*Endorsement) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{3} } func init() { proto.RegisterType((*ProposalResponse)(nil), "protos.ProposalResponse") @@ -144,9 +144,9 @@ func init() { proto.RegisterType((*Endorsement)(nil), "protos.Endorsement") } -func init() { proto.RegisterFile("peer/proposal_response.proto", fileDescriptor7) } +func init() { proto.RegisterFile("peer/proposal_response.proto", fileDescriptor8) } -var fileDescriptor7 = []byte{ +var fileDescriptor8 = []byte{ // 345 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x52, 0x5f, 0x4b, 0xfb, 0x30, 0x14, 0xa5, 0xfb, 0xfd, 0x36, 0xb7, 0xbb, 0x09, 0xa3, 0x82, 0x96, 0x31, 0x70, 0xd4, 0x97, 0x89, diff --git a/protos/peer/transaction.pb.go b/protos/peer/transaction.pb.go index 432287480ad..357acf64adc 100644 --- a/protos/peer/transaction.pb.go +++ b/protos/peer/transaction.pb.go @@ -31,7 +31,7 @@ type SignedTransaction struct { func (m *SignedTransaction) Reset() { *m = SignedTransaction{} } func (m *SignedTransaction) String() string { return proto.CompactTextString(m) } func (*SignedTransaction) ProtoMessage() {} -func (*SignedTransaction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{0} } +func (*SignedTransaction) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{0} } // ProcessedTransaction wraps an Envelope that includes a transaction along with an indication // of whether the transaction was validated or invalidated by committing peer. @@ -49,7 +49,7 @@ type ProcessedTransaction struct { func (m *ProcessedTransaction) Reset() { *m = ProcessedTransaction{} } func (m *ProcessedTransaction) String() string { return proto.CompactTextString(m) } func (*ProcessedTransaction) ProtoMessage() {} -func (*ProcessedTransaction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{1} } +func (*ProcessedTransaction) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{1} } func (m *ProcessedTransaction) GetTransactionEnvelope() *common.Envelope { if m != nil { @@ -79,7 +79,7 @@ type Transaction struct { func (m *Transaction) Reset() { *m = Transaction{} } func (m *Transaction) String() string { return proto.CompactTextString(m) } func (*Transaction) ProtoMessage() {} -func (*Transaction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{2} } +func (*Transaction) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{2} } func (m *Transaction) GetActions() []*TransactionAction { if m != nil { @@ -101,7 +101,7 @@ type TransactionAction struct { func (m *TransactionAction) Reset() { *m = TransactionAction{} } func (m *TransactionAction) String() string { return proto.CompactTextString(m) } func (*TransactionAction) ProtoMessage() {} -func (*TransactionAction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{3} } +func (*TransactionAction) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{3} } // ChaincodeActionPayload is the message to be used for the TransactionAction's // payload when the Header's type is set to CHAINCODE. It carries the @@ -124,7 +124,7 @@ type ChaincodeActionPayload struct { func (m *ChaincodeActionPayload) Reset() { *m = ChaincodeActionPayload{} } func (m *ChaincodeActionPayload) String() string { return proto.CompactTextString(m) } func (*ChaincodeActionPayload) ProtoMessage() {} -func (*ChaincodeActionPayload) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{4} } +func (*ChaincodeActionPayload) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{4} } func (m *ChaincodeActionPayload) GetAction() *ChaincodeEndorsedAction { if m != nil { @@ -148,7 +148,7 @@ type ChaincodeEndorsedAction struct { func (m *ChaincodeEndorsedAction) Reset() { *m = ChaincodeEndorsedAction{} } func (m *ChaincodeEndorsedAction) String() string { return proto.CompactTextString(m) } func (*ChaincodeEndorsedAction) ProtoMessage() {} -func (*ChaincodeEndorsedAction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{5} } +func (*ChaincodeEndorsedAction) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{5} } func (m *ChaincodeEndorsedAction) GetEndorsements() []*Endorsement { if m != nil { @@ -166,9 +166,9 @@ func init() { proto.RegisterType((*ChaincodeEndorsedAction)(nil), "protos.ChaincodeEndorsedAction") } -func init() { proto.RegisterFile("peer/transaction.proto", fileDescriptor8) } +func init() { proto.RegisterFile("peer/transaction.proto", fileDescriptor9) } -var fileDescriptor8 = []byte{ +var fileDescriptor9 = []byte{ // 416 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x93, 0xcf, 0x6b, 0xdb, 0x30, 0x14, 0xc7, 0x49, 0xc7, 0xd2, 0xed, 0xa5, 0x87, 0x46, 0x29, 0xa9, 0x1b, 0x0a, 0x1d, 0x3e, 0x75, diff --git a/protos/utils/proputils.go b/protos/utils/proputils.go index 69611a6a65a..8d0cbfd39fc 100644 --- a/protos/utils/proputils.go +++ b/protos/utils/proputils.go @@ -22,6 +22,7 @@ import ( "errors" "encoding/base64" + "encoding/binary" "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/bccsp" @@ -52,32 +53,42 @@ func GetChaincodeInvocationSpec(prop *peer.Proposal) (*peer.ChaincodeInvocationS return cis, nil } -// GetChaincodeProposalContext returns a ChaincodeProposalContext from a Proposal -func GetChaincodeProposalContext(prop *peer.Proposal) (*peer.ChaincodeProposalContext, error) { - // get back the header +// GetChaincodeProposalContext returns creator and transient +func GetChaincodeProposalContext(prop *peer.Proposal) ([]byte, map[string][]byte, error) { + if prop == nil { + return nil, nil, fmt.Errorf("Proposal is nil") + } + if len(prop.Header) == 0 { + return nil, nil, fmt.Errorf("Proposal's header is nil") + } + if len(prop.Payload) == 0 { + return nil, nil, fmt.Errorf("Proposal's payload is nil") + } + + //// get back the header hdr, err := GetHeader(prop.Header) if err != nil { - return nil, fmt.Errorf("Could not extract the header from the proposal: %s", err) + return nil, nil, fmt.Errorf("Could not extract the header from the proposal: %s", err) + } + if hdr == nil { + return nil, nil, fmt.Errorf("Unmarshalled header is nil") } if common.HeaderType(hdr.ChannelHeader.Type) != common.HeaderType_ENDORSER_TRANSACTION && common.HeaderType(hdr.ChannelHeader.Type) != common.HeaderType_CONFIG { - return nil, fmt.Errorf("Invalid proposal type expected ENDORSER_TRANSACTION or CONFIG. Was: %d", hdr.ChannelHeader.Type) + return nil, nil, fmt.Errorf("Invalid proposal type expected ENDORSER_TRANSACTION or CONFIG. Was: %d", hdr.ChannelHeader.Type) } if hdr.SignatureHeader == nil { - return nil, errors.New("Invalid signature header. It must be different from nil.") + return nil, nil, errors.New("Invalid signature header. It must be different from nil.") } ccPropPayload := &peer.ChaincodeProposalPayload{} err = proto.Unmarshal(prop.Payload, ccPropPayload) if err != nil { - return nil, err + return nil, nil, err } - return &peer.ChaincodeProposalContext{ - Creator: hdr.SignatureHeader.Creator, - Transient: ccPropPayload.Transient, - }, nil + return hdr.SignatureHeader.Creator, ccPropPayload.TransientMap, nil } // GetHeader Get Header from bytes @@ -262,7 +273,7 @@ func CreateChaincodeProposal(typ common.HeaderType, chainID string, cis *peer.Ch } // CreateChaincodeProposalWithTransient creates a proposal from given input -func CreateChaincodeProposalWithTransient(typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte, transient []byte) (*peer.Proposal, string, error) { +func CreateChaincodeProposalWithTransient(typ common.HeaderType, chainID string, cis *peer.ChaincodeInvocationSpec, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error) { ccHdrExt := &peer.ChaincodeHeaderExtension{ChaincodeId: cis.ChaincodeSpec.ChaincodeId} ccHdrExtBytes, err := proto.Marshal(ccHdrExt) if err != nil { @@ -274,7 +285,7 @@ func CreateChaincodeProposalWithTransient(typ common.HeaderType, chainID string, return nil, "", err } - ccPropPayload := &peer.ChaincodeProposalPayload{Input: cisBytes, Transient: transient} + ccPropPayload := &peer.ChaincodeProposalPayload{Input: cisBytes, TransientMap: transientMap} ccPropPayloadBytes, err := proto.Marshal(ccPropPayload) if err != nil { return nil, "", err @@ -537,3 +548,34 @@ func CheckProposalTxID(txid string, nonce, creator []byte) error { return nil } + +// ComputeProposalBinding computes the binding of a proposal +func ComputeProposalBinding(proposal *peer.Proposal) ([]byte, error) { + if proposal == nil { + return nil, fmt.Errorf("Porposal is nil") + } + if len(proposal.Header) == 0 { + return nil, fmt.Errorf("Proposal's Header is nil") + } + + h, err := GetHeader(proposal.Header) + if err != nil { + return nil, err + } + + return computeProposalBindingInternal(h.SignatureHeader.Nonce, h.SignatureHeader.Creator, h.ChannelHeader.Epoch) +} + +func computeProposalBindingInternal(nonce, creator []byte, epoch uint64) ([]byte, error) { + epochBytes := make([]byte, 8) + binary.LittleEndian.PutUint64(epochBytes, epoch) + + // TODO: add to genesis block the hash function used for the binding computation. + digest, err := factory.GetDefaultOrPanic().Hash( + append(append(nonce, creator...), epochBytes...), + &bccsp.SHA256Opts{}) + if err != nil { + return nil, err + } + return digest, nil +} diff --git a/protos/utils/proputils_test.go b/protos/utils/proputils_test.go index aaafe8d8993..b51a2b67c99 100644 --- a/protos/utils/proputils_test.go +++ b/protos/utils/proputils_test.go @@ -44,7 +44,11 @@ func createCIS() *pb.ChaincodeInvocationSpec { func TestProposal(t *testing.T) { // create a proposal from a ChaincodeInvocationSpec - prop, _, err := CreateChaincodeProposalWithTransient(common.HeaderType_ENDORSER_TRANSACTION, util.GetTestChainID(), createCIS(), []byte("creator"), []byte("transient")) + prop, _, err := CreateChaincodeProposalWithTransient( + common.HeaderType_ENDORSER_TRANSACTION, + util.GetTestChainID(), createCIS(), + []byte("creator"), + map[string][]byte{"certx": []byte("transient")}) if err != nil { t.Fatalf("Could not create chaincode proposal, err %s\n", err) return @@ -122,16 +126,17 @@ func TestProposal(t *testing.T) { return } - porposalContexd, err := GetChaincodeProposalContext(prop) + creator, transient, err := GetChaincodeProposalContext(prop) if err != nil { t.Fatalf("Failed getting chaincode proposal context [%s]", err) } - if string(porposalContexd.Transient) != "transient" { - t.Fatalf("Failed checking Transient field. Invalid value, expectext 'transient', got [%s]", string(porposalContexd.Transient)) + if string(creator) != "creator" { + t.Fatalf("Failed checking Creator field. Invalid value, expectext 'creator', got [%s]", string(creator)) return } - if string(porposalContexd.Creator) != "creator" { - t.Fatalf("Failed checking Creator field. Invalid value, expectext 'creator', got [%s]", string(porposalContexd.Creator)) + value, ok := transient["certx"] + if !ok || string(value) != "transient" { + t.Fatalf("Failed checking Transient field. Invalid value, expectext 'transient', got [%s]", string(value)) return } } diff --git a/protos/utils/txutils.go b/protos/utils/txutils.go index d246c5f17d3..136af0873de 100644 --- a/protos/utils/txutils.go +++ b/protos/utils/txutils.go @@ -247,7 +247,7 @@ func GetBytesProposalPayloadForTx(payload *peer.ChaincodeProposalPayload, visibi } // strip the transient bytes off the payload - this needs to be done no matter the visibility mode - cppNoTransient := &peer.ChaincodeProposalPayload{Input: payload.Input, Transient: nil} + cppNoTransient := &peer.ChaincodeProposalPayload{Input: payload.Input, TransientMap: nil} cppBytes, err := GetBytesChaincodeProposalPayload(cppNoTransient) if err != nil { return nil, errors.New("Failure while marshalling the ChaincodeProposalPayload!")