Skip to content

Commit

Permalink
Added IIN Agent support to NWO
Browse files Browse the repository at this point in the history
Need to fix membership recording and specify network admin user for Weaver CC ops.

Signed-off-by: VRamakrishna <vramakr2@in.ibm.com>
  • Loading branch information
VRamakrishna committed Dec 20, 2023
1 parent 77008d2 commit 6657280
Show file tree
Hide file tree
Showing 14 changed files with 290 additions and 48 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FABRIC_VERSION ?= 2.5.0
FABRIC_TWO_DIGIT_VERSION = $(shell echo $(FABRIC_VERSION) | cut -d '.' -f 1,2)
ORION_VERSION=v0.2.5
CACTI_VERSION=2.0.0-alpha.1
CACTI_VERSION=2.0.0-alpha.2

# need to install fabric binaries outside of fsc tree for now (due to chaincode packaging issues)
FABRIC_BINARY_BASE=$(PWD)/../fabric
Expand Down Expand Up @@ -61,10 +61,12 @@ fabric-docker-images:

.PHONY: cacti-weaver-docker-images
cacti-weaver-docker-images:
docker pull ghcr.io/hyperledger/cacti/cacti-weaver-fabric-driver:$(CACTI_VERSION)
docker image tag ghcr.io/hyperledger/cacti/cacti-weaver-fabric-driver:$(CACTI_VERSION) hyperledger/cacti/cacti-weaver-fabric-driver:latest
docker pull ghcr.io/hyperledger/cacti/cacti-weaver-relay-server:$(CACTI_VERSION)
docker image tag ghcr.io/hyperledger/cacti/cacti-weaver-relay-server:$(CACTI_VERSION) hyperledger/cacti/cacti-weaver-relay-server:latest
docker pull ghcr.io/hyperledger/cacti-weaver-driver-fabric:$(CACTI_VERSION)
docker image tag ghcr.io/hyperledger/cacti-weaver-driver-fabric:$(CACTI_VERSION) hyperledger/cacti-weaver-driver-fabric:latest
docker pull ghcr.io/hyperledger/cacti-weaver-relay-server:$(CACTI_VERSION)
docker image tag ghcr.io/hyperledger/cacti-weaver-relay-server:$(CACTI_VERSION) hyperledger/cacti-weaver-relay-server:latest
docker pull ghcr.io/hyperledger/cacti-weaver-iin-agent:$(CACTI_VERSION)
docker image tag ghcr.io/hyperledger/cacti-weaver-iin-agent:$(CACTI_VERSION) hyperledger/cacti-weaver-iin-agent:latest

