Skip to content

Commit

Permalink
pass unreconciled missing data info to ledger from reconciler (#1797)
Browse files Browse the repository at this point in the history
Signed-off-by: senthil <cendhu@gmail.com>
  • Loading branch information
cendhu authored and denyeart committed Sep 16, 2020
1 parent bc00758 commit ee2bc1b
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 116 deletions.
18 changes: 10 additions & 8 deletions core/chaincode/mock/peer_ledger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/committer/committer.go
Expand Up @@ -59,7 +59,7 @@ type Committer interface {
// If hashes for some of the private data supplied in this function does not match
// the corresponding hash present in the block, the unmatched private data is not
// committed and instead the mismatch inforation is returned back
CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata) ([]*ledger.PvtdataHashMismatch, error)
CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata, unreconciled ledger.MissingPvtDataInfo) ([]*ledger.PvtdataHashMismatch, error)

// GetMissingPvtDataTracker return the MissingPvtDataTracker
GetMissingPvtDataTracker() (ledger.MissingPvtDataTracker, error)
Expand Down
2 changes: 1 addition & 1 deletion core/committer/committer_impl.go
Expand Up @@ -28,7 +28,7 @@ type PeerLedgerSupport interface {

CommitLegacy(blockAndPvtdata *ledger.BlockAndPvtData, commitOpts *ledger.CommitOptions) error

CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata) ([]*ledger.PvtdataHashMismatch, error)
CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata, unreconciled ledger.MissingPvtDataInfo) ([]*ledger.PvtdataHashMismatch, error)

GetBlockchainInfo() (*common.BlockchainInfo, error)

Expand Down
2 changes: 1 addition & 1 deletion core/committer/committer_test.go
Expand Up @@ -112,7 +112,7 @@ func (m *mockLedger) CommitLegacy(blockAndPvtdata *ledger2.BlockAndPvtData, comm
return args.Error(0)
}

func (m *mockLedger) CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger2.ReconciledPvtdata) ([]*ledger2.PvtdataHashMismatch, error) {
func (m *mockLedger) CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger2.ReconciledPvtdata, unreconciled ledger2.MissingPvtDataInfo) ([]*ledger2.PvtdataHashMismatch, error) {
panic("implement me")
}

Expand Down
2 changes: 1 addition & 1 deletion core/committer/txvalidator/v14/validator_test.go
Expand Up @@ -1519,7 +1519,7 @@ func (m *mockLedger) GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever,
return args.Get(0).(ledger.ConfigHistoryRetriever), nil
}

func (m *mockLedger) CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata) ([]*ledger.PvtdataHashMismatch, error) {
func (m *mockLedger) CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata, unreconciled ledger.MissingPvtDataInfo) ([]*ledger.PvtdataHashMismatch, error) {
return nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion core/ledger/kvledger/kv_ledger.go
Expand Up @@ -669,7 +669,7 @@ func (l *kvLedger) GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, e
return l.configHistoryRetriever, nil
}

