Skip to content

Commit 68bfbfa

Browse files
committed
rollback: fix capability usage at gossip
Currently, we pass a static capability to the gossip which uses it to check whether to store the pvtData of invalid tx. With a channel update, the capability does not get updated. Hence, we need to use the channel with bundle listener so that the capability gets updated after a commit of a config update transaction. FAB-16114 #done Change-Id: I19d769432ce5783a1afdded5e7d4be9d682c2672 Signed-off-by: senthil <cendhu@gmail.com>
1 parent 45ed664 commit 68bfbfa

File tree

8 files changed

+431
-170
lines changed

8 files changed

+431
-170
lines changed

core/peer/peer.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,6 @@ func (p *Peer) createChannel(
360360
channel.store = store
361361

362362
simpleCollectionStore := privdata.NewSimpleCollectionStore(l, deployedCCInfoProvider)
363-
ac, exist := bundle.ApplicationConfig()
364-
if !exist {
365-
return errors.Wrapf(err, "application config does not exist for [channel %s]", bundle.ConfigtxValidator().ChainID())
366-
}
367363
p.GossipService.InitializeChannel(bundle.ConfigtxValidator().ChainID(), ordererAddresses, gossipservice.Support{
368364
Validator: validator,
369365
Committer: committer,
@@ -372,7 +368,7 @@ func (p *Peer) createChannel(
372368
IdDeserializeFactory: gossipprivdata.IdentityDeserializerFactoryFunc(func(chainID string) msp.IdentityDeserializer {
373369
return mspmgmt.GetManagerForChain(chainID)
374370
}),
375-
Capabilities: ac.Capabilities(),
371+
CapabilityProvider: channel,
376372
})
377373

378374
p.mutex.Lock()

gossip/privdata/coordinator.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/golang/protobuf/proto"
16+
"github.com/hyperledger/fabric/common/channelconfig"
1617
vsccErrors "github.com/hyperledger/fabric/common/errors"
1718
commonutil "github.com/hyperledger/fabric/common/util"
1819
"github.com/hyperledger/fabric/core/committer"
@@ -116,12 +117,12 @@ type Fetcher interface {
116117
fetch(dig2src dig2sources) (*privdatacommon.FetchedPvtDataContainer, error)
117118
}
118119

119-
//go:generate mockery -dir ./ -name AppCapabilities -case underscore -output mocks/
120-
// AppCapabilities defines the capabilities for the application portion of a channel
121-
type AppCapabilities interface {
122-
// StorePvtDataOfInvalidTx() returns true if the peer needs to store the pvtData of
123-
// invalid transactions.
124-
StorePvtDataOfInvalidTx() bool
120+
//go:generate mockery -dir ./ -name CapabilityProvider -case underscore -output mocks/
121+
122+
// CapabilityProvider contains functions to retrieve capability information for a channel
123+
type CapabilityProvider interface {
124+
// Capabilities defines the capabilities for the application portion of this channel
125+
Capabilities() channelconfig.ApplicationCapabilities
125126
}
126127

127128
// Support encapsulates set of interfaces to
@@ -133,7 +134,7 @@ type Support struct {
133134
committer.Committer
134135
TransientStore
135136
Fetcher
136-
AppCapabilities
137+
CapabilityProvider
137138
}
138139

139140
type coordinator struct {
@@ -716,7 +717,8 @@ func (c *coordinator) listMissingPrivateData(block *common.Block, ownedRWsets ma
716717
privateRWsetsInBlock: privateRWsetsInBlock,
717718
coordinator: c,
718719
}
719-
txList, err := data.forEachTxn(c.Support.StorePvtDataOfInvalidTx(), txsFilter, bi.inspectTransaction)
720+
storePvtDataOfInvalidTx := c.Support.CapabilityProvider.Capabilities().StorePvtDataOfInvalidTx()
721+
txList, err := data.forEachTxn(storePvtDataOfInvalidTx, txsFilter, bi.inspectTransaction)
720722
if err != nil {
721723
return nil, err
722724
}
@@ -893,7 +895,8 @@ func (c *coordinator) GetPvtDataAndBlockByNum(seqNum uint64, peerAuthInfo protou
893895

894896
seqs2Namespaces := aggregatedCollections(make(map[seqAndDataModel]map[string][]*rwset.CollectionPvtReadWriteSet))
895897
data := blockData(blockAndPvtData.Block.Data.Data)
896-
data.forEachTxn(c.Support.StorePvtDataOfInvalidTx(), make(txValidationFlags, len(data)),
898+
storePvtDataOfInvalidTx := c.Support.CapabilityProvider.Capabilities().StorePvtDataOfInvalidTx()
899+
data.forEachTxn(storePvtDataOfInvalidTx, make(txValidationFlags, len(data)),
897900
func(seqInBlock uint64, chdr *common.ChannelHeader, txRWSet *rwsetutil.TxRwSet, _ []*peer.Endorsement) error {
898901
item, exists := blockAndPvtData.PvtData[seqInBlock]
899902
if !exists {

0 commit comments

Comments
 (0)