Skip to content

Commit 46d2109

Browse files
committed
[FAB-5997] cleanup transientstore from ledger
As the transientstore is moved out of ledger and committer fetches private write set from transient store and pass it to ledger for commit, ledger no longer use transient store directly to fetch private write set. Hence, transientstore usage in ledger is cleaned up in this CR. Change-Id: Ic55940abab32ab7e25c9d3f7d899183ed599ab7b Signed-off-by: senthil <cendhu@gmail.com>
1 parent db18d92 commit 46d2109

File tree

10 files changed

+10
-479
lines changed

10 files changed

+10
-479
lines changed

core/ledger/kvledger/history/historydb/historyleveldb/pkg_test.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr"
3030
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr"
3131
"github.com/hyperledger/fabric/core/ledger/ledgerconfig"
32-
"github.com/hyperledger/fabric/core/transientstore"
3332
"github.com/spf13/viper"
3433
)
3534

@@ -39,9 +38,8 @@ type levelDBLockBasedHistoryEnv struct {
3938
t testing.TB
4039
testBlockStorageEnv *testBlockStoreEnv
4140

42-
testDBEnv privacyenabledstate.TestEnv
43-
testTransientStoreEnv *transientstore.StoreEnv
44-
txmgr txmgr.TxMgr
41+
testDBEnv privacyenabledstate.TestEnv
42+
txmgr txmgr.TxMgr
4543

4644
testHistoryDBProvider historydb.HistoryDBProvider
4745
testHistoryDB historydb.HistoryDB
@@ -57,17 +55,14 @@ func newTestHistoryEnv(t *testing.T) *levelDBLockBasedHistoryEnv {
5755
testDBEnv.Init(t)
5856
testDB := testDBEnv.GetDBHandle(testLedgerID)
5957

60-
testTStoreEnv := transientstore.NewTestStoreEnv(t)
61-
6258
txMgr := lockbasedtxmgr.NewLockBasedTxMgr(testDB)
6359
testHistoryDBProvider := NewHistoryDBProvider()
6460
testHistoryDB, err := testHistoryDBProvider.GetDBHandle("TestHistoryDB")
6561
testutil.AssertNoError(t, err, "")
6662

6763
return &levelDBLockBasedHistoryEnv{t,
6864
blockStorageTestEnv, testDBEnv,
69-
testTStoreEnv, txMgr,
70-
testHistoryDBProvider, testHistoryDB}
65+
txMgr, testHistoryDBProvider, testHistoryDB}
7166
}
7267

