hyperledger / fabric-sdk-go

https://wiki.hyperledger.org/display/fabric
Apache License 2.0
911 stars 511 forks source link

How to fix hyperledger issue (undefined: discovery.ChaincodeCall) after updating go lang to 1.20? #260

Open MrHIDEn opened 1 year ago

MrHIDEn commented 1 year ago

Hi. I have workig fabric application based on 'Go lang' and 'fabric-sdk-go'.

I just updated it to newer versions of 'Go lang' but without success as library uses internally 'discovery' instead of 'peer'.

I'm using those packages:

github.com/hyperledger/fabric-contract-api-go v1.2.1
github.com/hyperledger/fabric-sdk-go v1.0.0

Errors:

# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/discovery/client
..\vendor\github.com\hyperledger\fabric-sdk-go\internal\github.com\hyperledger\fabric\discovery\client\api.go:47:38: undefined: discovery.ChaincodeCall
..\vendor\github.com\hyperledger\fabric-sdk-go\internal\github.com\hyperledger\fabric\discovery\client\client.go:83:63: undefined: discovery.ChaincodeInterest
..\vendor\github.com\hyperledger\fabric-sdk-go\internal\github.com\hyperledger\fabric\discovery\client\client.go:120:65: undefined: discovery.ChaincodeCall
..\vendor\github.com\hyperledger\fabric-sdk-go\internal\github.com\hyperledger\fabric\discovery\client\client.go:124:23: undefined: discovery.ChaincodeInterest
..\vendor\github.com\hyperledger\fabric-sdk-go\internal\github.com\hyperledger\fabric\discovery\client\client.go:229:105: undefined: discovery.ChaincodeCall
..\vendor\github.com\hyperledger\fabric-sdk-go\internal\github.com\hyperledger\fabric\discovery\client\client.go:247:64: undefined: discovery.ChaincodeCall

What should I do to fix that?

Regards

MrRancy commented 1 year ago

Same error from me as well, is there a fix for this??

MrHIDEn commented 1 year ago

@MrRancy, I got error when I run tests. You too? I do not have solution yet. Sad.

Teja-S commented 1 year ago

@MrHIDEn, I am using fabric-sdk-go in a personal package development, and that's when I got this error. don't know, because of this, I am unable to build my package. By the way, what is the version you are using? I am working on v1.20

Teja-S commented 1 year ago

Hey @MrHIDEn, I got it working with these versions, for me, the error was from a different package which is the fabric-protos-go. Probably it's the same for you. Could you give it a try with this version?

go.mod file


go 1.20

require ( github.com/hyperledger/fabric-lib-go v1.0.0 // indirect github.com/hyperledger/fabric-sdk-go v1.0.0 // indirect github.com/hyperledger/fabric v2.1.1+incompatible github.com/hyperledger/fabric-amcl v0.0.0-20221107192335-5c75bc7be9c0 // indirect github.com/hyperledger/fabric-config v0.1.0 github.com/hyperledger/fabric-protos-go v0.0.0-20200707132912-fee30f3ccd23 )

MrHIDEn commented 1 year ago

Hey @Teja-S, Generali my app works on any Go version exept 1.14 but when I run tests I got error provided. No for Go 1.20 I have below code

// go.mod file
go 1.20

require (
    github.com/codahale/sss v0.0.0-20160501174526-0cb9f6d3f7f1
    github.com/ghodss/yaml v1.0.0
    github.com/hyperledger/fabric-contract-api-go v1.2.1
    github.com/hyperledger/fabric-sdk-go v1.0.0
)
MrHIDEn commented 1 year ago

One of error says:

C:\Users\user\go\pkg\mod\github.com\hyperledger\fabric-sdk-go@v1.0.0\internal\github.com\hyperledger\fabric\discovery\client\api.go:47:38: undefined: discovery.ChaincodeCall

when I go there to ..\api.go:47:38 I see there is real issue:

    // Peers returns a response for a peer membership query, or error if something went wrong
    Peers(invocationChain ...*discovery.ChaincodeCall) ([]*Peer, error)

*discovery doesn't have ChaincodeCall at all !!

MrHIDEn commented 1 year ago

That is interested: Github search: org:hyperledger Peers(invocationChain

https://github.com/hyperledger/fabric-sdk-go/blob/7af45cede6afa3939a9574bc9948cca9fb424257/internal/github.com/hyperledger/fabric/discovery/client/api.go#L48 Peers(invocationChain ...*peer.ChaincodeCall) ([]*Peer, error)

On my libs installed C:\Users\user\go\pkg\mod\github.com\hyperledger\fabric-sdk-go@v1.0.0\internal\github.com\hyperledger\fabric\discovery\client\api.go Peers(invocationChain ...*discovery.ChaincodeCall) ([]*Peer, error)

werniq commented 8 months ago

I also encountered this problem. Issue was resolved in this way:

  1. Delete fabric-sdk-go in vendor directory
  2. Replace with new version: git clone https://github.com/hyperledger/fabric-sdk-go/