Skip to content
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

FABGW-25 Endorse using generated ChaincodeInterest #2773

Merged
merged 1 commit into from
Jul 26, 2021

Conversation

andrew-coleman
Copy link
Member

Change the Endorse() method logic as described in the design document attached to the Jira.

  • Process proposal on local org peer.
  • Using the ChaincodeInterest in the propsal response, invoke discovery to obtain a layout that contains the local org
  • Obtain the remaining endorsements
  • Build the transaction to send back to the client.

Extra unit tests added to test the new logic.

Signed-off-by: andrew-coleman andrew_coleman@uk.ibm.com

@andrew-coleman andrew-coleman requested a review from a team as a code owner July 22, 2021 13:07
@andrew-coleman andrew-coleman marked this pull request as draft July 22, 2021 16:18
@andrew-coleman andrew-coleman marked this pull request as ready for review July 22, 2021 16:43
if err != nil {
return nil, err
logger.Errorf("PeersForEndorsement failed with error %s for channel %s and ChaincodeInterest %s", err, channel, proto.MarshalTextString(interest))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Errorf("PeersForEndorsement failed with error %s for channel %s and ChaincodeInterest %s", err, channel, proto.MarshalTextString(interest))
logger.Errorw("PeersForEndorsement failed.", "error", err, "channel", channel, "ChaincodeInterest", proto.MarshalTextString(interest))

For quite some time, we have been following this logging API for dumping logs in a better machine readable way.

@@ -127,19 +127,29 @@ func (reg *registry) endorsers(channel string, chaincode string) ([]*endorser, e
for _, peer := range receivers {
endorsers = append(endorsers, peer.endorser)
}

// if this plan doesn't contain the local org, abandon it in favour of one that does, since we already have a local endorsement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// if this plan doesn't contain the local org, abandon it in favour of one that does, since we already have a local endorsement
// if this plan doesn't contain the `preferOrg` org, abandon it in favour of one that does, since we already have a local endorsement

The term local org confused me for a while until I saw the usage of this function.
As far as this function is concerned, preferOrg is supplied and in some case (i.e., when transient data is missing), this could actually be non-local as well.

Comment on lines +132 to +133
// Otherwise, just let discovery pick one.
endorsers, err = gs.registry.endorsers(channel, defaultInterest, "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking a loud here - Is it worth a blind try or simply let client choose the gateway of the org that it thinks should succeed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to consider a future proposal for allowing the client to choose the 'initial' endorser

Comment on lines +154 to +158
if len(interest.GetChaincodes()) == 0 {
interest = defaultInterest
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A clarification question - Will this condition be ever true unless it's a read-only transaction? If no, then, is there any purpose of proceeding from here?

Also, that brings another thought, what if it's read-only transaction for pvtdata? That would record some entries in the interest which would give a wrong signal for proceeding.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be true if:

  • The Interest structure in the ProposalResponse is nil, which will be the case for legacy peers
  • The chaincode invocation doesn't create a RWset. This happens in one of the integration tests where the chaincode only sets an event

Comment on lines 173 to 175
if hasTransientData && len(endorsers) > 0 {
return nil, status.Error(codes.FailedPrecondition, "non-local organizations are required to endorse; retry specifying endorsing organization(s) to protect transient data")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this caution is need here at this stage. Won't this make this whole approach pretty much unusable with private data as in most of the scenario private data transactions will involve transient data and would require multi-org endorsements.

May be better to set the artificial pvt-reads set for all collections to narrow the scope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've implemented your suggestion

Change the Endorse() method logic as described in the design document attached to the Jira.
- Process proposal on local org peer.
- Using the ChaincodeInterest in the propsal response, invoke discovery to obtain a layout that contains the local org
- Obtain the remaining endorsements
- Build the transaction to send back to the client.

Extra unit tests added to test the new logic.

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
@manish-sethi manish-sethi merged commit f662d98 into hyperledger:main Jul 26, 2021
@andrew-coleman andrew-coleman deleted the FABGW-25 branch July 26, 2021 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants