Coder Social home page Coder Social logo

hyperledger / fabric-sdk-go Goto Github PK

View Code? Open in Web Editor NEW
910.0 68.0 511.0 13.49 MB

Home Page: https://wiki.hyperledger.org/display/fabric

License: Apache License 2.0

Go 97.13% Makefile 0.88% Shell 1.99%
hyperledger-fabric go distributed-ledger blockchain hyperledger

fabric-sdk-go's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fabric-sdk-go's Issues

Configuration file and dynamic network structure

As far as I understand, go SDK use config.yaml to initialize.

The network connection profile provides client applications the information about the target blockchain network that are necessary for the applications to interact with it. These are all knowledge that must be acquired from out-of-band sources. This file provides such a source.

But I want my network to be dynamic. i.e I may add new organisations, peers or channels to my network. So. for such a case I think a static config file wont help. Is such scenario possible with fabric??

Thanks

[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x4492eaa]

os:mac
golang:1.17.3
sdk:v1.0.1-0.20220428141930-cbdc79f1c9f2
error:

 [fabsdk/core] 2022/02/23 05:20:51 UTC - sw.getOptsByConfig -> DEBU Initialized SW cryptosuite
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - sw.(*fileBasedKeyStore).createKeyStore -> DEBU Creating KeyStore at [/tmp/msp/keystore]...
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - sw.(*fileBasedKeyStore).createKeyStore -> DEBU KeyStore created at [/tmp/msp/keystore].
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - n/a -> DEBU KeyStore opened at [/tmp/msp/keystore]...done
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU Client is: {Organization:org1 TLSCerts:{Client:{Key:{Path: Pem: bytes:[]} Cert:{Path: Pem: bytes:[]}}}}
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU channels are: map[mychannel:{Orderers:[] Peers:map[peer0.org1.example.com:{EndorsingPeer:true ChaincodeQuery:true LedgerQuery:true EventSource:true} peer0.org2.example.com:{EndorsingPeer:true ChaincodeQuery:true LedgerQuery:true EventSource:true}] Policies:{QueryChannelConfig:{MinResponses:0 MaxTargets:0 RetryOpts:{Attempts:0 InitialBackoff:0s MaxBackoff:0s BackoffFactor:0 RetryableCodes:map[]}} Discovery:{MinResponses:0 MaxTargets:0 RetryOpts:{Attempts:4 InitialBackoff:1s MaxBackoff:0s BackoffFactor:0 RetryableCodes:map[]}} Selection:{SortingStrategy: Balancer: BlockHeightLagThreshold:0} EventService:{ResolverStrategy: MinBlockHeightResolverMode: Balancer: BlockHeightLagThreshold:0 PeerMonitor: ReconnectBlockHeightLagThreshold:0 PeerMonitorPeriod:0s}}}]
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU organizations are: map[ordererorg:{MSPID:OrdererMSP CryptoPath:ordererOrganizations/example.com/users/{username}@example.com/msp Users:map[] Peers:[] CertificateAuthorities:[]} org1:{MSPID:Org1MSP CryptoPath:peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp Users:map[] Peers:[peer0.org1.example.com peer0.org2.example.com] CertificateAuthorities:[]}]
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU orderers are: map[orderer.example.com:{URL:orderer.example.com:7050 GRPCOptions:map[] TLSCACerts:{Path:${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/ordererOrganizations/example.com/orderers/orderer.example.com/tls/tlscacerts/tls-localhost-9054-ca-orderer.pem Pem: bytes:[]}}]
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU peers are: map[peer0.org1.example.com:{URL:peer0.org1.example.com:7051 GRPCOptions:map[] TLSCACerts:{Path:${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem Pem: bytes:[]}} peer0.org2.example.com:{URL:peer0.org2.example.com:8051 GRPCOptions:map[] TLSCACerts:{Path:${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem Pem: bytes:[]}}]
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - fab.(*EndpointConfig).compileMatchers -> DEBU Matchers are: {matchers:map[]}
 [fabsdk/fab] 2022/02/23 05:20:51 UTC - fab.(*EndpointConfig).compileMatchers -> DEBU Entity matchers are not configured
 [fabsdk/msp] 2022/02/23 05:20:51 UTC - msp.(*IdentityConfig).loadIdentityConfigEntities -> DEBU Client is: {Organization:org1 Logging:{Level:debug} CryptoConfig:{Path:${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}} TLSCerts:{Client:{Key:{Path: Pem: bytes:[]} Cert:{Path: Pem: bytes:[]}} SystemCertPool:false} CredentialStore:{Path:/tmp/state-store CryptoStore:{Path:/tmp/msp}}}
 [fabsdk/msp] 2022/02/23 05:20:51 UTC - msp.(*IdentityConfig).loadIdentityConfigEntities -> DEBU organizations are: map[ordererorg:{MSPID:OrdererMSP CryptoPath:ordererOrganizations/example.com/users/{username}@example.com/msp Users:map[] Peers:[] CertificateAuthorities:[]} org1:{MSPID:Org1MSP CryptoPath:peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp Users:map[] Peers:[peer0.org1.example.com peer0.org2.example.com] CertificateAuthorities:[]}]
 [fabsdk/msp] 2022/02/23 05:20:51 UTC - msp.(*IdentityConfig).loadIdentityConfigEntities -> DEBU certificateAuthorities are: map[]
 [fabsdk/msp] 2022/02/23 05:20:51 UTC - msp.(*IdentityConfig).compileMatchers -> DEBU Matchers are: {matchers:map[]}
 [fabsdk] 2022/02/23 05:20:51 UTC - fabsdk.initSDK -> DEBU SDK initialized successfully
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x4492eaa]

goroutine 1 [running]:
github.com/hyperledger/fabric-sdk-go/pkg/context.(*Client).Serialize(0xc000246400)
        <autogenerated>:1 +0x2a
github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/provider/chpvdr.newCtxtCacheKey({0x64e9618, 0xc000246400})
        /Users/edy/go/pkg/mod/github.com/hyperledger/[email protected]/pkg/fabsdk/provider/chpvdr/cachekey.go:25 +0x3f
github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/provider/chpvdr.(*ChannelProvider).ChannelService(0xc00011fb18, {0x64e9618, 0xc000246400}, {0x4884ed0, 0x9})
        /Users/edy/go/pkg/mod/github.com/hyperledger/[email protected]/pkg/fabsdk/provider/chpvdr/chprovider.go:69 +0x3c
github.com/hyperledger/fabric-sdk-go/pkg/context.NewChannel(0xc0002a00e0, {0x4884ed0, 0x3})
        /Users/edy/go/pkg/mod/github.com/hyperledger/[email protected]/pkg/context/context.go:267 +0xfb
github.com/hyperledger/fabric-sdk-go/pkg/fabsdk.(*FabricSDK).ChannelContext.func1()
        /Users/edy/go/pkg/mod/github.com/hyperledger/[email protected]/pkg/fabsdk/fabsdk.go:385 +0x4a
github.com/hyperledger/fabric-sdk-go/pkg/client/channel.New(0xc0002a00e0, {0xc0000c1ef8, 0x0, 0x4ffaaf0})
        /Users/edy/go/pkg/mod/github.com/hyperledger/[email protected]/pkg/client/channel/chclient.go:54 +0x42
test-fabric/example/base/sdk.NewChannel(0x48a0184)
        /Users/edy/code/blockchain/fabric/example/base/sdk/channel.go:19 +0x4d
test-fabric/example/base/sdk.New(0xc0000001a0)
        /Users/edy/code/blockchain/fabric/example/base/sdk/sdk.go:42 +0x57
main.main()
        /Users/edy/code/blockchain/fabric/example/base/main.go:10 +0x1e
``
May I ask why?

If the chaincode input and output functions have different packages but the same structure name then variable conflict issue in the chaincode

Using spec

  • Mac Book Pro M1 Ventura v13.5.1
  • Docker v24.0.6
  • Hyperledger Fabric v2.5.3
  • fabric-sdk-go v1.0.0

Literally, If the chaincode input and output functions have different packages but the same structure name then variable conflict issue in the chaincode.

Example

test1.go

package test1

type Test struct {
   A string `json:”a”`
}

test.go

package test

import (
   <path to>/test1
)

type Test struct {
   B int `json:”b”`
}

func(s *Contract) Test1(ctx contranctapi. TranscationContextInterface) (test1.Test) {}
func(s *Contract) Test2(ctx contranctapi. TranscationContextInterface) (Test) {}

In the case above, if Test2 is called after calling Test1, ‘Test’, the output of Test2, is recognized as ‘test1.Test’

If the structure name is different, no conflict will occur.

Please reply after confirmantion.

integration test cases failure

Test cases: TestChainQueries, TestChainCodeInvoke

error exception as below:

`
GOROOT=/usr/local/go
GOPATH=/home/crazybit/study/go/workspace
/usr/local/go/bin/go test -c -o "/tmp/TestChainQueries in chain_queries_test.gogo" github.com/hyperledger/fabric-sdk-go/test/integration
"/tmp/TestChainQueries in chain_queries_test.gogo" -test.v -test.run ^TestChainQueries$

2017/04/01 18:31:55 Using config file: ../fixtures/config/config_test.yaml

2017/04/01 18:31:55 fabric_sdk_go Logging level: debug

18:31:55.405 [SW_BCCSP] DEBU : KeyStore opened at [/tmp/keystore]...done

18:31:55.405 [BCCSP_FACTORY] DEBU : Initialize BCCSP [SW]

18:31:55.405 [fabric_sdk_go] INFO : KeyStore path [/tmp/enroll_user] missing [false]: [%!s()]

18:31:55.405 [SW_BCCSP] DEBU : Loading private key [6434de17974a1e251255979ebd2ea24e800b8736c769a5c475bb8ec56105450f] at [/tmp/keystore/6434de17974a1e251255979ebd2ea24e800b8736c769a5c475bb8ec56105450f_sk]...
18:31:55.418 [fabric_sdk_go] INFO : Constructed Chain instance: &{mychannel true map[] 200 map[] 0xc4202541c0 }
18:31:55.419 [fabric_sdk_go] INFO : Using config file: ../fixtures/config/config_test.yaml
18:31:55.419 [fabric_sdk_go] INFO : fabric_sdk_go Logging level: debug
18:31:55.587 [fabric_sdk_go] INFO : KeyStore path [/tmp/enroll_user] missing [false]: [%!s()]
18:31:55.588 [SW_BCCSP] DEBU : Loading private key [6434de17974a1e251255979ebd2ea24e800b8736c769a5c475bb8ec56105450f] at [/tmp/keystore/6434de17974a1e251255979ebd2ea24e800b8736c769a5c475bb8ec56105450f_sk]...
18:31:55.588 [fabric_sdk_go] INFO : Constructed Chain instance: &{mychannel true map[] 200 map[] 0xc420460000 }
18:31:55.588 [fabric_sdk_go] DEBU : packager: chaincodePath: github.com/example_cc, chaincodeType:
18:31:55.588 [fabric_sdk_go] DEBU : packager: type golang
18:31:55.588 [fabric_sdk_go] DEBU : GOPATH environment variable=/home/crazybit/study/go/workspace/src/github.com/hyperledger/fabric-sdk-go/test/fixtures
18:31:55.588 [fabric_sdk_go] DEBU : projDir variable=/home/crazybit/study/go/workspace/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/src/github.com/example_cc
18:31:55.588 [fabric_sdk_go] DEBU : generateTarGz for /home/crazybit/study/go/workspace/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/src/github.com/example_cc/example_cc.go
18:31:55.589 [fabric_sdk_go] DEBU : Send ProposalRequest to peer :localhost:7056
18:31:55.589 [fabric_sdk_go] DEBU : Send ProposalRequest to peer :localhost:7051
18:31:55.594 [fabric_sdk_go] DEBU : localhost:7056 ProposalResponsePayload Extension ChaincodeAction Results

18:31:55.594 [fabric_sdk_go] DEBU : Receive Proposal ChaincodeActionResponse :&{localhost:7056 200 0xc42036fa00 0xc4204616c0}
SendInstallProposal Endorser 'localhost:7056' return ProposalResponse status:200
SendInstallProposal Endorser 'localhost:7051' return ProposalResponse status:200
chain_queries_test.go:46: instantiateCC return error: SendInstantiateProposal Endorser localhost:7051 return error: Error calling endorser 'localhost:7051': rpc error: code = 2 desc = Failed to deserialize creator identity, err MSP Org1MSP is unknown

18:31:55.598 [fabric_sdk_go] DEBU : localhost:7051 ProposalResponsePayload Extension ChaincodeAction Results

18:31:55.598 [fabric_sdk_go] DEBU : Receive Proposal ChaincodeActionResponse :&{localhost:7051 200 0xc42036fa00 0xc420255300}

18:31:55.598 [fabric_sdk_go] DEBU : Send ProposalRequest to peer :localhost:7051

18:31:55.599 [fabric_sdk_go] DEBU : Receive Error Response :
`

4 Peer Network do not respond to REST client.

Hi,
I have hyperledger fabric 0.6 env setup on Windows 7 64bit using docker Toolbox and I m using REST API client to trigger requests. Following is my four-peer-ca.yaml file:-

**version: "2"
services: baseimage: image: hyperledger/fabric-baseimage:latest

membersrvc:
image: hyperledger/fabric-membersrvc
ports:
- "7054:7054"
command: membersrvc
environment:
- MEMBERSRVC_CA_LOGGING_SERVER=INFO
- MEMBERSRVC_CA_LOGGING_CA=INFO
- MEMBERSRVC_CA_LOGGING_ECA=INFO
- MEMBERSRVC_CA_LOGGING_ECAP=INFO
- MEMBERSRVC_CA_LOGGING_ECAA=INFO
- MEMBERSRVC_CA_LOGGING_ACA=INFO
- MEMBERSRVC_CA_LOGGING_ACAP=INFO
- MEMBERSRVC_CA_LOGGING_TCA=INFO
- MEMBERSRVC_CA_LOGGING_TCAP=INFO
- MEMBERSRVC_CA_LOGGING_TCAA=INFO
- MEMBERSRVC_CA_LOGGING_TLSCA=INFO

vp0:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"

environment:
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4

command: sh -c "sleep 10; peer node start"
links: - membersrvc

vp1:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "8050:7050"
- "8051:7051"
- "8053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp1
- CORE_SECURITY_ENROLLID=test_vp1
- CORE_SECURITY_ENROLLSECRET=5wgHK9qqYaPy
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links: - membersrvc - vp0
command: sh -c "sleep 10; peer node start"

vp2:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "9050:7050"
- "9051:7051"
- "9053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp2
- CORE_SECURITY_ENROLLID=test_vp2
- CORE_SECURITY_ENROLLSECRET=vQelbRvja7cJ
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links: - membersrvc - vp0
command: sh -c "sleep 10; peer node start"

vp3:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "10050:7050"
- "10051:7051"
- "10053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp3
- CORE_SECURITY_ENROLLID=test_vp3
- CORE_SECURITY_ENROLLSECRET=9LKqKH5peurL
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links: - membersrvc - vp0
command: sh -c "sleep 10; peer node start"**

//------------
using docker-compose up command, my server is up and all 4 peers are created successfully.
in another docker terminal I executed following command which is also working fine:

CORE_CHAINCODE_ID_NAME=mycc006 CORE_PEER_ADDRESS=192.168.99.100:7051 ./chaincode_example02

Since I m using docker toolbox only 192.168.99.100 is a acceptable ip address for CORE_PEER_ADDRESS.

The REST API request are responsive to only - 192.168.99.100:7050/chaincode for all operations

You can see in the docker-compose file above that I have mapped vp1, vp2, vp3 with different ports and forwarded to vp0.

But when I try to use any other peer, for example vp1 using 192.168.99.100:8050/chaincode the request fails as there is no response from vp1,vp2,vp3 even though I have specifically mapped ports with these peers.
Docker ps command shows memersrvc and all 4 peer containers running but ports are assigned only to vp0.

How do I map other peers vp1,vp2,vp3 with the ports inorder to access them via REST API ? Any help or guidance will be appreciated.

Thanks.

Use of vulnerable module jwt-go

jwt-go is an indirect dependency for fabric-sdk-go and there is a vulnerability in this module. The CVE report can be found here.

This can be removed by updating the module github.com/go-kit/kit to the latest version, v0.12.0.

gateway should implement function close()

now it is :

// Close the gateway connection and all associated resources, including removing listeners attached to networks and
// contracts created by the gateway.
func (gw *Gateway) Close() {
	// future use
}

after connect gateway ,get network and submit Transaction, I cannot break the tcp connection.

gw, err := gateway.Connect(
		gateway.WithConfig(config.FromFile(filepath.Clean(ccpPath))),
		gateway.WithUser(userid),
	)
...
network, err := gw.GetNetwork(channel)
...
connector.UseContract(..., ...)
funcName = "QueryAllRecords"
result, err = connector.Contract.EvaluateTransaction(funcName)

I can read the leadger by doing this ,the var result is expected, but I notice the connection is still active, I cannot close the gateway connection, after invoking chaincode some times ,the connection is getting more

root@hecs-ubuntu-18:/home/localrootchain/service_proxy# netstat -ap | grep serviceProxy
tcp        0      0 192.168.0.16:60070      peer0.cn:8050           ESTABLISHED 1249/./serviceProxy 
tcp        0      0 192.168.0.16:34686      peer0.cn:8050           ESTABLISHED 1249/./serviceProxy 
tcp        0      0 192.168.0.16:41730      peer0.cn:7050           ESTABLISHED 1249/./serviceProxy 
tcp        0      0 192.168.0.16:41282      peer0.cn:7050           ESTABLISHED 1249/./serviceProxy 
tcp        0      0 192.168.0.16:41050      peer0.cn:7050           ESTABLISHED 1249/./serviceProxy 
tcp        0      0 192.168.0.16:59808      peer0.cn:8050           ESTABLISHED 1249/./serviceProxy 
tcp6       0      0 [::]:8001               [::]:*                  LISTEN      1249/./serviceProxy

more and more memory and cpu is occupied ,and I cannot close the sdk in gateway because it is not leaked, it is in lower case

type Gateway struct {
	sdk        *fabsdk.FabricSDK
	options    *gatewayOptions
	cfg        core.ConfigBackend
	org        string
	mspid      string
	peers      []fab.PeerConfig
	mspfactory api.MSPProviderFactory
}

after some time, the gateway will write log as "error from discovery request...."so many times ,I think it is reported byhttps://github.com/hyperledger/fabric-sdk-go/blob/main/pkg/client/common/discovery/dynamicdiscovery/chservice.go#L120
besides ,I can find many tcp connection and I can hardly query ledger ,peer will response like "context deadline exceeded".
nothing i can do, i just restart my client, and it will work fine for some time ,and the same problem will appear again.
How can I Close the gateway connection and all associated resources?

Not able to build the Go file

For past few months we are using a go version (Go 1.16.6) ,we are able to build go code without any issue.
But yesterday we tried to build the same code with same version of go ,we are facing this issue while building.

The error is :
github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations
../../golang/pkg/mod/github.com/hyperledger/[email protected]/internal/github.com/hyperledger/fabric/core/operations/system.go:225:23: not enough arguments in call to s.statsd.SendLoop
        have (<-chan time.Time, string, string)
        want (context.Context, <-chan time.Time, string, string)

so we tried to solve this issue by adding a latest version of fabric-sdk "go get github.com/hyperledger/fabric-sdk-go@latest"
but we could'nt solve this issue.
we followed the second solution in - https://stackoverflow.com/questions/55811937/getting-error-not-enough-arguments-in-call-to-s-statsd-sendloop-when-running
We changed the vendor source code file of sytem.go by adding a extra params of "context.Background()" in the function SendLoop(context.Background(),s.sendTicker.C, network, address) ,and we build the file it worked,
But again we deleted the vendor file and tried running the code we got the same error
Please if someone look into this issue make sure we want solution for this issue without change the source code of vendor file
we don't want to edit the source code is there any other way to solve this issue?

Not able to create deliver client for event

Hi team,
can any one help me to create new deliver client code for event read from block number functionality.
I am using following snippet code.trying to create fabcontext client that needs signning identtiy and provider.
signing identity i am getting but how i can get provider.

ctxProvider := sdk.Context()

ctx, err := ctxProvider()

fmt.Println("userIdentity=================", userIdentity)
identityresp, err := mspClient.GetAllIdentities()
fmt.Println("userIdentity=================", identityresp)
ctxchProvider := sdk.ChannelContext("mychannel", fabsdk.WithUser("admin"), fabsdk.WithOrg("Org1"))
//provider := &contextImpl.Provider{}
discoveryService, err := ctx.LocalDiscoveryProvider().CreateLocalDiscoveryService("Org1MSP")

fabctx := contextImpl.Client{
	Providers:       &contextImpl.Provider{localDiscoveryProvider: discoveryService, channelProvider: ctxchProvider},
	SigningIdentity: userIdentity,
}
fmt.Println("fabctx======================", fabctx)

//fabctx.EndpointConfig().ChannelConfig("mychannel")

chconfig := chconfig.NewChannelCfg("mychannel")
discoveryServicefab := fabctx.LocalDiscoveryProvider()
dc, err := deliverclient.New(fabctx, chconfig, discoveryServicefab)
fmt.Println("dc============================", dc)
return dc

//discoveryService, err := fab.LocalDiscoveryProvider.CreateLocalDiscoveryService("Org1Msp")

}

=========================================

Endorser Client Status Code: (2) CONNECTION_FAILED

Go version : go1.19 linux/amd64
fabric-sdk-go version : v1.0.0

creating the channel client using identity and MSP client

err = MSPClient.Enroll("username", msp.WithSecret("pwd"))
if err != nil {
	fmt.Println(err)
}

identity, err := MSPClient.GetSigningIdentity("sample_admin")
if err != nil {
	fmt.Println(err)
	return 
}

channelClientProvider := sdk.ChannelContext(channelID, fabsdk.WithIdentity(identity))

channelClient, err = channel.New(channelClientProvider)
if err != nil {
	fmt.Println(err) <------ getting error while connecting to peer
}

peer info in yaml file

peers:

peer0.example.com:
  grpcOptions:
    hostnameOverride: peer0.example.com
    ssl-target-name-override: peer0.example.com
  tlsCACerts:
    pem: //giving pem file path
  url: grpcs://peer0.example.com:443

added the peer0.example.com in /etc/hosts with ip

we are able to connect to peer using telnet

After running getting error

event service creation failed: could not get chConfig cache reference: QueryBlockConfig failed: QueryBlockConfig failed: queryChaincode failed: Transaction processing for endorser [peer0.example.com:443]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [peer0.example.com:443]: connection is in TRANSIENT_FAILURE

Go sdk should support latest go version(1.17).

Currently, ask only support

You should install Go 1.14.0 to 1.16.99 to run hyperledger/fabric-sdk-go tests

As I found that fabric now can support latest go version, which is 1.17. I think go sdk should also support this.

sanitizeCert failed the supplied identity is not valid: x509: certificate signed by unknown authority

Get this error when creating a new SDK instance based on the loaded configuration:
[fabsdk/util] 2023/05/17 12:26:10 UTC - lazyref. (*Reference).refreshValue -> WARN Error - initializer returned error: load MSPs from config failed: configure MSP failed: sanitizeCert failed the supplied identity is not valid: x509: certificate signed by unknown authority. Will retry again later

My config.json file is below:

{
    "name": "first-network-org1",
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "logging": {
            "level": "info"
        },
        "cryptoconfig": {
            "path": "/home/lequocvieet/Desktop/fabric-samples/test-network/organizations"
        },
        "credentialStore": {
            "path": "/tmp/keystore",
            "cryptoStore": {
                "path": "/tmp/msp"
            }
        },
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300"
                }
            }
        }
    },
    "channels": {
        "mychannel": {
            "peers": {
                "peer0.org1.example.com": {},
                "peer0.org2.example.com": {}
            }
        }
    },
    "orderers": {
        "orderer.example.com": {
            "url": "orderer.example.com:7050",
            "cryptoPath": "ordererOrganizations/example.com/msp",
            "grpcOptions": {
                "ssl-target-name-override": "orderer.example.com",
                "keep-alive-time": "60s",
                "keep-alive-timeout": "60s",
                "keep-alive-permit": false,
                "fail-fast": false,
                "allow-insecure": false
            },
            "tlsCACerts": {
                "path": "/home/lequocvieet/Desktop/fabric-samples/test-network/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem"
            }
        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "cryptoPath": "peerOrganizations/org1.example.com/users/[email protected]/msp",
            "peers": [
                "peer0.org1.example.com"
            ],
            "certificateAuthorities": [
                "ca.org1.example.com"
            ]
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "peer0.org1.example.com:7051",
            "tlsCACerts": {
                "path": "/home/lequocvieet/Desktop/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
            },
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org1.example.com"
            }
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "https://localhost:7054",
            "caName": "ca-org1",
            "tlsCACerts": {
                "path": "/home/lequocvieet/Desktop/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
            },
            "httpOptions": {
                "verify": false
            }
        }
    }

}

