Skip to content

Commit

Permalink
[FAB-18194] Fix service discovery for legacy installed chaincodes
Browse files Browse the repository at this point in the history
Service discovery endorsers query fails with errors:
"failed constructing descriptor for chaincodes"
"required chaincodes are not installed on sufficient peers"

The chaincodes installed with legacy chaincode lifecycle were not getting recognized
after peer restart since the path to installed chaincodes was set after
the legacy chaincode cache initialized.
Setting the installed chaincode path earlier in peer start sequence resolves the issue.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
  • Loading branch information
denyeart authored and guoger committed Sep 4, 2020
1 parent bf75a97 commit ded37e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions integration/gossip/gossip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ var _ = Describe("Gossip Test", func() {
basePeerForTransactions := peer0Org1
nwo.DeployChaincodeLegacy(network, channelName, orderer, chaincode, basePeerForTransactions)

By("verifying peer0Org1 discovers all the peers and the legacy chaincode before starting the tests")
Eventually(nwo.DiscoverPeers(network, peer0Org1, "User1", "testchannel"), network.EventuallyTimeout).Should(ConsistOf(
network.DiscoveredPeer(peer0Org1, "_lifecycle", "mycc"),
network.DiscoveredPeer(peer1Org1, "_lifecycle"),
network.DiscoveredPeer(peer0Org2, "_lifecycle"),
network.DiscoveredPeer(peer1Org2, "_lifecycle"),
))

By("STATE TRANSFER TEST 1: newly joined peers should receive blocks from the peers that are already up")

// Note, a better test would be to bring orderer down before joining the two peers.
Expand All @@ -153,6 +161,14 @@ var _ = Describe("Gossip Test", func() {
basePeerForTransactions = peer1Org1
nwo.InstallChaincodeLegacy(network, chaincode, basePeerForTransactions)

By("verifying peer0Org1 discovers all the peers and the additional legacy chaincode installed on peer1Org1")
Eventually(nwo.DiscoverPeers(network, peer0Org1, "User1", "testchannel"), network.EventuallyTimeout).Should(ConsistOf(
network.DiscoveredPeer(peer0Org1, "_lifecycle", "mycc"),
network.DiscoveredPeer(peer1Org1, "_lifecycle", "mycc"),
network.DiscoveredPeer(peer0Org2, "_lifecycle"),
network.DiscoveredPeer(peer1Org2, "_lifecycle"),
))

By("stop peer0Org1 (currently elected leader in Org1) and peer1Org2 (static leader in Org2)")
peersToStop = []*nwo.Peer{peer0Org1, peer1Org2}
stopPeers(network, peersToStop, peerProcesses)
Expand All @@ -166,6 +182,13 @@ var _ = Describe("Gossip Test", func() {
// that receives blocks from orderer and will therefore serve as the provider of blocks to all other peers.
sendTransactionsAndSyncUpPeers(network, orderer, basePeerForTransactions, peersToSyncUp, channelName, &ordererProcess, ordererRunner, peerProcesses, peerRunners)

By("verifying peer0Org1 can still discover all the peers and the legacy chaincode after it has been restarted")
Eventually(nwo.DiscoverPeers(network, peer0Org1, "User1", "testchannel"), network.EventuallyTimeout).Should(ConsistOf(
network.DiscoveredPeer(peer0Org1, "_lifecycle", "mycc"),
network.DiscoveredPeer(peer1Org1, "_lifecycle", "mycc"),
network.DiscoveredPeer(peer0Org2, "_lifecycle"),
network.DiscoveredPeer(peer1Org2, "_lifecycle"),
))
})

})
Expand Down
8 changes: 4 additions & 4 deletions internal/peer/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ func serve(args []string) error {
LegacyDeployedCCInfoProvider: &lscc.DeployedCCInfoProvider{},
}

// Configure CC package storage before ccInfoFSImpl.ListInstalledChaincodes() gets called
lsccInstallPath := filepath.Join(coreconfig.GetPath("peer.fileSystemPath"), "chaincodes")
ccprovider.SetChaincodesPath(lsccInstallPath)

ccInfoFSImpl := &ccprovider.CCInfoFSImpl{GetHasher: factory.GetDefault()}

// legacyMetadataManager collects metadata information from the legacy
Expand Down Expand Up @@ -458,10 +462,6 @@ func serve(args []string) error {

peerInstance.GossipService = gossipService

// Configure CC package storage
lsccInstallPath := filepath.Join(coreconfig.GetPath("peer.fileSystemPath"), "chaincodes")
ccprovider.SetChaincodesPath(lsccInstallPath)

if err := lifecycleCache.InitializeLocalChaincodes(); err != nil {
return errors.WithMessage(err, "could not initialize local chaincodes")
}
Expand Down

0 comments on commit ded37e2

Please sign in to comment.