Skip to content

Commit 792bc93

Browse files
committed
Problem: don't support object store
Solution: - refactor to let executor/scheduler be value type agnostic. - make MVData and MVView generic over value type. use map stores reduce size of MultiReadSet cleanup Update memdb.go multilocations use map
1 parent e176b49 commit 792bc93

18 files changed

+756
-566
lines changed

bench_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import (
1010
)
1111

1212
func BenchmarkBlockSTM(b *testing.B) {
13-
stores := []storetypes.StoreKey{StoreKeyAuth, StoreKeyBank}
14-
for i := int64(0); i < 26; i++ {
15-
stores = append(stores, storetypes.NewKVStoreKey(strconv.FormatInt(i, 10)))
13+
stores := map[storetypes.StoreKey]int{StoreKeyAuth: 0, StoreKeyBank: 1}
14+
for i := 0; i < 26; i++ {
15+
key := storetypes.NewKVStoreKey(strconv.FormatInt(int64(i), 10))
16+
stores[key] = i + 2
1617
}
1718
storage := NewMultiMemDB(stores)
1819
testCases := []struct {

executor.go

+11-16
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@ package block_stm
22

33
import (
44
"context"
5-
6-
storetypes "cosmossdk.io/store/types"
75
)
86

97
// Executor fields are not mutated during execution.
108
type Executor struct {
11-
ctx context.Context // context for cancellation
12-
blockSize int // total number of transactions to execute
13-
stores []storetypes.StoreKey // store names
14-
scheduler *Scheduler // scheduler for task management
15-
storage MultiStore // storage for the executor
16-
txExecutor TxExecutor // callback to actually execute a transaction
17-
mvMemory *MVMemory // multi-version memory for the executor
9+
ctx context.Context // context for cancellation
10+
blockSize int // total number of transactions to execute
11+
scheduler *Scheduler // scheduler for task management
12+
storage MultiStore // storage for the executor
13+
txExecutor TxExecutor // callback to actually execute a transaction
14+
mvMemory *MVMemory // multi-version memory for the executor
1815

1916
// index of the executor, used for debugging output
2017
i int
@@ -23,7 +20,6 @@ type Executor struct {
2320
func NewExecutor(
2421
ctx context.Context,
2522
blockSize int,
26-
stores []storetypes.StoreKey,
2723
scheduler *Scheduler,
2824
storage MultiStore,
2925
txExecutor TxExecutor,
@@ -33,7 +29,6 @@ func NewExecutor(
3329
return &Executor{
3430
ctx: ctx,
3531
blockSize: blockSize,
36-
stores: stores,
3732
scheduler: scheduler,
3833
storage: storage,
3934
txExecutor: txExecutor,
@@ -73,8 +68,8 @@ func (e *Executor) Run() {
7368

7469
func (e *Executor) TryExecute(version TxnVersion) (TxnVersion, TaskKind) {
7570
e.scheduler.executedTxns.Add(1)
76-
readSet, writeSet := e.execute(version.Index)
77-
wroteNewLocation := e.mvMemory.Record(version, readSet, writeSet)
71+
view := e.execute(version.Index)
72+
wroteNewLocation := e.mvMemory.Record(version, view)
7873
return e.scheduler.FinishExecution(version, wroteNewLocation)
7974
}
8075

@@ -88,8 +83,8 @@ func (e *Executor) NeedsReexecution(version TxnVersion) (TxnVersion, TaskKind) {
8883
return e.scheduler.FinishValidation(version.Index, aborted)
8984
}
9085

91-
func (e *Executor) execute(txn TxnIndex) (MultiReadSet, MultiWriteSet) {
92-
view := NewMultiMVMemoryView(e.stores, e.storage, e.mvMemory, e.scheduler, txn)
86+
func (e *Executor) execute(txn TxnIndex) *MultiMVMemoryView {
87+
view := e.mvMemory.View(txn, e.storage, e.scheduler)
9388
e.txExecutor(txn, view)
94-
return view.Result()
89+
return view
9590
}

go.mod

+21-20
Original file line numberDiff line numberDiff line change
@@ -11,63 +11,64 @@ require (
1111

1212
require (
1313
cosmossdk.io/errors v1.0.1 // indirect
14-
cosmossdk.io/log v1.3.0 // indirect
15-
cosmossdk.io/math v1.2.0 // indirect
14+
cosmossdk.io/log v1.3.1 // indirect
15+
cosmossdk.io/math v1.3.0 // indirect
1616
github.com/DataDog/zstd v1.5.5 // indirect
1717
github.com/beorn7/perks v1.0.1 // indirect
1818
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
1919
github.com/cespare/xxhash/v2 v2.2.0 // indirect
2020
github.com/cockroachdb/errors v1.11.1 // indirect
2121
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
22-
github.com/cockroachdb/pebble v0.0.0-20231101195458-481da04154d6 // indirect
22+
github.com/cockroachdb/pebble v1.1.0 // indirect
2323
github.com/cockroachdb/redact v1.1.5 // indirect
2424
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
25-
github.com/cosmos/cosmos-db v1.0.0 // indirect
25+
github.com/cosmos/cosmos-db v1.0.2 // indirect
2626
github.com/cosmos/gogoproto v1.4.11 // indirect
2727
github.com/cosmos/ics23/go v0.10.0 // indirect
2828
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2929
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
30-
github.com/emicklei/dot v1.6.0 // indirect
31-
github.com/getsentry/sentry-go v0.25.0 // indirect
30+
github.com/getsentry/sentry-go v0.27.0 // indirect
3231
github.com/gogo/protobuf v1.3.2 // indirect
33-
github.com/golang/protobuf v1.5.3 // indirect
32+
github.com/golang/protobuf v1.5.4 // indirect
3433
github.com/golang/snappy v0.0.4 // indirect
3534
github.com/google/btree v1.1.2 // indirect
3635
github.com/google/go-cmp v0.6.0 // indirect
3736
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
3837
github.com/hashicorp/go-metrics v0.5.1 // indirect
3938
github.com/hashicorp/golang-lru v1.0.2 // indirect
40-
github.com/klauspost/compress v1.17.4 // indirect
39+
github.com/klauspost/compress v1.17.7 // indirect
4140
github.com/kr/pretty v0.3.1 // indirect
4241
github.com/kr/text v0.2.0 // indirect
43-
github.com/linxGnu/grocksdb v1.8.6 // indirect
42+
github.com/linxGnu/grocksdb v1.8.12 // indirect
4443
github.com/mattn/go-colorable v0.1.13 // indirect
4544
github.com/mattn/go-isatty v0.0.20 // indirect
46-
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
4745
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
4846
github.com/onsi/gomega v1.20.0 // indirect
4947
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
5048
github.com/pkg/errors v0.9.1 // indirect
5149
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
52-
github.com/prometheus/client_golang v1.17.0 // indirect
53-
github.com/prometheus/client_model v0.5.0 // indirect
54-
github.com/prometheus/common v0.45.0 // indirect
50+
github.com/prometheus/client_golang v1.18.0 // indirect
51+
github.com/prometheus/client_model v0.6.0 // indirect
52+
github.com/prometheus/common v0.47.0 // indirect
5553
github.com/prometheus/procfs v0.12.0 // indirect
56-
github.com/rogpeppe/go-internal v1.11.0 // indirect
57-
github.com/rs/zerolog v1.31.0 // indirect
54+
github.com/rogpeppe/go-internal v1.12.0 // indirect
55+
github.com/rs/zerolog v1.32.0 // indirect
5856
github.com/sasha-s/go-deadlock v0.3.1 // indirect
5957
github.com/spf13/cast v1.6.0 // indirect
6058
github.com/stretchr/testify v1.8.4 // indirect
6159
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
62-
golang.org/x/crypto v0.18.0 // indirect
63-
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
60+
golang.org/x/crypto v0.19.0 // indirect
61+
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
6462
golang.org/x/net v0.20.0 // indirect
65-
golang.org/x/sys v0.16.0 // indirect
63+
golang.org/x/sys v0.17.0 // indirect
6664
golang.org/x/text v0.14.0 // indirect
6765
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
6866
google.golang.org/grpc v1.60.1 // indirect
69-
google.golang.org/protobuf v1.32.0 // indirect
67+
google.golang.org/protobuf v1.33.0 // indirect
7068
gopkg.in/yaml.v3 v3.0.1 // indirect
7169
)
7270

73-
replace github.com/tidwall/btree => github.com/yihuang/btree v0.0.0-20240318010431-d365682df9a7
71+
replace (
72+
cosmossdk.io/store => github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240402064432-829c54275894
73+
github.com/tidwall/btree => github.com/yihuang/btree v0.0.0-20240318010431-d365682df9a7
74+
)

0 commit comments

Comments
 (0)