expend 2 orgs to 6 orgs, joinchannel ,chaincode query and chaincode invoke in [Multi Org Test] got error

below is the error message

 [fabsdk/client] 2022/01/07 01:12:05 UTC - dynamicdiscovery.(*ChannelService).evaluate -> WARN error from discovery request [peer0.org4.example.com:7051]: From target: peer0.org4.example.com:7051: could not connect to peer0.org4.example.com:7051: dialing connection on target [peer0.org4.example.com:7051]: connection is in TRANSIENT_FAILURE
 [fabsdk/client] 2022/01/07 01:12:10 UTC - dynamicdiscovery.(*ChannelService).evaluate -> WARN error from discovery request [peer0.org5.example.com:7051]: From target: peer0.org5.example.com:7051: could not connect to peer0.org5.example.com:7051: dialing connection on target [peer0.org5.example.com:7051]: connection is in TRANSIENT_FAILURE
 [fabsdk/client] 2022/01/07 01:12:15 UTC - dynamicdiscovery.(*ChannelService).evaluate -> WARN error from discovery request [peer0.org6.example.com:7051]: From target: peer0.org6.example.com:7051: could not connect to peer0.org6.example.com:7051: dialing connection on target [peer0.org6.example.com:7051]: connection is in TRANSIENT_FAILURE
 [fabsdk/client] 2022/01/07 01:12:20 UTC - dynamicdiscovery.(*ChannelService).evaluate -> WARN error from discovery request [peer0.org3.example.com:7051]: From target: peer0.org3.example.com:7051: could not connect to peer0.org3.example.com:7051: dialing connection on target [peer0.org3.example.com:7051]: connection is in TRANSIENT_FAILURE