.PHONY: fpc-docker-images
fpc-docker-images:
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/hyperledger-labs/orion-sdk-go v0.2.5
github.com/hyperledger-labs/orion-server v0.2.5
github.com/hyperledger/cacti/weaver/common/protos-go/v2 v2.0.0-alpha.1
github.com/VRamakrishna/cacti/weaver/sdks/fabric/go-sdk/v2 v2.0.0-alpha.1
github.com/hyperledger/cacti/weaver/common/protos-go/v2 v2.0.0-alpha.2
github.com/hyperledger/cacti/weaver/sdks/fabric/go-sdk/v2 v2.0.0-alpha.2
github.com/hyperledger/fabric v1.4.0-rc1.0.20230401164317-bd8e24856939
github.com/hyperledger/fabric-chaincode-go v0.0.0-20220920210243-7bc6fa0dd58b
github.com/hyperledger/fabric-contract-api-go v1.1.1
github.com/hyperledger/fabric-lib-go v1.0.0
github.com/hyperledger/fabric-private-chaincode v0.0.0-20210907122433-d56466264e4d
github.com/hyperledger/fabric-protos-go v0.2.0
github.com/hyperledger/fabric-protos-go v0.3.0
github.com/libp2p/go-libp2p v0.27.8
github.com/libp2p/go-libp2p-kad-dht v0.22.0
github.com/miekg/pkcs11 v1.1.1
Expand All @@ -52,7 +52,7 @@ require (
go.uber.org/zap v1.24.0
golang.org/x/net v0.8.0
golang.org/x/sync v0.1.0
google.golang.org/grpc v1.53.0
google.golang.org/grpc v1.54.0
google.golang.org/protobuf v1.30.0
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.4.0
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,10 @@ github.com/hyperledger-labs/orion-sdk-go v0.2.5 h1:HFGRTuMZgzo9EtyJeFAhVSlbrj6x3
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=
github.com/hyperledger-labs/orion-server v0.2.5/go.mod h1:8kXVAU1wvFYGbFL1qmXwMi2i8gKV2smOdp1F1kq0HMk=
github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go v1.2.3-alpha.1 h1:vBvo0PNm82ht7wpBjlYY4ZHxV3YprCfdVd3T4JG9vBw=
github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go v1.2.3-alpha.1/go.mod h1:POCGO/RK9YDfgdhuyqjoD9tRNtWfK7Rh5AYYmsb1Chc=
github.com/hyperledger-labs/weaver-dlt-interoperability/sdks/fabric/go-sdk v1.2.3-alpha.1.0.20210812140206-37f430515b8c h1:pKr8VnHlduEgdInwLWykYAw+lpUizjQJaJ8I5fVoRUo=
github.com/hyperledger-labs/weaver-dlt-interoperability/sdks/fabric/go-sdk v1.2.3-alpha.1.0.20210812140206-37f430515b8c/go.mod h1:si2XAWZclHXC359OyYMpNHfonf2P7P2nzABdCA8mPqs=
github.com/hyperledger/cacti/weaver/common/protos-go/v2 v2.0.0-alpha.2 h1:RCScZbqnxdX1RDrp4HATGXs8Pbh2yLI6F6ULjAjTUso=
github.com/hyperledger/cacti/weaver/common/protos-go/v2 v2.0.0-alpha.2/go.mod h1:3DmkYfZoc+TtcAgF3kX6CmQDNKKKCHgbaoQuYu/3ayc=
github.com/hyperledger/cacti/weaver/sdks/fabric/go-sdk/v2 v2.0.0-alpha.2 h1:3avzwjcN9D7k+ziCaJ9yBK6ubEYrrDiXFDWY3A7WWBA=
github.com/hyperledger/cacti/weaver/sdks/fabric/go-sdk/v2 v2.0.0-alpha.2/go.mod h1:sWzc/lqjN276P5cLForcSo7Qp8xvRNGDOxGnb7wakMI=
github.com/hyperledger/fabric v1.4.0-rc1.0.20201118191903-ec81f3e74fa1/go.mod h1:ppiyrJ+sUSk/rAX9cTd8xwAwSQ7chEbOQMAqtQ3pLG4=
github.com/hyperledger/fabric v1.4.0-rc1.0.20230401164317-bd8e24856939 h1:+XwAnpbvmxEeRD1yT+gd77643Y1QQUv0B2HUr4CRNWE=
github.com/hyperledger/fabric v1.4.0-rc1.0.20230401164317-bd8e24856939/go.mod h1:H7BI2gsTl4fW9ARtYG7UOGjwecXHSReVaIz4p2xqUB8=
Expand Down Expand Up @@ -722,8 +722,8 @@ github.com/hyperledger/fabric-protos-go v0.0.0-20190919234611-2a87503ac7c9/go.mo
github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20200707132912-fee30f3ccd23/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20201028172056-a3136dde2354/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.2.0 h1:opaGKvsYYD0abMl6ErriNc+CEgLW+ELdKKQ0QyBL7/0=
github.com/hyperledger/fabric-protos-go v0.2.0/go.mod h1:WWnyWP40P2roPmmvxsUXSvVI/CF6vwY1K1UFidnKBys=
github.com/hyperledger/fabric-protos-go v0.3.0 h1:MXxy44WTMENOh5TI8+PCK2x6pMj47Go2vFRKDHB2PZs=
github.com/hyperledger/fabric-protos-go v0.3.0/go.mod h1:WWnyWP40P2roPmmvxsUXSvVI/CF6vwY1K1UFidnKBys=
github.com/hyperledger/fabric-samples/chaincode/marbles02/go v0.0.0-20210428060230-9db8164f049b/go.mod h1:MvJbTLiLI/KBavKkC+OAqYU1IGvbY8WOu+Qzs/jncnA=
github.com/hyperledger/fabric-sdk-go v1.0.0/go.mod h1:qWE9Syfg1KbwNjtILk70bJLilnmCvllIYFCSY/pa1RU=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
Expand Down Expand Up @@ -2014,8 +2014,8 @@ google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9K
google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag=
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
2 changes: 2 additions & 0 deletions integration/fabric/weaver/relay/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func Topology() []api.Topology {
// Define weaver relay server topology. One relay server per Fabric network
wTopology := weaver.NewTopology()
wTopology.AddRelayServer(f1Topology, "Org1").AddFabricNetwork(f2Topology)
wTopology.AddIINAgents(f1Topology, "Org1")
wTopology.AddRelayServer(f2Topology, "Org3").AddFabricNetwork(f1Topology)
wTopology.AddIINAgents(f2Topology, "Org3")

// Define an FSC topology with 2 FCS nodes.
fscTopology := fsc.NewTopology()
Expand Down
28 changes: 17 additions & 11 deletions integration/nwo/cmd/cryptogen/ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,25 @@ func (ca *CA) SignCertificate(baseDir, name string, orgUnits, alternateNames []s
if nodeType == CLIENT {
hfType = "client"
}
// TODO: remove this by introducing custom attributes
relay := "false"
attrMap := map[string]string{
"hf.Affiliation": ca.OrganizationalUnit,
"hf.EnrollmentID": name,
"hf.Type": hfType,
"relay": relay,
}
// TODO: remove these by introducing custom attributes
// Note: Cacti-Weaver logic just depends on particular attributes
// being present, and not on their values
if strings.Contains(strings.ToLower(name), "relay") {
relay = "true"
}
attrs := &Attributes{
map[string]string{
"hf.Affiliation": ca.OrganizationalUnit,
"hf.EnrollmentID": name,
"hf.Type": hfType,
"relay": relay,
},
attrMap["relay"] = "true"
}
if strings.Contains(strings.ToLower(name), "iinagent") {
attrMap["iin-agent"] = "true"
}
if strings.Contains(strings.ToLower(name), "networkadmin") {
attrMap["network-admin"] = "true"
}
attrs := &Attributes{ attrMap }
buf, err := json.Marshal(attrs)
if err != nil {
return nil, errors.Wrap(err, "Failed to marshal attributes")
Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/fabric/network/network_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ func (n *Network) Discover(command common.Command) (*gexec.Session, error) {
// can be used to start and manage an orderer process.
func (n *Network) OrdererRunner(o *topology.Orderer) *runner2.Runner {
cmdPath := findCmdAtEnv(ordererCMD)
Expect(cmdPath).NotTo(Equal(""), "could not find %s in %s directory %s", configtxgenCMD, FabricBinsPathEnvKey, os.Getenv(FabricBinsPathEnvKey))
Expect(cmdPath).NotTo(Equal(""), "could not find %s in %s directory %s", ordererCMD, FabricBinsPathEnvKey, os.Getenv(FabricBinsPathEnvKey))

cmd := exec.Command(cmdPath)
cmd.Env = os.Environ()
Expand Down
3 changes: 2 additions & 1 deletion integration/nwo/fabric/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (p *Platform) Channels() []*fabric.Channel {
return channels
}

func (p *Platform) InvokeChaincode(cc *topology.ChannelChaincode, method string, args ...[]byte) []byte {
func (p *Platform) InvokeChaincode(cc *topology.ChannelChaincode, user, method string, args ...[]byte) []byte {
if cc.Private {
c := contract.GetContract(
&fpc.ChannelProvider{Network: p.Network, CC: cc},
Expand All @@ -415,6 +415,7 @@ func (p *Platform) InvokeChaincode(cc *topology.ChannelChaincode, method string,
ctor, err := json.Marshal(s)
Expect(err).NotTo(HaveOccurred())

// TODO: RAMA: Fix the username based on the passed parameter and fix the calls to this function
sess, err := p.Network.PeerUserSession(peer, "User1", commands.ChaincodeInvoke{
ChannelID: cc.Channel,
Orderer: p.Network.OrdererAddress(orderer, network.ListenPort),
Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/fsc/fsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (p *Platform) CheckTopology() {

for _, organization := range p.Organizations {
organization.Users += users[organization.Name]
organization.UserNames = append(userNames[organization.Name], "User1", "User2")
organization.UserNames = append(userNames[organization.Name], "User1", "User2", "NetworkAdmin")
}

if !bootstrapNodeFound {
Expand Down
9 changes: 9 additions & 0 deletions integration/nwo/weaver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ type (
MspId string `json:"mspId"`
CaUrl string `json:"caUrl"`
}

IINConfig struct {
Admin Admin `json:"admin"`
Relay Relay `json:"relay"`
MspId string `json:"mspId"`
OrdererMspIds []string `json:"ordererMspIds"`
Local bool `json:"local"`
CaUrl string `json:"caUrl"`
}
)
Loading

0 comments on commit 6657280

Please sign in to comment.