Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asset transfer #639

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 13 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
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ jobs:
interop-fabtoken-t4,
interop-fabtoken-t5,
interop-fabtoken-t6,
interop-fabtoken-t7,
interop-dlog-t1,
interop-dlog-t2,
interop-dlog-t3,
interop-dlog-t4,
interop-dlog-t5,
interop-dlog-t6,
interop-dlog-t7,
dlogstress-t1,
]

Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FABRIC_VERSION ?= 2.5.0
FABRIC_CA_VERSION ?= 1.5.7
FABRIC_TWO_DIGIT_VERSION = $(shell echo $(FABRIC_VERSION) | cut -d '.' -f 1,2)
ORION_VERSION=v0.2.10
WEAVER_VERSION=1.2.1

# need to install fabric binaries outside of fts tree for now (due to chaincode packaging issues)
FABRIC_BINARY_BASE=$(PWD)/../fabric
Expand Down Expand Up @@ -48,7 +49,7 @@ install-softhsm:
./ci/scripts/install_softhsm.sh

.PHONY: docker-images
docker-images: fabric-docker-images orion-server-images monitoring-docker-images testing-docker-images
docker-images: fabric-docker-images orion-server-images monitoring-docker-images testing-docker-images weaver-docker-images

.PHONY: testing-docker-images
testing-docker-images:
Expand Down Expand Up @@ -76,6 +77,12 @@ orion-server-images:
docker pull orionbcdb/orion-server:$(ORION_VERSION)
docker image tag orionbcdb/orion-server:$(ORION_VERSION) orionbcdb/orion-server:latest

.PHONY: weaver-docker-images
weaver-docker-images:
docker pull ghcr.io/hyperledger-labs/weaver-fabric-driver:$(WEAVER_VERSION)
docker image tag ghcr.io/hyperledger-labs/weaver-fabric-driver:$(WEAVER_VERSION) hyperledger-labs/weaver-fabric-driver:latest
docker pull ghcr.io/hyperledger-labs/weaver-relay-server:$(WEAVER_VERSION)
docker image tag ghcr.io/hyperledger-labs/weaver-relay-server:$(WEAVER_VERSION) hyperledger-labs/weaver-relay-server:latest

.PHONY: integration-tests-nft-dlog
integration-tests-nft-dlog:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go v1.2.3-alpha.1 // indirect
github.com/hyperledger-labs/weaver-dlt-interoperability/sdks/fabric/go-sdk v1.2.3-alpha.1.0.20210812140206-37f430515b8c // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 // indirect
github.com/hyperledger/fabric-private-chaincode v1.0.0-rc3.0.20231026135044-67a19b0fcda0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
85 changes: 85 additions & 0 deletions go.sum

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions integration/nwo/token/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ SPDX-License-Identifier: Apache-2.0
package token