[v1.0.0]Failed to work as a go vendor(dependency)

Now I am having a go.mod file with this content

module github.com/<my-name>/<my-repos>

go 1.16

require github.com/hyperledger/fabric-sdk-go v1.0.0 // indirect

And I run go mod tidy

It surprise me that it failed into indexing error like

...
go: found github.com/hyperledger/fabric-sdk-go/test/integration/e2e in github.com/hyperledger/fabric-sdk-go/test/integration v0.0.0-20220211081358-5c3f54614739
go: github.com/hyperledger/fabric-sdk-go/test/[email protected] requires
        github.com/hyperledger/[email protected]: invalid version: unknown revision 000000000000

I believe it is a long lasting issue, and what is suggested workaround?

Add support for go version 1.18+

It might be expected because of https://github.com/hyperledger/fabric-sdk-go/blob/main/test/fixtures/config/overrides/local_entity_matchers.yaml, but I haven't figured that out yet. Faced with the same issue #265, I resolved by downgrading golang to version 1.18. Reproducible scenario that works in go v1.18, but not higher.

config.yaml

version: 1.0.0

client:
  tlsEnable: true
  organization: org1
channels:
  channel0:
    orderers:
    - orderer1.orderer
    peers:
      peer0.org1: {}
organizations:
  org1:
    mspid: Org1MSP
    cryptoPath:  /home/fabric/crypto/orgs/org1/msp
    peers:
    - peer0.org1
    certificateAuthorities:
    - ca.org1
    users:
      admin:
        cert:
          path: /home/fabric/crypto/orgs/org1/admin/msp/signcerts/cert.pem
        key:
          path: /home/fabric/crypto/orgs/org1/admin/msp/keystore/key.pem
  orderer:
      mspID: OrdererMSP
      cryptoPath: /home/fabric/crypto/orderers/msp
