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 Sep 3, 2020
1 parent 737a116 commit 75d4c8d
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 115 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,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
2 changes: 1 addition & 1 deletion core/ledger/ledger_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,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
7 changes: 0 additions & 7 deletions core/ledger/pvtdatastorage/reconcile_missing_pvtdata.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 @@ -438,10 +438,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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 75d4c8d

Please sign in to comment.