-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement query committed chaincodes in channel #88
Implement query committed chaincodes in channel #88
Conversation
Signed-off-by: Samuel Venzi <samuel.venzi@me.com>
Signed-off-by: Samuel Venzi <samuel.venzi@me.com>
I let slip a small type error in the cc sequence verification. It's corrected and e2e test should be successful now. |
|
||
// QueryCommitted chaincode on a specific peer. | ||
func QueryCommitted(ctx context.Context, connection grpc.ClientConnInterface, signingID identity.SigningIdentity, channelID string) (*lifecycle.QueryChaincodeDefinitionsResult, error) { | ||
queryArgs := &lifecycle.QueryChaincodeDefinitionsArgs{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/hyperledger/fabric/blob/main/internal/peer/lifecycle/chaincode/querycommitted.go#L223-L227
if I am correct, we can add chaincode name a parameter? ref to fabric code as example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, @bestbeforetoday , we removed name as parameter at https://github.com/hyperledger/fabric-protos-go-apiv2/blob/main/peer/lifecycle/lifecycle.pb.go#L1290-L1328 ?
are we able to pass QueryChaincodeDefinitionsArgs with name in fabric-protos-go-apiv2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, @bestbeforetoday , we removed name as parameter at https://github.com/hyperledger/fabric-protos-go-apiv2/blob/main/peer/lifecycle/lifecycle.pb.go#L1290-L1328 ?
are we able to pass QueryChaincodeDefinitionsArgs with name in fabric-protos-go-apiv2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are currently two options for querying committed chaincodes in Fabric. One of them queries all committed in the channel and the other filters it by chaincode name.
One uses QueryChaincodeDefinitions
tx name and the other uses QueryChaincodeDefinition
.
Should I proceed to add both options then? In separate functions or the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose if possible, we should support both query all and query by name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we able to pass QueryChaincodeDefinitionsArgs with name in fabric-protos-go-apiv2?
We can use QueryChaincodeDefinitionArgs
with name. I can do this after this PR.
type QueryChaincodeDefinitionArgs struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by default, I will merge this PR before Monday, will keep this PR open for other reviewers. :-)
it's 11 pm my local time, I am going to have a rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samuelvenzi , you are able to have another PR for query by name after this PR been merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When querying installed chaincode, there are two options: query all installed chaincodes, or query a specific named chaincode. Both options return exactly the same information about the installed chaincode(s). The difference is whether you get information about all or only one of the installed chaincodes. I can't see much point in the versions where you specify the name since you can just pick the name you are interested in from the all installed chaincodes result.
When querying committed chaincode, there are the same two options: query all committed, or query a specific named chaincode. I have no idea why, but for this query they actually return slightly different information. Querying for a specific named chaincode returns all the information returned from querying all, and also includes the approvals for that chaincode.
So for query installed, I am personally happy with just querying for all installed chaincodes. Query for a specific installed chaincode just means more code to maintain for no value.
For query committed, I think we will need to prove API calls for both options. I would prefer to have two different API calls. Any preferences on the naming? It could be QueryAllCommitted
and QueryCommitted
, or QueryCommitted
and QueryCommittedWithName
, or something else...? That can happen in a later PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer QueryCommitted
and QueryCommittedWithName
. I didn't realize the information was slightly different, but you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, as comments with nit enhancement maybe blocked by proto definitions and I don't want that block this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Thank you for the contribution! I've added my thoughts to the discussions in the comments but generally happy with this PR as-is. Just one change to the e2e test code that I think would be worth making - see in-line comments.
|
||
// QueryCommitted chaincode on a specific peer. | ||
func QueryCommitted(ctx context.Context, connection grpc.ClientConnInterface, signingID identity.SigningIdentity, channelID string) (*lifecycle.QueryChaincodeDefinitionsResult, error) { | ||
queryArgs := &lifecycle.QueryChaincodeDefinitionsArgs{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When querying installed chaincode, there are two options: query all installed chaincodes, or query a specific named chaincode. Both options return exactly the same information about the installed chaincode(s). The difference is whether you get information about all or only one of the installed chaincodes. I can't see much point in the versions where you specify the name since you can just pick the name you are interested in from the all installed chaincodes result.
When querying committed chaincode, there are the same two options: query all committed, or query a specific named chaincode. I have no idea why, but for this query they actually return slightly different information. Querying for a specific named chaincode returns all the information returned from querying all, and also includes the approvals for that chaincode.
So for query installed, I am personally happy with just querying for all installed chaincodes. Query for a specific installed chaincode just means more code to maintain for no value.
For query committed, I think we will need to prove API calls for both options. I would prefer to have two different API calls. Any preferences on the naming? It could be QueryAllCommitted
and QueryCommitted
, or QueryCommitted
and QueryCommittedWithName
, or something else...? That can happen in a later PR.
test/e2e_test.go
Outdated
@@ -273,6 +273,14 @@ var _ = Describe("e2e", func() { | |||
printGrpcError(err) | |||
Expect(err).NotTo(HaveOccurred(), "commit chaincode") | |||
|
|||
result, err := chaincode.QueryCommitted(specCtx, peerConnections[0].connection, peerConnections[0].id, channelName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit above should have caused the chaincode to be committed on all network peers where it was installed. We could confirm this by querying installed chaincode on both org peers.
However, we only know for sure that the commit has completed on the (Gateway) peer where we invoked the commit since that is where we observe the successfully committed transaction in the ledger. The other peers may not yet have processed the transaction. So I think this approach of querying just the peer used for the commit is reasonable.
One thing I would change though... using peerConnections[0]
happens to be the same peer that was used for the commit but that could change if somebody changed the code above later. I think it would be better to be more explicit about the peer being used with n_conn1
as the connection and org1MSP
as the identity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer, @bestbeforetoday. Changing it now.
Signed-off-by: Samuel Venzi <samuel.venzi@me.com>
Signed-off-by: Samuel Venzi samuel.venzi@me.com