orderers:
  orderer1.orderer:
    url: orderer1.orderer:7050
    tlsCACerts:
      path: /home/fabric/crypto/orderers/admin/tls/ca.pem
peers:
  peer0.org1:
    url: peer0.org1:7051
    tlsCACerts:
      path: /home/fabric/crypto/orgs/org1/admin/tls/ca.pem
certificateAuthorities:
  ca.org1:
    url: https://ca.org1:7054
    caName: ca.org1
    tlsCACerts:
      path: /home/fabric/crypto/orgs/org1/admin/tls/ca.pem

main.go

package main

import (
	"fmt"

	"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
	"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
)

const (
	channelID   = "channel0"
	orgName     = "org1"
	orgAdmin    = "admin"
	chaincodeID = "samplecc"
)

func main() {
	sdk, err := fabsdk.New(config.FromFile("config.yaml"))
	if err != nil {
		fmt.Println(err)
	}
	defer sdk.Close()

	clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))
	client, err := channel.New(clientChannelContext)
	if err != nil {
		fmt.Println(err)
	}

	response, err := client.Execute(channel.Request{ChaincodeID: chaincodeID, Fcn: "YourFunction"})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(string(response.Payload))
}

how to install and institate chaincode without system channel

In Fabric 2.5, I can create application channel without system channel. However, in this way, there are no .tx files so I cannot use fabric-sdk-go to create and join channel. Now, I want to create application channel in Fabric(such as peer CLI) directly ,rather then using Fabric-sdk-go. I want to know whether this way is OK? If it's ok, I want to know how to prepare the config.yaml file and how to use fabric-sdk-go to install and institate chaincode.
By the way, I have noticed that someone recommended the new sdk, fabric-admin-sdk,to address this problem. But I want to know whether these two sdks can work in coordination. for example, fabric-admin-sdk will focus on creating and joining channel, fabric-sdk-go will solving others (such as installing chaincode).
Thanks!!

