From 39f1d090c60f98e116576342d768b81e8bb0407f Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Wed, 22 Mar 2023 12:21:11 +0700 Subject: [PATCH] e3: remove settings table (#946) --- kv/tables.go | 8 -------- state/aggregator.go | 8 ++++---- state/aggregator_v3.go | 6 +++--- state/domain.go | 18 ++++-------------- state/domain_test.go | 2 +- state/history.go | 17 +++-------------- state/history_test.go | 2 +- 7 files changed, 16 insertions(+), 45 deletions(-) diff --git a/kv/tables.go b/kv/tables.go index 681bced79..416ab77da 100644 --- a/kv/tables.go +++ b/kv/tables.go @@ -371,28 +371,24 @@ const ( AccountVals = "AccountVals" AccountHistoryKeys = "AccountHistoryKeys" AccountHistoryVals = "AccountHistoryVals" - AccountSettings = "AccountSettings" AccountIdx = "AccountIdx" StorageKeys = "StorageKeys" StorageVals = "StorageVals" StorageHistoryKeys = "StorageHistoryKeys" StorageHistoryVals = "StorageHistoryVals" - StorageSettings = "StorageSettings" StorageIdx = "StorageIdx" CodeKeys = "CodeKeys" CodeVals = "CodeVals" CodeHistoryKeys = "CodeHistoryKeys" CodeHistoryVals = "CodeHistoryVals" - CodeSettings = "CodeSettings" CodeIdx = "CodeIdx" CommitmentKeys = "CommitmentKeys" CommitmentVals = "CommitmentVals" CommitmentHistoryKeys = "CommitmentHistoryKeys" CommitmentHistoryVals = "CommitmentHistoryVals" - CommitmentSettings = "CommitmentSettings" CommitmentIdx = "CommitmentIdx" LogAddressKeys = "LogAddressKeys" @@ -537,28 +533,24 @@ var ChaindataTables = []string{ AccountVals, AccountHistoryKeys, AccountHistoryVals, - AccountSettings, AccountIdx, StorageKeys, StorageVals, StorageHistoryKeys, StorageHistoryVals, - StorageSettings, StorageIdx, CodeKeys, CodeVals, CodeHistoryKeys, CodeHistoryVals, - CodeSettings, CodeIdx, CommitmentKeys, CommitmentVals, CommitmentHistoryKeys, CommitmentHistoryVals, - CommitmentSettings, CommitmentIdx, LogAddressKeys, diff --git a/state/aggregator.go b/state/aggregator.go index eceeb7550..871e2448f 100644 --- a/state/aggregator.go +++ b/state/aggregator.go @@ -116,17 +116,17 @@ func NewAggregator(dir, tmpdir string, aggregationStep uint64, commitmentMode Co if err != nil { return nil, err } - if a.accounts, err = NewDomain(dir, tmpdir, aggregationStep, "accounts", kv.AccountKeys, kv.AccountVals, kv.AccountHistoryKeys, kv.AccountHistoryVals, kv.AccountSettings, kv.AccountIdx, false /* compressVals */, false); err != nil { + if a.accounts, err = NewDomain(dir, tmpdir, aggregationStep, "accounts", kv.AccountKeys, kv.AccountVals, kv.AccountHistoryKeys, kv.AccountHistoryVals, kv.AccountIdx, false, false); err != nil { return nil, err } - if a.storage, err = NewDomain(dir, tmpdir, aggregationStep, "storage", kv.StorageKeys, kv.StorageVals, kv.StorageHistoryKeys, kv.StorageHistoryVals, kv.StorageSettings, kv.StorageIdx, false /* compressVals */, false); err != nil { + if a.storage, err = NewDomain(dir, tmpdir, aggregationStep, "storage", kv.StorageKeys, kv.StorageVals, kv.StorageHistoryKeys, kv.StorageHistoryVals, kv.StorageIdx, false, false); err != nil { return nil, err } - if a.code, err = NewDomain(dir, tmpdir, aggregationStep, "code", kv.CodeKeys, kv.CodeVals, kv.CodeHistoryKeys, kv.CodeHistoryVals, kv.CodeSettings, kv.CodeIdx, true /* compressVals */, true); err != nil { + if a.code, err = NewDomain(dir, tmpdir, aggregationStep, "code", kv.CodeKeys, kv.CodeVals, kv.CodeHistoryKeys, kv.CodeHistoryVals, kv.CodeIdx, true, true); err != nil { return nil, err } - commitd, err := NewDomain(dir, tmpdir, aggregationStep, "commitment", kv.CommitmentKeys, kv.CommitmentVals, kv.CommitmentHistoryKeys, kv.CommitmentHistoryVals, kv.CommitmentSettings, kv.CommitmentIdx, false /* compressVals */, true) + commitd, err := NewDomain(dir, tmpdir, aggregationStep, "commitment", kv.CommitmentKeys, kv.CommitmentVals, kv.CommitmentHistoryKeys, kv.CommitmentHistoryVals, kv.CommitmentIdx, false, true) if err != nil { return nil, err } diff --git a/state/aggregator_v3.go b/state/aggregator_v3.go index df34ba141..3212ae12c 100644 --- a/state/aggregator_v3.go +++ b/state/aggregator_v3.go @@ -82,13 +82,13 @@ func NewAggregatorV3(ctx context.Context, dir, tmpdir string, aggregationStep ui ctx, ctxCancel := context.WithCancel(ctx) a := &AggregatorV3{ctx: ctx, ctxCancel: ctxCancel, onFreeze: func(frozenFileNames []string) {}, dir: dir, tmpdir: tmpdir, aggregationStep: aggregationStep, backgroundResult: &BackgroundResult{}, db: db, keepInDB: 2 * aggregationStep} var err error - if a.accounts, err = NewHistory(dir, a.tmpdir, aggregationStep, "accounts", kv.AccountHistoryKeys, kv.AccountIdx, kv.AccountHistoryVals, kv.AccountSettings, false /* compressVals */, nil, false); err != nil { + if a.accounts, err = NewHistory(dir, a.tmpdir, aggregationStep, "accounts", kv.AccountHistoryKeys, kv.AccountIdx, kv.AccountHistoryVals, false, nil, false); err != nil { return nil, err } - if a.storage, err = NewHistory(dir, a.tmpdir, aggregationStep, "storage", kv.StorageHistoryKeys, kv.StorageIdx, kv.StorageHistoryVals, kv.StorageSettings, false /* compressVals */, nil, false); err != nil { + if a.storage, err = NewHistory(dir, a.tmpdir, aggregationStep, "storage", kv.StorageHistoryKeys, kv.StorageIdx, kv.StorageHistoryVals, false, nil, false); err != nil { return nil, err } - if a.code, err = NewHistory(dir, a.tmpdir, aggregationStep, "code", kv.CodeHistoryKeys, kv.CodeIdx, kv.CodeHistoryVals, kv.CodeSettings, true /* compressVals */, nil, true); err != nil { + if a.code, err = NewHistory(dir, a.tmpdir, aggregationStep, "code", kv.CodeHistoryKeys, kv.CodeIdx, kv.CodeHistoryVals, true, nil, true); err != nil { return nil, err } if a.logAddrs, err = NewInvertedIndex(dir, a.tmpdir, aggregationStep, "logaddrs", kv.LogAddressKeys, kv.LogAddressIdx, false, nil); err != nil { diff --git a/state/domain.go b/state/domain.go index 73bdb244b..50d114c2f 100644 --- a/state/domain.go +++ b/state/domain.go @@ -145,19 +145,9 @@ type Domain struct { mergesCount uint64 } -func NewDomain( - dir, tmpdir string, - aggregationStep uint64, - filenameBase string, - keysTable string, - valsTable string, - indexKeysTable string, - historyValsTable string, - settingsTable string, - indexTable string, - compressVals bool, - largeValues bool, -) (*Domain, error) { +func NewDomain(dir, tmpdir string, aggregationStep uint64, + filenameBase, keysTable, valsTable, indexKeysTable, historyValsTable, indexTable string, + compressVals, largeValues bool) (*Domain, error) { d := &Domain{ keysTable: keysTable, valsTable: valsTable, @@ -166,7 +156,7 @@ func NewDomain( } var err error - if d.History, err = NewHistory(dir, tmpdir, aggregationStep, filenameBase, indexKeysTable, indexTable, historyValsTable, settingsTable, compressVals, []string{"kv"}, largeValues); err != nil { + if d.History, err = NewHistory(dir, tmpdir, aggregationStep, filenameBase, indexKeysTable, indexTable, historyValsTable, compressVals, []string{"kv"}, largeValues); err != nil { return nil, err } diff --git a/state/domain_test.go b/state/domain_test.go index 650458c32..a28123cdb 100644 --- a/state/domain_test.go +++ b/state/domain_test.go @@ -56,7 +56,7 @@ func testDbAndDomain(t *testing.T) (string, kv.RwDB, *Domain) { } }).MustOpen() t.Cleanup(db.Close) - d, err := NewDomain(path, path, 16 /* aggregationStep */, "base" /* filenameBase */, keysTable, valsTable, historyKeysTable, historyValsTable, settingsTable, indexTable, true /* compressVals */, false) + d, err := NewDomain(path, path, 16, "base", keysTable, valsTable, historyKeysTable, historyValsTable, indexTable, true, false) require.NoError(t, err) t.Cleanup(d.Close) return path, db, d diff --git a/state/history.go b/state/history.go index 0d0f27dcb..8ec2337bc 100644 --- a/state/history.go +++ b/state/history.go @@ -63,7 +63,6 @@ type History struct { roFiles atomic2.Pointer[[]ctxItem] historyValsTable string // key1+key2+txnNum -> oldValue , stores values BEFORE change - settingsTable string compressWorkers int compressVals bool integrityFileExtensions []string @@ -72,23 +71,13 @@ type History struct { wal *historyWAL } -func NewHistory( - dir, tmpdir string, - aggregationStep uint64, - filenameBase string, - indexKeysTable string, - indexTable string, - historyValsTable string, - settingsTable string, - compressVals bool, - integrityFileExtensions []string, - largeValues bool, -) (*History, error) { +func NewHistory(dir, tmpdir string, aggregationStep uint64, + filenameBase, indexKeysTable, indexTable, historyValsTable string, + compressVals bool, integrityFileExtensions []string, largeValues bool) (*History, error) { h := History{ files: btree2.NewBTreeGOptions[*filesItem](filesItemLess, btree2.Options{Degree: 128, NoLocks: false}), roFiles: *atomic2.NewPointer(&[]ctxItem{}), historyValsTable: historyValsTable, - settingsTable: settingsTable, compressVals: compressVals, compressWorkers: 1, integrityFileExtensions: integrityFileExtensions, diff --git a/state/history_test.go b/state/history_test.go index fa3fe9889..4201b73f8 100644 --- a/state/history_test.go +++ b/state/history_test.go @@ -53,7 +53,7 @@ func testDbAndHistory(tb testing.TB, largeValues bool) (string, kv.RwDB, *Histor settingsTable: kv.TableCfgItem{}, } }).MustOpen() - h, err := NewHistory(path, path, 16 /* aggregationStep */, "hist" /* filenameBase */, keysTable, indexTable, valsTable, settingsTable, false /* compressVals */, nil, false) + h, err := NewHistory(path, path, 16, "hist", keysTable, indexTable, valsTable, false, nil, false) require.NoError(tb, err) tb.Cleanup(db.Close) tb.Cleanup(h.Close)