Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/artifactgen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ require (
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.24.4 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.14.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions cmd/artifactgen/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,6 @@ github.com/bits-and-blooms/bitset v1.24.4 h1:95H15Og1clikBrKr/DuzMXkQzECs1M6hhoG
github.com/bits-and-blooms/bitset v1.24.4/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/canonical/go-sp800.90a-drbg v0.0.0-20210314144037-6eeb1040d6c3 h1:oe6fCvaEpkhyW3qAicT0TnGtyht/UrgvOwMcEgLb7Aw=
github.com/canonical/go-sp800.90a-drbg v0.0.0-20210314144037-6eeb1040d6c3/go.mod h1:qdP0gaj0QtgX2RUZhnlVrceJ+Qln8aSlDyJwelLLFeM=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
Expand Down
29 changes: 29 additions & 0 deletions docs/development/debug-integration-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@ are already covered by CI's parallel per-infra jobs.
It saves one cleaned, timestamp-stripped log file per failed job under
`pr_<PR_NUMBER>_failed_logs/`.

## Public Parameters Setup Failures (fabricx)

On a fabricx network the token public parameters are installed by invoking the
`SetupPublicParams` view on the `issuer` FSC node
(`integration/nwo/token/fabricx/factory.go`). Two things about how that failure is
reported are worth knowing when a suite goes red:

- **Installation is asynchronous.** `Backend.InstallPublicParams` is called from
`PostRun` and returns as soon as the work is scheduled, because it has to wait for the
issuer node to accept connections. Its outcome is recorded on the backend and reported
later:
- `NetworkHandler.UpdatePublicParams` checks it first, so a spec that updates the
public parameters fails with the original installation error rather than with a
confusing follow-up failure;
- `NetworkHandler.Cleanup` logs it at teardown (`public params installation for [...]
failed: ...`), so grep the suite log for that line when a network never became usable
but no spec pointed at the public parameters;
- a test can also block on it explicitly with
`Backend.WaitForPublicParams(tms, timeout)`.
- **A not-yet-started issuer is a wait, not a failure.** Both `InstallPublicParams` and
`UpdatePublicParams` retry the issuer client lookup (60 attempts, 1s apart by default,
configurable via the `ClientRetries`/`ClientRetryDelay`/`InstallDelay` fields of
`Backend`). `client [issuer] not ready after 60 attempts` therefore means the issuer FSC
node never came up — look at its own logs, not at the token platform.
- **Neither path panics.** A `SetupPublicParams` failure surfaces as a test failure
wrapping the view error (`failed setting up the public params on
[network:channel:namespace:driver]`). A process that dies with
`panic: failed updating pps` is running an old build.

## Debugging Techniques
- **Manual Inspection**: Use `time.Sleep()` or pause loops in tests to inspect Docker state
- **Network Preservation**: Check for `no-cleanup` option or manually comment test suite cleanup
Expand Down
2 changes: 1 addition & 1 deletion integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/IBM/idemix v0.2.0
github.com/IBM/mathlib v0.3.0
github.com/LFDT-Panurus/panurus v0.0.0
github.com/bytedance/gopkg v0.1.3
github.com/gin-gonic/gin v1.12.0
github.com/hyperledger-labs/fabric-smart-client v0.17.0
github.com/hyperledger-labs/fabric-smart-client/integration v0.17.0
Expand Down Expand Up @@ -37,6 +36,7 @@ require (
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.24.4 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.15.0 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
Expand Down
25 changes: 19 additions & 6 deletions integration/nwo/token/fabric/cc/tcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/LFDT-Panurus/panurus/token/services/network/fabric/tcc/ccpackage"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/packager"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/topology"
"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
"github.com/onsi/gomega"
)

Expand Down Expand Up @@ -115,11 +116,15 @@ func (p *GenericBackend) PrepareNamespace(tms *topology3.TMS) {
p.Fabric(tms).Topology().AddChaincode(cc)
}

func (p *GenericBackend) InstallPublicParams(tms *topology3.TMS, raw []byte) {
// nothing to do here cause the chaincode initialization is done already in the fabric platform
// InstallPublicParams does nothing, cause the chaincode initialization is done already in
// the fabric platform.
func (p *GenericBackend) InstallPublicParams(tms *topology3.TMS, raw []byte) error {
return nil
}

func (p *GenericBackend) UpdatePublicParams(tms *topology3.TMS, ppRaw []byte) {
// UpdatePublicParams repackages the token chaincode of tms with the given public parameters
// and upgrades it, returning any failure as an error.
func (p *GenericBackend) UpdatePublicParams(tms *topology3.TMS, ppRaw []byte) error {
var cc *topology.ChannelChaincode
for _, chaincode := range p.Fabric(tms).Topology().Chaincodes {
if chaincode.Chaincode.Name == tms.Namespace {
Expand All @@ -128,7 +133,9 @@ func (p *GenericBackend) UpdatePublicParams(tms *topology3.TMS, ppRaw []byte) {
break
}
}
gomega.Expect(cc).NotTo(gomega.BeNil(), "failed to find chaincode [%s]", tms.Namespace)
if cc == nil {
return errors.Errorf("failed to find chaincode [%s]", tms.Namespace)
}

packageDir := filepath.Join(
p.TokenPlatform.GetContext().RootDir(),
Expand All @@ -144,7 +151,9 @@ func (p *GenericBackend) UpdatePublicParams(tms *topology3.TMS, ppRaw []byte) {
packageDir,
cc.Chaincode.Name+newChaincodeVersion+".tar.gz",
)
gomega.Expect(os.MkdirAll(packageDir, 0750)).ToNot(gomega.HaveOccurred())
if err := os.MkdirAll(packageDir, 0750); err != nil {
return errors.Wrapf(err, "failed creating package dir [%s]", packageDir)
}

paramsFile := PublicParamsTemplate(ppRaw)

Expand All @@ -171,11 +180,15 @@ func (p *GenericBackend) UpdatePublicParams(tms *topology3.TMS, ppRaw []byte) {
return "", nil
},
)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
if err != nil {
return errors.Wrapf(err, "failed packaging chaincode [%s]", cc.Chaincode.Name)
}
cc.Chaincode.PackageFile = packageFile
p.Fabric(tms).UpdateChaincode(cc.Chaincode.Name,
newChaincodeVersion,
cc.Chaincode.Path, cc.Chaincode.PackageFile)

return nil
}

func (p *GenericBackend) tccSetup(tms *topology3.TMS, cc *topology.ChannelChaincode) (*topology.ChannelChaincode, uint16) {
Expand Down
41 changes: 37 additions & 4 deletions integration/nwo/token/fabric/fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ type Entry struct {

type Backend interface {
PrepareNamespace(tms *topology2.TMS)
UpdatePublicParams(tms *topology2.TMS, raw []byte)
InstallPublicParams(tms *topology2.TMS, raw []byte)
UpdatePublicParams(tms *topology2.TMS, raw []byte) error
InstallPublicParams(tms *topology2.TMS, raw []byte) error
}

// PublicParamsInstallWatcher is implemented by backends that install the public parameters
// in the background and can report the outcome of that work after InstallPublicParams has
// returned.
type PublicParamsInstallWatcher interface {
// PendingInstallError returns the failure recorded by the background installation of the
// public parameters of tms, or nil if it succeeded, is still running, or never started.
PendingInstallError(tms *topology2.TMS) error
}

type NetworkHandler struct {
Expand Down Expand Up @@ -149,19 +158,43 @@ func (p *NetworkHandler) PostRun(load bool, tms *topology2.TMS) {
}
}

p.Backend.InstallPublicParams(tms, p.TokenPlatform.PublicParameters(tms))
err := p.Backend.InstallPublicParams(tms, p.TokenPlatform.PublicParameters(tms))
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed installing public params for [%s]", tms.ID())
}

func (p *NetworkHandler) Cleanup() {
for _, entry := range p.Entries {
if entry.CA != nil {
entry.CA.Stop()
}
// report a background public params installation that failed after PostRun returned,
// so that it does not go unnoticed. Cleanup runs at teardown, where raising an
// assertion would hide the failures of the tests themselves.
if err := p.pendingInstallError(entry.TMS); err != nil {
logger.Errorf("public params installation for [%s] failed: %v", entry.TMS.ID(), err)
}
}
}

func (p *NetworkHandler) UpdatePublicParams(tms *topology2.TMS, ppRaw []byte) {
p.Backend.UpdatePublicParams(tms, ppRaw)
// a failed background installation is the most likely cause of a failing update,
// and it carries the original error, so report it first
err := p.pendingInstallError(tms)
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "public params installation for [%s] failed", tms.ID())

err = p.Backend.UpdatePublicParams(tms, ppRaw)
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed updating public params for [%s]", tms.ID())
}

// pendingInstallError returns the failure of the background public params installation for
// tms, if the backend tracks one, and nil otherwise.
func (p *NetworkHandler) pendingInstallError(tms *topology2.TMS) error {
watcher, ok := p.Backend.(PublicParamsInstallWatcher)
if !ok {
return nil
}

return watcher.PendingInstallError(tms)
}

func (p *NetworkHandler) GenIssuerCryptoMaterial(tms *topology2.TMS, nodeID string, walletID string) string {
Expand Down
Loading
Loading