direct dependency cloudflare/cfssl has experimantal and dengerious dependency

fabric-sdk-go has direct dependency github.com/cloudflare/cfssl which depends from github.com/zmap/zcrypto.Thus this package is our service transitive dependency.
The github.com/zmap/zcrypto package specifies in its README file :
"ZCrypto is a research library, designed to be used for data collection and analysis, as well as experimenting and prototyping. It should not be used to provide security for production systems".
We cannot include into our stack a package which marked as experimental and dangerous . Can you exclude dependency from github.com/zmap/zcrypto or make it optional?

when I use fabric-sdk-go to deploy chaincode ,occur an error "Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/testchaincode1: cannot find package "github.com/testchaincode1" in any of: "

Hi,everyone,

fabric version:1.4.2
fabric-sdk-go version:1.0.0

when I use fabric-sdk-go(my computer os is windows 10 ) to deploy chaincode,occur an error "Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/testchaincode1: cannot find package "github.com/testchaincode1" in any of: ",but it can normal run in ubuntu,the sdk config almost same except tls and private key path, and they connect same fabric network.

error on ide

[fabsdk/fab] 2021/09/11 18:56:41 UTC - txn.SendProposal.func1 -> DEBU Received error response from txn proposal processing: Transaction processing for endorser [192.168.126.128:7051]: Chaincode status Code: (500) UNKNOWN. Description: error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package github.com/testchaincode1: cannot find package "github.com/testchaincode1" in any of:
	/opt/go/src/github.com/testchaincode1 (from $GOROOT)
	/chaincode/input/src/github.com/testchaincode1 (from $GOPATH)
	/opt/gopath/src/github.com/testchaincode1

