Skip to content

Commit

Permalink
Merge branch 'main' into add-orderer-backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
pfi79 committed Oct 31, 2023
2 parents 2ff9e57 + acc1133 commit afe1f1f
Show file tree
Hide file tree
Showing 405 changed files with 28,653 additions and 11,567 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/broken-link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- .github/workflows/broken-link-checker.yml

env:
GO_VER: 1.20.7
GO_VER: 1.21.3

jobs:
broken-lint-checker:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- v3.*

env:
GO_VER: 1.20.7
GO_VER: 1.21.3
UBUNTU_VER: 20.04
FABRIC_VER: ${{ github.ref_name }}
DOCKER_REGISTRY: ${{ github.repository_owner == 'hyperledger' && 'docker.io' || 'ghcr.io' }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/verify-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ on:
env:
GOPATH: /opt/go
PATH: /opt/go/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
GO_VER: 1.20.7
GO_VER: 1.21.3

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
basic-checks:
name: Basic Checks
runs-on: fabric-ubuntu-20.04
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-20.04' || 'ubuntu-20.04' }}
steps:
- uses: actions/setup-go@v3
name: Install Go
Expand All @@ -36,7 +36,7 @@ jobs:
unit-tests:
name: Unit Tests
needs: basic-checks
runs-on: fabric-ubuntu-20.04
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-20.04' || 'ubuntu-20.04' }}
steps:
- uses: actions/setup-go@v3
name: Install Go
Expand All @@ -55,7 +55,7 @@ jobs:
fail-fast: false
matrix:
INTEGRATION_TEST_SUITE: ["raft","pvtdata","pvtdatapurge","ledger","lifecycle","e2e smartbft","discovery gossip devmode pluggable","gateway idemix pkcs11 configtx configtxlator","sbe nwo msp"]
runs-on: fabric-ubuntu-20.04
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-20.04' || 'ubuntu-20.04' }}
steps:
- uses: actions/setup-go@v3
name: Install Go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vulnerability-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.7
go-version: 1.21.3
- name: Scan
run: make scan
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ METADATA_VAR += CommitSHA=$(EXTRA_VERSION)
METADATA_VAR += BaseDockerLabel=$(BASE_DOCKER_LABEL)
METADATA_VAR += DockerNamespace=$(DOCKER_NS)

GO_VER = 1.20.7
GO_VER = 1.21.3
GO_TAGS ?=

RELEASE_EXES = orderer $(TOOLS_EXES)
Expand Down Expand Up @@ -249,7 +249,10 @@ $(BUILD_DIR)/images/%/$(DUMMY):
--build-arg TARGETARCH=$(ARCH) \
--build-arg TARGETOS=linux \
$(BUILD_ARGS) \
-t $(DOCKER_NS)/fabric-$* ./$(BUILD_CONTEXT)
-t $(DOCKER_NS)/fabric-$* \
-t $(DOCKER_NS)/fabric-$*:$(FABRIC_VER) \
-t $(DOCKER_NS)/fabric-$*:$(TWO_DIGIT_VERSION) \
./$(BUILD_CONTEXT)

# builds release packages for the host platform
.PHONY: release
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ for the full details.

## Community

[Hyperledger Community](https://www.hyperledger.org/community)
[Hyperledger Community](https://www.meetup.com/pro/hyperledger/)

[Hyperledger mailing lists and archives](http://lists.hyperledger.org/)

Expand Down
2 changes: 1 addition & 1 deletion bccsp/pkcs11/pkcs11.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ func (csp *Provider) verifyP11ECDSA(ski []byte, msg []byte, R, S *big.Int, byteS
return false, fmt.Errorf("PKCS11: Verify-initialize [%s]", err)
}
err = csp.ctx.Verify(session, msg, sig)
if err == pkcs11.Error(pkcs11.CKR_SIGNATURE_INVALID) {
if errors.Is(err, pkcs11.Error(pkcs11.CKR_SIGNATURE_INVALID)) {
return false, nil
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/fileks.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func dirEmpty(path string) (bool, error) {
defer f.Close()

_, err = f.Readdir(1)
if err == io.EOF {
if errors.Is(err, io.EOF) {
return true, nil
}
return false, err
Expand Down
22 changes: 8 additions & 14 deletions ccaas_builder/cmd/detect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func main() {
}

logger.Printf("::Type detected as ccaas")

}

type chaincodeMetadata struct {
Expand All @@ -42,26 +41,22 @@ func run() error {

chaincodeMetaData := os.Args[2]

// Check metadata file's existence
metadataFile := filepath.Join(chaincodeMetaData, "metadata.json")
_, err := os.Stat(metadataFile)
if err != nil {
return fmt.Errorf("%s not found ", metadataFile)
}

if _, err := os.Stat(metadataFile); err != nil {
return errors.WithMessagef(err, "%s not found ", metadataFile)
}

mdbytes, cause := os.ReadFile(metadataFile)
if cause != nil {
err := errors.WithMessagef(cause, "%s not readable", metadataFile)
return err
// Read the metadata file
mdbytes, err := os.ReadFile(metadataFile)
if err != nil {
return errors.WithMessagef(err, "%s not readable", metadataFile)
}

var metadata chaincodeMetadata
cause = json.Unmarshal(mdbytes, &metadata)
if cause != nil {
return errors.WithMessage(cause, "Unable to parse the metadata.json file")
err = json.Unmarshal(mdbytes, &metadata)
if err != nil {
return errors.WithMessage(err, "Unable to parse the metadata.json file")
}

if strings.ToLower(metadata.Type) != "ccaas" {
Expand All @@ -70,5 +65,4 @@ func run() error {

// returning nil indicates to the peer a successful detection
return nil

}
40 changes: 19 additions & 21 deletions cmd/common/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,31 @@ func (cli *CLI) Run(args []string) {
configureFlags(cli.app)

command := kingpin.MustParse(cli.app.Parse(args))
if command == persist.FullCommand() {
switch command {
case persist.FullCommand():
if *configFile == "" {
out("--configFile must be used to specify the configuration file")
return
}
persistConfig(parseFlagsToConfig(), *configFile)
return
}

var conf Config
if *configFile == "" {
conf = parseFlagsToConfig()
} else {
conf = loadConfig(*configFile)
}
default:
var conf Config
if *configFile == "" {
conf = parseFlagsToConfig()
} else {
conf = loadConfig(*configFile)
}

f, exists := cli.dispatchers[command]
if !exists {
out("Unknown command:", command)
terminate(1)
return
}
err := f(conf)
if err != nil {
out(err)
terminate(1)
return
f, exists := cli.dispatchers[command]
if !exists {
out("Unknown command:", command)
terminate(1)
return
}
if err := f(conf); err != nil {
out(err)
terminate(1)
}
}
}

Expand Down
20 changes: 12 additions & 8 deletions cmd/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,28 @@ func (c Config) ToFile(file string) error {
if err := validateConfig(c); err != nil {
return errors.Wrap(err, "config isn't valid")
}
b, _ := yaml.Marshal(c)
b, err := yaml.Marshal(c)
if err != nil {
return errors.Wrap(err, "failed to marshal config")
}
if err := os.WriteFile(file, b, 0o600); err != nil {
return errors.Errorf("failed writing file %s: %v", file, err)
}
return nil
}

func validateConfig(conf Config) error {
nonEmptyStrings := []string{
conf.SignerConfig.MSPID,
conf.SignerConfig.IdentityPath,
conf.SignerConfig.KeyPath,
nonEmptyElems := map[string]string{
"MSPID": conf.SignerConfig.MSPID,
"IdentityPath": conf.SignerConfig.IdentityPath,
"KeyPath": conf.SignerConfig.KeyPath,
}

for _, s := range nonEmptyStrings {
if s == "" {
return errors.New("empty string that is mandatory")
for key, value := range nonEmptyElems {
if value == "" {
return errors.Errorf("%s is mandatory and cannot be empty", key)
}
}

return nil
}
2 changes: 1 addition & 1 deletion cmd/discover/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ func TestMissingArguments(t *testing.T) {
process, err := Start(cmd, nil, nil)
gt.Expect(err).NotTo(HaveOccurred())
gt.Eventually(process, 5*time.Second).Should(Exit(1))
gt.Expect(process.Err).To(gbytes.Say("empty string that is mandatory"))
gt.Expect(process.Err).To(gbytes.Say("IdentityPath|KeyPath is mandatory and cannot be empty"))
}
2 changes: 1 addition & 1 deletion common/channelconfig/consortium.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (cc *ConsortiumConfig) Organizations() map[string]Org {
return cc.orgs
}

// CreationPolicy returns the policy structure used to validate
// ChannelCreationPolicy returns the policy structure used to validate
// the channel creation
func (cc *ConsortiumConfig) ChannelCreationPolicy() *cb.Policy {
return cc.protos.ChannelCreationPolicy
Expand Down
10 changes: 8 additions & 2 deletions common/deliver/deliver.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,18 @@ func (h *Handler) deliverBlocks(ctx context.Context, srv *Server, envelope *cb.E

logger.Debugf("[channel: %s] Delivering block [%d] for (%p) for %s", chdr.ChannelId, block.Header.Number, seekInfo, addr)

// Data blocks carry nil data for block attestations.
// Never mutate the block received from the iterator as it is from a cache.
block2send := block
if seekInfo.ContentType == ab.SeekInfo_HEADER_WITH_SIG && !protoutil.IsConfigBlock(block) {
block.Data = nil
block2send = &cb.Block{
Header: block.Header,
Metadata: block.Metadata,
}
}

signedData := &protoutil.SignedData{Data: envelope.Payload, Identity: shdr.Creator, Signature: envelope.Signature}
if err := srv.SendBlockResponse(block, chdr.ChannelId, chain, signedData); err != nil {
if err := srv.SendBlockResponse(block2send, chdr.ChannelId, chain, signedData); err != nil {
logger.Warningf("[channel: %s] Error sending to %s: %s", chdr.ChannelId, addr, err)
return cb.Status_INTERNAL_SERVER_ERROR, err
}
Expand Down
8 changes: 7 additions & 1 deletion common/deliver/deliver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ var _ = Describe("Deliver", func() {
})

Context("when seek info is configured to header with sig content type", func() {
var cachedBlocks []*cb.Block
BeforeEach(func() {
seekInfo = &ab.SeekInfo{
Start: &ab.SeekPosition{},
Expand All @@ -516,11 +517,12 @@ var _ = Describe("Deliver", func() {
Data: &cb.BlockData{Data: [][]byte{{1}, {2}}},
Metadata: &cb.BlockMetadata{Metadata: [][]byte{{3}, {4}}},
}
cachedBlocks = append(cachedBlocks, blk)
return blk, cb.Status_SUCCESS
}
})

It("sends blocks with nil Data", func() {
It("sends blocks with nil Data, but does not mutate cached blocks", func() {
err := handler.Handle(context.Background(), server)
Expect(err).NotTo(HaveOccurred())

Expand All @@ -538,6 +540,10 @@ var _ = Describe("Deliver", func() {
Metadata: &cb.BlockMetadata{Metadata: [][]byte{{3}, {4}}},
}))
}

for _, b := range cachedBlocks {
Expect(b.Data).ToNot(BeNil())
}
})
})

Expand Down
4 changes: 3 additions & 1 deletion common/fabhttp/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"net"
"net/http"
"net/url"
"os"
"path/filepath"
"syscall"
Expand Down Expand Up @@ -169,7 +170,8 @@ var _ = Describe("Server", func() {
Expect(err).NotTo(HaveOccurred())

_, err = unauthClient.Get(fmt.Sprintf("https://%s/healthz", server.Addr()))
Expect(err).To(MatchError(ContainSubstring("remote error: tls: bad certificate")))
Expect(err).To(BeAssignableToTypeOf(&url.Error{}))
Expect(err.(*url.Error).Err.Error()).To(ContainSubstring("remote error: tls: certificate required"))
})
})

Expand Down
2 changes: 1 addition & 1 deletion common/ledger/blkstorage/blockfile_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (mgr *blockfileMgr) syncIndex() error {
nextIndexableBlock := uint64(0)
lastBlockIndexed, err := mgr.index.getLastBlockIndexed()
if err != nil {
if err != errIndexSavePointKeyNotPresent {
if !errors.Is(err, errIndexSavePointKeyNotPresent) {
return err
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion common/ledger/blockledger/fileledger/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
package fileledger

import (
"errors"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -59,7 +60,7 @@ func (f *fileLedgerFactory) Remove(channelID string) error {
f.mutex.Lock()
defer f.mutex.Unlock()

if err := f.removeFileRepo.Save(channelID, []byte{}); err != nil && err != os.ErrExist {
if err := f.removeFileRepo.Save(channelID, []byte{}); err != nil && !errors.Is(err, os.ErrExist) {
return err
}

Expand Down
5 changes: 2 additions & 3 deletions common/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ import (
)

func ExtractRemoteAddress(ctx context.Context) string {
var remoteAddress string
p, ok := peer.FromContext(ctx)
if !ok {
return ""
}
if address := p.Addr; address != nil {
remoteAddress = address.String()
return address.String()
}
return remoteAddress
return ""
}

// ExtractCertificateHashFromContext extracts the hash of the certificate from the given context.
Expand Down
Loading

0 comments on commit afe1f1f

Please sign in to comment.