func (l *kvLedger) CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata) ([]*ledger.PvtdataHashMismatch, error) {
func (l *kvLedger) CommitPvtDataOfOldBlocks(reconciledPvtdata []*ledger.ReconciledPvtdata, unreconciled ledger.MissingPvtDataInfo) ([]*ledger.PvtdataHashMismatch, error) {
logger.Debugf("[%s:] Comparing pvtData of [%d] old blocks against the hashes in transaction's rwset to find valid and invalid data",
l.ledgerID, len(reconciledPvtdata))

Expand Down
3 changes: 1 addition & 2 deletions core/ledger/ledger_interface.go
Expand Up @@ -178,7 +178,7 @@ type PeerLedger interface {
// If hashes for some of the private data supplied in this function does not match
// the corresponding hash present in the block, the unmatched private data is not
// committed and instead the mismatch inforation is returned back
CommitPvtDataOfOldBlocks(reconciledPvtdata []*ReconciledPvtdata) ([]*PvtdataHashMismatch, error)
CommitPvtDataOfOldBlocks(reconciledPvtdata []*ReconciledPvtdata, unreconciled MissingPvtDataInfo) ([]*PvtdataHashMismatch, error)
// GetMissingPvtDataTracker return the MissingPvtDataTracker
GetMissingPvtDataTracker() (MissingPvtDataTracker, error)
// DoesPvtDataInfoExist returns true when
Expand Down Expand Up @@ -499,7 +499,6 @@ type KVStateUpdates struct {

// ConfigHistoryRetriever allow retrieving history of collection configs
type ConfigHistoryRetriever interface {
CollectionConfigAt(blockNum uint64, chaincodeName string) (*CollectionConfigInfo, error)
MostRecentCollectionConfigBelow(blockNum uint64, chaincodeName string) (*CollectionConfigInfo, error)
}

Expand Down
7 changes: 0 additions & 7 deletions core/ledger/pvtdatastorage/reconcile_missing_pvtdata.go
Expand Up @@ -14,13 +14,6 @@ import (
"github.com/willf/bitset"
)

type elgMissingDataGroup int

const (
prioritized elgMissingDataGroup = iota
deprioritized
)

// CommitPvtDataOfOldBlocks commits the pvtData (i.e., previously missing data) of old blockp.
// The parameter `blocksPvtData` refers a list of old block's pvtdata which are missing in the pvtstore.
// Given a list of old block's pvtData, `CommitPvtDataOfOldBlocks` performs the following three
Expand Down
4 changes: 3 additions & 1 deletion core/ledger/pvtdatastorage/store.go
Expand Up @@ -31,7 +31,7 @@ var (
// from other peers. A chance for eligible deprioritized missing data
// would be given after giving deprioritizedMissingDataPeriodicity number
// of chances to the eligible prioritized missing data
deprioritizedMissingDataPeriodicity = 1000
deprioritizedMissingDataPeriodicity = 100
)

// Provider provides handle to specific 'Store' that in turn manages
Expand Down Expand Up @@ -423,10 +423,12 @@ func (s *Store) GetMissingPvtDataInfoForMostRecentBlocks(maxBlock int) (ledger.M

if s.iterSinceDeprioMissingDataAccess == deprioritizedMissingDataPeriodicity {
s.iterSinceDeprioMissingDataAccess = 0
logger.Debug("fetching missing pvtdata entries from the deprioritized list")
return s.getMissingData(elgDeprioritizedMissingDataGroup, maxBlock)
}

s.iterSinceDeprioMissingDataAccess++
logger.Debug("fetching missing pvtdata entries from the prioritized list")
return s.getMissingData(elgPrioritizedMissingDataGroup, maxBlock)
}

Expand Down
18 changes: 10 additions & 8 deletions core/peer/mock/peer_ledger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions gossip/privdata/mocks/committer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions gossip/privdata/mocks/config_history_retriever.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions gossip/privdata/reconcile.go
Expand Up @@ -161,14 +161,10 @@ func (r *Reconciler) reconcile() error {
logger.Error("reconciliation error when trying to fetch missing items from different peers:", err)
return err
}
if len(fetchedData.AvailableElements) == 0 {
logger.Warning("missing private data is not available on other peers")
return nil
}

pvtDataToCommit := r.preparePvtDataToCommit(fetchedData.AvailableElements)
// commit missing private data that was reconciled and log mismatched
pvtdataHashMismatch, err := r.CommitPvtDataOfOldBlocks(pvtDataToCommit)
unreconciled := constructUnreconciledMissingData(dig2collectionCfg, fetchedData.AvailableElements)
pvtdataHashMismatch, err := r.CommitPvtDataOfOldBlocks(pvtDataToCommit, unreconciled)
if err != nil {
return errors.Wrap(err, "failed to commit private data")
}
Expand Down

0 comments on commit ee2bc1b

Please sign in to comment.