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

add fabric-protos-go-apiv2 #66

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

pfi79
Copy link
Contributor

@pfi79 pfi79 commented Aug 29, 2024

and change github.com/golang/protobuf on google.golang.org/protobuf

it's an alternative to pr
you can choose one of them or propose a 3rd alternative

hyperledger/fabric#3650

@bestbeforetoday
Copy link
Member

Based on experience of the v2 implementations for Go chaincode, my preference would be for the approach in this PR where the v2 code replaces the previous code in the root of the repository. It really does require a v2.0.0 release/tag to then be created at this point to differentiate from the older (pre-v2) code. If any future maintenance updates are required to the pre-v2 code, they would be made in a new branch (populated with the last pre-v2 commit from the main branch), and tagged there.

@pfi79
Copy link
Contributor Author

pfi79 commented Sep 5, 2024

Based on experience of the v2 implementations for Go chaincode, my preference would be for the approach in this PR where the v2 code replaces the previous code in the root of the repository. It really does require a v2.0.0 release/tag to then be created at this point to differentiate from the older (pre-v2) code. If any future maintenance updates are required to the pre-v2 code, they would be made in a new branch (populated with the last pre-v2 commit from the main branch), and tagged there.

So for those who still need the old version, we should make a separate branch called “v1”, and main update to v2?

@bestbeforetoday
Copy link
Member

It seems you don't actually need a new branch. You can depend based on tag, provided the pre-v2 release is tagged. Or you can use pseudo-versions. It just makes it harder to pick pre-v2 versions without an actual Git tag.

The second branch just comes in if you need to release a new pre-v2 version after you have already made the main branch the v2 stream. You need somewhere to deliver the change. Only once this is necessary, I would create a new branch based on the last commit before the v2 change, deliver pre-v2 changes to that branch, then just tag the new pre-v2 version commit so make it accessible as a specific Go version.

…oogle.golang.org/protobuf

Signed-off-by: Fedor Partanskiy <[email protected]>
@pfi79 pfi79 force-pushed the add-fabric-protos-go-apiv2 branch from d535363 to 637026e Compare September 7, 2024 08:42
@pfi79
Copy link
Contributor Author

pfi79 commented Sep 7, 2024

@C0rWin @denyeart @yacovm please review

Copy link

@C0rWin C0rWin left a comment

Choose a reason for hiding this comment

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

the change looks good to me, thanks @pfi79

@pfi79
Copy link
Contributor Author

pfi79 commented Sep 11, 2024

@denyeart can you see pr, please?
"At least write that everything here is nonsense and should be redone ))))"

Copy link
Contributor

@denyeart denyeart left a comment

Choose a reason for hiding this comment

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

LGTM, just one question...

fieldName := prop.OrigName
fieldValue := mVal.FieldByName(prop.Name)
fieldTypeStruct, ok := mVal.Type().FieldByName(prop.Name)
for i := 0; i < t.NumField(); i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the different approach here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, what do you see as a different approach?

Functions were used here that are no longer present in the new protobuf. I was just trying to replicate the logic by other means. Although in my opinion, this code fragment is very overcomplicated.

I think it can be written in a simpler way. But not in this pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

proto.GetProperties is missing from the new protobuf
I got inside her and tried to replicate her logic here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I rewrote it, I got it wrong 3 or 4 times. And the tests didn't pass. This is the result of long debugging.

But if there is something wrong here, tell me what. I'll rewrite it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant why did you have to utilize a new approach versus the prior code. I understand now. I've also tested the fabric consumers such as configtxgen -inspect with the new PR, and it works fine, so I'll go ahead and merge.

@denyeart denyeart merged commit df5311a into hyperledger:main Sep 12, 2024
3 checks passed
@denyeart
Copy link
Contributor

denyeart commented Sep 12, 2024

Based on experience of the v2 implementations for Go chaincode, my preference would be for the approach in this PR where the v2 code replaces the previous code in the root of the repository. It really does require a v2.0.0 release/tag to then be created at this point to differentiate from the older (pre-v2) code. If any future maintenance updates are required to the pre-v2 code, they would be made in a new branch (populated with the last pre-v2 commit from the main branch), and tagged there.

@bestbeforetoday Does this really require a v2.0.0 release tag? I didn't see any signature changes. Plus, the current version is v0.x which implies that this module is not yet stable. We kept it at v0.x because this module has not been used in a fabric admin SDK yet (as we expected), so the signatures could still potentially change once we do that integration. I'm thinking of tagging as v0.3.0.

@bestbeforetoday
Copy link
Member

Right now you definitely cannot tag it as v2.x since the module path remains as github.com/hyperledger/fabric-config. A v2 release would require a github.com/hyperledger/fabric-config/v2 module path. See: https://go.dev/ref/mod#major-version-suffixes.

The key issue with compatibility is likely to be the switch from github.com/hyperledger/fabric-protos-go to github.com/hyperledger/fabric-protos-go-apiv2. Any module that depends on this one and also github.com/hyperledger/fabric-protos-go is likely to break due to a protobuf namespace conflict between the two fabric-protos modules.

Given that it's currently at v0.x, you could certainly argue that there is no compatibility guarantee and, particularly if the public API is unchanged, just stick at a v0.x release. A middle ground could be to declare a v1.x release, which would indicate a breaking change from v0.x without the module path change. I guess the choice is likely to be guided by the risk of breaking any users of this module (who also use fabric-protos) moving up a minor release version without realising the implications.

@pfi79 pfi79 deleted the add-fabric-protos-go-apiv2 branch September 13, 2024 04:44
@denyeart
Copy link
Contributor

Thanks @bestbeforetoday , I've gone ahead and released as v0.3.0, remaining at v0.x.x will allow us to make small changes if needed for any important consumers such as a fabric SDK or CLI consumer.

@pfi79 Go ahead and update your fabric PR to use v0.3.0.

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.

4 participants