error on peer container
image

may It is a bug or It has been fixed?

and I fix it by modify fabric-sdk-go,so I think It shoud be a bug.and I think this bug related to os type.

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

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

HSM Mixin and Checkpointer missing

Hi,

I want to migrate a worker I have using nodejs to go, and I was testing the fabric-sdk-go library but I haven't been able to find the classes for the HSMMixin and the Checkpointer classes.

Can you tell me where to find the implementations?

Thank you.

Change network connection profile format to the same as sdk node/java

certificateAuthorities..registrar is a list in sdk-node and sdk-java

In go sdk, it is a map type, can we consider to use the same format with sdk-node and sdk-java? This will save the convert efforts.

sdk-go:

sdk-node: https://github.com/hyperledger/fabric-sdk-node/blob/9e3fe1b0052b12e5d0acc6e1835b83a388a0f258/test/fixtures/profiles/network.yaml#L210

Thanks!

Apple M1 unable to build: hyperledger/fabric-tools:arm64-2.2.0 not found: manifest unknown

The SDK fails a local build on an Apple M1 Macbook Pro arm64 architecture with an error of:

Unable to find image 'hyperledger/fabric-tools:arm64-2.2.0' locally
docker: Error response from daemon: manifest for hyperledger/fabric-tools:arm64-2.2.0 not found: manifest unknown: manifest unknown.

