-
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
Categorise chaincode operations by peer and gateway #194
base: main
Are you sure you want to change the base?
Conversation
@SamYuan1990 @samuelvenzi What do you think of this as an approach? It's been bugging me for a long time that so many parameters are duplicated across chaincode functions. This is an alternative approach. Both work so I'm interested in your perspective on whether it's worth making a change from what we have. Any change needs to happen before we hit a proper v1 release. I actually included the service discovery PeerMembershipQuery on Gateway. We could go further down that route and associate all functionality (not just chaincode lifecycle) with appropriate node connections (Gateway, Peer, Orderer) and hide all the implementation code/packages, or we could keep each category of functionality separate, like we do currently with a different package for each concern. |
I am good to see we simply the logic, but I have a question as |
There are definitely some areas where a replacement admin CLI can be simplified compared to the existing peer CLI. The key one is that, for all existing peer CLI commands that submit a transaction to the ledger (which means all the ones on Gateway in this PR), the user needs to specify sufficient endorsing peers and the orderer(s) to which the endorsed transaction will be submitted. The admin SDK implementation makes use of the peer’s Gateway service to handle these interactions and so only ever requires a connection to a single (Gateway) peer for these interactions. This remains true for a BFT ordering service since the Gateway service handles the different ordering requirements for the consensus implementation. Chaincode install talks directly to a specific peer so doesn’t use the Gateway service. It might not be possible to simplify that one. You could argue for a chaincode install command that allows multiple target peers to be specified, but I think that is going to make it harder to handle failure scenarios compared to just having the user script (or code) their own flow to drive install on each of the desired peers. |
let's make it step by step, also we need to considering with existing user habits, this PR LGTM. |
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
4bd3d7a
to
22b9bca
Compare
@bestbeforetoday Sorry it took me this long to respond. I def like this approach. I see that this is now a draft, but I'll keep an eye to check it again once it's ready. |
Previous implementation was standalone functions, with all requiring both a gRPC connection and a client signing identity. This required: - An underisably large number of prameters. - Unwritten conventions on parameter ordering. - Documentation comments to highlight when the connection should be to a specific peer or to an organization gateway. - Duplication of arguments across multiple functions for calling code driving the chaincode lifecycle. This implementation defines a Peer and Gateway struct that hold a gRPC connection and a client identity. Each of these types defines methods appropriate to their logical role to: - Avoid the need to provide gRPC connection and client identity arguments on every call. - Provide calling code with logical context for what they are interacting with. - Allow IDE code completion to suggest appropriate methods for the connection type. For example, this pseudo-code flow: chaincode.Install(ctx, peerConnection, id, chaincodePackage) chaincode.Approve(ctx, gatewayConnection, id, chaincodeDefinition) chaincode.Commit(ctx, gatewayConnection, id, chaincodeDefinition) becomes: peer.Install(ctx, chaincodePackage) gateway.Approve(ctx, chaincodeDefinition) gateway.Commit(ctx, chaincodeDefinition) Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
22b9bca
to
c4071a7
Compare
Previous implementation was standalone functions, with all requiring both a gRPC connection and a client signing identity. This required:
This implementation defines a Peer and Gateway struct that hold a gRPC connection and a client identity. Each of these types defines methods appropriate to their logical role to:
For example, this pseudo-code flow:
becomes: