diff --git a/bddtests/chaincode.go b/bddtests/chaincode.go index 04e23cd519c..c137fdbdfe0 100644 --- a/bddtests/chaincode.go +++ b/bddtests/chaincode.go @@ -48,6 +48,9 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen ChaincodeID: &pb.ChaincodeID{Name: "lccc"}, CtorMsg: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}} lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec} + + uuid := createPropsalID() + // make proposal - return putils.CreateChaincodeProposal(lcChaincodeInvocationSpec, creator) + return putils.CreateChaincodeProposal(uuid, lcChaincodeInvocationSpec, creator) } diff --git a/bddtests/syschaincode/noop/chaincode.go b/bddtests/syschaincode/noop/chaincode.go deleted file mode 100644 index 9bae0d08bb9..00000000000 --- a/bddtests/syschaincode/noop/chaincode.go +++ /dev/null @@ -1,95 +0,0 @@ -/* - Copyright Digital Asset Holdings, LLC 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. -*/ - -package noop - -import ( - "errors" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/core/chaincode/shim" - - pb "github.com/hyperledger/fabric/protos/peer" -) - -var logger = shim.NewLogger("noop") - -type ledgerHandler interface { - GetTransactionByID(txID string) (*pb.Transaction, error) -} - -// SystemChaincode is type representing the chaincode -// In general, one should not use vars in memory that can hold state -// across invokes but this is used JUST for MOCKING -type SystemChaincode struct { - mockLedgerH ledgerHandler -} - -func (t *SystemChaincode) getLedger() ledgerHandler { - if t.mockLedgerH == nil { - panic("Chaincode is unable to get the ledger.") - } else { - return t.mockLedgerH - } -} - -// Init initailizes the system chaincode -func (t *SystemChaincode) Init(stub shim.ChaincodeStubInterface) ([]byte, error) { - logger.SetLevel(shim.LogDebug) - logger.Debugf("NOOP INIT") - return nil, nil -} - -// Invoke runs an invocation on the system chaincode -func (t *SystemChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, error) { - args := stub.GetStringArgs() - if len(args) != 1 { - return nil, errors.New("Noop execute operation must have one single argument.") - } - logger.Infof("Executing noop invoke.") - return nil, nil -} - -// Query callback representing the query of a chaincode -func (t *SystemChaincode) Query(stub shim.ChaincodeStubInterface) ([]byte, error) { - function, args := stub.GetFunctionAndParameters() - switch function { - case "getTran": - if len(args) < 1 { - return nil, errors.New("getTran operation must include a single argument, the TX hash hex") - } - logger.Infof("Executing NOOP QUERY") - logger.Infof("--> %x", args[0]) - - var txHashHex = args[0] - var tx, txerr = t.getLedger().GetTransactionByID(txHashHex) - if nil != txerr || nil == tx { - return nil, txerr - } - newCCIS := &pb.ChaincodeInvocationSpec{} - var merr = proto.Unmarshal(tx.Payload, newCCIS) - if nil != merr { - return nil, merr - } - if len(newCCIS.ChaincodeSpec.CtorMsg.Args) < 1 { - return nil, errors.New("The requested transaction is malformed.") - } - var dataInByteForm = newCCIS.ChaincodeSpec.CtorMsg.Args[0] - return dataInByteForm, nil - default: - return nil, errors.New("Unsupported operation") - } -} diff --git a/bddtests/syschaincode/noop/chaincode_test.go b/bddtests/syschaincode/noop/chaincode_test.go deleted file mode 100644 index fc0fc2397cb..00000000000 --- a/bddtests/syschaincode/noop/chaincode_test.go +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright Digital Asset Holdings, LLC 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. -*/ - -package noop - -import ( - "fmt" - "testing" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/core/chaincode/shim" - "github.com/hyperledger/fabric/core/util" - - pb "github.com/hyperledger/fabric/protos/peer" -) - -var something = "c29tZXRoaW5n" - -func TestMocking(t *testing.T) { - var mockledger, ledger ledgerHandler - mockledger = mockLedger{} - var noop = SystemChaincode{mockledger} - ledger = noop.getLedger() - if mockledger != ledger { - t.Errorf("Mocking functionality of Noop system chaincode does not work.") - } -} - -func TestInvokeUnsupported(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("unsupported_operation", "arg1", "arg2") - var res, err = noop.Invoke(stub) - if res != nil || err == nil { - t.Errorf("Invoke has to return nil and error when called with unsupported operation!") - } -} - -func TestInvokeExecuteNotEnoughArgs(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub() - var res, err = noop.Invoke(stub) - if res != nil || err == nil { - t.Errorf("Invoke.execute has to indicate error if called with less than one arguments!") - } -} - -func TestInvokeExecuteOneArgReturnsNothing(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("transaction") - var res, err = noop.Invoke(stub) - if res != nil || err != nil { - t.Errorf("Invoke.execute has to return nil with no error.") - } -} - -func TestInvokeExecuteMoreArgsReturnsError(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("transaction", "arg1") - var res, err = noop.Invoke(stub) - if res != nil || err == nil { - t.Errorf("Invoke.execute has to return error when called with more than one arguments.") - } -} - -func TestQueryUnsupported(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("unsupported_operation", "arg1", "arg2") - var res, err = noop.Query(stub) - if res != nil || err == nil { - t.Errorf("Invoke has to return nil and error when called with unsupported operation!") - } -} - -func TestQueryGetTranNotEnoughArgs(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("getTran") - var res, err = noop.Query(stub) - if res != nil || err == nil { - t.Errorf("Invoke has to return nil and error when called with unsupported operation!") - } -} - -func TestQueryGetTranNonExisting(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("getTran", "noSuchTX") - res, err := noop.Query(stub) - if res != nil || err == nil { - t.Errorf("Invoke has to return nil when called with a non-existent transaction.") - } -} - -func TestQueryGetTranNonExistingWithManyArgs(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("getTran", "noSuchTX", "arg2") - res, err := noop.Query(stub) - if res != nil || err == nil { - t.Errorf("Invoke has to return nil when called with a non-existent transaction.") - } -} - -func TestQueryGetTranExisting(t *testing.T) { - var noop = SystemChaincode{mockLedger{}} - stub := shim.InitTestStub("getTran", "someTx") - var res, err = noop.Query(stub) - if res == nil || err != nil { - t.Errorf("Invoke has to return a transaction when called with an existing one.") - } -} - -type mockLedger struct { -} - -func (ml mockLedger) GetTransactionByID(txID string) (*pb.Transaction, error) { - if txID == "noSuchTX" { - return nil, fmt.Errorf("Some error") - } - newCCIS := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("execute", something)}}} - pl, _ := proto.Marshal(newCCIS) - return &pb.Transaction{Payload: pl}, nil -} diff --git a/core/chaincode/chaincode_support.go b/core/chaincode/chaincode_support.go index 4cebab4145b..9c389f93c26 100644 --- a/core/chaincode/chaincode_support.go +++ b/core/chaincode/chaincode_support.go @@ -33,7 +33,6 @@ import ( "github.com/hyperledger/fabric/core/container" "github.com/hyperledger/fabric/core/container/ccintf" - "github.com/hyperledger/fabric/core/crypto" "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/flogging" pb "github.com/hyperledger/fabric/protos/peer" @@ -107,11 +106,11 @@ func (chaincodeSupport *ChaincodeSupport) chaincodeHasBeenLaunched(chaincode str } // NewChaincodeSupport creates a new ChaincodeSupport instance -func NewChaincodeSupport(chainname ChainName, getPeerEndpoint func() (*pb.PeerEndpoint, error), userrunsCC bool, ccstartuptimeout time.Duration, secHelper crypto.Peer) *ChaincodeSupport { +func NewChaincodeSupport(chainname ChainName, getPeerEndpoint func() (*pb.PeerEndpoint, error), userrunsCC bool, ccstartuptimeout time.Duration) *ChaincodeSupport { pnid := viper.GetString("peer.networkId") pid := viper.GetString("peer.id") - s := &ChaincodeSupport{name: chainname, runningChaincodes: &runningChaincodes{chaincodeMap: make(map[string]*chaincodeRTEnv)}, secHelper: secHelper, peerNetworkID: pnid, peerID: pid} + s := &ChaincodeSupport{name: chainname, runningChaincodes: &runningChaincodes{chaincodeMap: make(map[string]*chaincodeRTEnv)}, peerNetworkID: pnid, peerID: pid} //initialize global chain chains[chainname] = s @@ -193,7 +192,6 @@ type ChaincodeSupport struct { ccStartupTimeout time.Duration chaincodeInstallPath string userRunsCC bool - secHelper crypto.Peer peerNetworkID string peerID string peerTLS bool @@ -273,7 +271,7 @@ func (chaincodeSupport *ChaincodeSupport) deregisterHandler(chaincodehandler *Ha } // Based on state of chaincode send either init or ready to move to ready state -func (chaincodeSupport *ChaincodeSupport) sendInitOrReady(context context.Context, txid string, chaincode string, initArgs [][]byte, timeout time.Duration, tx *pb.Transaction, depTx *pb.Transaction) error { +func (chaincodeSupport *ChaincodeSupport) sendInitOrReady(context context.Context, txid string, prop *pb.Proposal, chaincode string, initArgs [][]byte, timeout time.Duration) error { chaincodeSupport.runningChaincodes.Lock() //if its in the map, there must be a connected stream...nothing to do var chrte *chaincodeRTEnv @@ -287,7 +285,7 @@ func (chaincodeSupport *ChaincodeSupport) sendInitOrReady(context context.Contex var notfy chan *pb.ChaincodeMessage var err error - if notfy, err = chrte.handler.initOrReady(context, txid, initArgs, tx, depTx); err != nil { + if notfy, err = chrte.handler.initOrReady(context, txid, prop, initArgs); err != nil { return fmt.Errorf("Error sending %s: %s", pb.ChaincodeMessage_INIT, err) } if notfy != nil { @@ -445,35 +443,30 @@ func (chaincodeSupport *ChaincodeSupport) Stop(context context.Context, cds *pb. } // Launch will launch the chaincode if not running (if running return nil) and will wait for handler of the chaincode to get into FSM ready state. -func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb.Transaction) (*pb.ChaincodeID, *pb.ChaincodeInput, error) { +func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, txid string, prop *pb.Proposal, spec interface{}) (*pb.ChaincodeID, *pb.ChaincodeInput, error) { //build the chaincode var cID *pb.ChaincodeID var cMsg *pb.ChaincodeInput var cLang pb.ChaincodeSpec_Type var initargs [][]byte - cds := &pb.ChaincodeDeploymentSpec{} - if t.Type == pb.Transaction_CHAINCODE_DEPLOY { - err := proto.Unmarshal(t.Payload, cds) - if err != nil { - return nil, nil, err + var cds *pb.ChaincodeDeploymentSpec + var ci *pb.ChaincodeInvocationSpec + if cds, _ = spec.(*pb.ChaincodeDeploymentSpec); cds == nil { + if ci, _ = spec.(*pb.ChaincodeInvocationSpec); ci == nil { + panic("Launch should be called with deployment or invocation spec") } + } + if cds != nil { cID = cds.ChaincodeSpec.ChaincodeID cMsg = cds.ChaincodeSpec.CtorMsg cLang = cds.ChaincodeSpec.Type initargs = cMsg.Args - } else if t.Type == pb.Transaction_CHAINCODE_INVOKE || t.Type == pb.Transaction_CHAINCODE_QUERY { - ci := &pb.ChaincodeInvocationSpec{} - err := proto.Unmarshal(t.Payload, ci) - if err != nil { - return nil, nil, err - } + } else { cID = ci.ChaincodeSpec.ChaincodeID cMsg = ci.ChaincodeSpec.CtorMsg - } else { - chaincodeSupport.runningChaincodes.Unlock() - return nil, nil, fmt.Errorf("invalid transaction type: %d", t.Type) } + chaincode := cID.Name chaincodeSupport.runningChaincodes.Lock() var chrte *chaincodeRTEnv @@ -496,21 +489,7 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb. } chaincodeSupport.runningChaincodes.Unlock() - var depTx *pb.Transaction - - //extract depTx so we can initialize hander.deployTXSecContext - //we need it only after container is launched and only if this is not a deploy tx - //NOTE: ideally this section should be moved before just before sendInitOrReady where - // where we need depTx. However, as we don't check for ExecuteTransactions failure - // in consensus/helper, the following race is not resolved: - // 1) deploy creates image - // 2) query launches chaincode - // 3) deploy returns "premature execution" error - // 4) error ignored and deploy committed - // 5) query successfully retrives committed tx and calls sendInitOrReady - // See issue #710 - - if t.Type != pb.Transaction_CHAINCODE_DEPLOY { + if cds == nil { if chaincodeSupport.userRunsCC { chaincodeLogger.Error("You are attempting to perform an action other than Deploy on Chaincode that is not ready and you are in developer mode. Did you forget to Deploy your chaincode?") } @@ -521,7 +500,7 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb. var depPayload []byte //hopefully we are restarting from existing image and the deployed transaction exists - depPayload, err = GetCDSFromLCCC(context, string(DefaultChain), chaincode) + depPayload, err = GetCDSFromLCCC(context, txid, prop, string(DefaultChain), chaincode) if err != nil { return cID, cMsg, fmt.Errorf("Could not get deployment transaction from LCCC for %s - %s", chaincode, err) } @@ -529,6 +508,7 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb. return cID, cMsg, fmt.Errorf("failed to get deployment payload %s - %s", chaincode, err) } + cds = &pb.ChaincodeDeploymentSpec{} //Get lang from original deployment err = proto.Unmarshal(depPayload, cds) if err != nil { @@ -542,7 +522,7 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb. //launch container if it is a System container or not in dev mode if (!chaincodeSupport.userRunsCC || cds.ExecEnv == pb.ChaincodeDeploymentSpec_SYSTEM) && (chrte == nil || chrte.handler == nil) { var targz io.Reader = bytes.NewBuffer(cds.CodePackage) - _, err = chaincodeSupport.launchAndWaitForRegister(context, cds, cID, t.Txid, cLang, targz) + _, err = chaincodeSupport.launchAndWaitForRegister(context, cds, cID, txid, cLang, targz) if err != nil { chaincodeLogger.Errorf("launchAndWaitForRegister failed %s", err) return cID, cMsg, err @@ -551,7 +531,7 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb. if err == nil { //send init (if (args)) and wait for ready state - err = chaincodeSupport.sendInitOrReady(context, t.Txid, chaincode, initargs, chaincodeSupport.ccStartupTimeout, t, depTx) + err = chaincodeSupport.sendInitOrReady(context, txid, prop, chaincode, initargs, chaincodeSupport.ccStartupTimeout) if err != nil { chaincodeLogger.Errorf("sending init failed(%s)", err) err = fmt.Errorf("Failed to init chaincode(%s)", err) @@ -568,11 +548,6 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb. return cID, cMsg, err } -// getSecHelper returns the security help set from NewChaincodeSupport -func (chaincodeSupport *ChaincodeSupport) getSecHelper() crypto.Peer { - return chaincodeSupport.secHelper -} - //getVMType - just returns a string for now. Another possibility is to use a factory method to //return a VM executor func (chaincodeSupport *ChaincodeSupport) getVMType(cds *pb.ChaincodeDeploymentSpec) (string, error) { @@ -583,19 +558,10 @@ func (chaincodeSupport *ChaincodeSupport) getVMType(cds *pb.ChaincodeDeploymentS } // Deploy deploys the chaincode if not in development mode where user is running the chaincode. -func (chaincodeSupport *ChaincodeSupport) Deploy(context context.Context, t *pb.Transaction) (*pb.ChaincodeDeploymentSpec, error) { - //build the chaincode - cds := &pb.ChaincodeDeploymentSpec{} - err := proto.Unmarshal(t.Payload, cds) - if err != nil { - return nil, err - } +func (chaincodeSupport *ChaincodeSupport) Deploy(context context.Context, cds *pb.ChaincodeDeploymentSpec) (*pb.ChaincodeDeploymentSpec, error) { cID := cds.ChaincodeSpec.ChaincodeID cLang := cds.ChaincodeSpec.Type chaincode := cID.Name - if err != nil { - return cds, err - } if chaincodeSupport.userRunsCC { chaincodeLogger.Debug("user runs chaincode, not deploying chaincode") @@ -652,17 +618,8 @@ func createTransactionMessage(txid string, cMsg *pb.ChaincodeInput) (*pb.Chainco return &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_TRANSACTION, Payload: payload, Txid: txid}, nil } -// createQueryMessage creates a query message. -func createQueryMessage(txid string, cMsg *pb.ChaincodeInput) (*pb.ChaincodeMessage, error) { - payload, err := proto.Marshal(cMsg) - if err != nil { - return nil, err - } - return &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_QUERY, Payload: payload, Txid: txid}, nil -} - // Execute executes a transaction and waits for it to complete until a timeout value. -func (chaincodeSupport *ChaincodeSupport) Execute(ctxt context.Context, chaincode string, msg *pb.ChaincodeMessage, timeout time.Duration, tx *pb.Transaction) (*pb.ChaincodeMessage, error) { +func (chaincodeSupport *ChaincodeSupport) Execute(ctxt context.Context, chaincode string, msg *pb.ChaincodeMessage, timeout time.Duration, prop *pb.Proposal) (*pb.ChaincodeMessage, error) { chaincodeSupport.runningChaincodes.Lock() //we expect the chaincode to be running... sanity check chrte, ok := chaincodeSupport.chaincodeHasBeenLaunched(chaincode) @@ -675,13 +632,13 @@ func (chaincodeSupport *ChaincodeSupport) Execute(ctxt context.Context, chaincod var notfy chan *pb.ChaincodeMessage var err error - if notfy, err = chrte.handler.sendExecuteMessage(ctxt, msg, tx); err != nil { + if notfy, err = chrte.handler.sendExecuteMessage(ctxt, msg, prop); err != nil { return nil, fmt.Errorf("Error sending %s: %s", msg.Type.String(), err) } var ccresp *pb.ChaincodeMessage select { case ccresp = <-notfy: - //response is sent to user or calling chaincode. ChaincodeMessage_ERROR and ChaincodeMessage_QUERY_ERROR + //response is sent to user or calling chaincode. ChaincodeMessage_ERROR //are typically treated as error case <-time.After(timeout): err = fmt.Errorf("Timeout expired while executing transaction") diff --git a/core/chaincode/chaincodeexec.go b/core/chaincode/chaincodeexec.go index f5899564ee2..fa352793a2e 100644 --- a/core/chaincode/chaincodeexec.go +++ b/core/chaincode/chaincodeexec.go @@ -21,37 +21,34 @@ import ( "fmt" - "github.com/hyperledger/fabric/core/util" pb "github.com/hyperledger/fabric/protos/peer" ) -//create a Transactions - this has to change to Proposal when we move chaincode to use Proposals -func createTx(typ pb.Transaction_Type, ccname string, args [][]byte) (*pb.Transaction, error) { - var tx *pb.Transaction +//create a chaincode invocation spec +func createCIS(ccname string, args [][]byte) (*pb.ChaincodeInvocationSpec, error) { var err error - uuid := util.GenerateUUID() spec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: ccname}, CtorMsg: &pb.ChaincodeInput{Args: args}}} - tx, err = pb.NewChaincodeExecute(spec, uuid, typ) if nil != err { return nil, err } - return tx, nil + return spec, nil } -func GetCDSFromLCCC(ctxt context.Context, chainID string, chaincodeID string) ([]byte, error) { - payload, _, err := ExecuteChaincode(ctxt, pb.Transaction_CHAINCODE_INVOKE, string(DefaultChain), "lccc", [][]byte{[]byte("getdepspec"), []byte(chainID), []byte(chaincodeID)}) +// GetCDSFromLCCC gets chaincode deployment spec from LCCC +func GetCDSFromLCCC(ctxt context.Context, txid string, prop *pb.Proposal, chainID string, chaincodeID string) ([]byte, error) { + payload, _, err := ExecuteChaincode(ctxt, txid, prop, string(DefaultChain), "lccc", [][]byte{[]byte("getdepspec"), []byte(chainID), []byte(chaincodeID)}) return payload, err } // ExecuteChaincode executes a given chaincode given chaincode name and arguments -func ExecuteChaincode(ctxt context.Context, typ pb.Transaction_Type, chainname string, ccname string, args [][]byte) ([]byte, *pb.ChaincodeEvent, error) { - var tx *pb.Transaction +func ExecuteChaincode(ctxt context.Context, txid string, prop *pb.Proposal, chainname string, ccname string, args [][]byte) ([]byte, *pb.ChaincodeEvent, error) { + var spec *pb.ChaincodeInvocationSpec var err error var b []byte var ccevent *pb.ChaincodeEvent - tx, err = createTx(typ, ccname, args) - b, ccevent, err = Execute(ctxt, GetChain(ChainName(chainname)), tx) + spec, err = createCIS(ccname, args) + b, ccevent, err = Execute(ctxt, GetChain(ChainName(chainname)), txid, prop, spec) if err != nil { return nil, nil, fmt.Errorf("Error deploying chaincode: %s", err) } diff --git a/core/chaincode/exectransaction.go b/core/chaincode/exectransaction.go index 076779cae3f..aaafeadd430 100644 --- a/core/chaincode/exectransaction.go +++ b/core/chaincode/exectransaction.go @@ -28,31 +28,29 @@ import ( ) //Execute - execute transaction or a query -func Execute(ctxt context.Context, chain *ChaincodeSupport, t *pb.Transaction) ([]byte, *pb.ChaincodeEvent, error) { +func Execute(ctxt context.Context, chain *ChaincodeSupport, txid string, prop *pb.Proposal, spec interface{}) ([]byte, *pb.ChaincodeEvent, error) { var err error - - if secHelper := chain.getSecHelper(); nil != secHelper { - var err error - t, err = secHelper.TransactionPreExecution(t) - // Note that t is now decrypted and is a deep clone of the original input t - if nil != err { - return nil, nil, err + var cds *pb.ChaincodeDeploymentSpec + var ci *pb.ChaincodeInvocationSpec + if cds, _ = spec.(*pb.ChaincodeDeploymentSpec); cds == nil { + if ci, _ = spec.(*pb.ChaincodeInvocationSpec); ci == nil { + panic("Execute should be called with deployment or invocation spec") } } - if t.Type == pb.Transaction_CHAINCODE_DEPLOY { - _, err := chain.Deploy(ctxt, t) + if cds != nil { + _, err := chain.Deploy(ctxt, cds) if err != nil { return nil, nil, fmt.Errorf("Failed to deploy chaincode spec(%s)", err) } - _, _, err = chain.Launch(ctxt, t) + _, _, err = chain.Launch(ctxt, txid, prop, cds) if err != nil { return nil, nil, fmt.Errorf("%s", err) } - } else if t.Type == pb.Transaction_CHAINCODE_INVOKE || t.Type == pb.Transaction_CHAINCODE_QUERY { + } else { //will launch if necessary (and wait for ready) - cID, cMsg, err := chain.Launch(ctxt, t) + cID, cMsg, err := chain.Launch(ctxt, txid, prop, ci) if err != nil { return nil, nil, fmt.Errorf("Failed to launch chaincode spec(%s)", err) } @@ -72,81 +70,38 @@ func Execute(ctxt context.Context, chain *ChaincodeSupport, t *pb.Transaction) ( } var ccMsg *pb.ChaincodeMessage - if t.Type == pb.Transaction_CHAINCODE_INVOKE { - ccMsg, err = createTransactionMessage(t.Txid, cMsg) - if err != nil { - return nil, nil, fmt.Errorf("Failed to transaction message(%s)", err) - } - } else { - ccMsg, err = createQueryMessage(t.Txid, cMsg) - if err != nil { - return nil, nil, fmt.Errorf("Failed to query message(%s)", err) - } + ccMsg, err = createTransactionMessage(txid, cMsg) + if err != nil { + return nil, nil, fmt.Errorf("Failed to transaction message(%s)", err) } - resp, err := chain.Execute(ctxt, chaincode, ccMsg, timeout, t) + resp, err := chain.Execute(ctxt, chaincode, ccMsg, timeout, prop) if err != nil { // Rollback transaction return nil, nil, fmt.Errorf("Failed to execute transaction or query(%s)", err) } else if resp == nil { // Rollback transaction - return nil, nil, fmt.Errorf("Failed to receive a response for (%s)", t.Txid) + return nil, nil, fmt.Errorf("Failed to receive a response for (%s)", txid) } else { if resp.ChaincodeEvent != nil { resp.ChaincodeEvent.ChaincodeID = chaincode - resp.ChaincodeEvent.TxID = t.Txid + resp.ChaincodeEvent.TxID = txid } - if resp.Type == pb.ChaincodeMessage_COMPLETED || resp.Type == pb.ChaincodeMessage_QUERY_COMPLETED { + if resp.Type == pb.ChaincodeMessage_COMPLETED { // Success return resp.Payload, resp.ChaincodeEvent, nil - } else if resp.Type == pb.ChaincodeMessage_ERROR || resp.Type == pb.ChaincodeMessage_QUERY_ERROR { + } else if resp.Type == pb.ChaincodeMessage_ERROR { // Rollback transaction return nil, resp.ChaincodeEvent, fmt.Errorf("Transaction or query returned with failure: %s", string(resp.Payload)) } - return resp.Payload, nil, fmt.Errorf("receive a response for (%s) but in invalid state(%d)", t.Txid, resp.Type) + return resp.Payload, nil, fmt.Errorf("receive a response for (%s) but in invalid state(%d)", txid, resp.Type) } - } else { - err = fmt.Errorf("Invalid transaction type %s", t.Type.String()) } return nil, nil, err } -/************** -//ExecuteTransactions - will execute transactions on the array one by one -//will return an array of errors one for each transaction. If the execution -//succeeded, array element will be nil. returns []byte of state hash or -//error -func ExecuteTransactions(ctxt context.Context, cname ChainName, xacts []*pb.Transaction) (succeededTXs []*pb.Transaction, stateHash []byte, ccevents []*pb.ChaincodeEvent, txerrs []error, err error) { - var chain = GetChain(cname) - if chain == nil { - // TODO: We should never get here, but otherwise a good reminder to better handle - panic(fmt.Sprintf("[ExecuteTransactions]Chain %s not found\n", cname)) - } - - txerrs = make([]error, len(xacts)) - ccevents = make([]*pb.ChaincodeEvent, len(xacts)) - var succeededTxs = make([]*pb.Transaction, 0) - for i, t := range xacts { - _, ccevents[i], txerrs[i] = Execute(ctxt, chain, t) - if txerrs[i] == nil { - succeededTxs = append(succeededTxs, t) - } else { - sendTxRejectedEvent(xacts[i], txerrs[i].Error()) - } - } - - var lgr *ledger.Ledger - lgr, err = ledger.GetLedger() - if err == nil { - stateHash, err = lgr.GetTempStateHash() - } - - return succeededTxs, stateHash, ccevents, txerrs, err -} -**************/ - // GetSecureContext returns the security context from the context object or error // Security context is nil if security is off from core.yaml file // func GetSecureContext(ctxt context.Context) (crypto.Peer, error) { diff --git a/core/chaincode/exectransaction_test.go b/core/chaincode/exectransaction_test.go index 27d506fed89..2773e159760 100644 --- a/core/chaincode/exectransaction_test.go +++ b/core/chaincode/exectransaction_test.go @@ -30,7 +30,6 @@ import ( "github.com/hyperledger/fabric/core/container" "github.com/hyperledger/fabric/core/container/ccintf" - "github.com/hyperledger/fabric/core/crypto" "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger/kvledger" "github.com/hyperledger/fabric/core/peer" @@ -86,14 +85,8 @@ func initPeer() (net.Listener, error) { return &pb.PeerEndpoint{ID: &pb.PeerID{Name: "testpeer"}, Address: peerAddress}, nil } - // Install security object for peer - var secHelper crypto.Peer - if viper.GetBool("security.enabled") { - //TODO: Integrate new crypto / idp code - } - ccStartupTimeout := time.Duration(chaincodeStartupTimeoutDefault) * time.Millisecond - pb.RegisterChaincodeSupportServer(grpcServer, NewChaincodeSupport(DefaultChain, getPeerEndpoint, false, ccStartupTimeout, secHelper)) + pb.RegisterChaincodeSupportServer(grpcServer, NewChaincodeSupport(DefaultChain, getPeerEndpoint, false, ccStartupTimeout)) RegisterSysCCs() @@ -128,14 +121,14 @@ func startTxSimulation(ctxt context.Context) (context.Context, ledger.TxSimulato return ctxt, txsim, nil } -func endTxSimulationCDS(txsim ledger.TxSimulator, payload []byte, commit bool, cds *pb.ChaincodeDeploymentSpec) error { +func endTxSimulationCDS(txid string, txsim ledger.TxSimulator, payload []byte, commit bool, cds *pb.ChaincodeDeploymentSpec) error { // get serialized version of the signer ss, err := signer.Serialize() if err != nil { return err } // get a proposal - we need it to get a transaction - prop, err := putils.CreateProposalFromCDS(cds, ss) + prop, err := putils.CreateProposalFromCDS(txid, cds, ss) if err != nil { return err } @@ -143,14 +136,14 @@ func endTxSimulationCDS(txsim ledger.TxSimulator, payload []byte, commit bool, c return endTxSimulation(txsim, payload, commit, prop) } -func endTxSimulationCIS(txsim ledger.TxSimulator, payload []byte, commit bool, cis *pb.ChaincodeInvocationSpec) error { +func endTxSimulationCIS(txid string, txsim ledger.TxSimulator, payload []byte, commit bool, cis *pb.ChaincodeInvocationSpec) error { // get serialized version of the signer ss, err := signer.Serialize() if err != nil { return err } // get a proposal - we need it to get a transaction - prop, err := putils.CreateProposalFromCIS(cis, ss) + prop, err := putils.CreateProposalFromCIS(txid, cis, ss) if err != nil { return err } @@ -214,38 +207,6 @@ func getDeploymentSpec(context context.Context, spec *pb.ChaincodeSpec) (*pb.Cha return chaincodeDeploymentSpec, nil } -func createDeployTransaction(dspec *pb.ChaincodeDeploymentSpec, uuid string) (*pb.Transaction, error) { - var tx *pb.Transaction - var err error - - //TODO: integrate new crypto / idp code if applicable - - tx, err = pb.NewChaincodeDeployTransaction(dspec, uuid) - if err != nil { - return nil, fmt.Errorf("Error deploying chaincode: %s ", err) - } - return tx, nil -} - -func createTransaction(invokeTx bool, spec *pb.ChaincodeInvocationSpec, uuid string) (*pb.Transaction, error) { - var tx *pb.Transaction - var err error - - //TODO: integrate new crypto / idp code if applicable - - var t pb.Transaction_Type - if invokeTx { - t = pb.Transaction_CHAINCODE_INVOKE - } else { - t = pb.Transaction_CHAINCODE_QUERY - } - tx, err = pb.NewChaincodeExecute(spec, uuid, t) - if nil != err { - return nil, err - } - return tx, nil -} - //getDeployLCCCSpec gets the spec for the chaincode deployment to be sent to LCCC func getDeployLCCCSpec(cds *pb.ChaincodeDeploymentSpec) (*pb.ChaincodeInvocationSpec, error) { b, err := proto.Marshal(cds) @@ -278,39 +239,30 @@ func deploy2(ctx context.Context, chaincodeDeploymentSpec *pb.ChaincodeDeploymen tid := chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeID.Name - // Now create the Transactions message and send to Peer. - transaction, err := createDeployTransaction(chaincodeDeploymentSpec, tid) - if err != nil { - return nil, fmt.Errorf("Error deploying chaincode: %s ", err) - } - ctx, txsim, err := startTxSimulation(ctx) if err != nil { return nil, fmt.Errorf("Failed to get handle to simulator: %s ", err) } + uuid := util.GenerateUUID() + defer func() { //no error, lets try commit if err == nil { //capture returned error from commit - err = endTxSimulationCDS(txsim, []byte("deployed"), true, chaincodeDeploymentSpec) + err = endTxSimulationCDS(uuid, txsim, []byte("deployed"), true, chaincodeDeploymentSpec) } else { //there was an error, just close simulation and return that - endTxSimulationCDS(txsim, []byte("deployed"), false, chaincodeDeploymentSpec) + endTxSimulationCDS(uuid, txsim, []byte("deployed"), false, chaincodeDeploymentSpec) } }() - uuid := util.GenerateUUID() - var lccctx *pb.Transaction - if lccctx, err = createTransaction(true, cis, uuid); err != nil { - return nil, fmt.Errorf("Error creating lccc transaction: %s", err) - } //write to lccc - if _, _, err = Execute(ctx, GetChain(DefaultChain), lccctx); err != nil { + if _, _, err = Execute(ctx, GetChain(DefaultChain), uuid, nil, cis); err != nil { return nil, fmt.Errorf("Error deploying chaincode: %s", err) } - if b, _, err = Execute(ctx, GetChain(DefaultChain), transaction); err != nil { + if b, _, err = Execute(ctx, GetChain(DefaultChain), tid, nil, chaincodeDeploymentSpec); err != nil { return nil, fmt.Errorf("Error deploying chaincode: %s", err) } @@ -324,12 +276,6 @@ func invoke(ctx context.Context, spec *pb.ChaincodeSpec) (ccevt *pb.ChaincodeEve // Now create the Transactions message and send to Peer. uuid = util.GenerateUUID() - var transaction *pb.Transaction - transaction, err = createTransaction(true, chaincodeInvocationSpec, uuid) - if err != nil { - return nil, uuid, nil, fmt.Errorf("Error invoking chaincode: %s ", err) - } - var txsim ledger.TxSimulator ctx, txsim, err = startTxSimulation(ctx) if err != nil { @@ -340,14 +286,14 @@ func invoke(ctx context.Context, spec *pb.ChaincodeSpec) (ccevt *pb.ChaincodeEve //no error, lets try commit if err == nil { //capture returned error from commit - err = endTxSimulationCIS(txsim, []byte("invoke"), true, chaincodeInvocationSpec) + err = endTxSimulationCIS(uuid, txsim, []byte("invoke"), true, chaincodeInvocationSpec) } else { //there was an error, just close simulation and return that - endTxSimulationCIS(txsim, []byte("invoke"), false, chaincodeInvocationSpec) + endTxSimulationCIS(uuid, txsim, []byte("invoke"), false, chaincodeInvocationSpec) } }() - retval, ccevt, err = Execute(ctx, GetChain(DefaultChain), transaction) + retval, ccevt, err = Execute(ctx, GetChain(DefaultChain), uuid, nil, chaincodeInvocationSpec) if err != nil { return nil, uuid, nil, fmt.Errorf("Error invoking chaincode: %s ", err) } @@ -388,6 +334,97 @@ func executeDeployTransaction(t *testing.T, name string, url string) { GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) } +func chaincodeQueryChaincode(user string) error { + var ctxt = context.Background() + + // Deploy first chaincode + url1 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + + cID1 := &pb.ChaincodeID{Name: "example02", Path: url1} + f := "init" + args := util.ToChaincodeArgs(f, "a", "100", "b", "200") + + spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} + + _, err := deploy(ctxt, spec1) + chaincodeID1 := spec1.ChaincodeID.Name + if err != nil { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + return fmt.Errorf("Error initializing chaincode %s(%s)", chaincodeID1, err) + } + + time.Sleep(time.Second) + + // Deploy second chaincode + url2 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example05" + + cID2 := &pb.ChaincodeID{Name: "example05", Path: url2} + f = "init" + args = util.ToChaincodeArgs(f, "sum", "0") + + spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} + + _, err = deploy(ctxt, spec2) + chaincodeID2 := spec2.ChaincodeID.Name + if err != nil { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + return fmt.Errorf("Error initializing chaincode %s(%s)", chaincodeID2, err) + } + + time.Sleep(time.Second) + + // Invoke second chaincode, which will inturn query the first chaincode + f = "invoke" + args = util.ToChaincodeArgs(f, chaincodeID1, "sum") + + spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} + // Invoke chaincode + var retVal []byte + _, _, retVal, err = invoke(ctxt, spec2) + + if err != nil { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + return fmt.Errorf("Error invoking <%s>: %s", chaincodeID2, err) + } + + // Check the return value + result, err := strconv.Atoi(string(retVal)) + if err != nil || result != 300 { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + return fmt.Errorf("Incorrect final state after transaction for <%s>: %s", chaincodeID1, err) + } + + // Query second chaincode, which will inturn query the first chaincode + f = "query" + args = util.ToChaincodeArgs(f, chaincodeID1, "sum") + + spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} + // Invoke chaincode + _, _, retVal, err = invoke(ctxt, spec2) + + if err != nil { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + return fmt.Errorf("Error querying <%s>: %s", chaincodeID2, err) + } + + // Check the return value + result, err = strconv.Atoi(string(retVal)) + if err != nil || result != 300 { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + return fmt.Errorf("Incorrect final value after query for <%s>: %s", chaincodeID1, err) + } + + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + + return nil +} + // Test deploy of a transaction func TestExecuteDeployTransaction(t *testing.T) { executeDeployTransaction(t, "example01", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01") @@ -532,7 +569,7 @@ func exec(ctxt context.Context, chaincodeID string, numTrans int, numQueries int var wg sync.WaitGroup errs := make([]error, numTrans+numQueries) - e := func(qnum int, typ pb.Transaction_Type) { + e := func(qnum int) { defer wg.Done() var spec *pb.ChaincodeSpec args := util.ToChaincodeArgs("invoke", "a", "b", "10") @@ -551,7 +588,7 @@ func exec(ctxt context.Context, chaincodeID string, numTrans int, numQueries int //execute transactions sequentially.. go func() { for i := 0; i < numTrans; i++ { - e(i, pb.Transaction_CHAINCODE_INVOKE) + e(i) } }() @@ -559,67 +596,6 @@ func exec(ctxt context.Context, chaincodeID string, numTrans int, numQueries int return errs } -// Test the execution of a query. -func TestExecuteQuery(t *testing.T) { - //we no longer do query... this function to be modified for concurrent invokes - t.Skip() - - lis, err := initPeer() - if err != nil { - t.Fail() - t.Logf("Error creating peer: %s", err) - } - - defer finitPeer(lis) - - var ctxt = context.Background() - - url := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" - - cID := &pb.ChaincodeID{Name: "example02", Path: url} - f := "init" - args := util.ToChaincodeArgs(f, "a", "100", "b", "200") - - spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}} - - _, err = deploy(ctxt, spec) - chaincodeID := spec.ChaincodeID.Name - if err != nil { - t.Fail() - t.Logf("Error initializing chaincode %s(%s)", chaincodeID, err) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) - return - } - - time.Sleep(2 * time.Second) - - //start := getNowMillis() - //fmt.Fprintf(os.Stderr, "Starting: %d\n", start) - numTrans := 2 - numQueries := 10 - errs := exec(ctxt, chaincodeID, numTrans, numQueries) - - var numerrs int - for i := 0; i < numTrans+numQueries; i++ { - if errs[i] != nil { - t.Logf("Error doing query on %d %s", i, errs[i]) - numerrs++ - } - } - - if numerrs == 0 { - t.Logf("Query test passed") - } else { - t.Logf("Query test failed(total errors %d)", numerrs) - t.Fail() - } - - //end := getNowMillis() - //fmt.Fprintf(os.Stderr, "Ending: %d\n", end) - //fmt.Fprintf(os.Stderr, "Elapsed : %d millis\n", end-start) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) -} - // Test the execution of an invalid transaction. func TestExecuteInvokeInvalidTransaction(t *testing.T) { lis, err := initPeer() @@ -838,102 +814,115 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) { GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) } -func chaincodeQueryChaincode(user string) error { +// Test the invocation of a transaction. +func TestRangeQuery(t *testing.T) { + //TODO enable after ledger enables RangeQuery + t.Skip() + + lis, err := initPeer() + if err != nil { + t.Fail() + t.Logf("Error creating peer: %s", err) + } + + defer finitPeer(lis) + var ctxt = context.Background() - // Deploy first chaincode - url1 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + url := "github.com/hyperledger/fabric/examples/chaincode/go/map" + cID := &pb.ChaincodeID{Name: "tmap", Path: url} - cID1 := &pb.ChaincodeID{Name: "example02", Path: url1} f := "init" - args := util.ToChaincodeArgs(f, "a", "100", "b", "200") + args := util.ToChaincodeArgs(f) - spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} + spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}} - _, err := deploy(ctxt, spec1) - chaincodeID1 := spec1.ChaincodeID.Name + _, err = deploy(ctxt, spec) + chaincodeID := spec.ChaincodeID.Name if err != nil { - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - return fmt.Errorf("Error initializing chaincode %s(%s)", chaincodeID1, err) + t.Fail() + t.Logf("Error initializing chaincode %s(%s)", chaincodeID, err) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) + return } - time.Sleep(time.Second) - - // Deploy second chaincode - url2 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example05" + // Invoke second chaincode, which will inturn invoke the first chaincode + f = "keys" + args = util.ToChaincodeArgs(f) - cID2 := &pb.ChaincodeID{Name: "example05", Path: url2} - f = "init" - args = util.ToChaincodeArgs(f, "sum", "0") + spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}} + _, _, _, err = invoke(ctxt, spec) - spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} + if err != nil { + t.Fail() + t.Logf("Error invoking <%s>: %s", chaincodeID, err) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) + return + } + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) +} - _, err = deploy(ctxt, spec2) - chaincodeID2 := spec2.ChaincodeID.Name +func TestGetEvent(t *testing.T) { + lis, err := initPeer() if err != nil { - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) - return fmt.Errorf("Error initializing chaincode %s(%s)", chaincodeID2, err) + t.Fail() + t.Logf("Error creating peer: %s", err) } - time.Sleep(time.Second) + defer finitPeer(lis) - // Invoke second chaincode, which will inturn query the first chaincode - f = "invoke" - args = util.ToChaincodeArgs(f, chaincodeID1, "sum") + var ctxt = context.Background() - spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} - // Invoke chaincode - var retVal []byte - _, _, retVal, err = invoke(ctxt, spec2) + url := "github.com/hyperledger/fabric/examples/chaincode/go/eventsender" + cID := &pb.ChaincodeID{Name: "esender", Path: url} + f := "init" + spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(f)}} + + _, err = deploy(ctxt, spec) + chaincodeID := spec.ChaincodeID.Name if err != nil { - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) - return fmt.Errorf("Error invoking <%s>: %s", chaincodeID2, err) + t.Fail() + t.Logf("Error initializing chaincode %s(%s)", chaincodeID, err) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) + return } - // Check the return value - result, err := strconv.Atoi(string(retVal)) - if err != nil || result != 300 { - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) - return fmt.Errorf("Incorrect final state after transaction for <%s>: %s", chaincodeID1, err) - } + time.Sleep(time.Second) - // Query second chaincode, which will inturn query the first chaincode - f = "query" - args = util.ToChaincodeArgs(f, chaincodeID1, "sum") + args := util.ToChaincodeArgs("", "i", "am", "satoshi") - spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user} - // Invoke chaincode - _, _, retVal, err = invoke(ctxt, spec2) + spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}} + + var ccevt *pb.ChaincodeEvent + ccevt, _, _, err = invoke(ctxt, spec) if err != nil { - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) - return fmt.Errorf("Error querying <%s>: %s", chaincodeID2, err) + t.Logf("Error invoking chaincode %s(%s)", chaincodeID, err) + t.Fail() } - // Check the return value - result, err = strconv.Atoi(string(retVal)) - if err != nil || result != 300 { - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) - return fmt.Errorf("Incorrect final value after query for <%s>: %s", chaincodeID1, err) + if ccevt == nil { + t.Logf("Error ccevt is nil %s(%s)", chaincodeID, err) + t.Fail() } - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + if ccevt.ChaincodeID != chaincodeID { + t.Logf("Error ccevt id(%s) != cid(%s)", ccevt.ChaincodeID, chaincodeID) + t.Fail() + } - return nil -} + if strings.Index(string(ccevt.Payload), "i,am,satoshi") < 0 { + t.Logf("Error expected event not found (%s)", string(ccevt.Payload)) + t.Fail() + } -// Test the execution of a chaincode query that queries another chaincode without security enabled -func TestChaincodeQueryChaincode(t *testing.T) { - //no longer supporting Query - t.Skip() + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) +} +// Test the execution of a chaincode that queries another chaincode +// example02 implements "query" as a function in Invoke. example05 calls example02 +func TestChaincodeQueryChaincodeUsingInvoke(t *testing.T) { var peerLis net.Listener var err error if peerLis, err = initPeer(); err != nil { @@ -944,27 +933,6 @@ func TestChaincodeQueryChaincode(t *testing.T) { defer finitPeer(peerLis) - if err = chaincodeQueryChaincode(""); err != nil { - t.Fail() - t.Logf("Error executing test %s", err) - return - } -} - -// Test the execution of a chaincode that queries another chaincode with invalid parameter. Should receive error from -// from the called chaincode -func TestChaincodeQueryChaincodeErrorCase(t *testing.T) { - //query no longer supported - t.Skip() - - lis, err := initPeer() - if err != nil { - t.Fail() - t.Logf("Error creating peer: %s", err) - } - - defer finitPeer(lis) - var ctxt = context.Background() // Deploy first chaincode @@ -979,178 +947,90 @@ func TestChaincodeQueryChaincodeErrorCase(t *testing.T) { _, err = deploy(ctxt, spec1) chaincodeID1 := spec1.ChaincodeID.Name if err != nil { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) t.Fail() t.Logf("Error initializing chaincode %s(%s)", chaincodeID1, err) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) return } time.Sleep(time.Second) // Deploy second chaincode - url2 := "github.com/hyperledger/fabric/examples/chaincode/go/passthru" + url2 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example05" - cID2 := &pb.ChaincodeID{Name: "pthru", Path: url2} + cID2 := &pb.ChaincodeID{Name: "example05", Path: url2} f = "init" - args = util.ToChaincodeArgs(f) + args = util.ToChaincodeArgs(f, "sum", "0") spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}} _, err = deploy(ctxt, spec2) chaincodeID2 := spec2.ChaincodeID.Name if err != nil { - t.Fail() - t.Logf("Error initializing chaincode %s(%s)", chaincodeID2, err) GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + t.Fail() + t.Logf("Error initializing chaincode %s(%s)", chaincodeID2, err) return } time.Sleep(time.Second) - // Invoke second chaincode, which will inturn invoke the first chaincode but pass bad params - f = chaincodeID1 - args = util.ToChaincodeArgs(f, "query", "c") + // Invoke second chaincode, which will inturn query the first chaincode + f = "invoke" + args = util.ToChaincodeArgs(f, chaincodeID1, "sum") spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}} // Invoke chaincode - _, _, _, err = invoke(ctxt, spec2) + var retVal []byte + _, _, retVal, err = invoke(ctxt, spec2) - if err == nil { - t.Fail() - t.Logf("Error invoking <%s>: %s", chaincodeID2, err) + if err != nil { GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) + t.Fail() + t.Logf("Error invoking <%s>: %s", chaincodeID2, err) return } - if strings.Index(err.Error(), "Nil amount for c") < 0 { - t.Fail() - t.Logf("Unexpected error %s", err) + // Check the return value + result, err := strconv.Atoi(string(retVal)) + if err != nil || result != 300 { GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) - return - } - - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) -} - -// Test the execution of a chaincode query that queries another chaincode with security enabled -// NOTE: this really needs to be a behave test. Remove when we have support in behave for multiple chaincodes -func TestChaincodeQueryChaincodeWithSec(t *testing.T) { - //query no longer supported - t.Skip() - - viper.Set("security.enabled", "true") - - //TODO: integrate new crypto / idp code if applicable -} - -// Test the invocation of a transaction. -func TestRangeQuery(t *testing.T) { - //TODO enable after ledger enables RangeQuery - t.Skip() - - lis, err := initPeer() - if err != nil { - t.Fail() - t.Logf("Error creating peer: %s", err) - } - - defer finitPeer(lis) - - var ctxt = context.Background() - - url := "github.com/hyperledger/fabric/examples/chaincode/go/map" - cID := &pb.ChaincodeID{Name: "tmap", Path: url} - - f := "init" - args := util.ToChaincodeArgs(f) - - spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}} - - _, err = deploy(ctxt, spec) - chaincodeID := spec.ChaincodeID.Name - if err != nil { t.Fail() - t.Logf("Error initializing chaincode %s(%s)", chaincodeID, err) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) + t.Logf("Incorrect final state after transaction for <%s>: %s", chaincodeID1, err) return } - // Invoke second chaincode, which will inturn invoke the first chaincode - f = "keys" - args = util.ToChaincodeArgs(f) + // Query second chaincode, which will inturn query the first chaincode + f = "query" + args = util.ToChaincodeArgs(f, chaincodeID1, "sum") - spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}} - _, _, _, err = invoke(ctxt, spec) + spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}} + // Invoke chaincode + _, _, retVal, err = invoke(ctxt, spec2) if err != nil { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) t.Fail() - t.Logf("Error invoking <%s>: %s", chaincodeID, err) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) + t.Logf("Error querying <%s>: %s", chaincodeID2, err) return } - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) -} -func TestGetEvent(t *testing.T) { - lis, err := initPeer() - if err != nil { - t.Fail() - t.Logf("Error creating peer: %s", err) - } - - defer finitPeer(lis) - - var ctxt = context.Background() - - url := "github.com/hyperledger/fabric/examples/chaincode/go/eventsender" - - cID := &pb.ChaincodeID{Name: "esender", Path: url} - f := "init" - spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(f)}} - - _, err = deploy(ctxt, spec) - chaincodeID := spec.ChaincodeID.Name - if err != nil { + // Check the return value + result, err = strconv.Atoi(string(retVal)) + if err != nil || result != 300 { + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) t.Fail() - t.Logf("Error initializing chaincode %s(%s)", chaincodeID, err) - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) + t.Logf("Incorrect final value after query for <%s>: %s", chaincodeID1, err) return } - time.Sleep(time.Second) - - args := util.ToChaincodeArgs("", "i", "am", "satoshi") - - spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}} - - var ccevt *pb.ChaincodeEvent - ccevt, _, _, err = invoke(ctxt, spec) - - if err != nil { - t.Logf("Error invoking chaincode %s(%s)", chaincodeID, err) - t.Fail() - } - - if ccevt == nil { - t.Logf("Error ccevt is nil %s(%s)", chaincodeID, err) - t.Fail() - } - - if ccevt.ChaincodeID != chaincodeID { - t.Logf("Error ccevt id(%s) != cid(%s)", ccevt.ChaincodeID, chaincodeID) - t.Fail() - } - - if strings.Index(string(ccevt.Payload), "i,am,satoshi") < 0 { - t.Logf("Error expected event not found (%s)", string(ccevt.Payload)) - t.Fail() - } - - GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1}) + GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2}) } var signer msp.SigningIdentity @@ -1162,9 +1042,9 @@ func TestMain(m *testing.M) { // setup the MSP manager so that we can sign/verify mspMgrConfigFile := "../../msp/peer-config.json" msp.GetManager().Setup(mspMgrConfigFile) - mspId := "DEFAULT" + mspID := "DEFAULT" id := "PEER" - signingIdentity := &msp.IdentityIdentifier{Mspid: msp.ProviderIdentifier{Value: mspId}, Value: id} + signingIdentity := &msp.IdentityIdentifier{Mspid: msp.ProviderIdentifier{Value: mspID}, Value: id} signer, err = msp.GetManager().GetSigningIdentity(signingIdentity) if err != nil { os.Exit(-1) diff --git a/core/chaincode/handler.go b/core/chaincode/handler.go index 2e9281c5685..240e414d651 100644 --- a/core/chaincode/handler.go +++ b/core/chaincode/handler.go @@ -24,7 +24,6 @@ import ( "github.com/golang/protobuf/proto" ccintf "github.com/hyperledger/fabric/core/container/ccintf" - "github.com/hyperledger/fabric/core/crypto" "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/util" pb "github.com/hyperledger/fabric/protos/peer" @@ -54,8 +53,8 @@ type MessageHandler interface { } type transactionContext struct { - transactionSecContext *pb.Transaction - responseNotifier chan *pb.ChaincodeMessage + proposal *pb.Proposal + responseNotifier chan *pb.ChaincodeMessage // tracks open iterators used for range queries rangeQueryIteratorMap map[string]ledger.ResultsIterator @@ -77,13 +76,10 @@ type Handler struct { FSM *fsm.FSM ChaincodeID *pb.ChaincodeID - // A copy of decrypted deploy tx this handler manages, no code - deployTXSecContext *pb.Transaction - chaincodeSupport *ChaincodeSupport registered bool readyNotify chan bool - // Map of tx txid to either invoke or query tx (decrypted). Each tx will be + // Map of tx txid to either invoke or query tx. Each tx will be // added prior to execute and remove when done execute txCtxs map[string]*transactionContext @@ -113,7 +109,7 @@ func (handler *Handler) serialSend(msg *pb.ChaincodeMessage) error { return nil } -func (handler *Handler) createTxContext(ctxt context.Context, txid string, tx *pb.Transaction) (*transactionContext, error) { +func (handler *Handler) createTxContext(ctxt context.Context, txid string, prop *pb.Proposal) (*transactionContext, error) { if handler.txCtxs == nil { return nil, fmt.Errorf("cannot create notifier for txid:%s", txid) } @@ -122,7 +118,7 @@ func (handler *Handler) createTxContext(ctxt context.Context, txid string, tx *p if handler.txCtxs[txid] != nil { return nil, fmt.Errorf("txid:%s exists", txid) } - txctx := &transactionContext{transactionSecContext: tx, responseNotifier: make(chan *pb.ChaincodeMessage, 1), + txctx := &transactionContext{proposal: prop, responseNotifier: make(chan *pb.ChaincodeMessage, 1), rangeQueryIteratorMap: make(map[string]ledger.ResultsIterator)} handler.txCtxs[txid] = txctx txctx.txsimulator = getTxSimulator(ctxt) @@ -166,21 +162,10 @@ func (handler *Handler) deleteRangeQueryIterator(txContext *transactionContext, //THIS CAN BE REMOVED ONCE WE FULL SUPPORT (Invoke and Query) CONFIDENTIALITY WITH CC-CALLING-CC //Only invocation are allowed, not queries func (handler *Handler) canCallChaincode(txid string, isQuery bool) *pb.ChaincodeMessage { - secHelper := handler.chaincodeSupport.getSecHelper() - if secHelper == nil { - return nil - } - var errMsg string txctx := handler.getTxContext(txid) if txctx == nil { errMsg = fmt.Sprintf("[%s]Error no context while checking for confidentiality. Sending %s", shorttxid(txid), pb.ChaincodeMessage_ERROR) - } else if txctx.transactionSecContext == nil { - errMsg = fmt.Sprintf("[%s]Error transaction context is nil while checking for confidentiality. Sending %s", shorttxid(txid), pb.ChaincodeMessage_ERROR) - } else if txctx.transactionSecContext.ConfidentialityLevel != pb.ConfidentialityLevel_PUBLIC { - if isQuery { - errMsg = fmt.Sprintf("[%s]Error chaincode-chaincode interactions not supported for with privacy enabled. Sending %s", shorttxid(txid), pb.ChaincodeMessage_ERROR) - } } if errMsg != "" { @@ -191,74 +176,6 @@ func (handler *Handler) canCallChaincode(txid string, isQuery bool) *pb.Chaincod return nil } -func (handler *Handler) encryptOrDecrypt(encrypt bool, txid string, payload []byte) ([]byte, error) { - secHelper := handler.chaincodeSupport.getSecHelper() - if secHelper == nil { - return payload, nil - } - - txctx := handler.getTxContext(txid) - if txctx == nil { - return nil, fmt.Errorf("[%s]No context for txid %s", shorttxid(txid), txid) - } - if txctx.transactionSecContext == nil { - return nil, fmt.Errorf("[%s]transaction context is nil for txid %s", shorttxid(txid), txid) - } - // TODO: this must be removed - if txctx.transactionSecContext.ConfidentialityLevel == pb.ConfidentialityLevel_PUBLIC { - return payload, nil - } - - var enc crypto.StateEncryptor - var err error - if txctx.transactionSecContext.Type == pb.Transaction_CHAINCODE_DEPLOY { - if enc, err = secHelper.GetStateEncryptor(handler.deployTXSecContext, handler.deployTXSecContext); err != nil { - chaincodeLogger.Errorf("error getting crypto encryptor for deploy tx :%s", err) - return nil, fmt.Errorf("error getting crypto encryptor for deploy tx :%s", err) - } - } else if txctx.transactionSecContext.Type == pb.Transaction_CHAINCODE_INVOKE || txctx.transactionSecContext.Type == pb.Transaction_CHAINCODE_QUERY { - if enc, err = secHelper.GetStateEncryptor(handler.deployTXSecContext, txctx.transactionSecContext); err != nil { - chaincodeLogger.Errorf("error getting crypto encryptor %s", err) - return nil, fmt.Errorf("error getting crypto encryptor %s", err) - } - } else { - return nil, fmt.Errorf("invalid transaction type %s", txctx.transactionSecContext.Type.String()) - } - if enc == nil { - return nil, fmt.Errorf("secure context returns nil encryptor for tx %s", txid) - } - if chaincodeLogger.IsEnabledFor(logging.DEBUG) { - chaincodeLogger.Debugf("[%s]Payload before encrypt/decrypt: %v", shorttxid(txid), payload) - } - if encrypt { - payload, err = enc.Encrypt(payload) - } else { - payload, err = enc.Decrypt(payload) - } - if chaincodeLogger.IsEnabledFor(logging.DEBUG) { - chaincodeLogger.Debugf("[%s]Payload after encrypt/decrypt: %v", shorttxid(txid), payload) - } - - return payload, err -} - -func (handler *Handler) decrypt(txid string, payload []byte) ([]byte, error) { - return handler.encryptOrDecrypt(false, txid, payload) -} - -func (handler *Handler) encrypt(txid string, payload []byte) ([]byte, error) { - return handler.encryptOrDecrypt(true, txid, payload) -} - -func (handler *Handler) getSecurityBinding(tx *pb.Transaction) ([]byte, error) { - secHelper := handler.chaincodeSupport.getSecHelper() - if secHelper == nil { - return nil, nil - } - - return secHelper.GetTransactionBinding(tx) -} - func (handler *Handler) deregister() error { if handler.registered { handler.chaincodeSupport.deregisterHandler(handler) @@ -632,22 +549,13 @@ func (handler *Handler) handleGetState(msg *pb.ChaincodeMessage) { chaincodeLogger.Errorf("[%s]Failed to get chaincode state(%s). Sending %s", shorttxid(msg.Txid), err, pb.ChaincodeMessage_ERROR) serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: payload, Txid: msg.Txid} } else if res == nil { - //The state object being requested does not exist, so don't attempt to decrypt it + //The state object being requested does not exist chaincodeLogger.Debugf("[%s]No state associated with key: %s. Sending %s with an empty payload", shorttxid(msg.Txid), key, pb.ChaincodeMessage_RESPONSE) serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE, Payload: res, Txid: msg.Txid} } else { - // Decrypt the data if the confidential is enabled - if res, err = handler.decrypt(msg.Txid, res); err == nil { - // Send response msg back to chaincode. GetState will not trigger event - chaincodeLogger.Debugf("[%s]Got state. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_RESPONSE) - serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE, Payload: res, Txid: msg.Txid} - } else { - // Send err msg back to chaincode. - chaincodeLogger.Errorf("[%s]Got error (%s) while decrypting. Sending %s", shorttxid(msg.Txid), err, pb.ChaincodeMessage_ERROR) - errBytes := []byte(err.Error()) - serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: errBytes, Txid: msg.Txid} - } - + // Send response msg back to chaincode. GetState will not trigger event + chaincodeLogger.Debugf("[%s]Got state. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_RESPONSE) + serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE, Payload: res, Txid: msg.Txid} } }() @@ -730,19 +638,7 @@ func (handler *Handler) handleRangeQueryState(msg *pb.ChaincodeMessage) { } //PDMP - let it panic if not KV kv := qresult.(ledger.KV) - // Decrypt the data if the confidential is enabled - decryptedValue, decryptErr := handler.decrypt(msg.Txid, kv.Value) - if decryptErr != nil { - payload := []byte(decryptErr.Error()) - chaincodeLogger.Errorf("Failed decrypt value. Sending %s", pb.ChaincodeMessage_ERROR) - serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: payload, Txid: msg.Txid} - - rangeIter.Close() - handler.deleteRangeQueryIterator(txContext, iterID) - - return - } - keyAndValue := pb.RangeQueryStateKeyValue{Key: kv.Key, Value: decryptedValue} + keyAndValue := pb.RangeQueryStateKeyValue{Key: kv.Key, Value: kv.Value} keysAndValues = append(keysAndValues, &keyAndValue) } @@ -841,19 +737,7 @@ func (handler *Handler) handleRangeQueryStateNext(msg *pb.ChaincodeMessage) { } //PDMP - let it panic if not KV kv := qresult.(ledger.KV) - // Decrypt the data if the confidential is enabled - decryptedValue, decryptErr := handler.decrypt(msg.Txid, kv.Value) - if decryptErr != nil { - payload := []byte(decryptErr.Error()) - chaincodeLogger.Errorf("Failed decrypt value. Sending %s", pb.ChaincodeMessage_ERROR) - serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: payload, Txid: msg.Txid} - - rangeIter.Close() - handler.deleteRangeQueryIterator(txContext, rangeQueryStateNext.ID) - - return - } - keyAndValue := pb.RangeQueryStateKeyValue{Key: kv.Key, Value: decryptedValue} + keyAndValue := pb.RangeQueryStateKeyValue{Key: kv.Key, Value: kv.Value} keysAndValues = append(keysAndValues, &keyAndValue) } @@ -1030,14 +914,9 @@ func (handler *Handler) enterBusyState(e *fsm.Event, state string) { return } - var pVal []byte - // Encrypt the data if the confidential is enabled - if pVal, err = handler.encrypt(msg.Txid, putStateInfo.Value); err == nil { - // Invoke ledger to put state - txContext := handler.getTxContext(msg.Txid) - err = txContext.txsimulator.SetState(chaincodeID, putStateInfo.Key, pVal) - - } + // Invoke ledger to put state + txContext := handler.getTxContext(msg.Txid) + err = txContext.txsimulator.SetState(chaincodeID, putStateInfo.Key, putStateInfo.Value) } else if msg.Type.String() == pb.ChaincodeMessage_DEL_STATE.String() { // Invoke ledger to delete state key := string(msg.Payload) @@ -1067,12 +946,11 @@ func (handler *Handler) enterBusyState(e *fsm.Event, state string) { ctxt := context.Background() ctxt = context.WithValue(ctxt, TXSimulatorKey, txContext.txsimulator) - // Create the transaction object + // Create the invocation spec chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: chaincodeSpec} - transaction, _ := pb.NewChaincodeExecute(chaincodeInvocationSpec, msg.Txid, pb.Transaction_CHAINCODE_INVOKE) // Launch the new chaincode if not already running - _, chaincodeInput, launchErr := handler.chaincodeSupport.Launch(ctxt, transaction) + _, chaincodeInput, launchErr := handler.chaincodeSupport.Launch(ctxt, msg.Txid, txContext.proposal, chaincodeInvocationSpec) if launchErr != nil { payload := []byte(launchErr.Error()) chaincodeLogger.Debugf("[%s]Failed to launch invoked chaincode. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_ERROR) @@ -1083,11 +961,10 @@ func (handler *Handler) enterBusyState(e *fsm.Event, state string) { // TODO: Need to handle timeout correctly timeout := time.Duration(30000) * time.Millisecond - ccMsg, _ := createTransactionMessage(transaction.Txid, chaincodeInput) + ccMsg, _ := createTransactionMessage(msg.Txid, chaincodeInput) // Execute the chaincode - //NOTE: when confidential C-call-C is understood, transaction should have the correct sec context for enc/dec - response, execErr := handler.chaincodeSupport.Execute(ctxt, newChaincodeID, ccMsg, timeout, transaction) + response, execErr := handler.chaincodeSupport.Execute(ctxt, newChaincodeID, ccMsg, timeout, txContext.proposal) //payload is marshalled and send to the calling chaincode's shim which unmarshals and //sends it to chaincode @@ -1138,16 +1015,6 @@ func (handler *Handler) enterInitState(e *fsm.Event, state string) { func (handler *Handler) enterReadyState(e *fsm.Event, state string) { // Now notify msg, ok := e.Args[0].(*pb.ChaincodeMessage) - //we have to encrypt chaincode event payload. We cannot encrypt event type as - //it is needed by the event system to filter clients by - if ok && msg.ChaincodeEvent != nil && msg.ChaincodeEvent.Payload != nil { - var err error - if msg.Payload, err = handler.encrypt(msg.Txid, msg.Payload); nil != err { - chaincodeLogger.Errorf("[%s]Failed to encrypt chaincode event payload", msg.Txid) - msg.Payload = []byte(fmt.Sprintf("Failed to encrypt chaincode event payload %s", err.Error())) - msg.Type = pb.ChaincodeMessage_ERROR - } - } handler.deleteIsTransaction(msg.Txid) if !ok { e.Cancel(fmt.Errorf("Received unexpected message type")) @@ -1171,109 +1038,21 @@ func (handler *Handler) enterEndState(e *fsm.Event, state string) { e.Cancel(fmt.Errorf("Entered end state")) } -func (handler *Handler) cloneTx(tx *pb.Transaction) (*pb.Transaction, error) { - raw, err := proto.Marshal(tx) - if err != nil { - chaincodeLogger.Errorf("Failed marshalling transaction [%s].", err.Error()) - return nil, err - } - - clone := &pb.Transaction{} - err = proto.Unmarshal(raw, clone) - if err != nil { - chaincodeLogger.Errorf("Failed unmarshalling transaction [%s].", err.Error()) - return nil, err - } - - return clone, nil -} - -func (handler *Handler) initializeSecContext(tx, depTx *pb.Transaction) error { - //set deploy transaction on the handler - if depTx != nil { - //we are given a deep clone of depTx.. Just use it - handler.deployTXSecContext = depTx - } else { - //nil depTx => tx is a deploy transaction, clone it - var err error - handler.deployTXSecContext, err = handler.cloneTx(tx) - if err != nil { - return fmt.Errorf("Failed to clone transaction: %s\n", err) - } - } - - //don't need the payload which is not useful and rather large - handler.deployTXSecContext.Payload = nil - - //we need to null out path from depTx as invoke or queries don't have it - cID := &pb.ChaincodeID{} - err := proto.Unmarshal(handler.deployTXSecContext.ChaincodeID, cID) - if err != nil { - return fmt.Errorf("Failed to unmarshall : %s\n", err) - } - - cID.Path = "" - data, err := proto.Marshal(cID) - if err != nil { - return fmt.Errorf("Failed to marshall : %s\n", err) - } - - handler.deployTXSecContext.ChaincodeID = data - - return nil -} - -func (handler *Handler) setChaincodeSecurityContext(tx, depTx *pb.Transaction, msg *pb.ChaincodeMessage) error { - chaincodeLogger.Debug("setting chaincode security context...") - if msg.SecurityContext == nil { - msg.SecurityContext = &pb.ChaincodeSecurityContext{} - } - if tx != nil { - chaincodeLogger.Debug("setting chaincode security context. Transaction different from nil") - chaincodeLogger.Debugf("setting chaincode security context. Metadata [% x]", tx.Metadata) - - msg.SecurityContext.CallerCert = tx.Cert - msg.SecurityContext.CallerSign = tx.Signature - binding, err := handler.getSecurityBinding(tx) - if err != nil { - chaincodeLogger.Errorf("Failed getting binding [%s]", err) - return err - } - msg.SecurityContext.Binding = binding - msg.SecurityContext.Metadata = tx.Metadata - - cis := &pb.ChaincodeInvocationSpec{} - if err := proto.Unmarshal(tx.Payload, cis); err != nil { - chaincodeLogger.Errorf("Failed getting payload [%s]", err) - return err - } - - ctorMsgRaw, err := proto.Marshal(cis.ChaincodeSpec.GetCtorMsg()) - if err != nil { - chaincodeLogger.Errorf("Failed getting ctorMsgRaw [%s]", err) - return err - } - - msg.SecurityContext.Payload = ctorMsgRaw - // TODO: add deploy metadata - if depTx != nil { - msg.SecurityContext.ParentMetadata = depTx.Metadata - } else { - msg.SecurityContext.ParentMetadata = handler.deployTXSecContext.Metadata - } - msg.SecurityContext.Payload = ctorMsgRaw - msg.SecurityContext.TxTimestamp = tx.Timestamp +func (handler *Handler) setChaincodeProposal(prop *pb.Proposal, msg *pb.ChaincodeMessage) error { + chaincodeLogger.Debug("setting chaincode proposal...") + if prop != nil { + chaincodeLogger.Debug("TODO pass Proposal to chaincode...") } return nil } //if initArgs is set (should be for "deploy" only) move to Init //else move to ready -func (handler *Handler) initOrReady(ctxt context.Context, txid string, initArgs [][]byte, tx *pb.Transaction, depTx *pb.Transaction) (chan *pb.ChaincodeMessage, error) { +func (handler *Handler) initOrReady(ctxt context.Context, txid string, prop *pb.Proposal, initArgs [][]byte) (chan *pb.ChaincodeMessage, error) { var ccMsg *pb.ChaincodeMessage var send bool - txctx, funcErr := handler.createTxContext(ctxt, txid, tx) + txctx, funcErr := handler.createTxContext(ctxt, txid, prop) if funcErr != nil { return nil, funcErr } @@ -1296,13 +1075,8 @@ func (handler *Handler) initOrReady(ctxt context.Context, txid string, initArgs send = true } - if err := handler.initializeSecContext(tx, depTx); err != nil { - handler.deleteTxContext(txid) - return nil, err - } - //if security is disabled the context elements will just be nil - if err := handler.setChaincodeSecurityContext(tx, depTx, ccMsg); err != nil { + if err := handler.setChaincodeProposal(prop, ccMsg); err != nil { return nil, err } @@ -1346,16 +1120,15 @@ func (handler *Handler) handleQueryChaincode(msg *pb.ChaincodeMessage) { // Get the chaincodeID to invoke newChaincodeID := chaincodeSpec.ChaincodeID.Name - // Create the transaction object + // Create the invocation spec chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: chaincodeSpec} - transaction, _ := pb.NewChaincodeExecute(chaincodeInvocationSpec, msg.Txid, pb.Transaction_CHAINCODE_QUERY) txContext := handler.getTxContext(msg.Txid) ctxt := context.Background() ctxt = context.WithValue(ctxt, TXSimulatorKey, txContext.txsimulator) // Launch the new chaincode if not already running - _, chaincodeInput, launchErr := handler.chaincodeSupport.Launch(ctxt, transaction) + _, chaincodeInput, launchErr := handler.chaincodeSupport.Launch(ctxt, msg.Txid, txContext.proposal, chaincodeInvocationSpec) if launchErr != nil { payload := []byte(launchErr.Error()) chaincodeLogger.Debugf("[%s]Failed to launch invoked chaincode. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_ERROR) @@ -1366,11 +1139,12 @@ func (handler *Handler) handleQueryChaincode(msg *pb.ChaincodeMessage) { // TODO: Need to handle timeout correctly timeout := time.Duration(30000) * time.Millisecond - ccMsg, _ := createQueryMessage(transaction.Txid, chaincodeInput) + //queries are all invokes + ccMsg, _ := createTransactionMessage(msg.Txid, chaincodeInput) // Query the chaincode //NOTE: when confidential C-call-C is understood, transaction should have the correct sec context for enc/dec - response, execErr := handler.chaincodeSupport.Execute(ctxt, newChaincodeID, ccMsg, timeout, transaction) + response, execErr := handler.chaincodeSupport.Execute(ctxt, newChaincodeID, ccMsg, timeout, txContext.proposal) if execErr != nil { // Send error msg back to chaincode and trigger event @@ -1399,29 +1173,6 @@ func (handler *Handler) handleQueryChaincode(msg *pb.ChaincodeMessage) { func (handler *Handler) HandleMessage(msg *pb.ChaincodeMessage) error { chaincodeLogger.Debugf("[%s]Handling ChaincodeMessage of type: %s in state %s", shorttxid(msg.Txid), msg.Type, handler.FSM.Current()) - //QUERY_COMPLETED message can happen ONLY for Transaction_QUERY (stateless) - if msg.Type == pb.ChaincodeMessage_QUERY_COMPLETED { - chaincodeLogger.Debugf("[%s]HandleMessage- QUERY_COMPLETED. Notify", msg.Txid) - handler.deleteIsTransaction(msg.Txid) - var err error - if msg.Payload, err = handler.encrypt(msg.Txid, msg.Payload); nil != err { - chaincodeLogger.Errorf("[%s]Failed to encrypt query result %s", msg.Txid, string(msg.Payload)) - msg.Payload = []byte(fmt.Sprintf("Failed to encrypt query result %s", err.Error())) - msg.Type = pb.ChaincodeMessage_QUERY_ERROR - } - handler.notify(msg) - return nil - } else if msg.Type == pb.ChaincodeMessage_QUERY_ERROR { - chaincodeLogger.Debugf("[%s]HandleMessage- QUERY_ERROR (%s). Notify", msg.Txid, string(msg.Payload)) - handler.deleteIsTransaction(msg.Txid) - handler.notify(msg) - return nil - } else if msg.Type == pb.ChaincodeMessage_INVOKE_QUERY { - // Received request to query another chaincode from shim - chaincodeLogger.Debugf("[%s]HandleMessage- Received request to query another chaincode", msg.Txid) - handler.handleQueryChaincode(msg) - return nil - } if handler.FSM.Cannot(msg.Type.String()) { // Check if this is a request from validator in query context if msg.Type.String() == pb.ChaincodeMessage_PUT_STATE.String() || msg.Type.String() == pb.ChaincodeMessage_DEL_STATE.String() || msg.Type.String() == pb.ChaincodeMessage_INVOKE_CHAINCODE.String() { @@ -1468,22 +1219,18 @@ func filterError(errFromFSMEvent error) error { return nil } -func (handler *Handler) sendExecuteMessage(ctxt context.Context, msg *pb.ChaincodeMessage, tx *pb.Transaction) (chan *pb.ChaincodeMessage, error) { - txctx, err := handler.createTxContext(ctxt, msg.Txid, tx) +func (handler *Handler) sendExecuteMessage(ctxt context.Context, msg *pb.ChaincodeMessage, prop *pb.Proposal) (chan *pb.ChaincodeMessage, error) { + txctx, err := handler.createTxContext(ctxt, msg.Txid, prop) if err != nil { return nil, err } // Mark TXID as either transaction or query chaincodeLogger.Debugf("[%s]Inside sendExecuteMessage. Message %s", shorttxid(msg.Txid), msg.Type.String()) - if msg.Type.String() == pb.ChaincodeMessage_QUERY.String() { - handler.markIsTransaction(msg.Txid, false) - } else { - handler.markIsTransaction(msg.Txid, true) - } + handler.markIsTransaction(msg.Txid, true) //if security is disabled the context elements will just be nil - if err := handler.setChaincodeSecurityContext(tx, nil, msg); err != nil { + if err := handler.setChaincodeProposal(prop, msg); err != nil { return nil, err } diff --git a/core/chaincode/lccc.go b/core/chaincode/lccc.go index ccb9e21c5be..6cab9957272 100644 --- a/core/chaincode/lccc.go +++ b/core/chaincode/lccc.go @@ -24,6 +24,7 @@ import ( "github.com/hyperledger/fabric/core/chaincode/shim" "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger/kvledger" + "github.com/hyperledger/fabric/core/util" pb "github.com/hyperledger/fabric/protos/peer" "github.com/op/go-logging" "golang.org/x/net/context" @@ -255,13 +256,6 @@ func (lccc *LifeCycleSysCC) isValidChaincodeName(chaincodename string) bool { //deploy the chaincode on to the chain func (lccc *LifeCycleSysCC) deploy(stub shim.ChaincodeStubInterface, chainname string, cds *pb.ChaincodeDeploymentSpec) error { - //TODO : this needs to be converted to another data structure to be handled - // by the chaincode framework (which currently handles "Transaction") - t, err := lccc.toTransaction(cds) - if err != nil { - return fmt.Errorf("could not convert proposal to transaction %s", err) - } - //if unit testing, just return..we cannot do the actual deploy if _, ismock := stub.(*shim.MockStub); ismock { //we got this far just stop short of actual deploy for test purposes @@ -280,6 +274,7 @@ func (lccc *LifeCycleSysCC) deploy(stub shim.ChaincodeStubInterface, chainname s lgr := kvledger.GetLedger(chainname) var dummytxsim ledger.TxSimulator + var err error if dummytxsim, err = lgr.NewTxSimulator(); err != nil { return fmt.Errorf("Could not get simulator for %s", chainname) @@ -290,13 +285,16 @@ func (lccc *LifeCycleSysCC) deploy(stub shim.ChaincodeStubInterface, chainname s //TODO - create chaincode support for chainname, for now use DefaultChain chaincodeSupport := GetChain(ChainName(chainname)) - _, err = chaincodeSupport.Deploy(ctxt, t) + _, err = chaincodeSupport.Deploy(ctxt, cds) if err != nil { return fmt.Errorf("Failed to deploy chaincode spec(%s)", err) } + //we don't need the original txid (in fact we need a new one) + txid := util.GenerateUUID() + //launch and wait for ready - _, _, err = chaincodeSupport.Launch(ctxt, t) + _, _, err = chaincodeSupport.Launch(ctxt, txid, nil, cds) if err != nil { return fmt.Errorf("%s", err) } @@ -350,11 +348,6 @@ func (lccc *LifeCycleSysCC) executeDeploy(stub shim.ChaincodeStubInterface, chai return err } -//TODO - this is temporary till we use Transaction in chaincode code -func (lccc *LifeCycleSysCC) toTransaction(cds *pb.ChaincodeDeploymentSpec) (*pb.Transaction, error) { - return pb.NewChaincodeDeployTransaction(cds, cds.ChaincodeSpec.ChaincodeID.Name) -} - //-------------- the chaincode stub interface implementation ---------- //Init does nothing diff --git a/core/chaincode/lccc_test.go b/core/chaincode/lccc_test.go index 00c6ac5d256..c80c2f3cc1c 100644 --- a/core/chaincode/lccc_test.go +++ b/core/chaincode/lccc_test.go @@ -58,7 +58,7 @@ func initialize() { } ccStartupTimeout := time.Duration(30000) * time.Millisecond - pb.RegisterChaincodeSupportServer(grpcServer, NewChaincodeSupport(DefaultChain, getPeerEndpoint, false, ccStartupTimeout, nil)) + pb.RegisterChaincodeSupportServer(grpcServer, NewChaincodeSupport(DefaultChain, getPeerEndpoint, false, ccStartupTimeout)) } //TestDeploy tests the deploy function (stops short of actually running the chaincode) diff --git a/core/chaincode/shim/chaincode.go b/core/chaincode/shim/chaincode.go index c423b45daf0..daa09cdaf42 100644 --- a/core/chaincode/shim/chaincode.go +++ b/core/chaincode/shim/chaincode.go @@ -47,11 +47,10 @@ var chaincodeLogger = logging.MustGetLogger("shim") // ChaincodeStub is an object passed to chaincode for shim side handling of // APIs. type ChaincodeStub struct { - TxID string - securityContext *pb.ChaincodeSecurityContext - chaincodeEvent *pb.ChaincodeEvent - args [][]byte - handler *Handler + TxID string + chaincodeEvent *pb.ChaincodeEvent + args [][]byte + handler *Handler } // Peer address derived from command line or env var @@ -259,26 +258,17 @@ func chatWithPeer(chaincodename string, stream PeerChaincodeStream, cc Chaincode // -- init stub --- // ChaincodeInvocation functionality -func (stub *ChaincodeStub) init(handler *Handler, txid string, secContext *pb.ChaincodeSecurityContext) { +func (stub *ChaincodeStub) init(handler *Handler, txid string, input *pb.ChaincodeInput) { stub.TxID = txid - stub.securityContext = secContext - stub.args = [][]byte{} - newCI := pb.ChaincodeInput{} - err := proto.Unmarshal(secContext.Payload, &newCI) - if err == nil { - stub.args = newCI.Args - } else { - panic("Arguments cannot be unmarshalled.") - } + stub.args = input.Args stub.handler = handler } func InitTestStub(funargs ...string) *ChaincodeStub { stub := ChaincodeStub{} allargs := util.ToChaincodeArgs(funargs...) - newCI := pb.ChaincodeInput{Args: allargs} - pl, _ := proto.Marshal(&newCI) - stub.init(&Handler{}, "TEST-txid", &pb.ChaincodeSecurityContext{Payload: pl}) + newCI := &pb.ChaincodeInput{Args: allargs} + stub.init(&Handler{}, "TEST-txid", newCI) return &stub } @@ -298,13 +288,6 @@ func (stub *ChaincodeStub) InvokeChaincode(chaincodeName string, args [][]byte) return stub.handler.handleInvokeChaincode(chaincodeName, args, stub.TxID) } -// QueryChaincode locally calls the specified chaincode `Query` using the -// same transaction context; that is, chaincode calling chaincode doesn't -// create a new transaction message. -func (stub *ChaincodeStub) QueryChaincode(chaincodeName string, args [][]byte) ([]byte, error) { - return stub.handler.handleQueryChaincode(chaincodeName, args, stub.TxID) -} - // --------- State functions ---------- // GetState returns the byte array value specified by the `key`. @@ -707,30 +690,30 @@ func (stub *ChaincodeStub) VerifySignature(certificate, signature, message []byt // GetCallerCertificate returns caller certificate func (stub *ChaincodeStub) GetCallerCertificate() ([]byte, error) { - return stub.securityContext.CallerCert, nil + return nil, nil } // GetCallerMetadata returns caller metadata func (stub *ChaincodeStub) GetCallerMetadata() ([]byte, error) { - return stub.securityContext.Metadata, nil + return nil, nil } // GetBinding returns the transaction binding func (stub *ChaincodeStub) GetBinding() ([]byte, error) { - return stub.securityContext.Binding, nil + return nil, nil } // GetPayload returns transaction payload, which is a `ChaincodeSpec` defined // in fabric/protos/chaincode.proto func (stub *ChaincodeStub) GetPayload() ([]byte, error) { - return stub.securityContext.Payload, nil + return nil, nil } // GetTxTimestamp returns transaction created timestamp, which is currently // taken from the peer receiving the transaction. Note that this timestamp // may not be the same with the other peers' time. func (stub *ChaincodeStub) GetTxTimestamp() (*timestamp.Timestamp, error) { - return stub.securityContext.TxTimestamp, nil + return nil, nil } func getTable(stub ChaincodeStubInterface, tableName string) (*Table, error) { diff --git a/core/chaincode/shim/handler.go b/core/chaincode/shim/handler.go index e2147955686..361d5aab6e3 100644 --- a/core/chaincode/shim/handler.go +++ b/core/chaincode/shim/handler.go @@ -163,20 +163,14 @@ func newChaincodeHandler(peerChatStream PeerChaincodeStream, chaincode Chaincode {Name: pb.ChaincodeMessage_COMPLETED.String(), Src: []string{"transaction"}, Dst: "ready"}, {Name: pb.ChaincodeMessage_ERROR.String(), Src: []string{"transaction"}, Dst: "ready"}, {Name: pb.ChaincodeMessage_RESPONSE.String(), Src: []string{"transaction"}, Dst: "transaction"}, - {Name: pb.ChaincodeMessage_QUERY.String(), Src: []string{"transaction"}, Dst: "transaction"}, - {Name: pb.ChaincodeMessage_QUERY.String(), Src: []string{"ready"}, Dst: "ready"}, {Name: pb.ChaincodeMessage_RESPONSE.String(), Src: []string{"ready"}, Dst: "ready"}, }, fsm.Callbacks{ "before_" + pb.ChaincodeMessage_REGISTERED.String(): func(e *fsm.Event) { v.beforeRegistered(e) }, - //"after_" + pb.ChaincodeMessage_INIT.String(): func(e *fsm.Event) { v.beforeInit(e) }, - //"after_" + pb.ChaincodeMessage_TRANSACTION.String(): func(e *fsm.Event) { v.beforeTransaction(e) }, - "after_" + pb.ChaincodeMessage_RESPONSE.String(): func(e *fsm.Event) { v.afterResponse(e) }, - "after_" + pb.ChaincodeMessage_ERROR.String(): func(e *fsm.Event) { v.afterError(e) }, - "enter_init": func(e *fsm.Event) { v.enterInitState(e) }, - "enter_transaction": func(e *fsm.Event) { v.enterTransactionState(e) }, - //"enter_ready": func(e *fsm.Event) { v.enterReadyState(e) }, - "before_" + pb.ChaincodeMessage_QUERY.String(): func(e *fsm.Event) { v.beforeQuery(e) }, //only checks for QUERY + "after_" + pb.ChaincodeMessage_RESPONSE.String(): func(e *fsm.Event) { v.afterResponse(e) }, + "after_" + pb.ChaincodeMessage_ERROR.String(): func(e *fsm.Event) { v.afterError(e) }, + "enter_init": func(e *fsm.Event) { v.enterInitState(e) }, + "enter_transaction": func(e *fsm.Event) { v.enterTransactionState(e) }, }, ) return v @@ -222,7 +216,7 @@ 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, msg.SecurityContext) + stub.init(handler, msg.Txid, input) res, err := handler.cc.Init(stub) // delete isTransaction entry @@ -289,7 +283,7 @@ 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, msg.SecurityContext) + stub.init(handler, msg.Txid, input) res, err := handler.cc.Invoke(stub) // delete isTransaction entry @@ -309,53 +303,6 @@ func (handler *Handler) handleTransaction(msg *pb.ChaincodeMessage) { }() } -// handleQuery handles request to execute a query. -func (handler *Handler) handleQuery(msg *pb.ChaincodeMessage) { - // Query does not transition state. It can happen anytime after Ready - go func() { - var serialSendMsg *pb.ChaincodeMessage - - defer func() { - handler.serialSend(serialSendMsg) - }() - - // Get the function and args from Payload - input := &pb.ChaincodeInput{} - unmarshalErr := proto.Unmarshal(msg.Payload, input) - if unmarshalErr != nil { - payload := []byte(unmarshalErr.Error()) - // Send ERROR message to chaincode support and change state - chaincodeLogger.Debugf("[%s]Incorrect payload format. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_QUERY_ERROR) - serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_QUERY_ERROR, Payload: payload, Txid: msg.Txid} - return - } - - // Mark as a query (do not allow put/del state) - handler.markIsTransaction(msg.Txid, false) - - // Call chaincode's Query - // Create the ChaincodeStub which the chaincode can use to callback - stub := new(ChaincodeStub) - stub.init(handler, msg.Txid, msg.SecurityContext) - res, err := handler.cc.Query(stub) - - // delete isTransaction entry - handler.deleteIsTransaction(msg.Txid) - - if err != nil { - payload := []byte(err.Error()) - // Send ERROR message to chaincode support and change state - chaincodeLogger.Errorf("[%s]Query execution failed. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_QUERY_ERROR) - serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_QUERY_ERROR, Payload: payload, Txid: msg.Txid} - return - } - - // Send COMPLETED message to chaincode support - chaincodeLogger.Debugf("[%s]Query completed. Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_QUERY_COMPLETED) - serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_QUERY_COMPLETED, Payload: res, Txid: msg.Txid} - }() -} - // enterTransactionState will execute chaincode's Run if coming from a TRANSACTION event. func (handler *Handler) enterTransactionState(e *fsm.Event) { msg, ok := e.Args[0].(*pb.ChaincodeMessage) @@ -386,18 +333,6 @@ func (handler *Handler) afterCompleted(e *fsm.Event) { } } -// beforeQuery is invoked when a query message is received from the validator -func (handler *Handler) beforeQuery(e *fsm.Event) { - if e.Args != nil { - msg, ok := e.Args[0].(*pb.ChaincodeMessage) - if !ok { - e.Cancel(fmt.Errorf("Received unexpected message type")) - return - } - handler.handleQuery(msg) - } -} - // afterResponse is called to deliver a response or error to the chaincode stub. func (handler *Handler) afterResponse(e *fsm.Event) { msg, ok := e.Args[0].(*pb.ChaincodeMessage) @@ -805,65 +740,6 @@ func (handler *Handler) handleInvokeChaincode(chaincodeName string, args [][]byt return nil, errors.New("Incorrect chaincode message received") } -// handleQueryChaincode communicates with the validator to query another chaincode. -func (handler *Handler) handleQueryChaincode(chaincodeName string, args [][]byte, txid string) ([]byte, error) { - chaincodeID := &pb.ChaincodeID{Name: chaincodeName} - input := &pb.ChaincodeInput{Args: args} - payload := &pb.ChaincodeSpec{ChaincodeID: chaincodeID, CtorMsg: input} - payloadBytes, err := proto.Marshal(payload) - if err != nil { - return nil, errors.New("Failed to process query chaincode request") - } - - // Create the channel on which to communicate the response from validating peer - respChan, uniqueReqErr := handler.createChannel(txid) - if uniqueReqErr != nil { - chaincodeLogger.Debug("Another request pending for this Txid. Cannot process.") - return nil, uniqueReqErr - } - - defer handler.deleteChannel(txid) - - // Send INVOKE_QUERY message to validator chaincode support - msg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_INVOKE_QUERY, Payload: payloadBytes, Txid: txid} - chaincodeLogger.Debugf("[%s]Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_INVOKE_QUERY) - if err = handler.serialSend(msg); err != nil { - chaincodeLogger.Errorf("[%s]error sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_INVOKE_QUERY) - return nil, errors.New("could not send msg") - } - - // Wait on responseChannel for response - responseMsg, ok := handler.receiveChannel(respChan) - if !ok { - chaincodeLogger.Errorf("[%s]Received unexpected message type", shorttxid(msg.Txid)) - return nil, errors.New("Received unexpected message type") - } - - if responseMsg.Type.String() == pb.ChaincodeMessage_RESPONSE.String() { - respMsg := &pb.ChaincodeMessage{} - if err := proto.Unmarshal(responseMsg.Payload, respMsg); err != nil { - chaincodeLogger.Errorf("[%s]Error unmarshaling called chaincode responseP: %s", shorttxid(responseMsg.Txid), err) - return nil, err - } - if respMsg.Type == pb.ChaincodeMessage_QUERY_COMPLETED { - // Success response - chaincodeLogger.Debugf("[%s]Received %s. Successfully queried chaincode", shorttxid(responseMsg.Txid), pb.ChaincodeMessage_RESPONSE) - return respMsg.Payload, nil - } - chaincodeLogger.Errorf("[%s]Error from chaincode: %s", shorttxid(responseMsg.Txid), string(respMsg.Payload[:])) - return nil, errors.New(string(respMsg.Payload[:])) - } - if responseMsg.Type.String() == pb.ChaincodeMessage_ERROR.String() { - // Error response - chaincodeLogger.Errorf("[%s]Received %s.", shorttxid(responseMsg.Txid), pb.ChaincodeMessage_ERROR) - return nil, errors.New(string(responseMsg.Payload[:])) - } - - // Incorrect chaincode message received - chaincodeLogger.Errorf("[%s]Incorrect chaincode message %s recieved. Expecting %s or %s", shorttxid(responseMsg.Txid), responseMsg.Type, pb.ChaincodeMessage_RESPONSE, pb.ChaincodeMessage_ERROR) - return nil, errors.New("Incorrect chaincode message received") -} - // handleMessage message handles loop for shim side of chaincode/validator stream. func (handler *Handler) handleMessage(msg *pb.ChaincodeMessage) error { if msg.Type == pb.ChaincodeMessage_KEEPALIVE { diff --git a/core/chaincode/shim/interfaces.go b/core/chaincode/shim/interfaces.go index ac0363483cb..f6bd6280877 100644 --- a/core/chaincode/shim/interfaces.go +++ b/core/chaincode/shim/interfaces.go @@ -32,10 +32,6 @@ type Chaincode interface { // Invoke is called for every Invoke transactions. The chaincode may change // its state variables Invoke(stub ChaincodeStubInterface) ([]byte, error) - - // Query is called for Query transactions. The chaincode may only read - // (but not modify) its state variables and return the result - Query(stub ChaincodeStubInterface) ([]byte, error) } // ChaincodeStubInterface is used by deployable chaincode apps to access and modify their ledgers @@ -58,11 +54,6 @@ type ChaincodeStubInterface interface { // create a new transaction message. InvokeChaincode(chaincodeName string, args [][]byte) ([]byte, error) - // QueryChaincode locally calls the specified chaincode `Query` using the - // same transaction context; that is, chaincode calling chaincode doesn't - // create a new transaction message. - QueryChaincode(chaincodeName string, args [][]byte) ([]byte, error) - // GetState returns the byte array value specified by the `key`. GetState(key string) ([]byte, error) 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 c529316a8cb..1056d2aecec 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 @@ -120,16 +120,6 @@ public String invokeChaincode(String chaincodeName, String function, List args) { - return handler.handleQueryChaincode(chaincodeName, function, args, uuid).toStringUtf8(); - } - //------RAW CALLS------ /** @@ -159,16 +149,6 @@ public void putRawState(String key, ByteString value) { // return handler.handleRangeQueryState(startKey, endKey, limit, uuid); // } - /** - * @param chaincodeName - * @param function - * @param args - * @return - */ - public ByteString queryRawChaincode(String chaincodeName, String function, List args) { - return handler.handleQueryChaincode(chaincodeName, function, args, uuid); - } - /** * Invokes the provided chaincode with the given function and arguments, and returns the * raw ByteString value that invocation generated. 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 652d602cd4a..efb465bc845 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 @@ -75,8 +75,6 @@ public Handler(StreamObserver chatStream, ChaincodeBase chainc new EventDesc(COMPLETED.toString(), "ready", "transaction"), new EventDesc(ERROR.toString(), "ready", "transaction"), new EventDesc(RESPONSE.toString(), "transaction", "transaction"), - new EventDesc(QUERY.toString(), "transaction", "transaction"), - new EventDesc(QUERY.toString(), "ready", "ready"), new EventDesc(RESPONSE.toString(), "ready", "ready") ); @@ -86,8 +84,7 @@ public Handler(StreamObserver chatStream, ChaincodeBase chainc new CBDesc(AFTER_EVENT, RESPONSE.toString(), (event) -> afterResponse(event)), new CBDesc(AFTER_EVENT, ERROR.toString(), (event) -> afterError(event)), new CBDesc(ENTER_STATE, "init", (event) -> enterInitState(event)), - new CBDesc(ENTER_STATE, "transaction", (event) -> enterTransactionState(event)), - new CBDesc(BEFORE_EVENT, QUERY.toString(), (event) -> beforeQuery(event)) + new CBDesc(ENTER_STATE, "transaction", (event) -> enterTransactionState(event)) ); } @@ -345,67 +342,6 @@ public void handleTransaction(ChaincodeMessage message) { new Thread(task).start(); } - // handleQuery handles request to execute a query. - public void handleQuery(ChaincodeMessage message) { - // Query does not transition state. It can happen anytime after Ready - Runnable task = () -> { - ChaincodeMessage serialSendMessage = null; - try { - // Get the function and args from Payload - ChaincodeInput input; - try { - input = ChaincodeInput.parseFrom(message.getPayload()); - } catch (Exception e) { - // Send ERROR message to chaincode support and change state - logger.debug(String.format("[%s]Incorrect payload format. Sending %s", - shortID(message), QUERY_ERROR)); - serialSendMessage = ChaincodeMessage.newBuilder() - .setType(QUERY_ERROR) - .setPayload(ByteString.copyFromUtf8(e.getMessage())) - .setTxid(message.getTxid()) - .build(); - return; - } - - // Mark as a query (do not allow put/del state) - markIsTransaction(message.getTxid(), false); - - // Call chaincode's Query - // Create the ChaincodeStub which the chaincode can use to callback - ChaincodeStub stub = new ChaincodeStub(message.getTxid(), this); - - - ByteString response; - try { - response = chaincode.queryHelper(stub, getFunction(input.getArgsList()), getParameters(input.getArgsList())); - } catch (Exception e) { - // Send ERROR message to chaincode support and change state - logger.debug(String.format("[%s]Query execution failed. Sending %s", - shortID(message), QUERY_ERROR)); - serialSendMessage = ChaincodeMessage.newBuilder() - .setType(QUERY_ERROR) - .setPayload(ByteString.copyFromUtf8(e.getMessage())) - .setTxid(message.getTxid()) - .build(); - return; - } finally { - deleteIsTransaction(message.getTxid()); - } - - // Send COMPLETED message to chaincode support - logger.debug("["+ shortID(message)+"]Query completed. Sending "+ QUERY_COMPLETED); - serialSendMessage = ChaincodeMessage.newBuilder() - .setType(QUERY_COMPLETED) - .setPayload(response) - .setTxid(message.getTxid()) - .build(); - } finally { - serialSend(serialSendMessage); - } - }; - - new Thread(task).start(); - } // enterTransactionState will execute chaincode's Run if coming from a TRANSACTION event. public void enterTransactionState(Event event) { @@ -429,12 +365,6 @@ public void afterCompleted(Event event) { } } - // beforeQuery is invoked when a query message is received from the validator - public void beforeQuery(Event event) { - ChaincodeMessage message = messageHelper(event); - handleQuery(message); - } - // afterResponse is called to deliver a response or error to the chaincode stub. public void afterResponse(Event event) { ChaincodeMessage message = messageHelper(event); @@ -821,77 +751,6 @@ public ByteString handleInvokeChaincode(String chaincodeName, String function, L } } - public ByteString handleQueryChaincode(String chaincodeName, String function, List args, String uuid) { - ChaincodeID id = ChaincodeID.newBuilder().setName(chaincodeName).build(); - ChaincodeInput input = ChaincodeInput.newBuilder() - .addArgs(ByteString.copyFromUtf8(function)) - .addAllArgs(args) - .build(); - ChaincodeSpec payload = ChaincodeSpec.newBuilder() - .setChaincodeID(id) - .setCtorMsg(input) - .build(); - - // Create the channel on which to communicate the response from validating peer - Channel responseChannel; - try { - responseChannel = createChannel(uuid); - } catch (Exception e) { - logger.debug(String.format("Another request pending for this Uuid. Cannot process.")); - throw e; - } - - //Defer - try { - - // Send INVOKE_QUERY message to validator chaincode support - ChaincodeMessage message = ChaincodeMessage.newBuilder() - .setType(INVOKE_QUERY) - .setPayload(payload.toByteString()) - .setTxid(uuid) - .build(); - - logger.debug(String.format("[%s]Sending %s", shortID(message), INVOKE_QUERY)); - - try { - serialSend(message); - } catch (Exception e) { - logger.error(String.format("[%s]error sending %s", shortID(message), INVOKE_QUERY)); - throw new RuntimeException("could not send message"); - } - - // Wait on responseChannel for response - ChaincodeMessage response; - try { - response = receiveChannel(responseChannel); - } catch (Exception e) { - logger.error(String.format("[%s]Received unexpected message type", shortID(message))); - throw new RuntimeException("Received unexpected message type"); - } - - if (response.getType() == RESPONSE) { - // Success response - logger.debug(String.format("[%s]Received %s. Successfully queried chaincode", - shortID(response.getTxid()), RESPONSE)); - return response.getPayload(); - } - - if (response.getType() == ERROR) { - // Error response - logger.error(String.format("[%s]Received %s.", - shortID(response.getTxid()), ERROR)); - throw new RuntimeException(response.getPayload().toStringUtf8()); - } - - // Incorrect chaincode message received - logger.error(String.format("[%s]Incorrect chaincode message %s recieved. Expecting %s or %s", - shortID(response.getTxid()), response.getType(), RESPONSE, ERROR)); - throw new RuntimeException("Incorrect chaincode message received"); - } finally { - deleteChannel(uuid); - } - } - // handleMessage message handles loop for org.hyperledger.java.shim side of chaincode/validator stream. public synchronized void handleMessage(ChaincodeMessage message) throws Exception { diff --git a/core/chaincode/shim/mockstub.go b/core/chaincode/shim/mockstub.go index 3e4f9d6d582..4c97edb5106 100644 --- a/core/chaincode/shim/mockstub.go +++ b/core/chaincode/shim/mockstub.go @@ -123,14 +123,6 @@ func (stub *MockStub) MockInvoke(uuid string, args [][]byte) ([]byte, error) { return bytes, err } -// Query this chaincode -func (stub *MockStub) MockQuery(args [][]byte) ([]byte, error) { - stub.args = args - // no transaction needed for queries - bytes, err := stub.cc.Query(stub) - return bytes, err -} - // GetState retrieves the value for a given key from the ledger func (stub *MockStub) GetState(key string) ([]byte, error) { value := stub.State[key] @@ -269,20 +261,6 @@ func (stub *MockStub) InvokeChaincode(chaincodeName string, args [][]byte) ([]by return bytes, err } -func (stub *MockStub) QueryChaincode(chaincodeName string, args [][]byte) ([]byte, error) { - // TODO "args" here should possibly be a serialized pb.ChaincodeInput - mockLogger.Debug("MockStub", stub.Name, "Looking for peer chaincode", chaincodeName) - otherStub := stub.Invokables[chaincodeName] - if otherStub == nil { - mockLogger.Error("Could not find peer chaincode to query", chaincodeName) - return nil, errors.New("Could not find peer chaincode to query") - } - mockLogger.Debug("MockStub", stub.Name, "Querying peer chaincode", otherStub.Name, args) - bytes, err := otherStub.MockQuery(args) - mockLogger.Debug("MockStub", stub.Name, "Queried peer chaincode", otherStub.Name, "got", bytes, err) - return bytes, err -} - // Not implemented func (stub *MockStub) ReadCertAttribute(attributeName string) ([]byte, error) { return nil, nil diff --git a/core/chaincode/sysccapi.go b/core/chaincode/sysccapi.go index af30ad3be75..27e41f151d7 100644 --- a/core/chaincode/sysccapi.go +++ b/core/chaincode/sysccapi.go @@ -138,12 +138,8 @@ func DeploySysCC(ctx context.Context, spec *pb.ChaincodeSpec) error { return err } - transaction, err := pb.NewChaincodeDeployTransaction(chaincodeDeploymentSpec, chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeID.Name) - if err != nil { - return fmt.Errorf("Error deploying chaincode: %s ", err) - } - - _, _, err = Execute(ctx, GetChain(DefaultChain), transaction) + txid := chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeID.Name + _, _, err = Execute(ctx, GetChain(DefaultChain), txid, nil, chaincodeDeploymentSpec) return err } diff --git a/core/chaincode/systemchaincode_test.go b/core/chaincode/systemchaincode_test.go index 1228c9bf28d..168f911b277 100644 --- a/core/chaincode/systemchaincode_test.go +++ b/core/chaincode/systemchaincode_test.go @@ -53,7 +53,7 @@ func TestExecuteDeploySysChaincode(t *testing.T) { } ccStartupTimeout := time.Duration(5000) * time.Millisecond - pb.RegisterChaincodeSupportServer(grpcServer, NewChaincodeSupport(DefaultChain, getPeerEndpoint, false, ccStartupTimeout, nil)) + pb.RegisterChaincodeSupportServer(grpcServer, NewChaincodeSupport(DefaultChain, getPeerEndpoint, false, ccStartupTimeout)) go grpcServer.Serve(lis) diff --git a/core/crypto/crypto.go b/core/crypto/crypto.go index a622ed7dcae..65f09ab6849 100644 --- a/core/crypto/crypto.go +++ b/core/crypto/crypto.go @@ -16,10 +16,6 @@ limitations under the License. package crypto -import ( - pb "github.com/hyperledger/fabric/protos/peer" -) - // Public Interfaces // NodeType represents the node's type @@ -44,23 +40,6 @@ type Node interface { GetName() string } -// Client is an entity able to deploy and invoke chaincode -type Client interface { - Node - - // NewChaincodeDeployTransaction is used to deploy chaincode. - NewChaincodeDeployTransaction(chaincodeDeploymentSpec *pb.ChaincodeDeploymentSpec, uuid string, attributes ...string) (*pb.Transaction, error) - - // NewChaincodeExecute is used to execute chaincode's functions. - NewChaincodeExecute(chaincodeInvocation *pb.ChaincodeInvocationSpec, uuid string, attributes ...string) (*pb.Transaction, error) - - // NewChaincodeQuery is used to query chaincode's functions. - NewChaincodeQuery(chaincodeInvocation *pb.ChaincodeInvocationSpec, uuid string, attributes ...string) (*pb.Transaction, error) - - // DecryptQueryResult is used to decrypt the result of a query transaction - DecryptQueryResult(queryTx *pb.Transaction, result []byte) ([]byte, error) -} - // Peer is an entity able to verify transactions type Peer interface { Node @@ -71,18 +50,6 @@ type Peer interface { // GetEnrollmentID returns this peer's enrollment id GetEnrollmentID() string - // TransactionPreValidation verifies that the transaction is - // well formed with the respect to the security layer - // prescriptions (i.e. signature verification). - TransactionPreValidation(tx *pb.Transaction) (*pb.Transaction, error) - - // TransactionPreExecution verifies that the transaction is - // well formed with the respect to the security layer - // prescriptions (i.e. signature verification). If this is the case, - // the method prepares the transaction to be executed. - // TransactionPreExecution returns a clone of tx. - TransactionPreExecution(tx *pb.Transaction) (*pb.Transaction, error) - // Sign signs msg with this validator's signing key and outputs // the signature if no error occurred. Sign(msg []byte) ([]byte, error) @@ -91,58 +58,4 @@ type Peer interface { // If the verification succeeded, Verify returns nil meaning no error occurred. // If vkID is nil, then the signature is verified against this validator's verification key. Verify(vkID, signature, message []byte) error - - // GetStateEncryptor returns a StateEncryptor linked to pair defined by - // the deploy transaction and the execute transaction. Notice that, - // executeTx can also correspond to a deploy transaction. - GetStateEncryptor(deployTx, executeTx *pb.Transaction) (StateEncryptor, error) - - GetTransactionBinding(tx *pb.Transaction) ([]byte, error) -} - -// StateEncryptor is used to encrypt chaincode's state -type StateEncryptor interface { - - // Encrypt encrypts message msg - Encrypt(msg []byte) ([]byte, error) - - // Decrypt decrypts ciphertext ct obtained - // from a call of the Encrypt method. - Decrypt(ct []byte) ([]byte, error) -} - -// CertificateHandler exposes methods to deal with an ECert/TCert -type CertificateHandler interface { - - // GetCertificate returns the certificate's DER - GetCertificate() []byte - - // Sign signs msg using the signing key corresponding to the certificate - Sign(msg []byte) ([]byte, error) - - // Verify verifies msg using the verifying key corresponding to the certificate - Verify(signature []byte, msg []byte) error - - // GetTransactionHandler returns a new transaction handler relative to this certificate - GetTransactionHandler() (TransactionHandler, error) -} - -// TransactionHandler represents a single transaction that can be named by the output of the GetBinding method. -// This transaction is linked to a single Certificate (TCert or ECert). -type TransactionHandler interface { - - // GetCertificateHandler returns the certificate handler relative to the certificate mapped to this transaction - GetCertificateHandler() (CertificateHandler, error) - - // GetBinding returns a binding to the underlying transaction - GetBinding() ([]byte, error) - - // NewChaincodeDeployTransaction is used to deploy chaincode - NewChaincodeDeployTransaction(chaincodeDeploymentSpec *pb.ChaincodeDeploymentSpec, uuid string, attributeNames ...string) (*pb.Transaction, error) - - // NewChaincodeExecute is used to execute chaincode's functions - NewChaincodeExecute(chaincodeInvocation *pb.ChaincodeInvocationSpec, uuid string, attributeNames ...string) (*pb.Transaction, error) - - // NewChaincodeQuery is used to query chaincode's functions - NewChaincodeQuery(chaincodeInvocation *pb.ChaincodeInvocationSpec, uuid string, attributeNames ...string) (*pb.Transaction, error) } diff --git a/core/endorser/endorser.go b/core/endorser/endorser.go index e9d451def6b..28323c7ad8e 100644 --- a/core/endorser/endorser.go +++ b/core/endorser/endorser.go @@ -63,24 +63,17 @@ func (*Endorser) getTxSimulator(ledgername string) (ledger.TxSimulator, error) { } //deploy the chaincode after call to the system chaincode is successful -func (e *Endorser) deploy(ctxt context.Context, chainname string, cds *pb.ChaincodeDeploymentSpec, cid *pb.ChaincodeID) error { - //TODO : this needs to be converted to another data structure to be handled - // by the chaincode framework (which currently handles "Transaction") - t, err := pb.NewChaincodeDeployTransaction(cds, cid.Name) - if err != nil { - return err - } - +func (e *Endorser) deploy(ctxt context.Context, txid string, proposal *pb.Proposal, chainname string, cds *pb.ChaincodeDeploymentSpec, cid *pb.ChaincodeID) error { //TODO - create chaincode support for chainname, for now use DefaultChain chaincodeSupport := chaincode.GetChain(chaincode.ChainName(chainname)) - _, err = chaincodeSupport.Deploy(ctxt, t) + _, err := chaincodeSupport.Deploy(ctxt, cds) if err != nil { return fmt.Errorf("Failed to deploy chaincode spec(%s)", err) } //launch and wait for ready - _, _, err = chaincodeSupport.Launch(ctxt, t) + _, _, err = chaincodeSupport.Launch(ctxt, txid, proposal, cds) if err != nil { return fmt.Errorf("%s", err) } @@ -92,7 +85,7 @@ func (e *Endorser) deploy(ctxt context.Context, chainname string, cds *pb.Chainc } //call specified chaincode (system or user) -func (e *Endorser) callChaincode(ctxt context.Context, cis *pb.ChaincodeInvocationSpec, cid *pb.ChaincodeID, txsim ledger.TxSimulator) ([]byte, *pb.ChaincodeEvent, error) { +func (e *Endorser) callChaincode(ctxt context.Context, txid string, prop *pb.Proposal, cis *pb.ChaincodeInvocationSpec, cid *pb.ChaincodeID, txsim ledger.TxSimulator) ([]byte, *pb.ChaincodeEvent, error) { var err error var b []byte var ccevent *pb.ChaincodeEvent @@ -101,7 +94,7 @@ func (e *Endorser) callChaincode(ctxt context.Context, cis *pb.ChaincodeInvocati chainName := string(chaincode.DefaultChain) ctxt = context.WithValue(ctxt, chaincode.TXSimulatorKey, txsim) - b, ccevent, err = chaincode.ExecuteChaincode(ctxt, pb.Transaction_CHAINCODE_INVOKE, chainName, cid.Name, cis.ChaincodeSpec.CtorMsg.Args) + b, ccevent, err = chaincode.ExecuteChaincode(ctxt, txid, prop, chainName, cid.Name, cis.ChaincodeSpec.CtorMsg.Args) if err != nil { return nil, nil, err @@ -121,7 +114,7 @@ func (e *Endorser) callChaincode(ctxt context.Context, cis *pb.ChaincodeInvocati if err != nil { return nil, nil, err } - err = e.deploy(ctxt, chainName, cds, cid) + err = e.deploy(ctxt, txid, prop, chainName, cds, cid) if err != nil { return nil, nil, err } @@ -132,7 +125,7 @@ func (e *Endorser) callChaincode(ctxt context.Context, cis *pb.ChaincodeInvocati } //simulate the proposal by calling the chaincode -func (e *Endorser) simulateProposal(ctx context.Context, prop *pb.Proposal, cid *pb.ChaincodeID, txsim ledger.TxSimulator) ([]byte, []byte, *pb.ChaincodeEvent, error) { +func (e *Endorser) simulateProposal(ctx context.Context, txid string, prop *pb.Proposal, cid *pb.ChaincodeID, txsim ledger.TxSimulator) ([]byte, []byte, *pb.ChaincodeEvent, error) { //we do expect the payload to be a ChaincodeInvocationSpec //if we are supporting other payloads in future, this be glaringly point //as something that should change @@ -154,7 +147,7 @@ func (e *Endorser) simulateProposal(ctx context.Context, prop *pb.Proposal, cid var simResult []byte var resp []byte var ccevent *pb.ChaincodeEvent - resp, ccevent, err = e.callChaincode(ctx, cis, cid, txsim) + resp, ccevent, err = e.callChaincode(ctx, txid, prop, cis, cid, txsim) if err != nil { return nil, nil, nil, err } @@ -166,19 +159,19 @@ func (e *Endorser) simulateProposal(ctx context.Context, prop *pb.Proposal, cid return resp, simResult, ccevent, nil } -func (e *Endorser) getCDSFromLCCC(ctx context.Context, chaincodeID string, txsim ledger.TxSimulator) ([]byte, error) { +func (e *Endorser) getCDSFromLCCC(ctx context.Context, txid string, prop *pb.Proposal, chaincodeID string, txsim ledger.TxSimulator) ([]byte, error) { ctxt := context.WithValue(ctx, chaincode.TXSimulatorKey, txsim) - return chaincode.GetCDSFromLCCC(ctxt, string(chaincode.DefaultChain), chaincodeID) + return chaincode.GetCDSFromLCCC(ctxt, txid, prop, string(chaincode.DefaultChain), chaincodeID) } //endorse the proposal by calling the ESCC -func (e *Endorser) endorseProposal(ctx context.Context, proposal *pb.Proposal, simRes []byte, event *pb.ChaincodeEvent, visibility []byte, ccid *pb.ChaincodeID, txsim ledger.TxSimulator) ([]byte, error) { +func (e *Endorser) endorseProposal(ctx context.Context, txid string, proposal *pb.Proposal, simRes []byte, event *pb.ChaincodeEvent, visibility []byte, ccid *pb.ChaincodeID, txsim ledger.TxSimulator) ([]byte, error) { endorserLogger.Infof("endorseProposal starts for proposal %p, simRes %p event %p, visibility %p, ccid %s", proposal, simRes, event, visibility, ccid) // 1) extract the chaincodeDeploymentSpec for the chaincode we are invoking; we need it to get the escc var escc string if ccid.Name != "lccc" { - depPayload, err := e.getCDSFromLCCC(ctx, ccid.Name, txsim) + depPayload, err := e.getCDSFromLCCC(ctx, txid, proposal, ccid.Name, txsim) if err != nil { return nil, fmt.Errorf("failed to obtain cds for %s - %s", ccid, err) } @@ -217,7 +210,7 @@ func (e *Endorser) endorseProposal(ctx context.Context, proposal *pb.Proposal, s // args[5] - payloadVisibility args := [][]byte{[]byte(""), proposal.Header, proposal.Payload, simRes, eventBytes, visibility} ecccis := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeID: &pb.ChaincodeID{Name: escc}, CtorMsg: &pb.ChaincodeInput{Args: args}}} - prBytes, _, err := e.callChaincode(ctx, ecccis, &pb.ChaincodeID{Name: escc}, txsim) + prBytes, _, err := e.callChaincode(ctx, txid, proposal, ecccis, &pb.ChaincodeID{Name: escc}, txsim) if err != nil { return nil, err } @@ -239,7 +232,20 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro // at first, we check whether the message is valid prop, _, hdrExt, err := peer.ValidateProposalMessage(signedProp) if err != nil { - return &pb.ProposalResponse{Response: &pb.Response2{Status: 500, Message: err.Error()}}, err + return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err + } + + hdr, err := putils.GetHeader(prop.Header) + if err != nil { + return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err + } + + //TODO check for uniqueness of prop.TxID with ledger + + txid := hdr.ChainHeader.TxID + if txid == "" { + err = fmt.Errorf("Invalid txID") + return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err } // obtaining once the tx simulator for this proposal @@ -247,7 +253,7 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro //TODO - get chainname from the proposal when defined chainName := string(chaincode.DefaultChain) if txsim, err = e.getTxSimulator(chainName); err != nil { - return &pb.ProposalResponse{Response: &pb.Response2{Status: 500, Message: err.Error()}}, err + return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err } defer txsim.Done() @@ -259,16 +265,16 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro //1 -- simulate //TODO what do we do with response ? We need it for Invoke responses for sure //Which field in PayloadResponse will carry return value ? - result, simulationResult, ccevent, err := e.simulateProposal(ctx, prop, hdrExt.ChaincodeID, txsim) + result, simulationResult, ccevent, err := e.simulateProposal(ctx, txid, prop, hdrExt.ChaincodeID, txsim) if err != nil { - return &pb.ProposalResponse{Response: &pb.Response2{Status: 500, Message: err.Error()}}, err + return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err } //2 -- endorse and get a marshalled ProposalResponse message //TODO what do we do with response ? We need it for Invoke responses for sure - prBytes, err := e.endorseProposal(ctx, prop, simulationResult, ccevent, hdrExt.PayloadVisibility, hdrExt.ChaincodeID, txsim) + prBytes, err := e.endorseProposal(ctx, txid, prop, simulationResult, ccevent, hdrExt.PayloadVisibility, hdrExt.ChaincodeID, txsim) if err != nil { - return &pb.ProposalResponse{Response: &pb.Response2{Status: 500, Message: err.Error()}}, err + return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, err } //3 -- respond diff --git a/core/endorser/endorser_test.go b/core/endorser/endorser_test.go index 8b4b21752ba..f05e1542e1c 100644 --- a/core/endorser/endorser_test.go +++ b/core/endorser/endorser_test.go @@ -28,7 +28,6 @@ import ( "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/core/chaincode" "github.com/hyperledger/fabric/core/container" - "github.com/hyperledger/fabric/core/crypto" "github.com/hyperledger/fabric/core/crypto/primitives" "github.com/hyperledger/fabric/core/db" "github.com/hyperledger/fabric/core/ledger/kvledger" @@ -82,7 +81,6 @@ func initPeer() (net.Listener, error) { } // Install security object for peer - var secHelper crypto.Peer if viper.GetBool("security.enabled") { //TODO: integrate new crypto / idp securityLevel := viper.GetInt("security.level") @@ -95,7 +93,7 @@ func initPeer() (net.Listener, error) { } ccStartupTimeout := time.Duration(30000) * time.Millisecond - pb.RegisterChaincodeSupportServer(grpcServer, chaincode.NewChaincodeSupport(chaincode.DefaultChain, getPeerEndpoint, false, ccStartupTimeout, secHelper)) + pb.RegisterChaincodeSupportServer(grpcServer, chaincode.NewChaincodeSupport(chaincode.DefaultChain, getPeerEndpoint, false, ccStartupTimeout)) chaincode.RegisterSysCCs() @@ -124,7 +122,8 @@ func closeListenerAndSleep(l net.Listener) { //getProposal gets the proposal for the chaincode invocation //Currently supported only for Invokes (Queries still go through devops client) func getProposal(cis *pb.ChaincodeInvocationSpec, creator []byte) (*pb.Proposal, error) { - return pbutils.CreateChaincodeProposal(cis, creator) + uuid := util.GenerateUUID() + return pbutils.CreateChaincodeProposal(uuid, cis, creator) } //getDeployProposal gets the proposal for the chaincode deployment diff --git a/core/ledger/blkstorage/blockstorage.go b/core/ledger/blkstorage/blockstorage.go index 4a6b2835ffc..bb936326b9b 100644 --- a/core/ledger/blkstorage/blockstorage.go +++ b/core/ledger/blkstorage/blockstorage.go @@ -55,6 +55,6 @@ type BlockStore interface { RetrieveBlocks(startNum uint64) (ledger.ResultsIterator, error) RetrieveBlockByHash(blockHash []byte) (*pb.Block2, error) RetrieveBlockByNumber(blockNum uint64) (*pb.Block2, error) - RetrieveTxByID(txID string) (*pb.Transaction2, error) + RetrieveTxByID(txID string) (*pb.Transaction, error) Shutdown() } diff --git a/core/ledger/blkstorage/fsblkstorage/blockfile_mgr.go b/core/ledger/blkstorage/fsblkstorage/blockfile_mgr.go index 33b32e1be4a..fbc206af5b3 100644 --- a/core/ledger/blkstorage/fsblkstorage/blockfile_mgr.go +++ b/core/ledger/blkstorage/fsblkstorage/blockfile_mgr.go @@ -436,7 +436,7 @@ func (mgr *blockfileMgr) retrieveBlocks(startNum uint64) (*BlocksItr, error) { return newBlockItr(mgr, startNum), nil } -func (mgr *blockfileMgr) retrieveTransactionByID(txID string) (*pb.Transaction2, error) { +func (mgr *blockfileMgr) retrieveTransactionByID(txID string) (*pb.Transaction, error) { logger.Debugf("retrieveTransactionByID() - txId = [%s]", txID) loc, err := mgr.index.getTxLoc(txID) if err != nil { @@ -465,12 +465,12 @@ func (mgr *blockfileMgr) fetchSerBlock(lp *fileLocPointer) (*pb.SerBlock2, error return pb.NewSerBlock2(blockBytes), nil } -func (mgr *blockfileMgr) fetchTransaction(lp *fileLocPointer) (*pb.Transaction2, error) { +func (mgr *blockfileMgr) fetchTransaction(lp *fileLocPointer) (*pb.Transaction, error) { txBytes, err := mgr.fetchRawBytes(lp) if err != nil { return nil, err } - tx := &pb.Transaction2{} + tx := &pb.Transaction{} err = proto.Unmarshal(txBytes, tx) if err != nil { return nil, err diff --git a/core/ledger/blkstorage/fsblkstorage/blockfile_mgr_test.go b/core/ledger/blkstorage/fsblkstorage/blockfile_mgr_test.go index 0823f6ac1a8..d8fe0d0f12c 100644 --- a/core/ledger/blkstorage/fsblkstorage/blockfile_mgr_test.go +++ b/core/ledger/blkstorage/fsblkstorage/blockfile_mgr_test.go @@ -148,7 +148,7 @@ func TestBlockfileMgrGetTxById(t *testing.T) { txID := constructTxID(uint64(i+1), j) txFromFileMgr, err := blkfileMgrWrapper.blockfileMgr.retrieveTransactionByID(txID) testutil.AssertNoError(t, err, "Error while retrieving tx from blkfileMgr") - tx := &pb.Transaction2{} + tx := &pb.Transaction{} err = proto.Unmarshal(txBytes, tx) testutil.AssertNoError(t, err, "Error while unmarshalling tx") testutil.AssertEquals(t, txFromFileMgr, tx) diff --git a/core/ledger/blkstorage/fsblkstorage/blockindex_test.go b/core/ledger/blkstorage/fsblkstorage/blockindex_test.go index 4bbf52d2c89..900869b589a 100644 --- a/core/ledger/blkstorage/fsblkstorage/blockindex_test.go +++ b/core/ledger/blkstorage/fsblkstorage/blockindex_test.go @@ -144,7 +144,7 @@ func testBlockIndexSelectiveIndexing(t *testing.T, indexItems []blkstorage.Index tx, err := blockfileMgr.retrieveTransactionByID(constructTxID(1, 0)) if testutil.Contains(indexItems, blkstorage.IndexableAttrTxID) { testutil.AssertNoError(t, err, "Error while retrieving tx by id") - txOrig := &pb.Transaction2{} + txOrig := &pb.Transaction{} proto.Unmarshal(blocks[0].Transactions[0], txOrig) testutil.AssertEquals(t, tx, txOrig) } else { diff --git a/core/ledger/blkstorage/fsblkstorage/fs_blockstore.go b/core/ledger/blkstorage/fsblkstorage/fs_blockstore.go index 6faa2e74666..9c22a5178df 100644 --- a/core/ledger/blkstorage/fsblkstorage/fs_blockstore.go +++ b/core/ledger/blkstorage/fsblkstorage/fs_blockstore.go @@ -64,7 +64,7 @@ func (store *FsBlockStore) RetrieveBlockByNumber(blockNum uint64) (*pb.Block2, e } // RetrieveTxByID returns a transaction for given transaction id -func (store *FsBlockStore) RetrieveTxByID(txID string) (*pb.Transaction2, error) { +func (store *FsBlockStore) RetrieveTxByID(txID string) (*pb.Transaction, error) { return store.fileMgr.retrieveTransactionByID(txID) } diff --git a/core/ledger/kvledger/example/app.go b/core/ledger/kvledger/example/app.go index ef170f5572d..517832c35e5 100644 --- a/core/ledger/kvledger/example/app.go +++ b/core/ledger/kvledger/example/app.go @@ -39,7 +39,7 @@ func ConstructAppInstance(ledger ledger.ValidatedLedger) *App { } // Init simulates init transaction -func (app *App) Init(initialBalances map[string]int) (*pb.Transaction2, error) { +func (app *App) Init(initialBalances map[string]int) (*pb.Transaction, error) { var txSimulator ledger.TxSimulator var err error if txSimulator, err = app.ledger.NewTxSimulator(); err != nil { @@ -58,7 +58,7 @@ func (app *App) Init(initialBalances map[string]int) (*pb.Transaction2, error) { } // TransferFunds simulates a transaction for transferring fund from fromAccount to toAccount -func (app *App) TransferFunds(fromAccount string, toAccount string, transferAmt int) (*pb.Transaction2, error) { +func (app *App) TransferFunds(fromAccount string, toAccount string, transferAmt int) (*pb.Transaction, error) { // act as endorsing peer shim code to simulate a transaction on behalf of chaincode var txSimulator ledger.TxSimulator @@ -113,7 +113,7 @@ func (app *App) QueryBalances(accounts []string) ([]int, error) { return balances, nil } -func constructTransaction(simulationResults []byte) *pb.Transaction2 { +func constructTransaction(simulationResults []byte) *pb.Transaction { tx, _ := putils.CreateTx(common.HeaderType_ENDORSER_TRANSACTION, nil, nil, simulationResults, []*pb.Endorsement{}) return tx } diff --git a/core/ledger/kvledger/example/consenter.go b/core/ledger/kvledger/example/consenter.go index cf784017215..baf8940f84d 100644 --- a/core/ledger/kvledger/example/consenter.go +++ b/core/ledger/kvledger/example/consenter.go @@ -32,7 +32,7 @@ func ConstructConsenter() *Consenter { } // ConstructBlock constructs a block from a list of transactions -func (c *Consenter) ConstructBlock(transactions ...*pb.Transaction2) *pb.Block2 { +func (c *Consenter) ConstructBlock(transactions ...*pb.Transaction) *pb.Block2 { logger.Debugf("Construct a block based on the transactions") block := &pb.Block2{} for _, tx := range transactions { diff --git a/core/ledger/kvledger/example/marble_app.go b/core/ledger/kvledger/example/marble_app.go index 333e421ea09..3117476bbc7 100644 --- a/core/ledger/kvledger/example/marble_app.go +++ b/core/ledger/kvledger/example/marble_app.go @@ -55,7 +55,7 @@ type Marble struct { } // CreateMarble simulates init transaction -func (marbleApp *MarbleApp) CreateMarble(args []string) (*pb.Transaction2, error) { +func (marbleApp *MarbleApp) CreateMarble(args []string) (*pb.Transaction, error) { // 0 1 2 3 // "asdf", "blue", "35", "bob" logger.Debugf("===COUCHDB=== Entering ----------CreateMarble()----------") @@ -126,7 +126,7 @@ func init_marble(args []string) ([]byte, error) { } // TransferMarble simulates transfer transaction -func (marbleApp *MarbleApp) TransferMarble(args []string) (*pb.Transaction2, error) { +func (marbleApp *MarbleApp) TransferMarble(args []string) (*pb.Transaction, error) { // 0 1 // "name", "bob" diff --git a/core/ledger/kvledger/kv_ledger.go b/core/ledger/kvledger/kv_ledger.go index 1dd6d216161..aa9a5c4ffd0 100644 --- a/core/ledger/kvledger/kv_ledger.go +++ b/core/ledger/kvledger/kv_ledger.go @@ -98,7 +98,7 @@ func NewKVLedger(conf *Conf) (*KVLedger, error) { } // GetTransactionByID retrieves a transaction by id -func (l *KVLedger) GetTransactionByID(txID string) (*pb.Transaction2, error) { +func (l *KVLedger) GetTransactionByID(txID string) (*pb.Transaction, error) { return l.blockStore.RetrieveTxByID(txID) } diff --git a/core/ledger/kvledger/txmgmt/couchdbtxmgmt/couchdb_txmgr.go b/core/ledger/kvledger/txmgmt/couchdbtxmgmt/couchdb_txmgr.go index 716ccd41fd5..1e83aba2952 100644 --- a/core/ledger/kvledger/txmgmt/couchdbtxmgmt/couchdb_txmgr.go +++ b/core/ledger/kvledger/txmgmt/couchdbtxmgmt/couchdb_txmgr.go @@ -24,9 +24,10 @@ import ( "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/couchdbtxmgmt/couchdb" "github.com/hyperledger/fabric/core/ledger/util/db" + "github.com/op/go-logging" + pb "github.com/hyperledger/fabric/protos/peer" putils "github.com/hyperledger/fabric/protos/utils" - "github.com/op/go-logging" ) var logger = logging.MustGetLogger("couchdbtxmgmt") @@ -164,7 +165,7 @@ func (txmgr *CouchDBTxMgr) ValidateAndPrepare(block *pb.Block2) (*pb.Block2, []* validatedBlock.Transactions = append(validatedBlock.Transactions, envBytes) } else { invalidTxs = append(invalidTxs, &pb.InvalidTransaction{ - Transaction: &pb.Transaction2{ /* FIXME */ }, Cause: pb.InvalidTransaction_RWConflictDuringCommit}) + Transaction: &pb.Transaction{ /* FIXME */ }, Cause: pb.InvalidTransaction_RWConflictDuringCommit}) } } logger.Debugf("===COUCHDB=== Exiting CouchDBTxMgr.ValidateAndPrepare()") diff --git a/core/ledger/kvledger/txmgmt/lockbasedtxmgmt/lockbased_txmgr.go b/core/ledger/kvledger/txmgmt/lockbasedtxmgmt/lockbased_txmgr.go index 223230ef551..7dd7925695b 100644 --- a/core/ledger/kvledger/txmgmt/lockbasedtxmgmt/lockbased_txmgr.go +++ b/core/ledger/kvledger/txmgmt/lockbasedtxmgmt/lockbased_txmgr.go @@ -24,9 +24,10 @@ import ( "github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt" "github.com/hyperledger/fabric/core/ledger/util/db" + "github.com/op/go-logging" + pb "github.com/hyperledger/fabric/protos/peer" putils "github.com/hyperledger/fabric/protos/utils" - "github.com/op/go-logging" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/iterator" ) @@ -141,7 +142,7 @@ func (txmgr *LockBasedTxMgr) ValidateAndPrepare(block *pb.Block2) (*pb.Block2, [ validatedBlock.Transactions = append(validatedBlock.Transactions, envBytes) } else { invalidTxs = append(invalidTxs, &pb.InvalidTransaction{ - Transaction: &pb.Transaction2{ /* FIXME */ }, Cause: pb.InvalidTransaction_RWConflictDuringCommit}) + Transaction: &pb.Transaction{ /* FIXME */ }, Cause: pb.InvalidTransaction_RWConflictDuringCommit}) } } return validatedBlock, invalidTxs, nil diff --git a/core/ledger/ledger_interface.go b/core/ledger/ledger_interface.go index 93e8f6a5d97..964560aa264 100644 --- a/core/ledger/ledger_interface.go +++ b/core/ledger/ledger_interface.go @@ -48,7 +48,7 @@ type RawLedger interface { type ValidatedLedger interface { Ledger // GetTransactionByID retrieves a transaction by id - GetTransactionByID(txID string) (*pb.Transaction2, error) + GetTransactionByID(txID string) (*pb.Transaction, error) // GetBlockByHash returns a block given it's hash GetBlockByHash(blockHash []byte) (*pb.Block2, error) // NewTxSimulator gives handle to a transaction simulator. diff --git a/core/ledger/testutil/test_helper.go b/core/ledger/testutil/test_helper.go index 0a7ca2f4de7..be2458c7846 100644 --- a/core/ledger/testutil/test_helper.go +++ b/core/ledger/testutil/test_helper.go @@ -21,6 +21,7 @@ import ( "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric/core/util" "github.com/hyperledger/fabric/msp" "github.com/hyperledger/fabric/protos/common" pb "github.com/hyperledger/fabric/protos/peer" @@ -51,7 +52,7 @@ func ConstructTestBlocks(t *testing.T, numBlocks int) []*pb.Block2 { // ConstructTestBlock constructs a block with 'numTx' number of transactions for testing func ConstructTestBlock(t *testing.T, numTx int, txSize int, startingTxID int) *pb.Block2 { - txs := []*pb.Transaction2{} + txs := []*pb.Transaction{} for i := startingTxID; i < numTx+startingTxID; i++ { tx, _ := putils.CreateTx(common.HeaderType_ENDORSER_TRANSACTION, []byte{}, []byte{}, ConstructRandomBytes(t, txSize), []*pb.Endorsement{}) txs = append(txs, tx) @@ -66,7 +67,8 @@ func ConstructTestTransaction(t *testing.T, simulationResults []byte, signer msp return nil, err } - prop, err := putils.CreateChaincodeProposal(&pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeID: &pb.ChaincodeID{Name: "foo"}}}, ss) + uuid := util.GenerateUUID() + prop, err := putils.CreateChaincodeProposal(uuid, &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeID: &pb.ChaincodeID{Name: "foo"}}}, ss) if err != nil { return nil, err } @@ -91,7 +93,7 @@ func ComputeBlockHash(t testing.TB, block *pb.Block2) []byte { return serBlock.ComputeHash() } -func newBlock(txs []*pb.Transaction2) *pb.Block2 { +func newBlock(txs []*pb.Transaction) *pb.Block2 { block := &pb.Block2{} block.PreviousBlockHash = []byte{} for i := 0; i < len(txs); i++ { diff --git a/core/peer/fullflow_test.go b/core/peer/fullflow_test.go index cba29e73e8a..ae581791577 100644 --- a/core/peer/fullflow_test.go +++ b/core/peer/fullflow_test.go @@ -25,6 +25,7 @@ import ( "os" "github.com/hyperledger/fabric/core/crypto/primitives" + "github.com/hyperledger/fabric/core/util" "github.com/hyperledger/fabric/msp" "github.com/hyperledger/fabric/protos/peer" "github.com/hyperledger/fabric/protos/utils" @@ -36,7 +37,9 @@ func getProposal() (*peer.Proposal, error) { ChaincodeID: &peer.ChaincodeID{Name: "foo"}, Type: peer.ChaincodeSpec_GOLANG}} - return utils.CreateProposalFromCIS(cis, signerSerialized) + uuid := util.GenerateUUID() + + return utils.CreateProposalFromCIS(uuid, cis, signerSerialized) } func TestGoodPath(t *testing.T) { diff --git a/core/system_chaincode/escc/endorser_onevalidsignature_test.go b/core/system_chaincode/escc/endorser_onevalidsignature_test.go index 4baafd4aff8..a3c0677efbb 100644 --- a/core/system_chaincode/escc/endorser_onevalidsignature_test.go +++ b/core/system_chaincode/escc/endorser_onevalidsignature_test.go @@ -26,6 +26,7 @@ import ( "github.com/hyperledger/fabric/core/chaincode/shim" "github.com/hyperledger/fabric/core/crypto/primitives" "github.com/hyperledger/fabric/core/peer" + "github.com/hyperledger/fabric/core/util" "github.com/hyperledger/fabric/msp" pb "github.com/hyperledger/fabric/protos/peer" putils "github.com/hyperledger/fabric/protos/utils" @@ -114,7 +115,9 @@ func TestInvoke(t *testing.T) { return } - proposal, err := putils.CreateChaincodeProposal(cis, sIdBytes) + uuid := util.GenerateUUID() + + proposal, err := putils.CreateChaincodeProposal(uuid, cis, sIdBytes) if err != nil { t.Fail() t.Fatalf("couldn't generate chaincode proposal: err %s", err) diff --git a/core/system_chaincode/vscc/validator_onevalidsignature_test.go b/core/system_chaincode/vscc/validator_onevalidsignature_test.go index 558c7d0d73d..9e892f0e033 100644 --- a/core/system_chaincode/vscc/validator_onevalidsignature_test.go +++ b/core/system_chaincode/vscc/validator_onevalidsignature_test.go @@ -23,6 +23,7 @@ import ( "github.com/hyperledger/fabric/core/chaincode/shim" "github.com/hyperledger/fabric/core/crypto/primitives" + "github.com/hyperledger/fabric/core/util" "github.com/hyperledger/fabric/msp" "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/peer" @@ -32,7 +33,9 @@ import ( func createTx() (*common.Envelope, error) { cis := &peer.ChaincodeInvocationSpec{ChaincodeSpec: &peer.ChaincodeSpec{ChaincodeID: &peer.ChaincodeID{Name: "foo"}}} - prop, err := utils.CreateProposalFromCIS(cis, sid) + uuid := util.GenerateUUID() + + prop, err := utils.CreateProposalFromCIS(uuid, cis, sid) if err != nil { return nil, err } diff --git a/events/events_test.go b/events/events_test.go index 0ff68cbf88a..daacedf3e9a 100644 --- a/events/events_test.go +++ b/events/events_test.go @@ -81,7 +81,7 @@ func (a *Adapter) Disconnected(err error) { } func createTestBlock() *ehpb.Event { - emsg := producer.CreateBlockEvent(&ehpb.Block{Transactions: []*ehpb.Transaction{}}) + emsg := producer.CreateBlockEvent(&ehpb.Block2{Transactions: [][]byte{[]byte("tx1"), []byte("tx2")}}) return emsg } diff --git a/events/producer/eventhelper.go b/events/producer/eventhelper.go index fa975a07345..6e9cda75d4a 100644 --- a/events/producer/eventhelper.go +++ b/events/producer/eventhelper.go @@ -21,7 +21,7 @@ import ( ) //CreateBlockEvent creates a Event from a Block -func CreateBlockEvent(te *ehpb.Block) *ehpb.Event { +func CreateBlockEvent(te *ehpb.Block2) *ehpb.Event { return &ehpb.Event{Event: &ehpb.Event_Block{Block: te}} } diff --git a/examples/chaincode/go/chaincode_example02/chaincode_example02.go b/examples/chaincode/go/chaincode_example02/chaincode_example02.go index 104b75645bb..3833cbe9466 100644 --- a/examples/chaincode/go/chaincode_example02/chaincode_example02.go +++ b/examples/chaincode/go/chaincode_example02/chaincode_example02.go @@ -78,6 +78,10 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, erro // Deletes an entity from its state return t.delete(stub, args) } + if function == "query" { + // the old "Query" is now implemtned in invoke + return t.query(stub, args) + } var A, B string // Entities var Aval, Bval int // Asset holdings @@ -151,12 +155,8 @@ func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string return nil, nil } -// Query callback representing the query of a chaincode -func (t *SimpleChaincode) Query(stub shim.ChaincodeStubInterface) ([]byte, error) { - function, args := stub.GetFunctionAndParameters() - if function != "query" { - return nil, errors.New("Invalid query function name. Expecting \"query\"") - } +// query callback representing the query of a chaincode +func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) { var A string // Entities var err error diff --git a/examples/chaincode/go/chaincode_example02/chaincode_example02_test.go b/examples/chaincode/go/chaincode_example02/chaincode_example02_test.go index da0e0b3777f..f145c595aba 100644 --- a/examples/chaincode/go/chaincode_example02/chaincode_example02_test.go +++ b/examples/chaincode/go/chaincode_example02/chaincode_example02_test.go @@ -43,7 +43,7 @@ func checkState(t *testing.T, stub *shim.MockStub, name string, value string) { } func checkQuery(t *testing.T, stub *shim.MockStub, name string, value string) { - bytes, err := stub.MockQuery([][]byte{[]byte("query"), []byte(name)}) + bytes, err := stub.MockInvoke("1", [][]byte{[]byte("query"), []byte(name)}) if err != nil { fmt.Println("Query", name, "failed", err) t.FailNow() diff --git a/examples/chaincode/go/chaincode_example04/chaincode_example04.go b/examples/chaincode/go/chaincode_example04/chaincode_example04.go index 35ba6a139a3..ade18147229 100644 --- a/examples/chaincode/go/chaincode_example04/chaincode_example04.go +++ b/examples/chaincode/go/chaincode_example04/chaincode_example04.go @@ -62,11 +62,19 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, erro var event string // Event entity var eventVal int // State of event var err error - chainCodeToCall, args := stub.GetFunctionAndParameters() + + function, args := stub.GetFunctionAndParameters() + + if function == "query" { + return t.query(stub, args) + } + if len(args) != 2 { return nil, errors.New("Incorrect number of arguments. Expecting 2") } + chainCodeToCall := function + event = args[0] eventVal, err = strconv.Atoi(args[1]) if err != nil { @@ -98,12 +106,8 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, erro return nil, nil } -// Query callback representing the query of a chaincode -func (t *SimpleChaincode) Query(stub shim.ChaincodeStubInterface) ([]byte, error) { - function, args := stub.GetFunctionAndParameters() - if function != "query" { - return nil, errors.New("Invalid query function name. Expecting \"query\"") - } +// query callback representing the query of a chaincode +func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) { var event string // Event entity var err error diff --git a/examples/chaincode/go/chaincode_example04/chaincode_example04_test.go b/examples/chaincode/go/chaincode_example04/chaincode_example04_test.go index 596a54b4949..f2954519dd8 100644 --- a/examples/chaincode/go/chaincode_example04/chaincode_example04_test.go +++ b/examples/chaincode/go/chaincode_example04/chaincode_example04_test.go @@ -47,7 +47,7 @@ func checkState(t *testing.T, stub *shim.MockStub, name string, value string) { } func checkQuery(t *testing.T, stub *shim.MockStub, name string, value string) { - bytes, err := stub.MockQuery([][]byte{[]byte("query"), []byte(name)}) + bytes, err := stub.MockInvoke("1", [][]byte{[]byte("query"), []byte(name)}) if err != nil { fmt.Println("Query", name, "failed", err) t.FailNow() diff --git a/examples/chaincode/go/chaincode_example05/chaincode_example05.go b/examples/chaincode/go/chaincode_example05/chaincode_example05.go index 1ee8e088692..fc333fac64a 100644 --- a/examples/chaincode/go/chaincode_example05/chaincode_example05.go +++ b/examples/chaincode/go/chaincode_example05/chaincode_example05.go @@ -64,7 +64,12 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, erro var sum string // Sum entity var Aval, Bval, sumVal int // value of sum entity - to be computed var err error - _, args := stub.GetFunctionAndParameters() + + function, args := stub.GetFunctionAndParameters() + if function != "query" { + return t.query(stub, args) + } + if len(args) != 2 { return nil, errors.New("Incorrect number of arguments. Expecting 2") } @@ -75,7 +80,7 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, erro // Query chaincode_example02 f := "query" queryArgs := util.ToChaincodeArgs(f, "a") - response, err := stub.QueryChaincode(chaincodeURL, queryArgs) + response, err := stub.InvokeChaincode(chaincodeURL, queryArgs) if err != nil { errStr := fmt.Sprintf("Failed to query chaincode. Got error: %s", err.Error()) fmt.Printf(errStr) @@ -89,7 +94,7 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, erro } queryArgs = util.ToChaincodeArgs(f, "b") - response, err = stub.QueryChaincode(chaincodeURL, queryArgs) + response, err = stub.InvokeChaincode(chaincodeURL, queryArgs) if err != nil { errStr := fmt.Sprintf("Failed to query chaincode. Got error: %s", err.Error()) fmt.Printf(errStr) @@ -115,12 +120,8 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, erro return []byte(strconv.Itoa(sumVal)), nil } -// Query callback representing the query of a chaincode -func (t *SimpleChaincode) Query(stub shim.ChaincodeStubInterface) ([]byte, error) { - function, args := stub.GetFunctionAndParameters() - if function != "query" { - return nil, errors.New("Invalid query function name. Expecting \"query\"") - } +// query callback representing the query of a chaincode +func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) { var sum string // Sum entity var Aval, Bval, sumVal int // value of sum entity - to be computed var err error @@ -136,7 +137,7 @@ func (t *SimpleChaincode) Query(stub shim.ChaincodeStubInterface) ([]byte, error // Query chaincode_example02 f := "query" queryArgs := util.ToChaincodeArgs(f, "a") - response, err := stub.QueryChaincode(chaincodeURL, queryArgs) + response, err := stub.InvokeChaincode(chaincodeURL, queryArgs) if err != nil { errStr := fmt.Sprintf("Failed to query chaincode. Got error: %s", err.Error()) fmt.Printf(errStr) @@ -150,7 +151,7 @@ func (t *SimpleChaincode) Query(stub shim.ChaincodeStubInterface) ([]byte, error } queryArgs = util.ToChaincodeArgs(f, "b") - response, err = stub.QueryChaincode(chaincodeURL, queryArgs) + response, err = stub.InvokeChaincode(chaincodeURL, queryArgs) if err != nil { errStr := fmt.Sprintf("Failed to query chaincode. Got error: %s", err.Error()) fmt.Printf(errStr) diff --git a/examples/chaincode/go/chaincode_example05/chaincode_example05_test.go b/examples/chaincode/go/chaincode_example05/chaincode_example05_test.go index 9d03cf775c4..9ff6553e87f 100644 --- a/examples/chaincode/go/chaincode_example05/chaincode_example05_test.go +++ b/examples/chaincode/go/chaincode_example05/chaincode_example05_test.go @@ -53,7 +53,7 @@ func checkState(t *testing.T, stub *shim.MockStub, name string, expect string) { } func checkQuery(t *testing.T, stub *shim.MockStub, args [][]byte, expect string) { - bytes, err := stub.MockQuery(args) + bytes, err := stub.MockInvoke("1", args) if err != nil { fmt.Println("Query", args, "failed", err) t.FailNow() diff --git a/examples/chaincode/go/passthru/passthru.go b/examples/chaincode/go/passthru/passthru.go index 4dab67115b1..654e13e5f5f 100644 --- a/examples/chaincode/go/passthru/passthru.go +++ b/examples/chaincode/go/passthru/passthru.go @@ -42,28 +42,19 @@ func (p *PassthruChaincode) Init(stub shim.ChaincodeStubInterface) ([]byte, erro } //helper -func (p *PassthruChaincode) iq(invoke bool, stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) { +func (p *PassthruChaincode) iq(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) { if function == "" { return nil, errors.New("Chaincode ID not provided") } chaincodeID := function - if invoke { - return stub.InvokeChaincode(chaincodeID, util.ToChaincodeArgs(args...)) - } - return stub.QueryChaincode(chaincodeID, util.ToChaincodeArgs(args...)) + return stub.InvokeChaincode(chaincodeID, util.ToChaincodeArgs(args...)) } // Invoke passes through the invoke call func (p *PassthruChaincode) Invoke(stub shim.ChaincodeStubInterface) ([]byte, error) { function, args := stub.GetFunctionAndParameters() - return p.iq(true, stub, function, args) -} - -// Query passes through the query call -func (p *PassthruChaincode) Query(stub shim.ChaincodeStubInterface) ([]byte, error) { - function, args := stub.GetFunctionAndParameters() - return p.iq(false, stub, function, args) + return p.iq(stub, function, args) } func main() { diff --git a/examples/events/block-listener/block-listener.go b/examples/events/block-listener/block-listener.go index 1872a43fe57..af853319889 100644 --- a/examples/events/block-listener/block-listener.go +++ b/examples/events/block-listener/block-listener.go @@ -124,7 +124,9 @@ func main() { fmt.Printf("\n") fmt.Printf("Received rejected transaction\n") fmt.Printf("--------------\n") - fmt.Printf("Transaction error:\n%s\t%s\n", r.Rejection.Tx.Txid, r.Rejection.ErrorMsg) + //TODO get TxID from pb.ChaincodeHeader from TransactionAction's Header + //fmt.Printf("Transaction error:\n%s\t%s\n", r.Rejection.Tx.Txid, r.Rejection.ErrorMsg) + fmt.Printf("Transaction error:\n%s\n", r.Rejection.ErrorMsg) case ce := <-a.cEvent: fmt.Printf("\n") fmt.Printf("\n") diff --git a/peer/chaincode/common.go b/peer/chaincode/common.go index d3266029b49..803b2ce5684 100755 --- a/peer/chaincode/common.go +++ b/peer/chaincode/common.go @@ -28,6 +28,7 @@ import ( "github.com/hyperledger/fabric/core/chaincode" "github.com/hyperledger/fabric/core/chaincode/platforms" "github.com/hyperledger/fabric/core/container" + cutil "github.com/hyperledger/fabric/core/util" "github.com/hyperledger/fabric/msp" "github.com/hyperledger/fabric/peer/common" "github.com/hyperledger/fabric/peer/util" @@ -187,8 +188,10 @@ func chaincodeInvokeOrQuery(cmd *cobra.Command, args []string, invoke bool) (err return fmt.Errorf("Error serializing identity for %s: %s\n", signingIdentity, err) } + uuid := cutil.GenerateUUID() + var prop *pb.Proposal - prop, err = putils.CreateProposalFromCIS(invocation, creator) + prop, err = putils.CreateProposalFromCIS(uuid, invocation, creator) if err != nil { return fmt.Errorf("Error creating proposal %s: %s\n", chainFuncName, err) } diff --git a/peer/chaincode/deploy.go b/peer/chaincode/deploy.go index 8bdb5165573..bbac2eae111 100755 --- a/peer/chaincode/deploy.go +++ b/peer/chaincode/deploy.go @@ -21,6 +21,7 @@ import ( "golang.org/x/net/context" + "github.com/hyperledger/fabric/core/util" "github.com/hyperledger/fabric/msp" "github.com/hyperledger/fabric/peer/common" protcommon "github.com/hyperledger/fabric/protos/common" @@ -77,7 +78,9 @@ func deploy(cmd *cobra.Command) (*protcommon.Envelope, error) { return nil, fmt.Errorf("Error serializing identity for %s: %s\n", signingIdentity, err) } - prop, err := utils.CreateProposalFromCDS(cds, creator) + uuid := util.GenerateUUID() + + prop, err := utils.CreateProposalFromCDS(uuid, cds, creator) if err != nil { return nil, fmt.Errorf("Error creating proposal %s: %s\n", chainFuncName, err) } diff --git a/peer/node/start.go b/peer/node/start.go index fb18d974316..7fd64b3408d 100755 --- a/peer/node/start.go +++ b/peer/node/start.go @@ -134,12 +134,7 @@ func serve(args []string) error { grpcServer := grpc.NewServer(opts...) - secHelper, err := getSecHelper() - if err != nil { - return err - } - - registerChaincodeSupport(chaincode.DefaultChain, grpcServer, secHelper) + registerChaincodeSupport(chaincode.DefaultChain, grpcServer) logger.Debugf("Running peer") @@ -212,9 +207,7 @@ func serve(args []string) error { return <-serve } -func registerChaincodeSupport(chainname chaincode.ChainName, grpcServer *grpc.Server, - secHelper crypto.Peer) { - +func registerChaincodeSupport(chainname chaincode.ChainName, grpcServer *grpc.Server) { //get user mode userRunsCC := false if viper.GetString("chaincode.mode") == chaincode.DevModeUserRunsChaincode { @@ -229,8 +222,7 @@ func registerChaincodeSupport(chainname chaincode.ChainName, grpcServer *grpc.Se } ccStartupTimeout := time.Duration(tOut) * time.Millisecond - ccSrv := chaincode.NewChaincodeSupport(chainname, peer.GetPeerEndpoint, userRunsCC, - ccStartupTimeout, secHelper) + ccSrv := chaincode.NewChaincodeSupport(chainname, peer.GetPeerEndpoint, userRunsCC, ccStartupTimeout) //Now that chaincode is initialized, register all system chaincodes. chaincode.RegisterSysCCs() diff --git a/protos/common/common.pb.go b/protos/common/common.pb.go index c8e658ed78b..813bca569c2 100644 --- a/protos/common/common.pb.go +++ b/protos/common/common.pb.go @@ -143,6 +143,13 @@ type ChainHeader struct { Timestamp *google_protobuf.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` // Identifier of the chain this message is bound for ChainID []byte `protobuf:"bytes,4,opt,name=chainID,proto3" json:"chainID,omitempty"` + // An unique identifier that is used end-to-end. + // - set by higher layers such as end user or SDK + // - passed to the endorser (which will check for uniqueness) + // - as the header is passed along unchanged, it will be + // be retrieved by the committer (uniqueness check here as well) + // - to be stored in the ledger + TxID string `protobuf:"bytes,5,opt,name=txID" json:"txID,omitempty"` // The epoch in which this header was generated, where epoch is defined based on block height // Epoch in which the response has been generated. This field identifies a // logical window of time. A proposal response is accepted by a peer only if @@ -150,9 +157,9 @@ type ChainHeader struct { // 1. the epoch specified in the message is the current epoch // 2. this message has been only seen once during this epoch (i.e. it hasn't // been replayed) - Epoch uint64 `protobuf:"varint,5,opt,name=epoch" json:"epoch,omitempty"` + Epoch uint64 `protobuf:"varint,6,opt,name=epoch" json:"epoch,omitempty"` // Extension that may be attached based on the header type - Extension []byte `protobuf:"bytes,6,opt,name=extension,proto3" json:"extension,omitempty"` + Extension []byte `protobuf:"bytes,7,opt,name=extension,proto3" json:"extension,omitempty"` } func (m *ChainHeader) Reset() { *m = ChainHeader{} } @@ -294,48 +301,49 @@ func init() { func init() { proto.RegisterFile("common/common.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 683 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x54, 0x4b, 0x6f, 0xd3, 0x4c, - 0x14, 0xad, 0xeb, 0x3c, 0x9a, 0xeb, 0x7c, 0xad, 0xbf, 0xe9, 0x83, 0x10, 0x81, 0x1a, 0x59, 0x02, - 0x55, 0xad, 0x48, 0x44, 0x11, 0x12, 0x5b, 0x27, 0x99, 0xb6, 0x16, 0xed, 0xb8, 0x8c, 0x9d, 0x22, - 0xb1, 0x89, 0x9c, 0x64, 0x9a, 0x04, 0x12, 0x4f, 0xe4, 0x38, 0x15, 0xdd, 0xb2, 0x45, 0x42, 0x48, - 0xf0, 0x8f, 0xd8, 0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, 0xd0, 0x01, 0xa0, 0x2c, 0xed, 0xf8, 0xf8, 0xca, 0xdc, 0x44, 0x15, 0xd8, - 0xc3, 0xa4, 0xed, 0x52, 0x0f, 0xd3, 0x4c, 0x85, 0xde, 0x7c, 0xf1, 0xe1, 0x64, 0x38, 0x8e, 0x47, - 0x8b, 0x9e, 0xb8, 0xd7, 0xc6, 0xe8, 0x7e, 0xc6, 0xa2, 0x09, 0x1b, 0x0c, 0x59, 0xd4, 0xb8, 0x0d, - 0x7a, 0xd1, 0xb8, 0xaf, 0x9e, 0xa4, 0x79, 0xf2, 0x6c, 0xf5, 0x0a, 0x12, 0xbe, 0xfa, 0x17, 0x00, - 0x00, 0xff, 0xff, 0x5c, 0xd4, 0x24, 0xbf, 0xce, 0x04, 0x00, 0x00, + // 694 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0xad, 0xeb, 0x3c, 0x9a, 0xeb, 0xd0, 0x9a, 0xe9, 0x03, 0x13, 0x81, 0x1a, 0x59, 0x02, 0x45, + 0xad, 0x48, 0x44, 0x11, 0x12, 0x5b, 0x27, 0x9e, 0xb6, 0x16, 0xad, 0x5d, 0xc6, 0x4e, 0x91, 0xd8, + 0x44, 0x4e, 0x32, 0x4d, 0x02, 0x89, 0x27, 0x72, 0x9c, 0xaa, 0xdd, 0xb2, 0x45, 0x42, 0x48, 0xf0, + 0x51, 0xfc, 0x01, 0x3f, 0x82, 0xc4, 0x16, 0xcd, 0x8c, 0x9d, 0x47, 0x57, 0x99, 0x73, 0xcf, 0x7d, + 0x9c, 0x73, 0xc7, 0x19, 0xd8, 0xed, 0xb1, 0xc9, 0x84, 0x45, 0x0d, 0xf9, 0x53, 0x9f, 0xc6, 0x2c, + 0x61, 0xa8, 0x20, 0x51, 0xe5, 0x70, 0xc0, 0xd8, 0x60, 0x4c, 0x1b, 0x22, 0xda, 0x9d, 0xdf, 0x34, + 0x92, 0xd1, 0x84, 0xce, 0x92, 0x70, 0x32, 0x95, 0x89, 0xe6, 0x57, 0x05, 0x0a, 0xe7, 0x34, 0xec, + 0xd3, 0x18, 0xbd, 0x05, 0xad, 0x37, 0x0c, 0x47, 0x91, 0x84, 0x86, 0x52, 0x55, 0x6a, 0xda, 0xc9, + 0x6e, 0x3d, 0xed, 0xdb, 0x5a, 0x52, 0x64, 0x35, 0x0f, 0x59, 0xb0, 0x33, 0x1b, 0x0d, 0xa2, 0x30, + 0x99, 0xc7, 0x34, 0x2d, 0xdd, 0x14, 0xa5, 0x4f, 0xb2, 0x52, 0x7f, 0x9d, 0x26, 0x0f, 0xf3, 0xcd, + 0x3f, 0x0a, 0x68, 0x2b, 0xfd, 0x11, 0x82, 0x5c, 0x72, 0x3f, 0xa5, 0x42, 0x42, 0x9e, 0x88, 0x33, + 0x32, 0xa0, 0x78, 0x4b, 0xe3, 0xd9, 0x88, 0x45, 0xa2, 0x7d, 0x9e, 0x64, 0x10, 0xbd, 0x83, 0xd2, + 0xc2, 0x95, 0xa1, 0x8a, 0xd1, 0x95, 0xba, 0xf4, 0x5d, 0xcf, 0x7c, 0xd7, 0x83, 0x2c, 0x83, 0x2c, + 0x93, 0x79, 0x4f, 0xe1, 0xc4, 0xb1, 0x8d, 0x5c, 0x55, 0xa9, 0x95, 0x49, 0x06, 0x85, 0x82, 0x3b, + 0xc7, 0x36, 0xf2, 0x55, 0xa5, 0x56, 0x22, 0xe2, 0x8c, 0xf6, 0x20, 0x4f, 0xa7, 0xac, 0x37, 0x34, + 0x0a, 0x55, 0xa5, 0x96, 0x23, 0x12, 0xa0, 0x67, 0x50, 0xa2, 0x77, 0x09, 0x8d, 0x84, 0xb2, 0xa2, + 0xe8, 0xb2, 0x0c, 0x98, 0x16, 0xec, 0x3c, 0x70, 0x2f, 0x86, 0xc6, 0x34, 0x4c, 0x98, 0x5c, 0x31, + 0x1f, 0x2a, 0x21, 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0x0c, + 0xef, 0xa7, 0x34, 0x1e, 0xd3, 0xfe, 0x80, 0xc6, 0x8d, 0x9b, 0xb0, 0x1b, 0x8f, 0x7a, 0xf2, 0x99, + 0x9a, 0xa5, 0x4f, 0x59, 0xb7, 0x20, 0xe0, 0x9b, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x46, + 0x37, 0x79, 0xe2, 0x04, 0x00, 0x00, } diff --git a/protos/common/common.proto b/protos/common/common.proto index 893399651ab..c296fa331e1 100644 --- a/protos/common/common.proto +++ b/protos/common/common.proto @@ -59,6 +59,14 @@ message ChainHeader { // Identifier of the chain this message is bound for bytes chainID = 4; + // An unique identifier that is used end-to-end. + // - set by higher layers such as end user or SDK + // - passed to the endorser (which will check for uniqueness) + // - as the header is passed along unchanged, it will be + // be retrieved by the committer (uniqueness check here as well) + // - to be stored in the ledger + string txID = 5; + // The epoch in which this header was generated, where epoch is defined based on block height // Epoch in which the response has been generated. This field identifies a // logical window of time. A proposal response is accepted by a peer only if @@ -66,10 +74,10 @@ message ChainHeader { // 1. the epoch specified in the message is the current epoch // 2. this message has been only seen once during this epoch (i.e. it hasn't // been replayed) - uint64 epoch = 5; + uint64 epoch = 6; // Extension that may be attached based on the header type - bytes extension = 6; + bytes extension = 7; } message SignatureHeader { diff --git a/protos/peer/block.go b/protos/peer/block.go deleted file mode 100644 index a71885b07dd..00000000000 --- a/protos/peer/block.go +++ /dev/null @@ -1,106 +0,0 @@ -/* -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. -*/ - -package peer - -import ( - "fmt" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/core/util" -) - -// NewBlock creates a new block with the specified proposer ID, list of, -// transactions, and hash of the state calculated by calling State.GetHash() -// after running all transactions in the block and updating the state. -// -// TODO Remove proposerID parameter. This should be fetched from the config. -// TODO Remove the stateHash parameter. The transactions in this block should -// be run when blockchain.AddBlock() is called. This function will then update -// the stateHash in this block. -// -// func NewBlock(proposerID string, transactions []transaction.Transaction, stateHash []byte) *Block { -// block := new(Block) -// block.ProposerID = proposerID -// block.transactions = transactions -// block.stateHash = stateHash -// return block -// } - -// Bytes returns this block as an array of bytes. -func (block *Block) Bytes() ([]byte, error) { - data, err := proto.Marshal(block) - if err != nil { - logger.Errorf("Error marshalling block: %s", err) - return nil, fmt.Errorf("Could not marshal block: %s", err) - } - return data, nil -} - -// NewBlock creates a new Block given the input parameters. -func NewBlock(transactions []*Transaction, metadata []byte) *Block { - block := new(Block) - block.Transactions = transactions - block.ConsensusMetadata = metadata - return block -} - -// GetHash returns the hash of this block. -func (block *Block) GetHash() ([]byte, error) { - - // copy the block and remove the non-hash data - blockBytes, err := block.Bytes() - if err != nil { - return nil, fmt.Errorf("Could not calculate hash of block: %s", err) - } - blockCopy, err := UnmarshallBlock(blockBytes) - if err != nil { - return nil, fmt.Errorf("Could not calculate hash of block: %s", err) - } - blockCopy.NonHashData = nil - - // Hash the block - data, err := proto.Marshal(blockCopy) - if err != nil { - return nil, fmt.Errorf("Could not calculate hash of block: %s", err) - } - hash := util.ComputeCryptoHash(data) - return hash, nil -} - -// GetStateHash returns the stateHash stored in this block. The stateHash -// is the value returned by state.GetHash() after running all transactions in -// the block. -func (block *Block) GetStateHash() []byte { - return block.StateHash -} - -// SetPreviousBlockHash sets the hash of the previous block. This will be -// called by blockchain.AddBlock when then the block is added. -func (block *Block) SetPreviousBlockHash(previousBlockHash []byte) { - block.PreviousBlockHash = previousBlockHash -} - -// UnmarshallBlock converts a byte array generated by Bytes() back to a block. -func UnmarshallBlock(blockBytes []byte) (*Block, error) { - block := &Block{} - err := proto.Unmarshal(blockBytes, block) - if err != nil { - logger.Errorf("Error unmarshalling block: %s", err) - return nil, fmt.Errorf("Could not unmarshal block: %s", err) - } - return block, nil -} diff --git a/protos/peer/block_test.go b/protos/peer/block_test.go deleted file mode 100644 index cfa43f4530f..00000000000 --- a/protos/peer/block_test.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -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. -*/ - -package peer - -import ( - "bytes" - "testing" - "time" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/core/util" -) - -func Test_Block_CreateNew(t *testing.T) { - - chaincodePath := "contract_001" - /* - input := &pb.ChaincodeInput{Function: "invoke", Args: {"arg1","arg2"}} - spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, - ChaincodeID: &pb.ChaincodeID{Path: chaincodePath}, CtorMsg: input} - - // Build the ChaincodeInvocationSpec message - chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec} - - data, err := proto.Marshal(chaincodeInvocationSpec) - */ - var data []byte - cidBytes, err := proto.Marshal(&ChaincodeID{Path: chaincodePath}) - if err != nil { - t.Fatalf("Could not marshal chaincode: %s", err) - } - transaction := &Transaction{Type: 2, ChaincodeID: cidBytes, Payload: data, Txid: "001"} - t.Logf("Transaction: %v", transaction) - - block := NewBlock([]*Transaction{transaction}, nil) - t.Logf("Block: %v", block) - - data, err = proto.Marshal(block) - if err != nil { - t.Errorf("Error marshalling block: %s", err) - } - t.Logf("Marshalled data: %v", data) - - // TODO: This doesn't seem like a proper test. Needs to be edited. - blockUnmarshalled := &Block{} - proto.Unmarshal(data, blockUnmarshalled) - t.Logf("Unmarshalled block := %v", blockUnmarshalled) - -} - -func TestBlockNonHashData(t *testing.T) { - block1 := NewBlock(nil, nil) - block2 := NewBlock(nil, nil) - time1 := util.CreateUtcTimestamp() - time.Sleep(100 * time.Millisecond) - time2 := util.CreateUtcTimestamp() - block1.NonHashData = &NonHashData{LocalLedgerCommitTimestamp: time1} - block2.NonHashData = &NonHashData{LocalLedgerCommitTimestamp: time2} - hash1, err := block1.GetHash() - if err != nil { - t.Fatalf("Error generating block1 hash: %s", err) - } - hash2, err := block2.GetHash() - if err != nil { - t.Fatalf("Error generating block2 hash: %s", err) - } - if bytes.Compare(hash1, hash2) != 0 { - t.Fatalf("Expected block hashes to be equal, but there were not") - } - if time1 != block1.NonHashData.LocalLedgerCommitTimestamp { - t.Fatalf("Expected time1 and block1 times to be equal, but there were not") - } - if time2 != block2.NonHashData.LocalLedgerCommitTimestamp { - t.Fatalf("Expected time2 and block2 times to be equal, but there were not") - } -} diff --git a/protos/peer/chaincode.pb.go b/protos/peer/chaincode.pb.go index dc5e307cf36..a56c06163eb 100644 --- a/protos/peer/chaincode.pb.go +++ b/protos/peer/chaincode.pb.go @@ -2,6 +2,71 @@ // source: peer/chaincode.proto // DO NOT EDIT! +/* +Package peer is a generated protocol buffer package. + +It is generated from these files: + peer/chaincode.proto + peer/chaincode_proposal.proto + peer/chaincode_transaction.proto + peer/chaincodeevent.proto + peer/events.proto + peer/fabric.proto + peer/fabric_block.proto + peer/fabric_message.proto + peer/fabric_proposal.proto + peer/fabric_proposal_response.proto + peer/fabric_service.proto + peer/fabric_transaction.proto + peer/server_admin.proto + +It has these top-level messages: + ChaincodeID + ChaincodeInput + ChaincodeSpec + ChaincodeDeploymentSpec + ChaincodeInvocationSpec + ChaincodeMessage + PutStateInfo + RangeQueryState + RangeQueryStateNext + RangeQueryStateClose + RangeQueryStateKeyValue + RangeQueryStateResponse + ChaincodeHeaderExtension + ChaincodeProposalPayload + ChaincodeAction + ChaincodeActionPayload + ChaincodeEndorsedAction + ChaincodeEvent + ChaincodeReg + Interest + Register + Rejection + Unregister + Event + PeerAddress + PeerID + PeerEndpoint + PeersMessage + PeersAddresses + BlockchainInfo + Block2 + Message + SignedProposal + Proposal + ProposalResponse + Response + ProposalResponsePayload + Endorsement + SignedTransaction + InvalidTransaction + Transaction + TransactionAction + ServerStatus + LogLevelRequest + LogLevelResponse +*/ package peer import proto "github.com/golang/protobuf/proto" @@ -19,6 +84,12 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + // Confidentiality Levels type ConfidentialityLevel int32 @@ -39,7 +110,7 @@ var ConfidentialityLevel_value = map[string]int32{ func (x ConfidentialityLevel) String() string { return proto.EnumName(ConfidentialityLevel_name, int32(x)) } -func (ConfidentialityLevel) EnumDescriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } +func (ConfidentialityLevel) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } type ChaincodeSpec_Type int32 @@ -69,7 +140,7 @@ var ChaincodeSpec_Type_value = map[string]int32{ func (x ChaincodeSpec_Type) String() string { return proto.EnumName(ChaincodeSpec_Type_name, int32(x)) } -func (ChaincodeSpec_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor2, []int{2, 0} } +func (ChaincodeSpec_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } type ChaincodeDeploymentSpec_ExecutionEnvironment int32 @@ -91,7 +162,7 @@ func (x ChaincodeDeploymentSpec_ExecutionEnvironment) String() string { return proto.EnumName(ChaincodeDeploymentSpec_ExecutionEnvironment_name, int32(x)) } func (ChaincodeDeploymentSpec_ExecutionEnvironment) EnumDescriptor() ([]byte, []int) { - return fileDescriptor2, []int{3, 0} + return fileDescriptor0, []int{3, 0} } type ChaincodeMessage_Type int32 @@ -109,15 +180,11 @@ const ( ChaincodeMessage_PUT_STATE ChaincodeMessage_Type = 9 ChaincodeMessage_DEL_STATE ChaincodeMessage_Type = 10 ChaincodeMessage_INVOKE_CHAINCODE ChaincodeMessage_Type = 11 - ChaincodeMessage_INVOKE_QUERY ChaincodeMessage_Type = 12 ChaincodeMessage_RESPONSE ChaincodeMessage_Type = 13 - ChaincodeMessage_QUERY ChaincodeMessage_Type = 14 - ChaincodeMessage_QUERY_COMPLETED ChaincodeMessage_Type = 15 - ChaincodeMessage_QUERY_ERROR ChaincodeMessage_Type = 16 - ChaincodeMessage_RANGE_QUERY_STATE ChaincodeMessage_Type = 17 - ChaincodeMessage_RANGE_QUERY_STATE_NEXT ChaincodeMessage_Type = 18 - ChaincodeMessage_RANGE_QUERY_STATE_CLOSE ChaincodeMessage_Type = 19 - ChaincodeMessage_KEEPALIVE ChaincodeMessage_Type = 20 + ChaincodeMessage_RANGE_QUERY_STATE ChaincodeMessage_Type = 14 + ChaincodeMessage_RANGE_QUERY_STATE_NEXT ChaincodeMessage_Type = 15 + ChaincodeMessage_RANGE_QUERY_STATE_CLOSE ChaincodeMessage_Type = 16 + ChaincodeMessage_KEEPALIVE ChaincodeMessage_Type = 17 ) var ChaincodeMessage_Type_name = map[int32]string{ @@ -133,15 +200,11 @@ var ChaincodeMessage_Type_name = map[int32]string{ 9: "PUT_STATE", 10: "DEL_STATE", 11: "INVOKE_CHAINCODE", - 12: "INVOKE_QUERY", 13: "RESPONSE", - 14: "QUERY", - 15: "QUERY_COMPLETED", - 16: "QUERY_ERROR", - 17: "RANGE_QUERY_STATE", - 18: "RANGE_QUERY_STATE_NEXT", - 19: "RANGE_QUERY_STATE_CLOSE", - 20: "KEEPALIVE", + 14: "RANGE_QUERY_STATE", + 15: "RANGE_QUERY_STATE_NEXT", + 16: "RANGE_QUERY_STATE_CLOSE", + 17: "KEEPALIVE", } var ChaincodeMessage_Type_value = map[string]int32{ "UNDEFINED": 0, @@ -156,21 +219,17 @@ var ChaincodeMessage_Type_value = map[string]int32{ "PUT_STATE": 9, "DEL_STATE": 10, "INVOKE_CHAINCODE": 11, - "INVOKE_QUERY": 12, "RESPONSE": 13, - "QUERY": 14, - "QUERY_COMPLETED": 15, - "QUERY_ERROR": 16, - "RANGE_QUERY_STATE": 17, - "RANGE_QUERY_STATE_NEXT": 18, - "RANGE_QUERY_STATE_CLOSE": 19, - "KEEPALIVE": 20, + "RANGE_QUERY_STATE": 14, + "RANGE_QUERY_STATE_NEXT": 15, + "RANGE_QUERY_STATE_CLOSE": 16, + "KEEPALIVE": 17, } func (x ChaincodeMessage_Type) String() string { return proto.EnumName(ChaincodeMessage_Type_name, int32(x)) } -func (ChaincodeMessage_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor2, []int{6, 0} } +func (ChaincodeMessage_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{5, 0} } // ChaincodeID contains the path as specified by the deploy transaction // that created it as well as the hashCode that is generated by the @@ -190,7 +249,7 @@ type ChaincodeID struct { func (m *ChaincodeID) Reset() { *m = ChaincodeID{} } func (m *ChaincodeID) String() string { return proto.CompactTextString(m) } func (*ChaincodeID) ProtoMessage() {} -func (*ChaincodeID) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } +func (*ChaincodeID) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } // Carries the chaincode function and its arguments. // UnmarshalJSON in transaction.go converts the string-based REST/JSON input to @@ -202,7 +261,7 @@ type ChaincodeInput struct { func (m *ChaincodeInput) Reset() { *m = ChaincodeInput{} } func (m *ChaincodeInput) String() string { return proto.CompactTextString(m) } func (*ChaincodeInput) ProtoMessage() {} -func (*ChaincodeInput) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{1} } +func (*ChaincodeInput) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } // Carries the chaincode specification. This is the actual metadata required for // defining a chaincode. @@ -220,7 +279,7 @@ type ChaincodeSpec struct { func (m *ChaincodeSpec) Reset() { *m = ChaincodeSpec{} } func (m *ChaincodeSpec) String() string { return proto.CompactTextString(m) } func (*ChaincodeSpec) ProtoMessage() {} -func (*ChaincodeSpec) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{2} } +func (*ChaincodeSpec) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } func (m *ChaincodeSpec) GetChaincodeID() *ChaincodeID { if m != nil { @@ -249,7 +308,7 @@ type ChaincodeDeploymentSpec struct { func (m *ChaincodeDeploymentSpec) Reset() { *m = ChaincodeDeploymentSpec{} } func (m *ChaincodeDeploymentSpec) String() string { return proto.CompactTextString(m) } func (*ChaincodeDeploymentSpec) ProtoMessage() {} -func (*ChaincodeDeploymentSpec) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{3} } +func (*ChaincodeDeploymentSpec) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } func (m *ChaincodeDeploymentSpec) GetChaincodeSpec() *ChaincodeSpec { if m != nil { @@ -281,7 +340,7 @@ type ChaincodeInvocationSpec struct { func (m *ChaincodeInvocationSpec) Reset() { *m = ChaincodeInvocationSpec{} } func (m *ChaincodeInvocationSpec) String() string { return proto.CompactTextString(m) } func (*ChaincodeInvocationSpec) ProtoMessage() {} -func (*ChaincodeInvocationSpec) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{4} } +func (*ChaincodeInvocationSpec) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } func (m *ChaincodeInvocationSpec) GetChaincodeSpec() *ChaincodeSpec { if m != nil { @@ -290,38 +349,11 @@ func (m *ChaincodeInvocationSpec) GetChaincodeSpec() *ChaincodeSpec { return nil } -// This structure contain transaction data that we send to the chaincode -// container shim and allow the chaincode to access through the shim interface. -// TODO: Consider remove this message and just pass the transaction object -// to the shim and/or allow the chaincode to query transactions. -type ChaincodeSecurityContext struct { - CallerCert []byte `protobuf:"bytes,1,opt,name=callerCert,proto3" json:"callerCert,omitempty"` - CallerSign []byte `protobuf:"bytes,2,opt,name=callerSign,proto3" json:"callerSign,omitempty"` - Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` - Binding []byte `protobuf:"bytes,4,opt,name=binding,proto3" json:"binding,omitempty"` - Metadata []byte `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` - ParentMetadata []byte `protobuf:"bytes,6,opt,name=parentMetadata,proto3" json:"parentMetadata,omitempty"` - TxTimestamp *google_protobuf.Timestamp `protobuf:"bytes,7,opt,name=txTimestamp" json:"txTimestamp,omitempty"` -} - -func (m *ChaincodeSecurityContext) Reset() { *m = ChaincodeSecurityContext{} } -func (m *ChaincodeSecurityContext) String() string { return proto.CompactTextString(m) } -func (*ChaincodeSecurityContext) ProtoMessage() {} -func (*ChaincodeSecurityContext) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{5} } - -func (m *ChaincodeSecurityContext) GetTxTimestamp() *google_protobuf.Timestamp { - if m != nil { - return m.TxTimestamp - } - return nil -} - type ChaincodeMessage struct { - Type ChaincodeMessage_Type `protobuf:"varint,1,opt,name=type,enum=protos.ChaincodeMessage_Type" json:"type,omitempty"` - Timestamp *google_protobuf.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"` - SecurityContext *ChaincodeSecurityContext `protobuf:"bytes,5,opt,name=securityContext" json:"securityContext,omitempty"` + Type ChaincodeMessage_Type `protobuf:"varint,1,opt,name=type,enum=protos.ChaincodeMessage_Type" json:"type,omitempty"` + Timestamp *google_protobuf.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"` // event emmited by chaincode. Used only with Init or Invoke. // This event is then stored (currently) // with Block.NonHashData.TransactionResult @@ -331,7 +363,7 @@ type ChaincodeMessage struct { func (m *ChaincodeMessage) Reset() { *m = ChaincodeMessage{} } func (m *ChaincodeMessage) String() string { return proto.CompactTextString(m) } func (*ChaincodeMessage) ProtoMessage() {} -func (*ChaincodeMessage) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{6} } +func (*ChaincodeMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } func (m *ChaincodeMessage) GetTimestamp() *google_protobuf.Timestamp { if m != nil { @@ -340,13 +372,6 @@ func (m *ChaincodeMessage) GetTimestamp() *google_protobuf.Timestamp { return nil } -func (m *ChaincodeMessage) GetSecurityContext() *ChaincodeSecurityContext { - if m != nil { - return m.SecurityContext - } - return nil -} - func (m *ChaincodeMessage) GetChaincodeEvent() *ChaincodeEvent { if m != nil { return m.ChaincodeEvent @@ -362,7 +387,7 @@ type PutStateInfo struct { func (m *PutStateInfo) Reset() { *m = PutStateInfo{} } func (m *PutStateInfo) String() string { return proto.CompactTextString(m) } func (*PutStateInfo) ProtoMessage() {} -func (*PutStateInfo) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{7} } +func (*PutStateInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } type RangeQueryState struct { StartKey string `protobuf:"bytes,1,opt,name=startKey" json:"startKey,omitempty"` @@ -372,7 +397,7 @@ type RangeQueryState struct { func (m *RangeQueryState) Reset() { *m = RangeQueryState{} } func (m *RangeQueryState) String() string { return proto.CompactTextString(m) } func (*RangeQueryState) ProtoMessage() {} -func (*RangeQueryState) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{8} } +func (*RangeQueryState) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } type RangeQueryStateNext struct { ID string `protobuf:"bytes,1,opt,name=ID" json:"ID,omitempty"` @@ -381,7 +406,7 @@ type RangeQueryStateNext struct { func (m *RangeQueryStateNext) Reset() { *m = RangeQueryStateNext{} } func (m *RangeQueryStateNext) String() string { return proto.CompactTextString(m) } func (*RangeQueryStateNext) ProtoMessage() {} -func (*RangeQueryStateNext) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{9} } +func (*RangeQueryStateNext) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } type RangeQueryStateClose struct { ID string `protobuf:"bytes,1,opt,name=ID" json:"ID,omitempty"` @@ -390,7 +415,7 @@ type RangeQueryStateClose struct { func (m *RangeQueryStateClose) Reset() { *m = RangeQueryStateClose{} } func (m *RangeQueryStateClose) String() string { return proto.CompactTextString(m) } func (*RangeQueryStateClose) ProtoMessage() {} -func (*RangeQueryStateClose) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{10} } +func (*RangeQueryStateClose) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } type RangeQueryStateKeyValue struct { Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` @@ -400,7 +425,7 @@ type RangeQueryStateKeyValue struct { func (m *RangeQueryStateKeyValue) Reset() { *m = RangeQueryStateKeyValue{} } func (m *RangeQueryStateKeyValue) String() string { return proto.CompactTextString(m) } func (*RangeQueryStateKeyValue) ProtoMessage() {} -func (*RangeQueryStateKeyValue) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{11} } +func (*RangeQueryStateKeyValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } type RangeQueryStateResponse struct { KeysAndValues []*RangeQueryStateKeyValue `protobuf:"bytes,1,rep,name=keysAndValues" json:"keysAndValues,omitempty"` @@ -411,7 +436,7 @@ type RangeQueryStateResponse struct { func (m *RangeQueryStateResponse) Reset() { *m = RangeQueryStateResponse{} } func (m *RangeQueryStateResponse) String() string { return proto.CompactTextString(m) } func (*RangeQueryStateResponse) ProtoMessage() {} -func (*RangeQueryStateResponse) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{12} } +func (*RangeQueryStateResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } func (m *RangeQueryStateResponse) GetKeysAndValues() []*RangeQueryStateKeyValue { if m != nil { @@ -426,7 +451,6 @@ func init() { proto.RegisterType((*ChaincodeSpec)(nil), "protos.ChaincodeSpec") proto.RegisterType((*ChaincodeDeploymentSpec)(nil), "protos.ChaincodeDeploymentSpec") proto.RegisterType((*ChaincodeInvocationSpec)(nil), "protos.ChaincodeInvocationSpec") - proto.RegisterType((*ChaincodeSecurityContext)(nil), "protos.ChaincodeSecurityContext") proto.RegisterType((*ChaincodeMessage)(nil), "protos.ChaincodeMessage") proto.RegisterType((*PutStateInfo)(nil), "protos.PutStateInfo") proto.RegisterType((*RangeQueryState)(nil), "protos.RangeQueryState") @@ -541,87 +565,79 @@ var _ChaincodeSupport_serviceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: fileDescriptor2, -} - -func init() { proto.RegisterFile("peer/chaincode.proto", fileDescriptor2) } - -var fileDescriptor2 = []byte{ - // 1210 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x6e, 0xdb, 0xc6, - 0x13, 0x8f, 0x3e, 0x6c, 0x4b, 0xa3, 0x0f, 0x6f, 0xd6, 0x8a, 0xa3, 0xbf, 0xfe, 0x6d, 0x22, 0x10, - 0x69, 0xa0, 0xf6, 0x20, 0xa7, 0x6a, 0x52, 0x14, 0x68, 0x11, 0x94, 0x21, 0x37, 0x2e, 0x63, 0x99, - 0x52, 0x56, 0xb4, 0x91, 0xf4, 0x62, 0xd0, 0xd4, 0x9a, 0x26, 0x22, 0x93, 0x04, 0xb9, 0x12, 0xac, - 0x5b, 0xcf, 0x3d, 0xf5, 0x19, 0xfa, 0x10, 0x3d, 0xf4, 0x81, 0xfa, 0x1c, 0xc5, 0x2e, 0x49, 0x59, - 0x5f, 0x09, 0x02, 0xf4, 0xc4, 0x9d, 0x99, 0xdf, 0xcc, 0xce, 0xce, 0xfc, 0x76, 0xb8, 0xd0, 0x08, - 0x19, 0x8b, 0x8e, 0x9c, 0x6b, 0xdb, 0xf3, 0x9d, 0x60, 0xc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xbf, 0x5d, 0xf0, 0x42, - 0xde, 0x89, 0x4f, 0x33, 0x67, 0x19, 0xae, 0xfc, 0xb9, 0x03, 0x68, 0x51, 0x92, 0x53, 0x16, 0xc7, - 0x82, 0x2a, 0xdf, 0xae, 0x8c, 0xa3, 0x2f, 0x37, 0xba, 0x90, 0xe2, 0x96, 0x27, 0xd2, 0x0f, 0x50, - 0x5e, 0xcc, 0xd0, 0xcf, 0x60, 0xef, 0x1d, 0xf8, 0x13, 0x75, 0xc3, 0x50, 0xe4, 0xb7, 0xde, 0x58, - 0x16, 0xad, 0x4c, 0xe5, 0x1a, 0xbf, 0x81, 0xfd, 0x78, 0xb5, 0x71, 0xb2, 0x70, 0x95, 0x5e, 0x7b, - 0x93, 0x2b, 0xab, 0x38, 0xba, 0xee, 0x88, 0x5f, 0x42, 0x7d, 0xc1, 0x24, 0x22, 0xfe, 0x0e, 0xb2, - 0xc2, 0xdb, 0xa6, 0xa2, 0xb4, 0xd2, 0x35, 0xb4, 0xf2, 0x4f, 0x7e, 0xfb, 0x3c, 0xa9, 0x42, 0x89, - 0x92, 0x63, 0x63, 0x64, 0x11, 0x8a, 0x72, 0xb8, 0x0e, 0x90, 0x49, 0x44, 0x47, 0x79, 0x31, 0x4e, - 0x0c, 0xd3, 0xb0, 0x50, 0x01, 0x97, 0x61, 0x87, 0x12, 0x55, 0x7f, 0x8f, 0x8a, 0x78, 0x1f, 0x2a, - 0x16, 0x55, 0xcd, 0x91, 0xaa, 0x59, 0xc6, 0xc0, 0x44, 0x3b, 0x22, 0xa4, 0x36, 0x38, 0x1d, 0xf6, - 0x89, 0x45, 0x74, 0xb4, 0x2b, 0xa0, 0x84, 0xd2, 0x01, 0x45, 0x7b, 0xc2, 0x72, 0x4c, 0xac, 0x8b, - 0x91, 0xa5, 0x5a, 0x04, 0x95, 0x84, 0x38, 0x3c, 0xcb, 0xc4, 0xb2, 0x10, 0x75, 0xd2, 0x4f, 0x45, - 0xc0, 0x0d, 0x40, 0x86, 0x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00, - 0xff, 0xff, 0xb5, 0xd0, 0x69, 0x9f, 0x63, 0x0a, 0x00, 0x00, + Metadata: fileDescriptor0, +} + +func init() { proto.RegisterFile("peer/chaincode.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 1073 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x56, 0x5f, 0x6f, 0xda, 0x56, + 0x14, 0xaf, 0x81, 0x24, 0x70, 0xf8, 0x93, 0xdb, 0x5b, 0x9a, 0x32, 0xf6, 0xa7, 0x91, 0xd5, 0x4d, + 0x6c, 0x0f, 0xa4, 0xcb, 0xda, 0x69, 0xd2, 0xa4, 0x6a, 0xae, 0x7d, 0xcb, 0xbc, 0x10, 0x43, 0x2f, + 0x4e, 0xd4, 0xee, 0x25, 0x72, 0xcc, 0x81, 0x58, 0x05, 0xdb, 0xb2, 0x2f, 0x28, 0xbc, 0xed, 0x79, + 0xaf, 0xfb, 0x08, 0xfb, 0x0e, 0x7b, 0xd8, 0xa7, 0x9b, 0xae, 0x8d, 0x29, 0x04, 0x22, 0x55, 0xda, + 0x13, 0xf7, 0x9c, 0xf3, 0xfb, 0x9d, 0x7b, 0xee, 0xf9, 0x87, 0xa1, 0x1e, 0x22, 0x46, 0x27, 0xee, + 0x8d, 0xe3, 0xf9, 0x6e, 0x30, 0xc4, 0x76, 0x18, 0x05, 0x22, 0xa0, 0xfb, 0xc9, 0x4f, 0xdc, 0xfc, + 0x6c, 0xd3, 0x8a, 0x73, 0xf4, 0x45, 0x0a, 0x69, 0x3e, 0x1d, 0x07, 0xc1, 0x78, 0x82, 0x27, 0x89, + 0x74, 0x3d, 0x1b, 0x9d, 0x08, 0x6f, 0x8a, 0xb1, 0x70, 0xa6, 0x61, 0x0a, 0x50, 0x5f, 0x42, 0x59, + 0xcf, 0x88, 0xa6, 0x41, 0x29, 0x14, 0x42, 0x47, 0xdc, 0x34, 0x94, 0x63, 0xa5, 0x55, 0xe2, 0xc9, + 0x59, 0xea, 0x7c, 0x67, 0x8a, 0x8d, 0x5c, 0xaa, 0x93, 0x67, 0xf5, 0x19, 0xd4, 0x3e, 0xd2, 0xfc, + 0x70, 0x26, 0x24, 0xca, 0x89, 0xc6, 0x71, 0x43, 0x39, 0xce, 0xb7, 0x2a, 0x3c, 0x39, 0xab, 0xff, + 0xe4, 0xa1, 0xba, 0x82, 0x0d, 0x42, 0x74, 0x69, 0x1b, 0x0a, 0x62, 0x11, 0x62, 0xe2, 0xbf, 0x76, + 0xda, 0x4c, 0x83, 0x88, 0xdb, 0x1b, 0xa0, 0xb6, 0xbd, 0x08, 0x91, 0x27, 0x38, 0xfa, 0x12, 0xca, + 0xee, 0xc7, 0xf0, 0x92, 0x10, 0xca, 0xa7, 0x8f, 0xb6, 0x68, 0xa6, 0xc1, 0xd7, 0x71, 0xf4, 0x39, + 0x1c, 0xb8, 0x22, 0x88, 0xce, 0xe3, 0x71, 0x23, 0x9f, 0x50, 0x8e, 0xb6, 0x29, 0x32, 0x6a, 0x9e, + 0xc1, 0x68, 0x03, 0x0e, 0x64, 0x6a, 0x82, 0x99, 0x68, 0x14, 0x8e, 0x95, 0xd6, 0x1e, 0xcf, 0x44, + 0xfa, 0x0c, 0xaa, 0x31, 0xba, 0xb3, 0x08, 0xf5, 0xc0, 0x17, 0x78, 0x2b, 0x1a, 0x7b, 0x49, 0x1e, + 0x36, 0x95, 0xb4, 0x0f, 0x75, 0x37, 0xf0, 0x47, 0xde, 0x10, 0x7d, 0xe1, 0x39, 0x13, 0x4f, 0x2c, + 0xba, 0x38, 0xc7, 0x49, 0x63, 0x3f, 0x79, 0xe8, 0x17, 0xab, 0xeb, 0x77, 0x60, 0xf8, 0x4e, 0x26, + 0x6d, 0x42, 0x71, 0x8a, 0xc2, 0x19, 0x3a, 0xc2, 0x69, 0x1c, 0x1c, 0x2b, 0xad, 0x0a, 0x5f, 0xc9, + 0xf4, 0x2b, 0x00, 0x47,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 0x09, 0x7d, 0xc1, 0x08, 0x00, + 0x00, } diff --git a/protos/peer/chaincode.proto b/protos/peer/chaincode.proto index 056e8110857..4c26144c823 100644 --- a/protos/peer/chaincode.proto +++ b/protos/peer/chaincode.proto @@ -106,20 +106,6 @@ message ChaincodeInvocationSpec { string idGenerationAlg = 2; } -// This structure contain transaction data that we send to the chaincode -// container shim and allow the chaincode to access through the shim interface. -// TODO: Consider remove this message and just pass the transaction object -// to the shim and/or allow the chaincode to query transactions. -message ChaincodeSecurityContext { - bytes callerCert = 1; - bytes callerSign = 2; - bytes payload = 3; - bytes binding = 4; - bytes metadata = 5; - bytes parentMetadata = 6; - google.protobuf.Timestamp txTimestamp = 7; // transaction timestamp -} - message ChaincodeMessage { enum Type { @@ -135,22 +121,17 @@ message ChaincodeMessage { PUT_STATE = 9; DEL_STATE = 10; INVOKE_CHAINCODE = 11; - INVOKE_QUERY = 12; RESPONSE = 13; - QUERY = 14; - QUERY_COMPLETED = 15; - QUERY_ERROR = 16; - RANGE_QUERY_STATE = 17; - RANGE_QUERY_STATE_NEXT = 18; - RANGE_QUERY_STATE_CLOSE = 19; - KEEPALIVE = 20; + RANGE_QUERY_STATE = 14; + RANGE_QUERY_STATE_NEXT = 15; + RANGE_QUERY_STATE_CLOSE = 16; + KEEPALIVE = 17; } Type type = 1; google.protobuf.Timestamp timestamp = 2; bytes payload = 3; string txid = 4; - ChaincodeSecurityContext securityContext = 5; //event emmited by chaincode. Used only with Init or Invoke. // This event is then stored (currently) diff --git a/protos/peer/chaincode_transaction.pb.go b/protos/peer/chaincode_transaction.pb.go index 286eb44ab8f..d464d520c81 100644 --- a/protos/peer/chaincode_transaction.pb.go +++ b/protos/peer/chaincode_transaction.pb.go @@ -34,7 +34,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 fileDescriptor3, []int{0} } +func (*ChaincodeActionPayload) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } func (m *ChaincodeActionPayload) GetAction() *ChaincodeEndorsedAction { if m != nil { @@ -58,7 +58,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 fileDescriptor3, []int{1} } +func (*ChaincodeEndorsedAction) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{1} } func (m *ChaincodeEndorsedAction) GetEndorsements() []*Endorsement { if m != nil { @@ -72,9 +72,9 @@ func init() { proto.RegisterType((*ChaincodeEndorsedAction)(nil), "protos.ChaincodeEndorsedAction") } -func init() { proto.RegisterFile("peer/chaincode_transaction.proto", fileDescriptor3) } +func init() { proto.RegisterFile("peer/chaincode_transaction.proto", fileDescriptor2) } -var fileDescriptor3 = []byte{ +var fileDescriptor2 = []byte{ // 248 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x90, 0x31, 0x4f, 0xc3, 0x30, 0x14, 0x84, 0xe5, 0x22, 0x75, 0x70, 0x3b, 0x19, 0x89, 0x46, 0x2c, 0x44, 0x65, 0x09, 0x42, 0x4a, diff --git a/protos/peer/chaincodeevent.pb.go b/protos/peer/chaincodeevent.pb.go index 32c48095271..91eb13ad47d 100644 --- a/protos/peer/chaincodeevent.pb.go +++ b/protos/peer/chaincodeevent.pb.go @@ -2,77 +2,6 @@ // source: peer/chaincodeevent.proto // DO NOT EDIT! -/* -Package peer is a generated protocol buffer package. - -It is generated from these files: - peer/chaincodeevent.proto - peer/chaincode_proposal.proto - peer/chaincode.proto - peer/chaincode_transaction.proto - peer/events.proto - peer/fabric_block.proto - peer/fabric_message.proto - peer/fabric_proposal.proto - peer/fabric_proposal_response.proto - peer/fabric.proto - peer/fabric_service.proto - peer/fabric_transaction.proto - peer/server_admin.proto - -It has these top-level messages: - ChaincodeEvent - ChaincodeHeaderExtension - ChaincodeProposalPayload - ChaincodeAction - ChaincodeID - ChaincodeInput - ChaincodeSpec - ChaincodeDeploymentSpec - ChaincodeInvocationSpec - ChaincodeSecurityContext - ChaincodeMessage - PutStateInfo - RangeQueryState - RangeQueryStateNext - RangeQueryStateClose - RangeQueryStateKeyValue - RangeQueryStateResponse - ChaincodeActionPayload - ChaincodeEndorsedAction - ChaincodeReg - Interest - Register - Rejection - Unregister - Event - Block2 - Message2 - SignedProposal - Proposal - ProposalResponse - Response2 - ProposalResponsePayload - Endorsement - Transaction - TransactionBlock - TransactionResult - Block - BlockchainInfo - NonHashData - PeerAddress - PeerID - PeerEndpoint - PeersMessage - PeersAddresses - SignedTransaction - InvalidTransaction - Transaction2 - TransactionAction - ServerStatus - LogLevelRequest - LogLevelResponse -*/ package peer import proto "github.com/golang/protobuf/proto" @@ -84,12 +13,6 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - // ChaincodeEvent is used for events and registrations that are specific to chaincode // string type - "chaincode" type ChaincodeEvent struct { @@ -102,15 +25,15 @@ type ChaincodeEvent struct { func (m *ChaincodeEvent) Reset() { *m = ChaincodeEvent{} } func (m *ChaincodeEvent) String() string { return proto.CompactTextString(m) } func (*ChaincodeEvent) ProtoMessage() {} -func (*ChaincodeEvent) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (*ChaincodeEvent) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } func init() { proto.RegisterType((*ChaincodeEvent)(nil), "protos.ChaincodeEvent") } -func init() { proto.RegisterFile("peer/chaincodeevent.proto", fileDescriptor0) } +func init() { proto.RegisterFile("peer/chaincodeevent.proto", fileDescriptor3) } -var fileDescriptor0 = []byte{ +var fileDescriptor3 = []byte{ // 186 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x48, 0x4d, 0x2d, 0xd2, 0x4f, 0xce, 0x48, 0xcc, 0xcc, 0x4b, 0xce, 0x4f, 0x49, 0x4d, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, diff --git a/protos/peer/events.pb.go b/protos/peer/events.pb.go index e72b52ee77a..5c0c2f78fab 100644 --- a/protos/peer/events.pb.go +++ b/protos/peer/events.pb.go @@ -234,7 +234,7 @@ type Event_Register struct { Register *Register `protobuf:"bytes,1,opt,name=register,oneof"` } type Event_Block struct { - Block *Block `protobuf:"bytes,2,opt,name=block,oneof"` + Block *Block2 `protobuf:"bytes,2,opt,name=block,oneof"` } type Event_ChaincodeEvent struct { ChaincodeEvent *ChaincodeEvent `protobuf:"bytes,3,opt,name=chaincodeEvent,oneof"` @@ -266,7 +266,7 @@ func (m *Event) GetRegister() *Register { return nil } -func (m *Event) GetBlock() *Block { +func (m *Event) GetBlock() *Block2 { if x, ok := m.GetEvent().(*Event_Block); ok { return x.Block } @@ -356,7 +356,7 @@ func _Event_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - msg := new(Block) + msg := new(Block2) err := b.DecodeMessage(msg) m.Event = &Event_Block{msg} return true, err @@ -544,36 +544,37 @@ var _Events_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("peer/events.proto", fileDescriptor4) } var fileDescriptor4 = []byte{ - // 485 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x93, 0xc1, 0x8f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3e, 0x46, 0x5f, 0xd7, 0x01, 0x31, 0x15, - 0x34, 0xa0, 0xef, 0x5d, 0xac, 0xfc, 0xcf, 0xa6, 0x8a, 0x23, 0x30, 0xfc, 0xf0, 0x43, 0xb4, 0xf4, - 0x57, 0xe7, 0x81, 0xa9, 0xed, 0x97, 0x24, 0xf8, 0x14, 0xf8, 0xeb, 0x68, 0xb5, 0x34, 0x7b, 0xee, - 0x02, 0x06, 0x62, 0x46, 0x89, 0x67, 0x70, 0xe4, 0x6f, 0x63, 0x8e, 0xa3, 0x07, 0x77, 0x72, 0xf2, - 0x70, 0x69, 0x2b, 0x33, 0xf5, 0xb5, 0xea, 0xbd, 0xfa, 0xfe, 0x32, 0xcd, 0xf8, 0xf6, 0x76, 0x33, - 0x4f, 0x8a, 0x1b, 0x67, 0x7b, 0xbf, 0xa3, 0xec, 0x9a, 0x5e, 0xa6, 0xcd, 0x73, 0x72, 0x2a, 0x8f, - 0xb3, 0x7f, 0x61, 0x9b, 0xea, 0x29, 0xbe, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xea, 0x3a, 0x18, - 0x18, 0xa6, 0x03, 0x00, 0x00, + // 499 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x53, 0x51, 0x8f, 0x93, 0x4c, + 0x14, 0x05, 0xba, 0xed, 0xc2, 0xed, 0x6e, 0x43, 0xef, 0xf7, 0x45, 0xb1, 0xd1, 0xa4, 0xc1, 0xc4, + 0xd4, 0x35, 0x29, 0x8a, 0x8d, 0xcf, 0x0a, 0x4b, 0x04, 0x5d, 0xdb, 0x64, 0xac, 0x2f, 0xbe, 0x18, + 0xca, 0xce, 0x52, 0x74, 0x17, 0x9a, 0x61, 0xd6, 0xec, 0xfe, 0x05, 0x5f, 0xfd, 0xc3, 0xa6, 0x03, + 0x03, 0xac, 0xfb, 0xe4, 0x13, 0xcc, 0x3d, 0xe7, 0x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x3d, 0x4a, 0x3c, 0x81, 0x03, 0x7f, 0x1b, 0x73, 0x3c, 0xbe, 0x73, 0x29, 0x27, 0x77, 0x8f, + 0xb6, 0x32, 0x53, 0x5f, 0xaa, 0xde, 0x8b, 0xaf, 0xcf, 0xd3, 0x8c, 0x6f, 0xaf, 0x37, 0xf3, 0xa4, + 0xb8, 0x72, 0xb6, 0xb7, 0x3b, 0xca, 0x2e, 0xe9, 0x79, 0xda, 0x6c, 0x95, 0x53, 0x69, 0x9c, 0xfd, + 0xa2, 0x6d, 0xaa, 0x85, 0x7d, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x44, 0x56, 0x27, 0xe8, 0xcc, + 0x03, 0x00, 0x00, } diff --git a/protos/peer/events.proto b/protos/peer/events.proto index ba83832a861..968688ff25a 100644 --- a/protos/peer/events.proto +++ b/protos/peer/events.proto @@ -17,7 +17,8 @@ limitations under the License. syntax = "proto3"; import "peer/chaincodeevent.proto"; -import "peer/fabric.proto"; +import "peer/fabric_transaction.proto"; +import "peer/fabric_block.proto"; option go_package = "github.com/hyperledger/fabric/protos/peer"; @@ -81,7 +82,7 @@ message Event { Register register = 1; //producer events - Block block = 2; + Block2 block = 2; ChaincodeEvent chaincodeEvent = 3; Rejection rejection = 4; diff --git a/protos/peer/fabric.pb.go b/protos/peer/fabric.pb.go index 8d62ee8fdeb..1d94bf5bec1 100644 --- a/protos/peer/fabric.pb.go +++ b/protos/peer/fabric.pb.go @@ -7,47 +7,12 @@ package peer import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import google_protobuf "github.com/golang/protobuf/ptypes/timestamp" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -type Transaction_Type int32 - -const ( - Transaction_UNDEFINED Transaction_Type = 0 - // deploy a chaincode to the network and call `Init` function - Transaction_CHAINCODE_DEPLOY Transaction_Type = 1 - // call a chaincode `Invoke` function as a transaction - Transaction_CHAINCODE_INVOKE Transaction_Type = 2 - // call a chaincode `query` function - Transaction_CHAINCODE_QUERY Transaction_Type = 3 - // terminate a chaincode; not implemented yet - Transaction_CHAINCODE_TERMINATE Transaction_Type = 4 -) - -var Transaction_Type_name = map[int32]string{ - 0: "UNDEFINED", - 1: "CHAINCODE_DEPLOY", - 2: "CHAINCODE_INVOKE", - 3: "CHAINCODE_QUERY", - 4: "CHAINCODE_TERMINATE", -} -var Transaction_Type_value = map[string]int32{ - "UNDEFINED": 0, - "CHAINCODE_DEPLOY": 1, - "CHAINCODE_INVOKE": 2, - "CHAINCODE_QUERY": 3, - "CHAINCODE_TERMINATE": 4, -} - -func (x Transaction_Type) String() string { - return proto.EnumName(Transaction_Type_name, int32(x)) -} -func (Transaction_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor9, []int{0, 0} } - type PeerEndpoint_Type int32 const ( @@ -70,175 +35,7 @@ var PeerEndpoint_Type_value = map[string]int32{ func (x PeerEndpoint_Type) String() string { return proto.EnumName(PeerEndpoint_Type_name, int32(x)) } -func (PeerEndpoint_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor9, []int{8, 0} } - -// Transaction defines a function call to a contract. -// `args` is an array of type string so that the chaincode writer can choose -// whatever format they wish for the arguments for their chaincode. -// For example, they may wish to use JSON, XML, or a custom format. -// TODO: Defined remaining fields. -type Transaction struct { - Type Transaction_Type `protobuf:"varint,1,opt,name=type,enum=protos.Transaction_Type" json:"type,omitempty"` - // store ChaincodeID as bytes so its encrypted value can be stored - ChaincodeID []byte `protobuf:"bytes,2,opt,name=chaincodeID,proto3" json:"chaincodeID,omitempty"` - Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` - Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` - Txid string `protobuf:"bytes,5,opt,name=txid" json:"txid,omitempty"` - Timestamp *google_protobuf.Timestamp `protobuf:"bytes,6,opt,name=timestamp" json:"timestamp,omitempty"` - ConfidentialityLevel ConfidentialityLevel `protobuf:"varint,7,opt,name=confidentialityLevel,enum=protos.ConfidentialityLevel" json:"confidentialityLevel,omitempty"` - ConfidentialityProtocolVersion string `protobuf:"bytes,8,opt,name=confidentialityProtocolVersion" json:"confidentialityProtocolVersion,omitempty"` - Nonce []byte `protobuf:"bytes,9,opt,name=nonce,proto3" json:"nonce,omitempty"` - ToValidators []byte `protobuf:"bytes,10,opt,name=toValidators,proto3" json:"toValidators,omitempty"` - Cert []byte `protobuf:"bytes,11,opt,name=cert,proto3" json:"cert,omitempty"` - Signature []byte `protobuf:"bytes,12,opt,name=signature,proto3" json:"signature,omitempty"` -} - -func (m *Transaction) Reset() { *m = Transaction{} } -func (m *Transaction) String() string { return proto.CompactTextString(m) } -func (*Transaction) ProtoMessage() {} -func (*Transaction) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{0} } - -func (m *Transaction) GetTimestamp() *google_protobuf.Timestamp { - if m != nil { - return m.Timestamp - } - return nil -} - -// TransactionBlock carries a batch of transactions. -type TransactionBlock struct { - Transactions []*Transaction `protobuf:"bytes,1,rep,name=transactions" json:"transactions,omitempty"` -} - -func (m *TransactionBlock) Reset() { *m = TransactionBlock{} } -func (m *TransactionBlock) String() string { return proto.CompactTextString(m) } -func (*TransactionBlock) ProtoMessage() {} -func (*TransactionBlock) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{1} } - -func (m *TransactionBlock) GetTransactions() []*Transaction { - if m != nil { - return m.Transactions - } - return nil -} - -// TransactionResult contains the return value of a transaction. It does -// not track potential state changes that were a result of the transaction. -// txid - The unique identifier of this transaction. -// result - The return value of the transaction. -// errorCode - An error code. 5xx will be logged as a failure in the dashboard. -// error - An error string for logging an issue. -// chaincodeEvent - any event emitted by a transaction -type TransactionResult struct { - Txid string `protobuf:"bytes,1,opt,name=txid" json:"txid,omitempty"` - Result []byte `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"` - ErrorCode uint32 `protobuf:"varint,3,opt,name=errorCode" json:"errorCode,omitempty"` - Error string `protobuf:"bytes,4,opt,name=error" json:"error,omitempty"` - ChaincodeEvent *ChaincodeEvent `protobuf:"bytes,5,opt,name=chaincodeEvent" json:"chaincodeEvent,omitempty"` -} - -func (m *TransactionResult) Reset() { *m = TransactionResult{} } -func (m *TransactionResult) String() string { return proto.CompactTextString(m) } -func (*TransactionResult) ProtoMessage() {} -func (*TransactionResult) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{2} } - -func (m *TransactionResult) GetChaincodeEvent() *ChaincodeEvent { - if m != nil { - return m.ChaincodeEvent - } - return nil -} - -// Block carries The data that describes a block in the blockchain. -// version - Version used to track any protocol changes. -// timestamp - The time at which the block or transaction order -// was proposed. This may not be used by all consensus modules. -// transactions - The ordered list of transactions in the block. -// stateHash - The state hash after running transactions in this block. -// previousBlockHash - The hash of the previous block in the chain. -// consensusMetadata - Consensus modules may optionally store any -// additional metadata in this field. -// nonHashData - Data stored with the block, but not included in the blocks -// hash. This allows this data to be different per peer or discarded without -// impacting the blockchain. -type Block struct { - Version uint32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` - Timestamp *google_protobuf.Timestamp `protobuf:"bytes,2,opt,name=timestamp" json:"timestamp,omitempty"` - Transactions []*Transaction `protobuf:"bytes,3,rep,name=transactions" json:"transactions,omitempty"` - StateHash []byte `protobuf:"bytes,4,opt,name=stateHash,proto3" json:"stateHash,omitempty"` - PreviousBlockHash []byte `protobuf:"bytes,5,opt,name=previousBlockHash,proto3" json:"previousBlockHash,omitempty"` - ConsensusMetadata []byte `protobuf:"bytes,6,opt,name=consensusMetadata,proto3" json:"consensusMetadata,omitempty"` - NonHashData *NonHashData `protobuf:"bytes,7,opt,name=nonHashData" json:"nonHashData,omitempty"` -} - -func (m *Block) Reset() { *m = Block{} } -func (m *Block) String() string { return proto.CompactTextString(m) } -func (*Block) ProtoMessage() {} -func (*Block) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{3} } - -func (m *Block) GetTimestamp() *google_protobuf.Timestamp { - if m != nil { - return m.Timestamp - } - return nil -} - -func (m *Block) GetTransactions() []*Transaction { - if m != nil { - return m.Transactions - } - return nil -} - -func (m *Block) GetNonHashData() *NonHashData { - if m != nil { - return m.NonHashData - } - return nil -} - -// Contains information about the blockchain ledger such as height, current -// block hash, and previous block hash. -type BlockchainInfo struct { - Height uint64 `protobuf:"varint,1,opt,name=height" json:"height,omitempty"` - CurrentBlockHash []byte `protobuf:"bytes,2,opt,name=currentBlockHash,proto3" json:"currentBlockHash,omitempty"` - PreviousBlockHash []byte `protobuf:"bytes,3,opt,name=previousBlockHash,proto3" json:"previousBlockHash,omitempty"` -} - -func (m *BlockchainInfo) Reset() { *m = BlockchainInfo{} } -func (m *BlockchainInfo) String() string { return proto.CompactTextString(m) } -func (*BlockchainInfo) ProtoMessage() {} -func (*BlockchainInfo) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{4} } - -// NonHashData is data that is recorded on the block, but not included in -// the block hash when verifying the blockchain. -// localLedgerCommitTimestamp - The time at which the block was added -// to the ledger on the local peer. -// chaincodeEvent - is an array ChaincodeEvents, one per transaction in the -// block -type NonHashData struct { - LocalLedgerCommitTimestamp *google_protobuf.Timestamp `protobuf:"bytes,1,opt,name=localLedgerCommitTimestamp" json:"localLedgerCommitTimestamp,omitempty"` - ChaincodeEvents []*ChaincodeEvent `protobuf:"bytes,2,rep,name=chaincodeEvents" json:"chaincodeEvents,omitempty"` -} - -func (m *NonHashData) Reset() { *m = NonHashData{} } -func (m *NonHashData) String() string { return proto.CompactTextString(m) } -func (*NonHashData) ProtoMessage() {} -func (*NonHashData) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{5} } - -func (m *NonHashData) GetLocalLedgerCommitTimestamp() *google_protobuf.Timestamp { - if m != nil { - return m.LocalLedgerCommitTimestamp - } - return nil -} - -func (m *NonHashData) GetChaincodeEvents() []*ChaincodeEvent { - if m != nil { - return m.ChaincodeEvents - } - return nil -} +func (PeerEndpoint_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor5, []int{2, 0} } type PeerAddress struct { Host string `protobuf:"bytes,1,opt,name=host" json:"host,omitempty"` @@ -248,7 +45,7 @@ type PeerAddress struct { func (m *PeerAddress) Reset() { *m = PeerAddress{} } func (m *PeerAddress) String() string { return proto.CompactTextString(m) } func (*PeerAddress) ProtoMessage() {} -func (*PeerAddress) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{6} } +func (*PeerAddress) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} } type PeerID struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` @@ -257,7 +54,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 fileDescriptor9, []int{7} } +func (*PeerID) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{1} } type PeerEndpoint struct { ID *PeerID `protobuf:"bytes,1,opt,name=ID" json:"ID,omitempty"` @@ -269,7 +66,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 fileDescriptor9, []int{8} } +func (*PeerEndpoint) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{2} } func (m *PeerEndpoint) GetID() *PeerID { if m != nil { @@ -285,7 +82,7 @@ type PeersMessage struct { func (m *PeersMessage) Reset() { *m = PeersMessage{} } func (m *PeersMessage) String() string { return proto.CompactTextString(m) } func (*PeersMessage) ProtoMessage() {} -func (*PeersMessage) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{9} } +func (*PeersMessage) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{3} } func (m *PeersMessage) GetPeers() []*PeerEndpoint { if m != nil { @@ -301,84 +98,58 @@ type PeersAddresses struct { func (m *PeersAddresses) Reset() { *m = PeersAddresses{} } func (m *PeersAddresses) String() string { return proto.CompactTextString(m) } func (*PeersAddresses) ProtoMessage() {} -func (*PeersAddresses) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{10} } +func (*PeersAddresses) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{4} } + +// Contains information about the blockchain ledger such as height, current +// block hash, and previous block hash. +type BlockchainInfo struct { + Height uint64 `protobuf:"varint,1,opt,name=height" json:"height,omitempty"` + CurrentBlockHash []byte `protobuf:"bytes,2,opt,name=currentBlockHash,proto3" json:"currentBlockHash,omitempty"` + PreviousBlockHash []byte `protobuf:"bytes,3,opt,name=previousBlockHash,proto3" json:"previousBlockHash,omitempty"` +} + +func (m *BlockchainInfo) Reset() { *m = BlockchainInfo{} } +func (m *BlockchainInfo) String() string { return proto.CompactTextString(m) } +func (*BlockchainInfo) ProtoMessage() {} +func (*BlockchainInfo) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{5} } func init() { - proto.RegisterType((*Transaction)(nil), "protos.Transaction") - proto.RegisterType((*TransactionBlock)(nil), "protos.TransactionBlock") - proto.RegisterType((*TransactionResult)(nil), "protos.TransactionResult") - proto.RegisterType((*Block)(nil), "protos.Block") - proto.RegisterType((*BlockchainInfo)(nil), "protos.BlockchainInfo") - proto.RegisterType((*NonHashData)(nil), "protos.NonHashData") proto.RegisterType((*PeerAddress)(nil), "protos.PeerAddress") proto.RegisterType((*PeerID)(nil), "protos.PeerID") proto.RegisterType((*PeerEndpoint)(nil), "protos.PeerEndpoint") proto.RegisterType((*PeersMessage)(nil), "protos.PeersMessage") proto.RegisterType((*PeersAddresses)(nil), "protos.PeersAddresses") - proto.RegisterEnum("protos.Transaction_Type", Transaction_Type_name, Transaction_Type_value) + proto.RegisterType((*BlockchainInfo)(nil), "protos.BlockchainInfo") proto.RegisterEnum("protos.PeerEndpoint_Type", PeerEndpoint_Type_name, PeerEndpoint_Type_value) } -func init() { proto.RegisterFile("peer/fabric.proto", fileDescriptor9) } - -var fileDescriptor9 = []byte{ - // 917 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x55, 0xdd, 0x6e, 0xdb, 0x36, - 0x14, 0x9e, 0xfc, 0x93, 0xd4, 0xc7, 0x49, 0xea, 0x30, 0x46, 0xa7, 0x1a, 0x41, 0x67, 0xe8, 0xca, - 0xeb, 0x3a, 0x1b, 0xc8, 0x50, 0x74, 0xd8, 0xc5, 0x30, 0xd7, 0x52, 0x51, 0xa1, 0x89, 0x9d, 0x11, - 0x6e, 0x80, 0xf6, 0xa6, 0x60, 0x24, 0xc6, 0x16, 0x2a, 0x93, 0x02, 0x49, 0x07, 0xf3, 0xed, 0x5e, - 0x67, 0x97, 0x7b, 0x86, 0xed, 0x19, 0xf6, 0x38, 0x83, 0x8e, 0x24, 0xcb, 0x4e, 0xdc, 0x6e, 0xbd, - 0x12, 0xcf, 0xf7, 0x7d, 0xa4, 0xce, 0x39, 0xfc, 0x48, 0xc2, 0x71, 0xc2, 0xb9, 0x1a, 0xdc, 0xb0, - 0x6b, 0x15, 0x05, 0xfd, 0x44, 0x49, 0x23, 0xc9, 0x1e, 0x7e, 0x74, 0xa7, 0x8d, 0x54, 0x30, 0x67, - 0x91, 0x08, 0x64, 0xc8, 0x33, 0xb6, 0xf3, 0x78, 0x1b, 0xe5, 0xb7, 0x5c, 0x98, 0x9c, 0xfa, 0x66, - 0x26, 0xe5, 0x2c, 0xe6, 0x03, 0x8c, 0xae, 0x97, 0x37, 0x03, 0x13, 0x2d, 0xb8, 0x36, 0x6c, 0x91, - 0x64, 0x02, 0xe7, 0x9f, 0x1a, 0x34, 0xa7, 0x8a, 0x09, 0xcd, 0x02, 0x13, 0x49, 0x41, 0x9e, 0x41, - 0xcd, 0xac, 0x12, 0x6e, 0x5b, 0x5d, 0xab, 0x77, 0x74, 0x66, 0x67, 0x2a, 0xdd, 0xdf, 0x90, 0xf4, - 0xa7, 0xab, 0x84, 0x53, 0x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 0x00, 0x00, 0xff, 0xff, 0x94, 0xd6, 0xd8, - 0xfd, 0x05, 0x08, 0x00, 0x00, +func init() { proto.RegisterFile("peer/fabric.proto", fileDescriptor5) } + +var fileDescriptor5 = []byte{ + // 398 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x52, 0x51, 0x6b, 0xd4, 0x40, + 0x10, 0x76, 0x73, 0xb9, 0x93, 0xcc, 0x5d, 0xc3, 0xdd, 0x52, 0x24, 0x42, 0x91, 0x90, 0xa7, 0x58, + 0x35, 0x81, 0x13, 0x11, 0x7c, 0xbb, 0x92, 0x13, 0x03, 0x9a, 0xca, 0x52, 0x7d, 0xf0, 0x45, 0x72, + 0xc9, 0x34, 0x09, 0x6d, 0xb3, 0xcb, 0x6e, 0x4e, 0xb8, 0x57, 0x7f, 0x9c, 0xbf, 0x4b, 0x76, 0xb7, + 0xf1, 0x84, 0xf6, 0x29, 0xf3, 0x7d, 0xf3, 0x7d, 0x93, 0x99, 0xd9, 0x81, 0x95, 0x40, 0x94, 0xe9, + 0x75, 0xb9, 0x93, 0x5d, 0x95, 0x08, 0xc9, 0x07, 0x4e, 0x67, 0xe6, 0xa3, 0xa2, 0x77, 0x30, 0xff, + 0x8a, 0x28, 0x37, 0x75, 0x2d, 0x51, 0x29, 0x4a, 0xc1, 0x6d, 0xb9, 0x1a, 0x02, 0x12, 0x92, 0xd8, + 0x63, 0x26, 0xd6, 0x9c, 0xe0, 0x72, 0x08, 0x9c, 0x90, 0xc4, 0x53, 0x66, 0xe2, 0xe8, 0x0c, 0x66, + 0xda, 0x96, 0x67, 0x3a, 0xdb, 0x97, 0x77, 0x38, 0x3a, 0x74, 0x1c, 0xfd, 0x21, 0xb0, 0xd0, 0xe9, + 0x6d, 0x5f, 0x0b, 0xde, 0xf5, 0x03, 0x7d, 0x01, 0x4e, 0x9e, 0x19, 0xc9, 0x7c, 0xed, 0xdb, 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x12, 0x7f, 0x75, 0x7c, 0xaf, 0x8e, 0xe2, 0x89, 0x11, 0x3f, 0x4c, + 0x5c, 0xbc, 0xfa, 0xf1, 0xb2, 0xe9, 0x86, 0x76, 0xbf, 0x4b, 0x2a, 0x7e, 0x97, 0xb6, 0x07, 0x81, + 0xf2, 0x16, 0xeb, 0xe6, 0xdf, 0xf5, 0xa4, 0x76, 0xe0, 0x54, 0x8f, 0xb8, 0xb3, 0x37, 0xf4, 0xf6, + 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x30, 0x01, 0x3f, 0x5f, 0x02, 0x00, 0x00, } diff --git a/protos/peer/fabric.proto b/protos/peer/fabric.proto index 9ec4c3229ea..0d7ac13fdda 100644 --- a/protos/peer/fabric.proto +++ b/protos/peer/fabric.proto @@ -18,107 +18,6 @@ syntax = "proto3"; option go_package = "github.com/hyperledger/fabric/protos/peer"; package protos; -import "peer/chaincode.proto"; -import "peer/chaincodeevent.proto"; -import "google/protobuf/timestamp.proto"; - - -// Transaction defines a function call to a contract. -// `args` is an array of type string so that the chaincode writer can choose -// whatever format they wish for the arguments for their chaincode. -// For example, they may wish to use JSON, XML, or a custom format. -// TODO: Defined remaining fields. -message Transaction { - enum Type { - UNDEFINED = 0; - // deploy a chaincode to the network and call `Init` function - CHAINCODE_DEPLOY = 1; - // call a chaincode `Invoke` function as a transaction - CHAINCODE_INVOKE = 2; - // call a chaincode `query` function - CHAINCODE_QUERY = 3; - // terminate a chaincode; not implemented yet - CHAINCODE_TERMINATE = 4; - } - Type type = 1; - //store ChaincodeID as bytes so its encrypted value can be stored - bytes chaincodeID = 2; - bytes payload = 3; - bytes metadata = 4; - string txid = 5; - google.protobuf.Timestamp timestamp = 6; - - ConfidentialityLevel confidentialityLevel = 7; - string confidentialityProtocolVersion = 8; - bytes nonce = 9; - - bytes toValidators = 10; - bytes cert = 11; - bytes signature = 12; -} - -// TransactionBlock carries a batch of transactions. -message TransactionBlock { - repeated Transaction transactions = 1; -} - -// TransactionResult contains the return value of a transaction. It does -// not track potential state changes that were a result of the transaction. -// txid - The unique identifier of this transaction. -// result - The return value of the transaction. -// errorCode - An error code. 5xx will be logged as a failure in the dashboard. -// error - An error string for logging an issue. -// chaincodeEvent - any event emitted by a transaction -message TransactionResult { - string txid = 1; - bytes result = 2; - uint32 errorCode = 3; - string error = 4; - ChaincodeEvent chaincodeEvent = 5; -} - -// Block carries The data that describes a block in the blockchain. -// version - Version used to track any protocol changes. -// timestamp - The time at which the block or transaction order -// was proposed. This may not be used by all consensus modules. -// transactions - The ordered list of transactions in the block. -// stateHash - The state hash after running transactions in this block. -// previousBlockHash - The hash of the previous block in the chain. -// consensusMetadata - Consensus modules may optionally store any -// additional metadata in this field. -// nonHashData - Data stored with the block, but not included in the blocks -// hash. This allows this data to be different per peer or discarded without -// impacting the blockchain. -message Block { - uint32 version = 1; - google.protobuf.Timestamp timestamp = 2; - repeated Transaction transactions = 3; - bytes stateHash = 4; - bytes previousBlockHash = 5; - bytes consensusMetadata = 6; - NonHashData nonHashData = 7; -} - -// Contains information about the blockchain ledger such as height, current -// block hash, and previous block hash. -message BlockchainInfo { - - uint64 height = 1; - bytes currentBlockHash = 2; - bytes previousBlockHash = 3; - -} - -// NonHashData is data that is recorded on the block, but not included in -// the block hash when verifying the blockchain. -// localLedgerCommitTimestamp - The time at which the block was added -// to the ledger on the local peer. -// chaincodeEvent - is an array ChaincodeEvents, one per transaction in the -// block -message NonHashData { - google.protobuf.Timestamp localLedgerCommitTimestamp = 1; - repeated ChaincodeEvent chaincodeEvents = 2; -} message PeerAddress { string host = 1; @@ -148,3 +47,13 @@ message PeersMessage { message PeersAddresses { repeated string addresses = 1; } + +// Contains information about the blockchain ledger such as height, current +// block hash, and previous block hash. +message BlockchainInfo { + + uint64 height = 1; + bytes currentBlockHash = 2; + bytes previousBlockHash = 3; + +} diff --git a/protos/peer/fabric_block.pb.go b/protos/peer/fabric_block.pb.go index 2bd5607d477..560564dad79 100644 --- a/protos/peer/fabric_block.pb.go +++ b/protos/peer/fabric_block.pb.go @@ -23,15 +23,15 @@ type Block2 struct { func (m *Block2) Reset() { *m = Block2{} } func (m *Block2) String() string { return proto.CompactTextString(m) } func (*Block2) ProtoMessage() {} -func (*Block2) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} } +func (*Block2) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{0} } func init() { proto.RegisterType((*Block2)(nil), "protos.Block2") } -func init() { proto.RegisterFile("peer/fabric_block.proto", fileDescriptor5) } +func init() { proto.RegisterFile("peer/fabric_block.proto", fileDescriptor6) } -var fileDescriptor5 = []byte{ +var fileDescriptor6 = []byte{ // 150 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x12, 0x2f, 0x48, 0x4d, 0x2d, 0xd2, 0x4f, 0x4b, 0x4c, 0x2a, 0xca, 0x4c, 0x8e, 0x4f, 0xca, 0xc9, 0x4f, 0xce, 0xd6, 0x2b, 0x28, diff --git a/protos/peer/fabric_message.pb.go b/protos/peer/fabric_message.pb.go index e069f48d07e..b9accc2aa92 100644 --- a/protos/peer/fabric_message.pb.go +++ b/protos/peer/fabric_message.pb.go @@ -13,37 +13,37 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -type Message2_Type int32 +type Message_Type int32 const ( // Undefined exists to prevent invalid message construction. - Message2_UNDEFINED Message2_Type = 0 + Message_UNDEFINED Message_Type = 0 // Handshake messages. - Message2_DISCOVERY Message2_Type = 1 + Message_DISCOVERY Message_Type = 1 // Sent to catch up with existing peers. - Message2_SYNC Message2_Type = 2 + Message_SYNC Message_Type = 2 ) -var Message2_Type_name = map[int32]string{ +var Message_Type_name = map[int32]string{ 0: "UNDEFINED", 1: "DISCOVERY", 2: "SYNC", } -var Message2_Type_value = map[string]int32{ +var Message_Type_value = map[string]int32{ "UNDEFINED": 0, "DISCOVERY": 1, "SYNC": 2, } -func (x Message2_Type) String() string { - return proto.EnumName(Message2_Type_name, int32(x)) +func (x Message_Type) String() string { + return proto.EnumName(Message_Type_name, int32(x)) } -func (Message2_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor6, []int{0, 0} } +func (Message_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor7, []int{0, 0} } -// A Message2 encapsulates a payload of the indicated type in this message. -type Message2 struct { +// A Message encapsulates a payload of the indicated type in this message. +type Message struct { // Type of this message. - Type Message2_Type `protobuf:"varint,1,opt,name=type,enum=protos.Message2_Type" json:"type,omitempty"` + Type Message_Type `protobuf:"varint,1,opt,name=type,enum=protos.Message_Type" json:"type,omitempty"` // Version indicates message protocol version. Version int32 `protobuf:"varint,2,opt,name=version" json:"version,omitempty"` // The payload in this message. The way it should be unmarshaled @@ -51,32 +51,32 @@ type Message2 struct { Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` } -func (m *Message2) Reset() { *m = Message2{} } -func (m *Message2) String() string { return proto.CompactTextString(m) } -func (*Message2) ProtoMessage() {} -func (*Message2) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{0} } +func (m *Message) Reset() { *m = Message{} } +func (m *Message) String() string { return proto.CompactTextString(m) } +func (*Message) ProtoMessage() {} +func (*Message) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{0} } func init() { - proto.RegisterType((*Message2)(nil), "protos.Message2") - proto.RegisterEnum("protos.Message2_Type", Message2_Type_name, Message2_Type_value) + proto.RegisterType((*Message)(nil), "protos.Message") + proto.RegisterEnum("protos.Message_Type", Message_Type_name, Message_Type_value) } -func init() { proto.RegisterFile("peer/fabric_message.proto", fileDescriptor6) } +func init() { proto.RegisterFile("peer/fabric_message.proto", fileDescriptor7) } -var fileDescriptor6 = []byte{ - // 213 bytes of a gzipped FileDescriptorProto +var fileDescriptor7 = []byte{ + // 212 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff,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 0xe4, 0xcb, 0x24, 0x88, 0x87, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x03, 0x5a, 0xce, - 0xdf, 0xf4, 0x00, 0x00, 0x00, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x03, 0x53, 0xc5, 0x4a, 0xd3, 0x19, 0xb9, 0xd8, 0x7d, + 0x21, 0x32, 0x42, 0x1a, 0x5c, 0x2c, 0x25, 0x95, 0x05, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x7c, + 0x46, 0x22, 0x10, 0x95, 0xc5, 0x7a, 0x50, 0x69, 0xbd, 0x90, 0xca, 0x82, 0xd4, 0x20, 0xb0, 0x0a, + 0x21, 0x09, 0x2e, 0xf6, 0xb2, 0xd4, 0xa2, 0xe2, 0xcc, 0xfc, 0x3c, 0x09, 0x26, 0x05, 0x46, 0x0d, + 0xd6, 0x20, 0x18, 0x17, 0x24, 0x53, 0x90, 0x58, 0x99, 0x93, 0x9f, 0x98, 0x22, 0xc1, 0xac, 0xc0, + 0xa8, 0xc1, 0x13, 0x04, 0xe3, 0x2a, 0xe9, 0x71, 0xb1, 0x80, 0x4c, 0x10, 0xe2, 0xe5, 0xe2, 0x0c, + 0xf5, 0x73, 0x71, 0x75, 0xf3, 0xf4, 0x73, 0x75, 0x11, 0x60, 0x00, 0x71, 0x5d, 0x3c, 0x83, 0x9d, + 0xfd, 0xc3, 0x5c, 0x83, 0x22, 0x05, 0x18, 0x85, 0x38, 0xb8, 0x58, 0x82, 0x23, 0xfd, 0x9c, 0x05, + 0x98, 0x9c, 0xb4, 0xa3, 0x34, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, + 0x33, 0x2a, 0x0b, 0x52, 0x8b, 0x72, 0x52, 0x53, 0xd2, 0xe1, 0x1e, 0xd2, 0x87, 0x38, 0x4f, 0x1f, + 0xe4, 0xc7, 0x24, 0x88, 0x77, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x59, 0x84, 0x5f, + 0xf2, 0x00, 0x00, 0x00, } diff --git a/protos/peer/fabric_message.proto b/protos/peer/fabric_message.proto index 2b12d4935ed..9bbcfe62927 100644 --- a/protos/peer/fabric_message.proto +++ b/protos/peer/fabric_message.proto @@ -20,8 +20,8 @@ option go_package = "github.com/hyperledger/fabric/protos/peer"; package protos; -// A Message2 encapsulates a payload of the indicated type in this message. -message Message2 { +// A Message encapsulates a payload of the indicated type in this message. +message Message { enum Type { diff --git a/protos/peer/fabric_proposal.pb.go b/protos/peer/fabric_proposal.pb.go index 624015b7d97..9c0d3e887b4 100644 --- a/protos/peer/fabric_proposal.pb.go +++ b/protos/peer/fabric_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 fileDescriptor7, []int{0} } +func (*SignedProposal) Descriptor() ([]byte, []int) { return fileDescriptor8, []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,16 +85,16 @@ 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 fileDescriptor7, []int{1} } +func (*Proposal) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{1} } func init() { proto.RegisterType((*SignedProposal)(nil), "protos.SignedProposal") proto.RegisterType((*Proposal)(nil), "protos.Proposal") } -func init() { proto.RegisterFile("peer/fabric_proposal.proto", fileDescriptor7) } +func init() { proto.RegisterFile("peer/fabric_proposal.proto", fileDescriptor8) } -var fileDescriptor7 = []byte{ +var fileDescriptor8 = []byte{ // 196 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x48, 0x4d, 0x2d, 0xd2, 0x4f, 0x4b, 0x4c, 0x2a, 0xca, 0x4c, 0x8e, 0x2f, 0x28, 0xca, 0x2f, 0xc8, 0x2f, 0x4e, 0xcc, diff --git a/protos/peer/fabric_proposal_response.pb.go b/protos/peer/fabric_proposal_response.pb.go index 9ca55539384..6e53d599202 100644 --- a/protos/peer/fabric_proposal_response.pb.go +++ b/protos/peer/fabric_proposal_response.pb.go @@ -30,7 +30,7 @@ type ProposalResponse struct { Timestamp *google_protobuf.Timestamp `protobuf:"bytes,2,opt,name=timestamp" json:"timestamp,omitempty"` // A response message indicating whether the // endorsement of the action was successful - Response *Response2 `protobuf:"bytes,4,opt,name=response" json:"response,omitempty"` + Response *Response `protobuf:"bytes,4,opt,name=response" json:"response,omitempty"` // The payload of response. It is the bytes of ProposalResponsePayload Payload []byte `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` // The endorsement of the proposal, basically @@ -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 fileDescriptor8, []int{0} } +func (*ProposalResponse) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{0} } func (m *ProposalResponse) GetTimestamp() *google_protobuf.Timestamp { if m != nil { @@ -50,7 +50,7 @@ func (m *ProposalResponse) GetTimestamp() *google_protobuf.Timestamp { return nil } -func (m *ProposalResponse) GetResponse() *Response2 { +func (m *ProposalResponse) GetResponse() *Response { if m != nil { return m.Response } @@ -66,7 +66,7 @@ func (m *ProposalResponse) GetEndorsement() *Endorsement { // A response with a representation similar to an HTTP response that can // be used within another message. -type Response2 struct { +type Response struct { // A status code that should follow the HTTP status codes. Status int32 `protobuf:"varint,1,opt,name=status" json:"status,omitempty"` // A message associated with the response code. @@ -75,10 +75,10 @@ type Response2 struct { Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` } -func (m *Response2) Reset() { *m = Response2{} } -func (m *Response2) String() string { return proto.CompactTextString(m) } -func (*Response2) ProtoMessage() {} -func (*Response2) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{1} } +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} +func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor9, []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 fileDescriptor8, []int{2} } +func (*ProposalResponsePayload) Descriptor() ([]byte, []int) { return fileDescriptor9, []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,39 +135,39 @@ 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 fileDescriptor8, []int{3} } +func (*Endorsement) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{3} } func init() { proto.RegisterType((*ProposalResponse)(nil), "protos.ProposalResponse") - proto.RegisterType((*Response2)(nil), "protos.Response2") + proto.RegisterType((*Response)(nil), "protos.Response") proto.RegisterType((*ProposalResponsePayload)(nil), "protos.ProposalResponsePayload") proto.RegisterType((*Endorsement)(nil), "protos.Endorsement") } -func init() { proto.RegisterFile("peer/fabric_proposal_response.proto", fileDescriptor8) } - -var fileDescriptor8 = []byte{ - // 344 bytes of a gzipped FileD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x82, 0xaf, 0x83, 0xfe, 0xd4, 0x9b, 0x8d, 0x99, 0x83, 0xf4, 0x91, - 0x8c, 0xa0, 0x5c, 0x0b, 0x85, 0x50, 0x40, 0xa9, 0x83, 0x81, 0xd1, 0x3a, 0x77, 0x5a, 0x2f, 0xfb, - 0x5f, 0xac, 0xcb, 0x0b, 0x3f, 0x88, 0xdf, 0xfa, 0xd0, 0x0b, 0x32, 0x40, 0xcd, 0x75, 0x85, 0x76, - 0x3f, 0x8b, 0x6a, 0xd7, 0x02, 0x10, 0x79, 0x0a, 0x66, 0x39, 0x9f, 0x39, 0xd8, 0xcd, 0x73, 0x74, - 0x90, 0x27, 0xfc, 0x22, 0x97, 0xff, 0x2f, 0x70, 0x61, 0xa3, 0x86, 0x64, 0xec, 0x1e, 0xe8, 0x8d, - 0xe3, 0xd6, 0x98, 0x8d, 0xd9, 0xc1, 0x8c, 0x5e, 0x11, 0x1f, 0x7e, 0x34, 0x94, 0xe6, 0xb6, 0x7b, - 0x86, 0xb0, 0x1f, 0x84, 0xaf, 0x64, 0xd4, 0xd9, 0x88, 0x4e, 0xc8, 0xd0, 0xee, 0xa4, 0xac, 0x58, - 0x8b, 0x6b, 0x21, 0xcc, 0xd2, 0x92, 0xeb, 0x4a, 0x81, 0x13, 0x6a, 0x07, 0xcf, 0x77, 0x9f, 0xb7, - 0x69, 0xa6, 0xb7, 0x55, 0x12, 0xad, 0x44, 0x11, 0x6f, 0x77, 0x12, 0x54, 0x0e, 0xeb, 0xb4, 0x6d, - 0x52, 0xd3, 0x10, 0x8c, 0xeb, 0x72, 0x25, 0x4d, 0x7b, 0x1e, 0xfe, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x16, 0x38, 0x09, 0x98, 0x6b, 0x02, 0x00, 0x00, +func init() { proto.RegisterFile("peer/fabric_proposal_response.proto", fileDescriptor9) } + +var fileDescriptor9 = []byte{ + // 345 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 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84, 0x7b, 0xc8, + 0xee, 0x60, 0x8c, 0xd5, 0x46, 0x6a, 0xc2, 0x12, 0x2b, 0x13, 0x0e, 0xac, 0xd4, 0x5f, 0x2f, 0xf5, + 0x78, 0xf8, 0xc5, 0x8f, 0x79, 0xd1, 0x2b, 0x0c, 0xbb, 0x7a, 0xff, 0x60, 0x40, 0x46, 0x98, 0x9a, + 0x5c, 0x3b, 0x87, 0x1a, 0xd3, 0x12, 0x89, 0x44, 0x86, 0xb6, 0xda, 0x88, 0x7b, 0x78, 0x1c, 0xe7, + 0xd7, 0x49, 0x9c, 0xe8, 0x1d, 0xfe, 0xff, 0xbc, 0xbe, 0xa5, 0x4b, 0x1a, 0xc1, 0xc4, 0x3f, 0xcf, + 0xb3, 0xa0, 0x9d, 0x35, 0x9b, 0xf0, 0x93, 0x19, 0x3b, 0x83, 0x11, 0x7e, 0x1a, 0xac, 0xec, 0x5d, + 0xf7, 0x2c, 0xe1, 0x30, 0x88, 0x9e, 0x60, 0x7c, 0x54, 0x88, 0xcd, 0x60, 0xe8, 0x2a, 0x69, 0x27, + 0xd6, 0xe1, 0x46, 0x88, 0xf2, 0xac, 0x12, 0xa6, 0xd6, 0xe8, 0x85, 0xba, 0xc1, 0xc3, 0xd5, 0xdb, + 0x65, 0x96, 0x9b, 0x5d, 0x9d, 0xc6, 0x6b, 0x59, 0x26, 0xbb, 0xbd, 0x42, 0x5d, 0xe0, 0x26, 0xeb, + 0xf6, 0xa8, 0xdd, 0x0f, 0x4a, 0x9a, 0xd5, 0x4a, 0xdb, 0xdd, 0xb9, 0xfd, 0x0e, 0x00, 0x00, 0xff, + 0xff, 0x43, 0xe1, 0xd2, 0xab, 0x69, 0x02, 0x00, 0x00, } diff --git a/protos/peer/fabric_proposal_response.proto b/protos/peer/fabric_proposal_response.proto index b020b9f09c8..d1a58eecbb7 100644 --- a/protos/peer/fabric_proposal_response.proto +++ b/protos/peer/fabric_proposal_response.proto @@ -41,7 +41,7 @@ message ProposalResponse { // A response message indicating whether the // endorsement of the action was successful - Response2 response = 4; + Response response = 4; // The payload of response. It is the bytes of ProposalResponsePayload bytes payload = 5; @@ -53,7 +53,7 @@ message ProposalResponse { // A response with a representation similar to an HTTP response that can // be used within another message. -message Response2 { +message Response { // A status code that should follow the HTTP status codes. int32 status = 1; diff --git a/protos/peer/fabric_transaction.pb.go b/protos/peer/fabric_transaction.pb.go index 57639a44ee8..104c0448044 100644 --- a/protos/peer/fabric_transaction.pb.go +++ b/protos/peer/fabric_transaction.pb.go @@ -55,7 +55,7 @@ func (*SignedTransaction) Descriptor() ([]byte, []int) { return fileDescriptor11 // This is used to wrap an invalid Transaction with the cause type InvalidTransaction struct { - Transaction *Transaction2 `protobuf:"bytes,1,opt,name=transaction" json:"transaction,omitempty"` + Transaction *Transaction `protobuf:"bytes,1,opt,name=transaction" json:"transaction,omitempty"` Cause InvalidTransaction_Cause `protobuf:"varint,2,opt,name=cause,enum=protos.InvalidTransaction_Cause" json:"cause,omitempty"` } @@ -64,7 +64,7 @@ func (m *InvalidTransaction) String() string { return proto.CompactTe func (*InvalidTransaction) ProtoMessage() {} func (*InvalidTransaction) Descriptor() ([]byte, []int) { return fileDescriptor11, []int{1} } -func (m *InvalidTransaction) GetTransaction() *Transaction2 { +func (m *InvalidTransaction) GetTransaction() *Transaction { if m != nil { return m.Transaction } @@ -83,7 +83,7 @@ func (m *InvalidTransaction) GetTransaction() *Transaction2 { // (ProposalResponsePayload) with one signature per Endorser. Any number of // independent proposals (and their action) might be included in a transaction // to ensure that they are treated atomically. -type Transaction2 struct { +type Transaction struct { // Version indicates message protocol version. Version int32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` // Timestamp is the local time that the @@ -94,19 +94,19 @@ type Transaction2 struct { Actions []*TransactionAction `protobuf:"bytes,3,rep,name=actions" json:"actions,omitempty"` } -func (m *Transaction2) Reset() { *m = Transaction2{} } -func (m *Transaction2) String() string { return proto.CompactTextString(m) } -func (*Transaction2) ProtoMessage() {} -func (*Transaction2) Descriptor() ([]byte, []int) { return fileDescriptor11, []int{2} } +func (m *Transaction) Reset() { *m = Transaction{} } +func (m *Transaction) String() string { return proto.CompactTextString(m) } +func (*Transaction) ProtoMessage() {} +func (*Transaction) Descriptor() ([]byte, []int) { return fileDescriptor11, []int{2} } -func (m *Transaction2) GetTimestamp() *google_protobuf.Timestamp { +func (m *Transaction) GetTimestamp() *google_protobuf.Timestamp { if m != nil { return m.Timestamp } return nil } -func (m *Transaction2) GetActions() []*TransactionAction { +func (m *Transaction) GetActions() []*TransactionAction { if m != nil { return m.Actions } @@ -131,7 +131,7 @@ func (*TransactionAction) Descriptor() ([]byte, []int) { return fileDescriptor11 func init() { proto.RegisterType((*SignedTransaction)(nil), "protos.SignedTransaction") proto.RegisterType((*InvalidTransaction)(nil), "protos.InvalidTransaction") - proto.RegisterType((*Transaction2)(nil), "protos.Transaction2") + proto.RegisterType((*Transaction)(nil), "protos.Transaction") proto.RegisterType((*TransactionAction)(nil), "protos.TransactionAction") proto.RegisterEnum("protos.InvalidTransaction_Cause", InvalidTransaction_Cause_name, InvalidTransaction_Cause_value) } @@ -139,29 +139,29 @@ func init() { func init() { proto.RegisterFile("peer/fabric_transaction.proto", fileDescriptor11) } var fileDescriptor11 = []byte{ - // 373 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x92, 0xd1, 0x6a, 0xe2, 0x40, - 0x18, 0x85, 0x37, 0x2b, 0x2a, 0xfe, 0x91, 0x45, 0x87, 0x5d, 0xc9, 0x4a, 0x4b, 0x25, 0x57, 0xb6, - 0x85, 0x04, 0x22, 0x48, 0xe9, 0x9d, 0x5a, 0x2f, 0xbc, 0x4d, 0x85, 0x42, 0xa1, 0x94, 0x49, 0x32, - 0xc6, 0x81, 0x24, 0x13, 0x66, 0x26, 0x62, 0x9e, 0xa4, 0xaf, 0xd3, 0x47, 0x2b, 0x66, 0x1c, 0x4d, - 0xb1, 0x37, 0x09, 0x67, 0xf2, 0xe5, 0xfc, 0x87, 0xf9, 0x0f, 0x5c, 0xe7, 0x84, 0x70, 0x77, 0x83, - 0x03, 0x4e, 0xc3, 0x77, 0xc9, 0x71, 0x26, 0x70, 0x28, 0x29, 0xcb, 0x9c, 0x9c, 0x33, 0xc9, 0x50, - 0xab, 0x7a, 0x89, 0xe1, 0x4d, 0xcc, 0x58, 0x9c, 0x10, 0xb7, 0x92, 0x41, 0xb1, 0x71, 0x25, 0x4d, - 0x89, 0x90, 0x38, 0xcd, 0x15, 0x68, 0xbf, 0x41, 0xff, 0x99, 0xc6, 0x19, 0x89, 0xd6, 0x67, 0x0f, - 0x74, 0x07, 0xbd, 0x9a, 0xe5, 0xbc, 0x94, 0x44, 0x58, 0xc6, 0xc8, 0x18, 0x77, 0xfd, 0x8b, 0x73, - 0x74, 0x05, 0x1d, 0x41, 0xe3, 0x0c, 0xcb, 0x82, 0x13, 0xeb, 0x77, 0x05, 0x9d, 0x0f, 0xec, 0x4f, - 0x03, 0xd0, 0x2a, 0xdb, 0xe1, 0x84, 0x7e, 0x1b, 0x30, 0x05, 0xb3, 0x66, 0x54, 0x79, 0x9b, 0xde, - 0x5f, 0x15, 0x49, 0x38, 0x35, 0xd2, 0xf3, 0xeb, 0x20, 0x9a, 0x42, 0x33, 0xc4, 0x85, 0x50, 0x83, - 0xfe, 0x78, 0x23, 0xfd, 0xc7, 0xe5, 0x08, 0x67, 0x71, 0xe0, 0x7c, 0x85, 0xdb, 0x8f, 0xd0, 0xac, - 0x34, 0xfa, 0x07, 0xfd, 0xf5, 0x7e, 0x15, 0xcd, 0x12, 0x4e, 0x70, 0x54, 0x2e, 0xf7, 0x54, 0x48, - 0xd1, 0xfb, 0x85, 0x86, 0x30, 0xf0, 0x5f, 0x16, 0x2c, 0xdb, 0x24, 0x34, 0x94, 0x4f, 0x05, 0xa7, - 0x59, 0xbc, 0x60, 0x69, 0x4a, 0x65, 0xcf, 0xb0, 0x3f, 0x0c, 0xe8, 0xd6, 0x13, 0x21, 0x0b, 0xda, - 0x3b, 0xc2, 0x85, 0x0e, 0xde, 0xf4, 0xb5, 0x44, 0x0f, 0xd0, 0x39, 0xdd, 0x6f, 0x15, 0xd1, 0xf4, - 0x86, 0x8e, 0xda, 0x80, 0xa3, 0x37, 0xe0, 0xac, 0x35, 0xe1, 0x9f, 0x61, 0x34, 0x81, 0xb6, 0xb2, - 0x17, 0x56, 0x63, 0xd4, 0x18, 0x9b, 0xde, 0xff, 0x1f, 0x2e, 0x63, 0x56, 0x3d, 0x7d, 0x4d, 0xda, - 0x4b, 0xe8, 0x5f, 0x7c, 0x45, 0x03, 0x68, 0x6d, 0x09, 0x8e, 0x08, 0x3f, 0x6e, 0xec, 0xa8, 0x0e, - 0xa9, 0x73, 0x5c, 0x26, 0x0c, 0x47, 0xc7, 0x2d, 0x69, 0x39, 0xbf, 0x7f, 0xbd, 0x8d, 0xa9, 0xdc, - 0x16, 0x81, 0x13, 0xb2, 0xd4, 0xdd, 0x96, 0x39, 0xe1, 0x09, 0x89, 0xe2, 0x53, 0xbd, 0x54, 0x79, - 0x84, 0x7b, 0x68, 0x5c, 0xa0, 0x8a, 0x35, 0xf9, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x67, 0xfe, - 0x54, 0x80, 0x02, 0x00, 0x00, + // 371 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x92, 0x51, 0x6b, 0xea, 0x30, + 0x1c, 0xc5, 0x6f, 0xaf, 0xa8, 0xf8, 0xef, 0xe5, 0xa2, 0x19, 0x93, 0x4e, 0x36, 0x26, 0x7d, 0x72, + 0x1b, 0xb4, 0x50, 0xd9, 0x18, 0x7b, 0x53, 0xe7, 0x83, 0xaf, 0x9d, 0x30, 0x18, 0x8c, 0x91, 0xb6, + 0xb1, 0x06, 0xda, 0xa6, 0x24, 0xa9, 0xd8, 0x2f, 0xb2, 0xaf, 0xb3, 0xaf, 0x36, 0x6c, 0x8c, 0x76, + 0xb8, 0xa7, 0x72, 0xd2, 0x5f, 0xce, 0xff, 0x70, 0xf2, 0x87, 0xab, 0x9c, 0x10, 0xee, 0xae, 0x70, + 0xc0, 0x69, 0xf8, 0x21, 0x39, 0xce, 0x04, 0x0e, 0x25, 0x65, 0x99, 0x93, 0x73, 0x26, 0x19, 0x6a, + 0x55, 0x1f, 0x31, 0xb8, 0x8e, 0x19, 0x8b, 0x13, 0xe2, 0x56, 0x32, 0x28, 0x56, 0xae, 0xa4, 0x29, + 0x11, 0x12, 0xa7, 0xb9, 0x02, 0xed, 0x77, 0xe8, 0xbd, 0xd0, 0x38, 0x23, 0xd1, 0xf2, 0xe8, 0x81, + 0x6e, 0xa1, 0x5b, 0xb3, 0x9c, 0x96, 0x92, 0x08, 0xcb, 0x18, 0x1a, 0xa3, 0x7f, 0xfe, 0xc9, 0x39, + 0xba, 0x84, 0x8e, 0xa0, 0x71, 0x86, 0x65, 0xc1, 0x89, 0xf5, 0xb7, 0x82, 0x8e, 0x07, 0xf6, 0x97, + 0x01, 0x68, 0x91, 0x6d, 0x70, 0x42, 0x7f, 0x0c, 0xb8, 0x07, 0xb3, 0x66, 0x54, 0x79, 0x9b, 0xde, + 0x99, 0x8a, 0x24, 0x9c, 0x1a, 0xe9, 0xd7, 0x39, 0xf4, 0x00, 0xcd, 0x10, 0x17, 0x42, 0xcd, 0xf9, + 0xef, 0x0d, 0xf5, 0x85, 0xd3, 0x09, 0xce, 0x6c, 0xc7, 0xf9, 0x0a, 0xb7, 0x9f, 0xa0, 0x59, 0x69, + 0x74, 0x0e, 0xbd, 0xe5, 0x76, 0x11, 0x4d, 0x12, 0x4e, 0x70, 0x54, 0xce, 0xb7, 0x54, 0x48, 0xd1, + 0xfd, 0x83, 0x06, 0xd0, 0xf7, 0x5f, 0x67, 0x2c, 0x5b, 0x25, 0x34, 0x94, 0xcf, 0x05, 0xa7, 0x59, + 0x3c, 0x63, 0x69, 0x4a, 0x65, 0xd7, 0xb0, 0x3f, 0x0d, 0x30, 0xeb, 0xd1, 0x2d, 0x68, 0x6f, 0x08, + 0x17, 0x3a, 0x76, 0xd3, 0xd7, 0x12, 0x3d, 0x42, 0xe7, 0xd0, 0x6e, 0x95, 0xd0, 0xf4, 0x06, 0x8e, + 0xea, 0xdf, 0xd1, 0xfd, 0x3b, 0x4b, 0x4d, 0xf8, 0x47, 0x18, 0x8d, 0xa1, 0xad, 0xdc, 0x85, 0xd5, + 0x18, 0x36, 0x46, 0xa6, 0x77, 0xf1, 0x4b, 0x15, 0x13, 0x55, 0x88, 0x26, 0xed, 0x39, 0xf4, 0x4e, + 0xfe, 0xa2, 0x3e, 0xb4, 0xd6, 0x04, 0x47, 0x84, 0xef, 0xdf, 0x6b, 0xaf, 0x76, 0xa9, 0x73, 0x5c, + 0x26, 0x0c, 0x47, 0xfb, 0x37, 0xd2, 0x72, 0x7a, 0xf7, 0x76, 0x13, 0x53, 0xb9, 0x2e, 0x02, 0x27, + 0x64, 0xa9, 0xbb, 0x2e, 0x73, 0xc2, 0x13, 0x12, 0xc5, 0x87, 0xe5, 0x52, 0xab, 0x23, 0xdc, 0xdd, + 0xbe, 0x05, 0x6a, 0xad, 0xc6, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x48, 0x72, 0x86, 0x7e, + 0x02, 0x00, 0x00, } diff --git a/protos/peer/fabric_transaction.proto b/protos/peer/fabric_transaction.proto index d0e215ec045..a701d671110 100644 --- a/protos/peer/fabric_transaction.proto +++ b/protos/peer/fabric_transaction.proto @@ -43,7 +43,7 @@ message InvalidTransaction { TxIdAlreadyExists = 0; RWConflictDuringCommit = 1; } - Transaction2 transaction = 1; + Transaction transaction = 1; Cause cause = 2; } @@ -59,7 +59,7 @@ message InvalidTransaction { // (ProposalResponsePayload) with one signature per Endorser. Any number of // independent proposals (and their action) might be included in a transaction // to ensure that they are treated atomically. -message Transaction2 { +message Transaction { // Version indicates message protocol version. int32 version = 1; diff --git a/protos/peer/ser_block2_test.go b/protos/peer/ser_block2_test.go index da853f622ed..0e85b17d7d2 100644 --- a/protos/peer/ser_block2_test.go +++ b/protos/peer/ser_block2_test.go @@ -24,7 +24,7 @@ import ( ) func TestSerBlock2(t *testing.T) { - tx1 := &Transaction2{} + tx1 := &Transaction{} tx1.Actions = []*TransactionAction{ &TransactionAction{Header: []byte("action1"), Payload: []byte("payload1")}, &TransactionAction{Header: []byte("action2"), Payload: []byte("payload2")}} @@ -34,7 +34,7 @@ func TestSerBlock2(t *testing.T) { t.Fatalf("Error:%s", err) } - tx2 := &Transaction2{} + tx2 := &Transaction{} tx2.Actions = []*TransactionAction{ &TransactionAction{Header: []byte("action1"), Payload: []byte("payload1")}, &TransactionAction{Header: []byte("action2"), Payload: []byte("payload2")}} diff --git a/protos/peer/transaction.go b/protos/peer/transaction.go deleted file mode 100644 index 1dcad85db4a..00000000000 --- a/protos/peer/transaction.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -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. -*/ - -package peer - -import ( - "encoding/json" - "fmt" - - "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/core/util" -) - -// Bytes returns this transaction as an array of bytes. -func (transaction *Transaction) Bytes() ([]byte, error) { - data, err := proto.Marshal(transaction) - if err != nil { - logger.Errorf("Error marshalling transaction: %s", err) - return nil, fmt.Errorf("Could not marshal transaction: %s", err) - } - return data, nil -} - -// NewTransaction creates a new transaction. It defines the function to call, -// the chaincodeID on which the function should be called, and the arguments -// string. The arguments could be a string of JSON, but there is no strict -// requirement. -func NewTransaction(chaincodeID ChaincodeID, uuid string, function string, arguments []string) (*Transaction, error) { - data, err := proto.Marshal(&chaincodeID) - if err != nil { - return nil, fmt.Errorf("Could not marshal chaincode : %s", err) - } - transaction := new(Transaction) - transaction.ChaincodeID = data - transaction.Txid = uuid - transaction.Timestamp = util.CreateUtcTimestamp() - /* - // Build the spec - spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, - ChaincodeID: chaincodeID, ChaincodeInput: &pb.ChaincodeInput{Function: function, Args: arguments}} - - // Build the ChaincodeInvocationSpec message - invocation := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec} - - data, err := proto.Marshal(invocation) - if err != nil { - return nil, fmt.Errorf("Could not marshal payload for chaincode invocation: %s", err) - } - transaction.Payload = data - */ - return transaction, nil -} - -// NewChaincodeDeployTransaction is used to deploy chaincode. -func NewChaincodeDeployTransaction(chaincodeDeploymentSpec *ChaincodeDeploymentSpec, uuid string) (*Transaction, error) { - transaction := new(Transaction) - transaction.Type = Transaction_CHAINCODE_DEPLOY - transaction.Txid = uuid - transaction.Timestamp = util.CreateUtcTimestamp() - cID := chaincodeDeploymentSpec.ChaincodeSpec.GetChaincodeID() - if cID != nil { - data, err := proto.Marshal(cID) - if err != nil { - return nil, fmt.Errorf("Could not marshal chaincode : %s", err) - } - transaction.ChaincodeID = data - } - //if chaincodeDeploymentSpec.ChaincodeSpec.GetCtorMsg() != nil { - // transaction.Function = chaincodeDeploymentSpec.ChaincodeSpec.GetCtorMsg().Function - // transaction.Args = chaincodeDeploymentSpec.ChaincodeSpec.GetCtorMsg().Args - //} - data, err := proto.Marshal(chaincodeDeploymentSpec) - if err != nil { - logger.Errorf("Error mashalling payload for chaincode deployment: %s", err) - return nil, fmt.Errorf("Could not marshal payload for chaincode deployment: %s", err) - } - transaction.Payload = data - return transaction, nil -} - -// NewChaincodeExecute is used to invoke chaincode. -func NewChaincodeExecute(chaincodeInvocationSpec *ChaincodeInvocationSpec, uuid string, typ Transaction_Type) (*Transaction, error) { - transaction := new(Transaction) - transaction.Type = typ - transaction.Txid = uuid - transaction.Timestamp = util.CreateUtcTimestamp() - cID := chaincodeInvocationSpec.ChaincodeSpec.GetChaincodeID() - if cID != nil { - data, err := proto.Marshal(cID) - if err != nil { - return nil, fmt.Errorf("Could not marshal chaincode : %s", err) - } - transaction.ChaincodeID = data - } - data, err := proto.Marshal(chaincodeInvocationSpec) - if err != nil { - return nil, fmt.Errorf("Could not marshal payload for chaincode invocation: %s", err) - } - transaction.Payload = data - return transaction, nil -} - -type strArgs struct { - Function string - Args []string -} - -// UnmarshalJSON converts the string-based REST/JSON input to -// the []byte-based current ChaincodeInput structure. -func (c *ChaincodeInput) UnmarshalJSON(b []byte) error { - sa := &strArgs{} - err := json.Unmarshal(b, sa) - if err != nil { - return err - } - allArgs := sa.Args - if sa.Function != "" { - allArgs = append([]string{sa.Function}, sa.Args...) - } - c.Args = util.ToChaincodeArgs(allArgs...) - return nil -} diff --git a/protos/peer/transaction_test.go b/protos/peer/transaction_test.go deleted file mode 100644 index 30a9324b637..00000000000 --- a/protos/peer/transaction_test.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -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. -*/ - -package peer - -import ( - "testing" - - "github.com/golang/protobuf/proto" -) - -func Test_Transaction_CreateNew(t *testing.T) { - - cidBytes, err := proto.Marshal(&ChaincodeID{Name: "C01", Path: "Contract001"}) - if err != nil { - t.Fatalf("Could not marshal chaincode: %s", err) - } - tx := &Transaction{ChaincodeID: cidBytes} - t.Logf("Transaction: %v", tx) - - data, err := proto.Marshal(tx) - if err != nil { - t.Errorf("Error marshalling transaction: %s", err) - } - t.Logf("Marshalled data: %v", data) - - // TODO: This doesn't seem like a proper test. Needs to be edited. - txUnmarshalled := &Transaction{} - err = proto.Unmarshal(data, txUnmarshalled) - t.Logf("Unmarshalled transaction: %v", txUnmarshalled) - if err != nil { - t.Errorf("Error unmarshalling block: %s", err) - } - -} diff --git a/protos/utils/block.go b/protos/utils/block.go new file mode 100644 index 00000000000..c1eee5764be --- /dev/null +++ b/protos/utils/block.go @@ -0,0 +1,47 @@ +/* +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. +*/ + +package utils + +import ( + "fmt" + + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric/protos/peer" +) + +// UnmarshallBlock converts a byte array generated by Bytes() back to a block. +func UnmarshallBlock(blockBytes []byte) (*peer.Block2, error) { + block := &peer.Block2{} + err := proto.Unmarshal(blockBytes, block) + if err != nil { + return nil, fmt.Errorf("Could not unmarshal block: %s", err) + } + return block, nil +} + +// GetTransactions gets Transactions out of Block2 +func GetTransactions(block *peer.Block2) ([]*peer.Transaction, error) { + txs := []*peer.Transaction{} + for _, b := range block.Transactions { + tx := &peer.Transaction{} + err := proto.Unmarshal(b, tx) + if err != nil { + return nil, fmt.Errorf("Could not unmarshal transaction: %s", err) + } + } + return txs, nil +} diff --git a/protos/utils/proputils.go b/protos/utils/proputils.go index 4d324688b6a..c6a0efdc361 100644 --- a/protos/utils/proputils.go +++ b/protos/utils/proputils.go @@ -141,8 +141,8 @@ func GetPayload(e *common.Envelope) (*common.Payload, error) { } // GetTransaction Get Transaction from bytes -func GetTransaction(txBytes []byte) (*peer.Transaction2, error) { - tx := &peer.Transaction2{} +func GetTransaction(txBytes []byte) (*peer.Transaction, error) { + tx := &peer.Transaction{} err := proto.Unmarshal(txBytes, tx) if err != nil { return nil, err @@ -196,7 +196,7 @@ func GetEnvelope(bytes []byte) (*common.Envelope, error) { } // CreateChaincodeProposal creates a proposal from given input -func CreateChaincodeProposal(cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, error) { +func CreateChaincodeProposal(txid string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, error) { ccHdrExt := &peer.ChaincodeHeaderExtension{ChaincodeID: cis.ChaincodeSpec.ChaincodeID} ccHdrExtBytes, err := proto.Marshal(ccHdrExt) if err != nil { @@ -221,6 +221,7 @@ func CreateChaincodeProposal(cis *peer.ChaincodeInvocationSpec, creator []byte) } hdr := &common.Header{ChainHeader: &common.ChainHeader{Type: int32(common.HeaderType_ENDORSER_TRANSACTION), + TxID: txid, Extension: ccHdrExtBytes}, SignatureHeader: &common.SignatureHeader{Nonce: nonce, Creator: creator}} @@ -320,7 +321,7 @@ func GetBytesSignatureHeader(hdr *common.SignatureHeader) ([]byte, error) { } // GetBytesTransaction get the bytes of Transaction from the message -func GetBytesTransaction(tx *peer.Transaction2) ([]byte, error) { +func GetBytesTransaction(tx *peer.Transaction) ([]byte, error) { bytes, err := proto.Marshal(tx) if err != nil { return nil, err @@ -371,12 +372,12 @@ func GetActionFromEnvelope(envBytes []byte) (*peer.ChaincodeAction, error) { } // CreateProposalFromCIS returns a proposal given a serialized identity and a ChaincodeInvocationSpec -func CreateProposalFromCIS(cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, error) { - return CreateChaincodeProposal(cis, creator) +func CreateProposalFromCIS(txid string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, error) { + return CreateChaincodeProposal(txid, cis, creator) } // CreateProposalFromCDS returns a proposal given a serialized identity and a ChaincodeDeploymentSpec -func CreateProposalFromCDS(cds *peer.ChaincodeDeploymentSpec, creator []byte) (*peer.Proposal, error) { +func CreateProposalFromCDS(txid string, cds *peer.ChaincodeDeploymentSpec, creator []byte) (*peer.Proposal, error) { b, err := proto.Marshal(cds) if err != nil { return nil, err @@ -390,5 +391,5 @@ func CreateProposalFromCDS(cds *peer.ChaincodeDeploymentSpec, creator []byte) (* CtorMsg: &peer.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), b}}}} //...and get the proposal for it - return CreateProposalFromCIS(lcccSpec, creator) + return CreateProposalFromCIS(txid, lcccSpec, creator) } diff --git a/protos/utils/proputils_test.go b/protos/utils/proputils_test.go index dcc192adbd1..dfb88c6a35b 100644 --- a/protos/utils/proputils_test.go +++ b/protos/utils/proputils_test.go @@ -26,6 +26,7 @@ import ( "os" "github.com/hyperledger/fabric/core/crypto/primitives" + "github.com/hyperledger/fabric/core/util" "github.com/hyperledger/fabric/msp" "github.com/hyperledger/fabric/protos/common" pb "github.com/hyperledger/fabric/protos/peer" @@ -41,8 +42,9 @@ func createCIS() *pb.ChaincodeInvocationSpec { } func TestProposal(t *testing.T) { + uuid := util.GenerateUUID() // create a proposal from a ChaincodeInvocationSpec - prop, err := CreateChaincodeProposal(createCIS(), []byte("creator")) + prop, err := CreateChaincodeProposal(uuid, createCIS(), []byte("creator")) if err != nil { t.Fatalf("Could not create chaincode proposal, err %s\n", err) return @@ -167,7 +169,7 @@ func TestProposalResponse(t *testing.T) { Payload: prpBytes, Endorsement: &pb.Endorsement{Endorser: []byte("endorser"), Signature: []byte("signature")}, Version: 1, // TODO: pick right version number - Response: &pb.Response2{Status: 200, Message: "OK"}} + Response: &pb.Response{Status: 200, Message: "OK"}} // create a proposal response prBytes, err := GetBytesProposalResponse(pr) @@ -195,7 +197,8 @@ func TestProposalResponse(t *testing.T) { func TestEnvelope(t *testing.T) { // create a proposal from a ChaincodeInvocationSpec - prop, err := CreateChaincodeProposal(createCIS(), signerSerialized) + uuid := util.GenerateUUID() + prop, err := CreateChaincodeProposal(uuid, createCIS(), signerSerialized) if err != nil { t.Fatalf("Could not create chaincode proposal, err %s\n", err) return @@ -246,7 +249,7 @@ func TestEnvelope(t *testing.T) { tx2, err := GetTransaction(txpayl.Data) if err != nil { - t.Fatalf("Could not unmarshal Transaction2, err %s\n", err) + t.Fatalf("Could not unmarshal Transaction, err %s\n", err) return } diff --git a/protos/utils/txutils.go b/protos/utils/txutils.go index 0240b16ea5c..0c2d0690a98 100644 --- a/protos/utils/txutils.go +++ b/protos/utils/txutils.go @@ -59,8 +59,8 @@ func GetPayloads(txActions *peer.TransactionAction) (*peer.ChaincodeActionPayloa return ccPayload, respPayload, nil } -// CreateTx creates a Transaction2 from given inputs -func CreateTx(typ common.HeaderType, ccPropPayload []byte, ccEvents []byte, simulationResults []byte, endorsements []*peer.Endorsement) (*peer.Transaction2, error) { +// CreateTx creates a Transaction from given inputs +func CreateTx(typ common.HeaderType, ccPropPayload []byte, ccEvents []byte, simulationResults []byte, endorsements []*peer.Endorsement) (*peer.Transaction, error) { if typ != common.HeaderType_ENDORSER_TRANSACTION { panic("-----Only CHAINCODE Type is supported-----") } @@ -90,13 +90,13 @@ func CreateTx(typ common.HeaderType, ccPropPayload []byte, ccEvents []byte, simu return nil, err } - tx := &peer.Transaction2{} + tx := &peer.Transaction{} tx.Actions = []*peer.TransactionAction{&peer.TransactionAction{Header: hdrBytes, Payload: actionBytes}} return tx, nil } -// GetEndorserTxFromBlock gets Transaction2 from Block.Data.Data +// GetEndorserTxFromBlock gets Transaction from Block.Data.Data func GetEnvelopeFromBlock(data []byte) (*common.Envelope, error) { //Block always begins with an envelope var err error @@ -193,7 +193,7 @@ func CreateSignedTx(proposal *peer.Proposal, signer msp.SigningIdentity, resps . taa := &peer.TransactionAction{Header: sHdrBytes, Payload: capBytes} taas := make([]*peer.TransactionAction, 1) taas[0] = taa - tx := &peer.Transaction2{Actions: taas} + tx := &peer.Transaction{Actions: taas} // serialize the tx txBytes, err := GetBytesTransaction(tx) @@ -248,7 +248,7 @@ func CreateProposalResponse(hdr []byte, payl []byte, results []byte, events []by Version: 1, // TODO: pick right version number Endorsement: &peer.Endorsement{Signature: signature, Endorser: endorser}, Payload: prpBytes, - Response: &peer.Response2{Status: 200, Message: "OK"}} + Response: &peer.Response{Status: 200, Message: "OK"}} return resp, nil } diff --git a/tools/dbutility/dump_db_stats.go b/tools/dbutility/dump_db_stats.go index b53f5a35519..8aa52ec5e15 100644 --- a/tools/dbutility/dump_db_stats.go +++ b/tools/dbutility/dump_db_stats.go @@ -21,12 +21,11 @@ import ( "fmt" "os" - "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/core/db" "github.com/spf13/viper" "github.com/tecbot/gorocksdb" - pb "github.com/hyperledger/fabric/protos/peer" + pbutils "github.com/hyperledger/fabric/protos/utils" ) const ( @@ -144,15 +143,19 @@ func scan(openchainDB *db.OpenchainDB, cfName string, cf *gorocksdb.ColumnFamily } func blockDetailPrinter(blockBytes []byte) { - block, _ := pb.UnmarshallBlock(blockBytes) - txs := block.GetTransactions() + block, err := pbutils.UnmarshallBlock(blockBytes) + if err != nil { + fmt.Printf("Error unmarshaling block %s\n", err) + return + } + txs, err := pbutils.GetTransactions(block) + if err != nil { + fmt.Printf("Error getting transactions from block %s\n", err) + return + } fmt.Printf("Number of transactions = [%d]\n", len(txs)) + /****** TODO pretty print Transaction for _, tx := range txs { - if len(tx.Payload) >= MaxValueSize { - cIDBytes := tx.ChaincodeID - cID := &pb.ChaincodeID{} - proto.Unmarshal(cIDBytes, cID) - fmt.Printf("TxDetails: payloadSize=[%d], tx.Type=[%s], cID.Name=[%s], cID.Path=[%s]\n", len(tx.Payload), tx.Type, cID.Name, cID.Path) - } } + ********/ }