7368
func (env *levelDBLockBasedHistoryEnv) cleanup() {
@@ -77,13 +72,11 @@ func (env *levelDBLockBasedHistoryEnv) cleanup() {
7772

7873
// clean up history
7974
env.testHistoryDBProvider.Close()
80-
env.testTransientStoreEnv.Cleanup()
8175
removeDBPath(env.t)
8276
}
8377

8478
func removeDBPath(t testing.TB) {
8579
removePath(t, ledgerconfig.GetHistoryLevelDBPath())
86-
removePath(t, ledgerconfig.GetTransientStorePath())
8780
}
8881

8982
func removePath(t testing.TB, path string) {

core/ledger/kvledger/kv_ledger.go

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package kvledger
@@ -20,22 +10,18 @@ import (
2010
"errors"
2111
"fmt"
2212

23-
"github.com/golang/protobuf/proto"
2413
"github.com/hyperledger/fabric/common/flogging"
2514
commonledger "github.com/hyperledger/fabric/common/ledger"
2615
"github.com/hyperledger/fabric/common/util"
2716
"github.com/hyperledger/fabric/core/ledger"
2817
"github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb"
2918
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/privacyenabledstate"
3019
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr"
31-
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/pvtdatatxmgr"
20+
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr"
3221
"github.com/hyperledger/fabric/core/ledger/ledgerconfig"
3322
"github.com/hyperledger/fabric/core/ledger/ledgerstorage"
34-
"github.com/hyperledger/fabric/core/transientstore"
3523
"github.com/hyperledger/fabric/protos/common"
36-
"github.com/hyperledger/fabric/protos/ledger/rwset"
3724
"github.com/hyperledger/fabric/protos/peer"
38-
"github.com/hyperledger/fabric/protos/utils"
3925
)
4026

4127
var logger = flogging.MustGetLogger("kvledger")
@@ -57,7 +43,7 @@ func newKVLedger(ledgerID string, blockStore *ledgerstorage.Store,
5743

5844
//Initialize transaction manager using state database
5945
var txmgmt txmgr.TxMgr
60-
txmgmt = pvtdatatxmgr.NewLockbasedTxMgr(versionedDB)
46+
txmgmt = lockbasedtxmgr.NewLockBasedTxMgr(versionedDB)
6147

6248
// Create a kvLedger for this chain/ledger, which encasulates the underlying
6349
// id store, blockstore, txmgr (state database), history database
@@ -270,38 +256,3 @@ func (l *kvLedger) Close() {
270256
l.blockStore.Shutdown()
271257
l.txtmgmt.Shutdown()
272258
}
273-
274-
// retrievePrivateData retrieves the pvt data from the transient store for committing it into the
275-
// pvt data store along with block commit.
276-
// KVLedger does this job temporarily for phase-1 and will be moved out to committer
277-
func retrievePrivateData(transientStore transientstore.Store, block *common.Block) (map[uint64]*ledger.TxPvtData, error) {
278-
pvtdata := make(map[uint64]*ledger.TxPvtData)
279-
for txIndex, envBytes := range block.Data.Data {
280-
env, err := utils.GetEnvelopeFromBlock(envBytes)
281-
if err != nil {
282-
return nil, err
283-
}
284-
payload, err := utils.GetPayload(env)
285-
if err != nil {
286-
return nil, err
287-
}
288-
chdr, err := utils.UnmarshalChannelHeader(payload.Header.ChannelHeader)
289-
if err != nil {
290-
return nil, err
291-
}
292-
pvtEndorsement, err := transientStore.GetSelfSimulatedTxPvtRWSetByTxid(chdr.TxId)
293-
if err != nil {
294-
return nil, err
295-
}
296-
if pvtEndorsement == nil {
297-
continue
298-
}
299-
txPvtRWSet := &rwset.TxPvtReadWriteSet{}
300-
if err := proto.Unmarshal(pvtEndorsement.PvtSimulationResults, txPvtRWSet); err != nil {
301-
return nil, err
302-
}
303-
seqInBlock := uint64(txIndex)
304-
pvtdata[seqInBlock] = &ledger.TxPvtData{SeqInBlock: seqInBlock, WriteSet: txPvtRWSet}
305-
}
306-
return pvtdata, nil
307-
}

core/ledger/kvledger/kv_ledger_provider.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package kvledger
@@ -70,8 +60,6 @@ func NewProvider() (ledger.PeerLedgerProvider, error) {
7060
if err != nil {
7161
return nil, err
7262
}
73-
// Initialize the transient store (temporary storage of private rwset)
74-
//transientStoreProvider := transientstore.NewCustomPathStoreProvider(ledgerconfig.GetTransientStorePath())
7563

7664
// Initialize the history database (index for history of values by key)
7765
var historydbProvider historydb.HistoryDBProvider

core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/pkg_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/privacyenabledstate"
2626
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr"
2727
"github.com/hyperledger/fabric/core/ledger/util"
28-
"github.com/hyperledger/fabric/core/transientstore"
2928
"github.com/hyperledger/fabric/protos/common"
3029
"github.com/hyperledger/fabric/protos/ledger/rwset"
3130
)
@@ -60,8 +59,6 @@ type lockBasedEnv struct {
6059
testDBEnv privacyenabledstate.TestEnv
6160
testDB privacyenabledstate.DB
6261

63-
testTStoreEnv *transientstore.StoreEnv
64-
6562
txmgr txmgr.TxMgr
6663
}
6764

@@ -75,7 +72,6 @@ func (env *lockBasedEnv) init(t *testing.T, testLedgerID string) {
7572
env.testDBEnv.Init(t)
7673
env.testDB = env.testDBEnv.GetDBHandle(testLedgerID)
7774
testutil.AssertNoError(t, err, "")
78-
env.testTStoreEnv = transientstore.NewTestStoreEnv(t)
7975
env.txmgr = NewLockBasedTxMgr(env.testDB)
8076
}
8177

@@ -90,7 +86,6 @@ func (env *lockBasedEnv) getVDB() privacyenabledstate.DB {
9086
func (env *lockBasedEnv) cleanup() {
9187
env.txmgr.Shutdown()
9288
env.testDBEnv.Cleanup()
93-
env.testTStoreEnv.Cleanup()
9489
}
9590

9691
//////////// txMgrTestHelper /////////////

core/ledger/kvledger/txmgmt/txmgr/pvtdatatxmgr/pkg_test.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

core/ledger/kvledger/txmgmt/txmgr/pvtdatatxmgr/pvtdata_txmgr.go

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)