From f8dd7a32824554746137542bed3c75814a836d76 Mon Sep 17 00:00:00 2001 From: denyeart Date: Sat, 11 Feb 2017 12:51:38 -0500 Subject: [PATCH] [FAB-2024] Add valid indicator to GetTransactionById When clients retrieve a transaction from ledger, they need to know whether the transaction was validated or invalidated by committing peer. GetTransactionByID API needs to retrieve the transaction Envelope from block storage, and return it to a client, and indicate whether the transaction was validated or invalidated by committing peer. So that the originally submitted transaction Envelope is not modified, a new ProcessedTransaction wrapper is returned. Also removed InvalidTransaction, since it is not used. Change-Id: I7a4ec2b56b120f5df4ef18f0df415bab1a7dc9d1 Signed-off-by: denyeart --- core/ledger/kvledger/kv_ledger.go | 20 +++- core/ledger/kvledger/kv_ledger_test.go | 15 +++ core/ledger/ledger_interface.go | 3 +- core/scc/qscc/querier.go | 7 +- protos/peer/admin.pb.go | 2 +- protos/peer/transaction.pb.go | 121 +++++++++++-------------- protos/peer/transaction.proto | 21 +++-- 7 files changed, 104 insertions(+), 85 deletions(-) diff --git a/core/ledger/kvledger/kv_ledger.go b/core/ledger/kvledger/kv_ledger.go index c4ec0fd5ded..fa8803838b1 100644 --- a/core/ledger/kvledger/kv_ledger.go +++ b/core/ledger/kvledger/kv_ledger.go @@ -29,6 +29,7 @@ import ( "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr" "github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/protos/common" + "github.com/hyperledger/fabric/protos/peer" logging "github.com/op/go-logging" ) @@ -199,8 +200,23 @@ func recommitLostBlocks(l *kvLedger, savepoint uint64, blockHeight uint64, recov } // GetTransactionByID retrieves a transaction by id -func (l *kvLedger) GetTransactionByID(txID string) (*common.Envelope, error) { - return l.blockStore.RetrieveTxByID(txID) +func (l *kvLedger) GetTransactionByID(txID string) (*peer.ProcessedTransaction, error) { + + tranEnv, err := l.blockStore.RetrieveTxByID(txID) + if err != nil { + return nil, err + } + + // Hardocde to Valid:true for now + processedTran := &peer.ProcessedTransaction{TransactionEnvelope: tranEnv, Valid: true} + + // TODO subsequent changeset will retrieve validation bit array on the block to indicate + // whether the tran was validated or invalidated. It is possible to retreive both the tran + // and the block (with bit array) from storage and combine the results. But it would be + // more efficient to refactor block storage to retrieve the tran and the validation bit + // in one operation. + + return processedTran, nil } // GetBlockchainInfo returns basic info about blockchain diff --git a/core/ledger/kvledger/kv_ledger_test.go b/core/ledger/kvledger/kv_ledger_test.go index 74f40db290a..c09bed988eb 100644 --- a/core/ledger/kvledger/kv_ledger_test.go +++ b/core/ledger/kvledger/kv_ledger_test.go @@ -26,6 +26,7 @@ import ( "github.com/hyperledger/fabric/core/ledger/ledgerconfig" ledgertestutil "github.com/hyperledger/fabric/core/ledger/testutil" "github.com/hyperledger/fabric/protos/common" + putils "github.com/hyperledger/fabric/protos/utils" "github.com/stretchr/testify/assert" ) @@ -81,6 +82,20 @@ func TestKVLedgerBlockStorage(t *testing.T) { b2, _ = ledger.GetBlockByNumber(2) testutil.AssertEquals(t, b2, block2) + + // get the tran id from the 2nd block, then use it to test GetTransactionByID() + txEnvBytes2 := block2.Data.Data[0] + txEnv2, err := putils.GetEnvelopeFromBlock(txEnvBytes2) + testutil.AssertNoError(t, err, "Error upon GetEnvelopeFromBlock") + payload2, err := putils.GetPayload(txEnv2) + testutil.AssertNoError(t, err, "Error upon GetPayload") + txID2 := payload2.Header.ChannelHeader.TxId + processedTran2, err := ledger.GetTransactionByID(txID2) + testutil.AssertNoError(t, err, "Error upon GetTransactionByID") + // get the tran envelope from the retrieved ProcessedTransaction + retrievedTxEnv2 := processedTran2.TransactionEnvelope + testutil.AssertEquals(t, retrievedTxEnv2, txEnv2) + } func TestKVLedgerDBRecovery(t *testing.T) { diff --git a/core/ledger/ledger_interface.go b/core/ledger/ledger_interface.go index 8a2ea27da06..3495885d256 100644 --- a/core/ledger/ledger_interface.go +++ b/core/ledger/ledger_interface.go @@ -19,6 +19,7 @@ package ledger import ( commonledger "github.com/hyperledger/fabric/common/ledger" "github.com/hyperledger/fabric/protos/common" + "github.com/hyperledger/fabric/protos/peer" ) // PeerLedgerProvider provides handle to ledger instances @@ -40,7 +41,7 @@ type PeerLedgerProvider interface { type PeerLedger interface { commonledger.Ledger // GetTransactionByID retrieves a transaction by id - GetTransactionByID(txID string) (*common.Envelope, error) + GetTransactionByID(txID string) (*peer.ProcessedTransaction, error) // GetBlockByHash returns a block given it's hash GetBlockByHash(blockHash []byte) (*common.Block, error) // NewTxSimulator gives handle to a transaction simulator. diff --git a/core/scc/qscc/querier.go b/core/scc/qscc/querier.go index 5c68cdc92ac..d6e4f01b14c 100644 --- a/core/scc/qscc/querier.go +++ b/core/scc/qscc/querier.go @@ -199,14 +199,13 @@ func getTransactionByID(vledger ledger.PeerLedger, tid []byte) pb.Response { if tid == nil { return shim.Error("Transaction ID must not be nil.") } - txEnvelope, err := vledger.GetTransactionByID(string(tid)) + + processedTran, err := vledger.GetTransactionByID(string(tid)) if err != nil { return shim.Error(fmt.Sprintf("Failed to get transaction with id %s, error %s", string(tid), err)) } - // TODO In the returned transaction, need to replace binary simulation results with a proto - // structure including write set, so that clients know what this transaction wrote - bytes, err := utils.Marshal(txEnvelope) + bytes, err := utils.Marshal(processedTran) if err != nil { return shim.Error(err.Error()) } diff --git a/protos/peer/admin.pb.go b/protos/peer/admin.pb.go index 517c847a893..c6cf89095f8 100644 --- a/protos/peer/admin.pb.go +++ b/protos/peer/admin.pb.go @@ -56,7 +56,7 @@ It has these top-level messages: ProposalResponsePayload Endorsement SignedTransaction - InvalidTransaction + ProcessedTransaction Transaction TransactionAction ChaincodeActionPayload diff --git a/protos/peer/transaction.pb.go b/protos/peer/transaction.pb.go index f83280e2ace..6473944fb2f 100644 --- a/protos/peer/transaction.pb.go +++ b/protos/peer/transaction.pb.go @@ -8,33 +8,13 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import google_protobuf1 "github.com/golang/protobuf/ptypes/timestamp" +import common "github.com/hyperledger/fabric/protos/common" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -type InvalidTransaction_Cause int32 - -const ( - InvalidTransaction_TX_ID_ALREADY_EXISTS InvalidTransaction_Cause = 0 - InvalidTransaction_RW_CONFLICT_DURING_COMMIT InvalidTransaction_Cause = 1 -) - -var InvalidTransaction_Cause_name = map[int32]string{ - 0: "TX_ID_ALREADY_EXISTS", - 1: "RW_CONFLICT_DURING_COMMIT", -} -var InvalidTransaction_Cause_value = map[string]int32{ - "TX_ID_ALREADY_EXISTS": 0, - "RW_CONFLICT_DURING_COMMIT": 1, -} - -func (x InvalidTransaction_Cause) String() string { - return proto.EnumName(InvalidTransaction_Cause_name, int32(x)) -} -func (InvalidTransaction_Cause) EnumDescriptor() ([]byte, []int) { return fileDescriptor8, []int{1, 0} } - // This message is necessary to facilitate the verification of the signature // (in the signature field) over the bytes of the transaction (in the // transactionBytes field). @@ -53,20 +33,27 @@ func (m *SignedTransaction) String() string { return proto.CompactTex func (*SignedTransaction) ProtoMessage() {} func (*SignedTransaction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{0} } -// This is used to wrap an invalid Transaction with the cause -type InvalidTransaction struct { - 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"` -} - -func (m *InvalidTransaction) Reset() { *m = InvalidTransaction{} } -func (m *InvalidTransaction) String() string { return proto.CompactTextString(m) } -func (*InvalidTransaction) ProtoMessage() {} -func (*InvalidTransaction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{1} } - -func (m *InvalidTransaction) GetTransaction() *Transaction { +// ProcessedTransaction wraps an Envelope that includes a transaction along with an indication +// of whether the transaction was validated or invalidated by committing peer. +// The use case is that GetTransactionByID API needs to retrieve the transaction Envelope +// from block storage, and return it to a client, and indicate whether the transaction +// was validated or invalidated by committing peer. So that the originally submitted +// transaction Envelope is not modified, the ProcessedTransaction wrapper is returned. +type ProcessedTransaction struct { + // An Envelope which includes a processed transaction + TransactionEnvelope *common.Envelope `protobuf:"bytes,1,opt,name=transactionEnvelope" json:"transactionEnvelope,omitempty"` + // An indication of whether the transaction was validated or invalidated by committing peer + Valid bool `protobuf:"varint,2,opt,name=valid" json:"valid,omitempty"` +} + +func (m *ProcessedTransaction) Reset() { *m = ProcessedTransaction{} } +func (m *ProcessedTransaction) String() string { return proto.CompactTextString(m) } +func (*ProcessedTransaction) ProtoMessage() {} +func (*ProcessedTransaction) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{1} } + +func (m *ProcessedTransaction) GetTransactionEnvelope() *common.Envelope { if m != nil { - return m.Transaction + return m.TransactionEnvelope } return nil } @@ -184,48 +171,44 @@ func (m *ChaincodeEndorsedAction) GetEndorsements() []*Endorsement { func init() { proto.RegisterType((*SignedTransaction)(nil), "protos.SignedTransaction") - proto.RegisterType((*InvalidTransaction)(nil), "protos.InvalidTransaction") + proto.RegisterType((*ProcessedTransaction)(nil), "protos.ProcessedTransaction") proto.RegisterType((*Transaction)(nil), "protos.Transaction") proto.RegisterType((*TransactionAction)(nil), "protos.TransactionAction") proto.RegisterType((*ChaincodeActionPayload)(nil), "protos.ChaincodeActionPayload") proto.RegisterType((*ChaincodeEndorsedAction)(nil), "protos.ChaincodeEndorsedAction") - proto.RegisterEnum("protos.InvalidTransaction_Cause", InvalidTransaction_Cause_name, InvalidTransaction_Cause_value) } func init() { proto.RegisterFile("peer/transaction.proto", fileDescriptor8) } var fileDescriptor8 = []byte{ - // 506 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x93, 0xdf, 0x6a, 0xdb, 0x30, - 0x14, 0xc6, 0xe7, 0x96, 0xa6, 0xf4, 0xa4, 0x8c, 0x44, 0x1b, 0xa9, 0x13, 0x3a, 0x1a, 0x7c, 0xd5, - 0x51, 0xb0, 0x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54, - 0x43, 0x96, 0x67, 0x71, 0xa2, 0xf6, 0x54, 0xa7, 0x39, 0x59, 0xc4, 0xb8, 0xa0, 0x51, 0xb5, 0xb3, - 0x0a, 0x37, 0x7e, 0x68, 0x70, 0xf4, 0x1f, 0x06, 0xbd, 0x83, 0xe1, 0xd6, 0x85, 0xfe, 0xab, 0xa3, - 0x23, 0x05, 0xe0, 0x4a, 0x6f, 0x1a, 0x3a, 0xa4, 0xd2, 0x6d, 0x49, 0xb3, 0x42, 0xe8, 0x3b, 0xe5, - 0x51, 0xd7, 0x77, 0xcf, 0x69, 0x34, 0xfc, 0x08, 0xbc, 0x38, 0xfb, 0xf6, 0x32, 0x4e, 0x8a, 0xc5, - 0x2a, 0x30, 0x43, 0xb6, 0xb4, 0x16, 0xeb, 0x9c, 0xf2, 0x94, 0x46, 0x31, 0xe5, 0xd6, 0x3d, 0x09, - 0x78, 0x12, 0xca, 0x27, 0x28, 0xac, 0xcd, 0x7b, 0x0b, 0xe4, 0xf3, 0x3c, 0xff, 0x13, 0x00, 0x00, - 0xff, 0xff, 0xf9, 0x23, 0xe4, 0x85, 0xbf, 0x03, 0x00, 0x00, + // 449 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x53, 0x4d, 0x6b, 0xdb, 0x40, + 0x14, 0x44, 0x09, 0x71, 0x9a, 0xe7, 0x1c, 0xe2, 0x75, 0x70, 0x14, 0x13, 0x48, 0xd0, 0x29, 0x25, + 0x20, 0x81, 0x73, 0x68, 0x29, 0xbd, 0xd4, 0xc5, 0x77, 0xa3, 0xe6, 0xd4, 0x43, 0xcd, 0x4a, 0x7a, + 0x91, 0x17, 0xa4, 0xdd, 0x65, 0x77, 0x6d, 0xf0, 0x9f, 0x68, 0x6f, 0xfd, 0xbd, 0xc5, 0xfb, 0x61, + 0x29, 0x75, 0x7b, 0x91, 0x78, 0x6f, 0x46, 0x33, 0xa3, 0x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x00, 0x00, 0xff, 0xff, 0x86, 0x51, 0xa3, 0x83, 0x7e, 0x03, 0x00, + 0x00, } diff --git a/protos/peer/transaction.proto b/protos/peer/transaction.proto index 3e1eba77cbd..6118c790dcb 100644 --- a/protos/peer/transaction.proto +++ b/protos/peer/transaction.proto @@ -22,6 +22,7 @@ package protos; import "google/protobuf/timestamp.proto"; import "peer/proposal_response.proto"; +import "common/common.proto"; // This message is necessary to facilitate the verification of the signature // (in the signature field) over the bytes of the transaction (in the @@ -38,14 +39,18 @@ message SignedTransaction { bytes signature = 2; } -// This is used to wrap an invalid Transaction with the cause -message InvalidTransaction { - enum Cause { - TX_ID_ALREADY_EXISTS = 0; - RW_CONFLICT_DURING_COMMIT = 1; - } - Transaction transaction = 1; - Cause cause = 2; +// ProcessedTransaction wraps an Envelope that includes a transaction along with an indication +// of whether the transaction was validated or invalidated by committing peer. +// The use case is that GetTransactionByID API needs to retrieve the transaction Envelope +// from block storage, and return it to a client, and indicate whether the transaction +// was validated or invalidated by committing peer. So that the originally submitted +// transaction Envelope is not modified, the ProcessedTransaction wrapper is returned. +message ProcessedTransaction { + // An Envelope which includes a processed transaction + common.Envelope transactionEnvelope = 1; + + // An indication of whether the transaction was validated or invalidated by committing peer + bool valid = 2; } // The transaction to be sent to the ordering service. A transaction contains