Skip to content

Commit

Permalink
remove orion commit processor (hyperledger-labs#613)
Browse files Browse the repository at this point in the history
Signed-off-by: Angelo De Caro <[email protected]>
Signed-off-by: Alexandros Filios <[email protected]>
  • Loading branch information
adecaro authored Apr 29, 2024
1 parent d6132e5 commit b934597
Show file tree
Hide file tree
Showing 62 changed files with 1,101 additions and 700 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
dlog-fabric-t1-extras,
dlog-fabric-t2,
dlog-fabric-t3,
dlog-fabric-t4,
fabtoken-dlog-fabric,
dloghsm-fabric-t1,
dloghsm-fabric-t2,
Expand Down
6 changes: 3 additions & 3 deletions cmd/tokengen/samples/topology/fungible.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func Topology(tokenSDKDriver string) []api.Topology {
issuer := fscTopology.AddNodeByName("issuer").AddOptions(
fabric.WithOrganization("Org1"),
fabric.WithAnonymousIdentity(),
token.WithDefaultIssuerIdentity(),
token.WithIssuerIdentity("issuer.id1"),
token.WithDefaultIssuerIdentity(false),
token.WithIssuerIdentity("issuer.id1", false),
)
issuer.RegisterViewFactory("issue", &views.IssueCashViewFactory{})
issuer.RegisterViewFactory("issued", &views.ListIssuedTokensViewFactory{})
Expand All @@ -49,7 +49,7 @@ func Topology(tokenSDKDriver string) []api.Topology {
auditor := fscTopology.AddNodeByName("auditor").AddOptions(
fabric.WithOrganization("Org1"),
fabric.WithAnonymousIdentity(),
token.WithAuditorIdentity(),
token.WithAuditorIdentity(false),
)
auditor.RegisterViewFactory("registerAuditor", &views.RegisterAuditorViewFactory{})

Expand Down
4 changes: 4 additions & 0 deletions fungible.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ integration-tests-dlog-fabric-t2:
integration-tests-dlog-fabric-t3:
cd ./integration/token/fungible/dlog; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) --focus "T3" .

.PHONY: integration-tests-dlog-fabric-t4
integration-tests-dlog-fabric-t4:
cd ./integration/token/fungible/dlog; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) --focus "Tr" .

.PHONY: integration-tests-fabtoken-dlog-fabric
integration-tests-fabtoken-dlog-fabric:
cd ./integration/token/fungible/mixed; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/dgraph-io/badger/v3 v3.2103.2
github.com/gammazero/deque v0.2.1
github.com/hashicorp/go-uuid v1.0.2
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20240426121454-7cc4bf2a24b9
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20240429075528-d9c32cfa8d8f
github.com/hyperledger-labs/orion-sdk-go v0.2.5
github.com/hyperledger-labs/orion-server v0.2.5
github.com/hyperledger/fabric v1.4.0-rc1.0.20230405174026-695dd57e01c2
Expand Down Expand Up @@ -190,7 +190,6 @@ require (
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY=
github.com/huin/goupnp v1.2.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20240426121454-7cc4bf2a24b9 h1:5EfOkx8f6ktWDZ9g42kTlrzr0PuVaeATaQ3C5vVLROo=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20240426121454-7cc4bf2a24b9/go.mod h1:30VplCjZJRhZtBh+nKa4k8uulCj84Z3Ae7Ok4ZahB/M=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20240429075528-d9c32cfa8d8f h1:8h2Wi1+kG2H2vI96zG+DTHI3yMb4uOn3+vmaFIWg4HE=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20240429075528-d9c32cfa8d8f/go.mod h1:30VplCjZJRhZtBh+nKa4k8uulCj84Z3Ae7Ok4ZahB/M=
github.com/hyperledger-labs/orion-sdk-go v0.2.5 h1:HFGRTuMZgzo9EtyJeFAhVSlbrj6x3jtY0aDcghdjzRE=
github.com/hyperledger-labs/orion-sdk-go v0.2.5/go.mod h1:At8hiFATfkDXQ4AFLVbaTiC9GDhVDo8aN/supb1KBb4=
github.com/hyperledger-labs/orion-server v0.2.5 h1:aFudmB9SAnsT5v8jhazkuszEu0pdJNFqaYZF2GpvAuI=
Expand Down
17 changes: 13 additions & 4 deletions integration/nwo/token/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/topology"
)

func WithIssuerIdentity(label string) fsc.Option {
func WithIssuerIdentity(label string, hsm bool) fsc.Option {
if hsm {
return WithIssuerIdentityWithHSM(label)
}
return func(o *fsc.Options) error {
to := topology.ToOptions(o)
to.SetIssuers(append(to.Issuers(), label))
Expand All @@ -36,8 +39,11 @@ func WithIssuerIdentityWithHSM(label string) fsc.Option {
}
}

func WithDefaultIssuerIdentity() fsc.Option {
return WithIssuerIdentity("_default_")
func WithDefaultIssuerIdentity(hsm bool) fsc.Option {
if hsm {
return WithDefaultIssuerIdentityWithHSM()
}
return WithIssuerIdentity("_default_", false)
}

func WithDefaultIssuerIdentityWithHSM() fsc.Option {
Expand Down Expand Up @@ -82,7 +88,10 @@ func WithCertifierIdentity() fsc.Option {
}
}

func WithAuditorIdentity() fsc.Option {
func WithAuditorIdentity(hsm bool) fsc.Option {
if hsm {
return WithAuditorIdentityWithHSM()
}
return func(o *fsc.Options) error {
topology.ToOptions(o).SetAuditor(true)

Expand Down
30 changes: 30 additions & 0 deletions integration/token/common/support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package common

import (
"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/views"
"github.com/hyperledger-labs/fabric-token-sdk/token"
. "github.com/onsi/gomega"
)

func CheckFinality(network *integration.Infrastructure, id string, txID string, tmsID *token.TMSID, fail bool) {
if len(id) == 0 {
return
}
_, err := network.Client(id).CallView("TxFinality", common.JSONMarshall(&views.TxFinality{
TxID: txID,
TMSID: tmsID,
}))
if fail {
Expect(err).To(HaveOccurred())
} else {
Expect(err).NotTo(HaveOccurred())
}
}
45 changes: 45 additions & 0 deletions integration/token/common/views/finality.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package views

import (
"encoding/json"

"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/assert"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
"github.com/hyperledger-labs/fabric-token-sdk/token"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/ttx"
)

type TxFinality struct {
TxID string
TMSID *token.TMSID
}

type TxFinalityView struct {
*TxFinality
}

func (r *TxFinalityView) Call(context view.Context) (interface{}, error) {
var tmsID token.TMSID
if r.TMSID != nil {
tmsID = *r.TMSID
}
tms := token.GetManagementService(context, token.WithTMSID(tmsID))
assert.NotNil(tms)
return context.RunView(ttx.NewFinalityWithOpts(ttx.WithTxID(r.TxID), ttx.WithTMSID(tms.ID())))
}

type TxFinalityViewFactory struct{}

func (p *TxFinalityViewFactory) NewView(in []byte) (view.View, error) {
f := &TxFinalityView{TxFinality: &TxFinality{}}
err := json.Unmarshal(in, f.TxFinality)
assert.NoError(err, "failed unmarshalling input")

return f, nil
}
3 changes: 2 additions & 1 deletion integration/token/dvp/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common"
common2 "github.com/hyperledger-labs/fabric-token-sdk/integration/token/common"
views2 "github.com/hyperledger-labs/fabric-token-sdk/integration/token/dvp/views"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/dvp/views/cash"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/dvp/views/house"
Expand Down Expand Up @@ -72,7 +73,7 @@ func sellHouse(network *integration.Infrastructure, houseID string) {
Buyer: "buyer",
}))
Expect(err).NotTo(HaveOccurred())
Expect(network.Client("buyer").IsTxFinal(common.JSONUnmarshalString(txIDBoxed))).NotTo(HaveOccurred())
common2.CheckFinality(network, "buyer", common.JSONUnmarshalString(txIDBoxed), nil, false)
}

func checkBalance(network *integration.Infrastructure, id string, wallet string, typ string, expected uint64) {
Expand Down
11 changes: 7 additions & 4 deletions integration/token/dvp/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token"
fabric2 "github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/fabric"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/common/views"
views2 "github.com/hyperledger-labs/fabric-token-sdk/integration/token/dvp/views"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/dvp/views/cash"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/dvp/views/house"
Expand Down Expand Up @@ -41,7 +42,7 @@ func Topology(tokenSDKDriver string) []api.Topology {
issuer := fscTopology.AddNodeByName("issuer").AddOptions(
fabric.WithOrganization("Org1"),
fabric.WithAnonymousIdentity(),
token.WithDefaultIssuerIdentity(),
token.WithDefaultIssuerIdentity(false),
)
issuer.RegisterViewFactory("issue", &cash.IssueCashViewFactory{})
issuer.RegisterViewFactory("issued", &cash.ListIssuedTokensViewFactory{})
Expand All @@ -50,21 +51,21 @@ func Topology(tokenSDKDriver string) []api.Topology {
auditor := fscTopology.AddNodeByName("auditor").AddOptions(
fabric.WithOrganization("Org1"),
fabric.WithAnonymousIdentity(),
token.WithAuditorIdentity(),
token.WithAuditorIdentity(false),
)
auditor.RegisterViewFactory("registerAuditor", &views2.RegisterAuditorViewFactory{})

// issuers
fscTopology.AddNodeByName("cash_issuer").AddOptions(
fabric.WithOrganization("Org1"),
fabric.WithAnonymousIdentity(),
token.WithDefaultIssuerIdentity(),
token.WithDefaultIssuerIdentity(false),
).RegisterViewFactory("issue_cash", &cash.IssueCashViewFactory{})

fscTopology.AddNodeByName("house_issuer").AddOptions(
fabric.WithOrganization("Org1"),
fabric.WithAnonymousIdentity(),
token.WithDefaultIssuerIdentity(),
token.WithDefaultIssuerIdentity(false),
).RegisterViewFactory("issue_house", &house.IssueHouseViewFactory{})

// seller and buyer
Expand All @@ -87,6 +88,8 @@ func Topology(tokenSDKDriver string) []api.Topology {
buyer.RegisterResponder(&views2.BuyHouseView{}, &views2.SellHouseView{})
buyer.RegisterViewFactory("queryHouse", &house.GetHouseViewFactory{})
buyer.RegisterViewFactory("balance", &views2.BalanceViewFactory{})
buyer.RegisterViewFactory("balance", &views2.BalanceViewFactory{})
buyer.RegisterViewFactory("TxFinality", &views.TxFinalityViewFactory{})

tokenTopology := token.NewTopology()
tokenTopology.SetSDK(fscTopology, &sdk.SDK{})
Expand Down
23 changes: 23 additions & 0 deletions integration/token/fungible/dlog/dlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ var _ = Describe("EndToEnd", func() {
})
})

Describe("T4 Malicious Transactions", func() {
BeforeEach(func() {
// notice that fabric-ca does not support yet aries
var err error
network, err = integration.New(StartPortDlog(), "", topology2.Topology(
topology2.Opts{
Backend: "fabric",
TokenSDKDriver: "dlog",
Aries: true,
NoAuditor: true,
})...)
Expect(err).NotTo(HaveOccurred())
network.RegisterPlatformFactory(token.NewPlatformFactory())
network.Generate()
network.Start()
})

It("Malicious Transactions", func() {
fungible.TestMaliciousTransactions(network)
})

})

})

func PrepareUpdatedPublicParams(network *integration.Infrastructure, auditor string, tms *topology.TMS) []byte {
Expand Down
28 changes: 23 additions & 5 deletions integration/token/fungible/dloghsm/dlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ SPDX-License-Identifier: Apache-2.0
package dloghsm

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/fungible"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/fungible/topology"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("EndToEnd", func() {
Expand All @@ -27,7 +27,16 @@ var _ = Describe("EndToEnd", func() {
Describe("Fungible with HSM", func() {
BeforeEach(func() {
var err error
network, err = integration.New(StartPortDlog(), "", Topology("fabric", "dlog", false)...)
network, err = integration.New(StartPortDlog(), "", topology.Topology(
topology.Opts{
Backend: "fabric",
TokenSDKDriver: "dlog",
Aries: true,
HSM: true,
AuditorAsIssuer: false,
//FSCLogSpec: "token-sdk=debug:fabric-sdk=debug:info",
})...,
)
Expect(err).NotTo(HaveOccurred())
network.RegisterPlatformFactory(token.NewPlatformFactory())
network.Generate()
Expand All @@ -42,7 +51,16 @@ var _ = Describe("EndToEnd", func() {
Describe("Fungible with Auditor = Issuer with HSM", func() {
BeforeEach(func() {
var err error
network, err = integration.New(StartPortDlog(), "", Topology("fabric", "dlog", true)...)
network, err = integration.New(StartPortDlog(), "", topology.Topology(
topology.Opts{
Backend: "fabric",
TokenSDKDriver: "dlog",
Aries: true,
HSM: true,
AuditorAsIssuer: true,
//FSCLogSpec: "token-sdk=debug:fabric-sdk=debug:info",
})...,
)
Expect(err).NotTo(HaveOccurred())
network.RegisterPlatformFactory(token.NewPlatformFactory())
network.Generate()
Expand Down
Loading

0 comments on commit b934597

Please sign in to comment.