import (
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/node"
"github.com/hyperledger-labs/fabric-smart-client/pkg/api"
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/topology"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/ttx"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -84,12 +82,6 @@ func (t *Topology) AddTMS(fscNodes []*node.Node, backend BackedTopology, channel
return tms
}

func (t *Topology) SetSDK(fscTopology *fsc.Topology, sdk api.SDK) {
for _, node := range fscTopology.Nodes {
node.AddSDK(sdk)
}
}

func (t *Topology) GetTMSs() []*topology.TMS {
return t.TMSs
}
2 changes: 2 additions & 0 deletions integration/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const (
ZKATDLogInteropHTLCSwapNoCrossTwoFabricNetworks
ZKATDLogInteropHTLCOrion
ZKATDLogInteropHTLCSwapNoCrossWithOrionAndFabricNetworks
FabTokenInteropAssetTransfer
ZKATDLogInteropAssetTransfer

Mixed
)
64 changes: 63 additions & 1 deletion integration/token/common/sdk/fall/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ SPDX-License-Identifier: Apache-2.0
package fall

import (
"context"
"errors"

"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
dig2 "github.com/hyperledger-labs/fabric-smart-client/platform/common/sdk/dig"
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/weaver"
fabtoken "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/driver"
fabric3 "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/driver/interop/state/fabric"
dlog "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/driver"
fabric4 "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/driver/interop/state/fabric"
tokensdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk/dig"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/interop/pledge"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/interop/state"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/interop/state/driver"
fabric2 "github.com/hyperledger-labs/fabric-token-sdk/token/services/interop/state/fabric"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/network/fabric"
"go.uber.org/dig"
)
Expand All @@ -40,5 +49,58 @@ func (p *SDK) Install() error {
return err
}

return p.SDK.Install()
fabricEnabled := p.ConfigService().GetBool("fabric.enabled")
adecaro marked this conversation as resolved.
Show resolved Hide resolved
if fabricEnabled {
err := errors.Join(
// weaver
p.Container().Provide(weaver.NewProvider, dig.As(new(fabric2.RelayProvider))),
// state provider
p.Container().Provide(state.NewServiceProvider),
p.Container().Provide(fabric3.NewStateDriver, dig.Group("fabric-ssp-state-drivers")),
p.Container().Provide(fabric4.NewStateDriver, dig.Group("fabric-ssp-state-drivers")),
p.Container().Provide(fabric2.NewSSPDriver, dig.Group("ssp-drivers")),
p.Container().Provide(pledge.NewVaultStore),
)
if err != nil {
return err
}
}

if err := p.SDK.Install(); err != nil {
return err
}

if fabricEnabled {
return errors.Join(
digutils.Register[fabric2.RelayProvider](p.Container()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all of the apps that use the fdlog sdk need the relay and pledge services? Otherwise maybe itd make more sense to extend to another sdk

digutils.Register[*pledge.VaultStore](p.Container()),
digutils.Register[*state.ServiceProvider](p.Container()),
)
}

return nil
}

func (p *SDK) Start(ctx context.Context) error {
if err := p.SDK.Start(ctx); err != nil {
return err
}

fabricEnabled := p.ConfigService().GetBool("fabric.enabled")
if fabricEnabled {
return errors.Join(
p.Container().Invoke(registerInteropStateDrivers),
)
}
return nil
}

func registerInteropStateDrivers(in struct {
dig.In
StateServiceProvider *state.ServiceProvider
Drivers []driver.NamedSSPDriver `group:"ssp-drivers"`
}) {
for _, d := range in.Drivers {
in.StateServiceProvider.RegisterDriver(d)
}
}
2 changes: 1 addition & 1 deletion integration/token/fungible/mixed/mixed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var _ = Describe("EndToEnd", func() {
for _, t := range integration.AllTestTypes {
for _, t := range integration.WebSocketNoReplicationOnly {
Describe("Fungible with Auditor ne Issuer", t.Label, func() {
ts, selector := newTestSuite(t.CommType, t.ReplicationFactor, "alice", "bob")
BeforeEach(ts.Setup)
Expand Down
22 changes: 21 additions & 1 deletion integration/token/interop/dlog/dlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token"
token2 "github.com/hyperledger-labs/fabric-token-sdk/integration/token"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/fall"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/fdlog"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/fodlog"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/odlog"
Expand All @@ -23,7 +24,7 @@ import (
var _ = Describe("DLog end to end", func() {
BeforeEach(func() { token.Drivers = append(token.Drivers, "dlog") })

for _, t := range integration2.AllTestTypes {
for _, t := range integration2.WebSocketNoReplicationOnly {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to revert this, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Describe("HTLC Single Fabric Network", t.Label, func() {
ts, selector := newTestSuiteSingleFabric(t.CommType, t.ReplicationFactor, "alice", "bob")
AfterEach(ts.TearDown)
Expand Down Expand Up @@ -59,6 +60,13 @@ var _ = Describe("DLog end to end", func() {
BeforeEach(ts.Setup)
It("Performed an htlc based atomic swap", Label("T6"), func() { interop.TestHTLCNoCrossClaimTwoNetworks(ts.II, selector) })
})

Describe("Asset Transfer With Two Fabric Networks", func() {
ts, selector := newTestSuiteInteropAssetTransfer(t.CommType, t.ReplicationFactor, "alice", "bob")
AfterEach(ts.TearDown)
BeforeEach(ts.Setup)
It("Performed a cross network asset transfer", Label("T7"), func() { interop.TestAssetTransferWithTwoNetworks(ts.II, selector) })
})
}
})

Expand Down Expand Up @@ -118,3 +126,15 @@ func newTestSuiteNoCrossClaimOrion(commType fsc.P2PCommunicationType, factor int
}))
return ts, selector
}

func newTestSuiteInteropAssetTransfer(commType fsc.P2PCommunicationType, factor int, names ...string) (*token2.TestSuite, *token2.ReplicaSelector) {
opts, selector := token2.NewReplicationOptions(factor, names...)
ts := token2.NewTestSuite(opts.SQLConfigs, integration2.ZKATDLogInteropAssetTransfer.StartPortForNode, interop.AssetTransferTopology(common.Opts{
CommType: commType,
ReplicationOpts: opts,
TokenSDKDriver: "dlog",
SDKs: []api2.SDK{&fall.SDK{}},
// FSCLogSpec: "token-sdk=debug:fabric-sdk=debug:view-sdk=debug:info",
}))
return ts, selector
}
20 changes: 20 additions & 0 deletions integration/token/interop/fabtoken/fabtoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token"
token2 "github.com/hyperledger-labs/fabric-token-sdk/integration/token"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/fall"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/ffabtoken"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/fofabtoken"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/sdk/ofabtoken"
Expand Down Expand Up @@ -59,6 +60,13 @@ var _ = Describe("FabToken end to end", func() {
BeforeEach(ts.Setup)
It("Performed an htlc based atomic swap", Label("T6"), func() { interop.TestHTLCNoCrossClaimTwoNetworks(ts.II, selector) })
})

Describe("Asset Transfer With Two Fabric Networks", func() {
ts, selector := newTestSuiteInteropAssetTransfer(t.CommType, t.ReplicationFactor, "alice", "bob")
AfterEach(ts.TearDown)
BeforeEach(ts.Setup)
It("Performed a cross network asset transfer", Label("T7"), func() { interop.TestAssetTransferWithTwoNetworks(ts.II, selector) })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we figure out a solution, maybe we could run both legs of this test as T7-websocket and T7-libp2p with a todo

})
}
})

Expand Down Expand Up @@ -116,3 +124,15 @@ func newTestSuiteNoCrossClaimOrion(commType fsc.P2PCommunicationType, factor int
}))
return ts, selector
}

func newTestSuiteInteropAssetTransfer(commType fsc.P2PCommunicationType, factor int, names ...string) (*token2.TestSuite, *token2.ReplicaSelector) {
opts, selector := token2.NewReplicationOptions(factor, names...)
ts := token2.NewTestSuite(opts.SQLConfigs, integration2.ZKATDLogInteropAssetTransfer.StartPortForNode, interop.AssetTransferTopology(common.Opts{
CommType: commType,
ReplicationOpts: opts,
TokenSDKDriver: "fabtoken",
SDKs: []api2.SDK{&fall.SDK{}},
// FSCLogSpec: "token-sdk=debug:fabric-sdk=debug:view-sdk=debug:info",
}))
return ts, selector
}
Loading
Loading