diff --git a/.github/workflows/golang_nofunction.yml b/.github/workflows/golang_nofunction.yml index 077626c..a618289 100644 --- a/.github/workflows/golang_nofunction.yml +++ b/.github/workflows/golang_nofunction.yml @@ -45,5 +45,5 @@ jobs: - run: make generate name: Generate test mocks - name: run lint - run: make golint || true + run: make golint diff --git a/go/go.mod b/go/go.mod index 0c0d22b..75c9634 100644 --- a/go/go.mod +++ b/go/go.mod @@ -49,7 +49,6 @@ require ( github.com/spf13/afero v1.3.1 // indirect github.com/spf13/cast v1.4.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.1.1 // indirect github.com/sykesm/zap-logfmt v0.0.4 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/go/go.sum b/go/go.sum index 1b8d9c4..70b5284 100644 --- a/go/go.sum +++ b/go/go.sum @@ -31,7 +31,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.0+incompatible h1:7o6+MAPhYTCF0+fdvoz1xDedhRb4f6s9Tn1Tt7/WTEg= @@ -279,7 +278,6 @@ github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.1.1 h1:/8JBRFO4eoHu1TmpsLgNBq1CQgRUg4GolYlEFieqJgo= github.com/spf13/viper v1.1.1/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/go/internal/configtxgen/genesisconfig/config.go b/go/internal/configtxgen/genesisconfig/config.go index 52fdfd8..600befb 100644 --- a/go/internal/configtxgen/genesisconfig/config.go +++ b/go/internal/configtxgen/genesisconfig/config.go @@ -18,7 +18,6 @@ import ( "time" "github.com/hyperledger/fabric-protos-go-apiv2/orderer/etcdraft" - cf "github.com/hyperledger/fabric/core/config" ) const ( @@ -399,10 +398,10 @@ loop: log.Panicf("consenter info in %s configuration did not specify server TLS cert", EtcdRaft) } clientCertPath := string(c.GetClientTlsCert()) - cf.TranslatePathInPlace(configDir, &clientCertPath) + TranslatePathInPlace(configDir, &clientCertPath) c.ClientTlsCert = []byte(clientCertPath) serverCertPath := string(c.GetServerTlsCert()) - cf.TranslatePathInPlace(configDir, &serverCertPath) + TranslatePathInPlace(configDir, &serverCertPath) c.ServerTlsCert = []byte(serverCertPath) } default: @@ -410,8 +409,20 @@ loop: } } +func TranslatePathInPlace(base string, p *string) { + *p = TranslatePath(base, *p) +} + +func TranslatePath(base, p string) string { + if filepath.IsAbs(p) { + return p + } + + return filepath.Join(base, p) +} + func translatePaths(configDir string, org *Organization) { - cf.TranslatePathInPlace(configDir, &org.MSPDir) + TranslatePathInPlace(configDir, &org.MSPDir) } // configCache stores marshalled bytes of config structures that produced from diff --git a/go/internal/configtxgen/metadata/metadata.go b/go/internal/configtxgen/metadata/metadata.go index 8d6b703..c2f9431 100644 --- a/go/internal/configtxgen/metadata/metadata.go +++ b/go/internal/configtxgen/metadata/metadata.go @@ -9,15 +9,13 @@ package metadata import ( "fmt" "runtime" - - "github.com/hyperledger/fabric/common/metadata" ) const ProgramName = "configtxgen" var ( - CommitSHA = metadata.CommitSHA - Version = metadata.Version + CommitSHA = "development build" + Version = "latest" ) func GetVersionInfo() string { diff --git a/go/internal/genesis/genesis.go b/go/internal/genesis/genesis.go index 33898d5..02d8222 100644 --- a/go/internal/genesis/genesis.go +++ b/go/internal/genesis/genesis.go @@ -46,7 +46,7 @@ func (f *factory) Block(channelID string) *cb.Block { block := protoutil.NewBlock(0, nil) block.Data = &cb.BlockData{Data: [][]byte{protoutil.MarshalOrPanic(envelope)}} block.Header.DataHash = protoutil.BlockDataHash(block.Data) - block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIG] = protoutil.MarshalOrPanic(&cb.Metadata{ + block.Metadata.Metadata[1] = protoutil.MarshalOrPanic(&cb.Metadata{ Value: protoutil.MarshalOrPanic(&cb.LastConfig{Index: 0}), }) block.Metadata.Metadata[cb.BlockMetadataIndex_SIGNATURES] = protoutil.MarshalOrPanic(&cb.Metadata{ diff --git a/go/internal/msp/msp.go b/go/internal/msp/msp.go index 2cfd360..ea3d59b 100644 --- a/go/internal/msp/msp.go +++ b/go/internal/msp/msp.go @@ -3,12 +3,10 @@ package msp import ( "encoding/pem" "fmt" - "io/ioutil" "os" "path/filepath" "github.com/hyperledger/fabric-protos-go-apiv2/msp" - "github.com/hyperledger/fabric/bccsp" "google.golang.org/protobuf/proto" "gopkg.in/yaml.v2" ) @@ -121,7 +119,7 @@ func getMspConfig(dir string, ID string, sigid *msp.SigningIdentityInfo) (*msp.M if err == nil { // load the file, if there is a failure in loading it then // return an error - raw, err := ioutil.ReadFile(configFile) + raw, err := os.ReadFile(configFile) if err != nil { return nil, fmt.Errorf("failed loading configuration file at [%s] %w", configFile, err) } @@ -193,8 +191,8 @@ func getMspConfig(dir string, ID string, sigid *msp.SigningIdentityInfo) (*msp.M // Set FabricCryptoConfig cryptoConfig := &msp.FabricCryptoConfig{ - SignatureHashFamily: bccsp.SHA2, - IdentityIdentifierHashFunction: bccsp.SHA256, + SignatureHashFamily: "SHA2", + IdentityIdentifierHashFunction: "SHA256", } // Compose FabricMSPConfig @@ -228,7 +226,7 @@ func getPemMaterialFromDir(dir string) ([][]byte, error) { } content := make([][]byte, 0) - files, err := ioutil.ReadDir(dir) + files, err := os.ReadDir(dir) if err != nil { return nil, fmt.Errorf("could not read directory %s %w", dir, err) } @@ -297,7 +295,7 @@ type Configuration struct { } func readFile(file string) ([]byte, error) { - fileCont, err := ioutil.ReadFile(file) + fileCont, err := os.ReadFile(file) if err != nil { return nil, fmt.Errorf("could not read file %s %w", file, err) } diff --git a/go/internal/network/network.go b/go/internal/network/network.go index 069a3b0..f732a79 100644 --- a/go/internal/network/network.go +++ b/go/internal/network/network.go @@ -6,8 +6,8 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" "net" + "os" "time" grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing" @@ -15,6 +15,7 @@ import ( "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" ) @@ -55,7 +56,7 @@ func GetTLSCACerts(file string) ([]byte, error) { return nil, nil } - in, err := ioutil.ReadFile(file) + in, err := os.ReadFile(file) if err != nil { return nil, fmt.Errorf("error loading %s %w", file, err) } @@ -370,7 +371,7 @@ func (client *GRPCClient) NewConnection(address string, tlsOptions ...TLSOption) }, )) } else { - dialOpts = append(dialOpts, grpc.WithInsecure()) + dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials())) } dialOpts = append(dialOpts, grpc.WithDefaultCallOptions( diff --git a/go/pkg/chaincode/packageID.go b/go/pkg/chaincode/packageID.go index 5a149a9..c400420 100644 --- a/go/pkg/chaincode/packageID.go +++ b/go/pkg/chaincode/packageID.go @@ -4,13 +4,12 @@ import ( "archive/tar" "bytes" "compress/gzip" + "crypto/sha256" "encoding/json" "fmt" "io" "os" "regexp" - - "github.com/hyperledger/fabric/common/util" ) const ( @@ -40,7 +39,9 @@ func PackageID(PackageFile string) (string, error) { // PackageID returns the package ID with the label and hash of the chaincode install package func GetPackageID(label string, ccInstallPkg []byte) string { - hash := util.ComputeSHA256(ccInstallPkg) + h := sha256.New() + h.Write(ccInstallPkg) + hash := h.Sum(nil) return fmt.Sprintf("%s:%x", label, hash) }