This is with Go 1.18 which I know isn't supported yet. I changed the ci.properties to allow building with Go 1.18. Everything worked up until the missing Fabric Tools repo, which is a showstopper at present.

I set up my local SDK repo with GO111MODULE=off go get -u github.com/myitcv/gobin and make depend and had the following output afterwards when running make:

$ make       
Checking Go version
go version go1.18 darwin/arm64
Running check_license.sh
Examining working directory changes
All files are excluded from having license headers
rm -Rf /tmp/enroll_user /tmp/msp /tmp/keyvaluestore /tmp/hfc-kvs /tmp/state /tmp/state-store
rm -f integration-report.xml report.xml
go clean
FIXTURE_PROJECT_NAME=fabsdkgo DOCKER_REMOVE_FORCE=false test/scripts/clean_integration.sh
Removing docker-compose network created from fixtures ...
[+] Running 1/0
 ⠿ fabsdkgo  Warning: No resource found to remove                                                                                                  0.0s
Crypto config directory does not exist - will need to populate fixture
Generating crypto directory ...
Unable to find image 'hyperledger/fabric-tools:arm64-2.2.0' locally
docker: Error response from daemon: manifest for hyperledger/fabric-tools:arm64-2.2.0 not found: manifest unknown: manifest unknown.
See 'docker run --help'.
make[1]: *** [crypto-gen] Error 125
make: *** [populate-fixtures-stable-noforce] Error 2

In Fabric 2.4, channels are created using Fabric-SDK-Go in a non-system channel way

Hello, I'm using fabric-sdk-go for creating channels. I created channels using the system channel method and created channels via the SaveChannel function in go-sdk. But when I upgraded to fabric 2.4, when I used the non-system channel mode, no .tx file was generated, only a .block file, and there was no function in the go-sdk to create channels through the .block file. Do you have any suggestions for this problem?

The error occurred when using fabric-sdk-go client-side

oot@jf-02:~/fisco/go-sdk# go run kvtabletest/contract/monitor.go

github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations

/root/go/pkg/mod/github.com/hyperledger/[email protected]/internal/github.com/hyperledger/fabric/core/operations/system.go:225:49: not enough arguments in call to s.statsd.SendLoop
have (<-chan time.Time, string, string)
want (context.Context, <-chan time.Time, string, string)

Am I missing anything? Changing the code to a different machine and downloading the dependency package again resulted in this issue with the dependency package

Fabric 2.4 support

What is the roadmap to support fabric 2.4 features? Importantly Fabric Gateway service.
Basically, I was looking for the WithEndorsingOrganizations() function which is very useful but missing fabric-sdk-go.
This function requires only Orgs MSP Ids whereas the existing WithEndorsingPeers() requires the complete peer address.

WithEndorsingOrganizations() is available in fabric-gatway

Potential Privacy leakage in the "move" function in example_cc.go

The "move" fuunction in test/fixtures/testdata/go/src/github.com/example_cc/example_cc.go returns "transientData" in line 240, which is obtained from "GetTransient" in line 238. Since transient data is local to the peer and is private to other peers, there are two issues about this design:

  1. if transientData is private, the functions that query private data should be read-only, but "move" updates the world state.
  2. the transient data is local to the peer and will be exculded to the transaction, so how can other peers verify the "transientData"?

Is there a tutorial to introduce how to implement 'fabric-ca-server/fabric-ca-client' functionality using this SDK like the official document

Hello there,

I want to run a Fabric CA Server and Fabric CA Client using this SDK, to implement the functionality like the offical document using binary 'fabric-ca-server' and 'fabric-ca-client'. I want to use this SDK to start a new organization CA server, then register admin and enroll admin and so on.

Unfortunately, I couldn't find a useful tutorial online. Is it possible to do that using this SDK or Fabric CA SDK?

Thank you!

Best,
Wei

Unable to install

First, let me say you should state if we need to installa sdk as root, as sudoer user, or as normal user.

Anyway, I'm doing all as root by now, because it's first time here for me.

I canno execute this:

go get github.com/hyperledger/fabric-sdk-go

Becasuse I get

go: go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.
        To build and install a command, use 'go install' with a version,
        like 'go install example.com/cmd@latest'
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

Please update readme

不要假设用户链码位置

github.com/hyperledger/fabric-sdk-go/pkg/fab/ccpackager/gopackager/packager.go

projDir = filepath.Join(gp, "src", chaincodePath)

可以去掉src吗?

