fabric-sdk-go icon indicating copy to clipboard operation
fabric-sdk-go copied to clipboard

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

Open MrHIDEn opened this issue 1 year ago • 8 comments

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

MrHIDEn avatar Mar 10 '23 16:03 MrHIDEn

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

MrRancy avatar Mar 16 '23 05:03 MrRancy

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

MrHIDEn avatar Mar 16 '23 15:03 MrHIDEn

@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 avatar Mar 16 '23 19:03 Teja-S

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
)

Teja-S avatar Mar 16 '23 19:03 Teja-S

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 avatar Mar 16 '23 22:03 MrHIDEn

One of error says:

C:\Users\user\go\pkg\mod\github.com\hyperledger\[email protected]\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 avatar Mar 16 '23 22:03 MrHIDEn

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\[email protected]\internal\github.com\hyperledger\fabric\discovery\client\api.go Peers(invocationChain ...*discovery.ChaincodeCall) ([]*Peer, error)

MrHIDEn avatar Mar 17 '23 09:03 MrHIDEn

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/

werniq avatar Oct 17 '23 11:10 werniq