i know you will not click or answer... but i cant stop to ask ..T_T

  1. I succeeded in operating the test-network provided by hyperledger fabric v2.2 itself.

    1. Chaincode installation complete

      • ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript -ccl javascript
    2. Setting environment variables

      • export CORE_PEER_TLS_ENABLED=true
      • export CORE_PEER_LOCALMSPID="Org1MSP"
      • export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      • export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
      • export CORE_PEER_ADDRESS=localhost:7051
    3. Chaincode (Invoke) InitLedger function execution

      • peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}'
    4. Execute chaincode (query) GetAllAssets function

      • It returned as follows.
      • [{"Key":"asset1","Record":{"ID":"asset1","Color":"blue","Size":5,"Owner":"Tomoko","AppraisedValue":300,"docType":"asset"}},{"Key":"asset2","Record":{"ID":"asset2","Color":"red","Size":5,"Owner":"Brad","AppraisedValue":400,"docType":"asset"}},{"Key":"asset3","Record":{"ID":"asset3","Color":"green","Size":10,"Owner":"Jin Soo","AppraisedValue":500,"docType":"asset"}},{"Key":"asset4","Record":{"ID":"asset4","Color":"yellow","Size":10,"Owner":"Max","AppraisedValue":600,"docType":"asset"}},{"Key":"asset5","Record":{"ID":"asset5","Color":"black","Size":15,"Owner":"Adriana","AppraisedValue":700,"docType":"asset"}},{"Key":"asset6","Record":{"ID":"asset6","Color":"white","Size":15,"Owner":"Michel","AppraisedValue":800,"docType":"asset"}}]
  2. Trying to access fabric-network using nodejs SDK

    1. cd fabric-samples/test-network/docker

    2. Execute command => COMPOSE_PROJECT_NAME=fabric-test docker-compose -f docker-compose-ca.yaml up -d

    3. There are currently 9 containers in operation.

      • ca.org1
      • ca.org2
      • ca.orderer
      • orderer.example.com
      • peer0.org1.example.com
      • peer0.org2.example.com
      • dev-peer0.org1.example.com-basic_1.0
      • dev-peer0.org2.example.com-basic_1.0
      • cli
    4. cd fabric-sample/fabcar/javascript

    5. Execute command => node enrollAdmin.js, node registerUser.js

      • admin.id and appUser.id files were created in the wallet directory.
    6. An error occurred when running node query.js (the error details are written below.)

      • 2024-01-24T00:45:41.065Z - error: [DiscoveryResultsProcessor]: parseDiscoveryResults[mychannel] - Channel:mychannel received discovery error:access denied
      • Failed to evaluate transaction: Error: DiscoveryService: mychannel error: access denied
      • Below is the log of the org1 container (docker logs peer0.or1.example.com)
      • [discovery] processQuery -> WARN 0e2 got query for channel mychannel from 172.18.0.1:59762 but it isn't eligible: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Writers' sub-policies to be satisfied
  3. The same error occurs with hyperledger fabric v2.5, and the same error occurs even if you change the Ubuntu version. I'm curious what causes this problem. I'm also curious about the solution to this problem. I am waiting for your reply. please help me

Too many open files error with go sdk user register and enroll

While using go sdk User registration and user enroll it is found that connection established to ca node is not getting closed.
In below mentioned file on line number 473 inside defer function "err := resp.Body.Close()" body is getting closed but not the connection established with CA.
https://github.com/hyperledger/fabric-sdk-go/blob/main/internal/github.com/hyperledger/fabric-ca/lib/client.go

Solution to close the session is to modify the defer function as

defer func() {
err := resp.Body.Close()
c.httpClient.CloseIdleConnections() //Add this new Line to close connection
if err != nil {
log.Debugf("Failed to close the response body: %s", err.Error())
}
}()

connectionNotClosingPostRegistrationEnroll

How to calculate the block size ?

One block can have multiple transactions. So i want to calculate the size of the block.

Is it possible ? Kindly guide me.

Thank you !!

The SDK version is incompatible?

When I build fabric app, I got this error.
`

github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations

C:\Users\95762\go\pkg\mod\github.com\hyperledger\[email protected]\internal\github.com\hyperledger\fabric\core\operations\system.go:225:23: not enough arguments in call to s.statsd.SendLoop
have (<-chan time.Time, string, string)
want (context.Context, <-chan time.Time, string, string)
`

Add examples on how we can create the fabric-sdk-go config.yaml file, in order to be able to instantiate an sdk instance.

According to the fabric-samples, within the first-network and test-network there are two templates, one json file and one yaml file that are being created when network started. Using the ccp-generate.sh we can fill with these templates with the latest pem files. These files will be used later from the API in order to be able to execute SubmitTransaction and EvaluateTransaction and interact with the smart contract.

What I am trying to achieve?
I am trying to fetch the latest block for from the channel , using qscc chaincode queries against peers. When I am trying to load the aforementioned json file in order to be able to create a channel context using the following command:
sdk, err := fabsdk.New(config.FromFile("<path to connection-org1.json file>"))

I am getting the following error:
Failed to create fabric sdk: failed to create identity manager provider: failed to initialize identity manager for organization: org1: Either a cryptopath or an embedded list of users is required.

What is the correct format of the config file that we need to create in order to be able to create the sdk instance correctly?

Tag version bump to solve error

When using github.com/hyperledger/fabric-sdk-go/pkg/gateway you only have access to v1.0.0 for this tag and commit we get this error - repo with an example - https://github.com/anonsachin/fabric-error

# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations
vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations/system.go:225:49: not enough arguments in call to s.statsd.SendLoop
        have (<-chan time.Time, string, string)
        want (context.Context, <-chan time.Time, string, string)
make: *** [Makefile:5: run-error] Error 2

But it is fixed in file https://github.com/hyperledger/fabric-sdk-go/blob/main/internal/github.com/hyperledger/fabric/core/operations/system.go in update #180 the required changes are made but they are not accessible in the go module.

Please release a new tag with this update present in it.

So if instead of using the v1.0.0 we used the commit hash of the pull request which is done with the following command

go get github.com/hyperledger/fabric-sdk-go/pkg/gateway@14047c6d88f0e995f09d55817bfbf735e245547a

it works properly, so a simple version bump up will fix the issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.