Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: catchpointdb #5444

Draft
wants to merge 69 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
98106ac
cleanup: remove redundant method LookupAccountDataByAddress
icorderi Mar 17, 2023
717995b
refactor: upgrade `MakeAccountsOptimizedReader` from a testing only m…
icorderi Mar 17, 2023
d53d749
misc: import pebble module
icorderi Apr 4, 2023
252c58b
feat: add storage engine to the config
icorderi Apr 4, 2023
6988a2b
feat: adjustments to the store interface
icorderi Apr 4, 2023
69f6000
feat: update sql impl based on latest interface changes
icorderi Apr 4, 2023
0d56ded
feat: a generic KV impl of store
icorderi Apr 4, 2023
55a8bf5
feat: pebble impl using generickv
icorderi Apr 4, 2023
95fe47f
feat: mockdb and multi engine testing suite
icorderi Apr 4, 2023
f674291
test: add new db tests to compare impls
icorderi Apr 4, 2023
ef7d0cc
misc: adjust make file for msp
icorderi Apr 4, 2023
72f8ab8
fix: different ErrNotFound by engine
icorderi Apr 4, 2023
dc688d3
feat: split tracker init to aavoid read-after-write txn
icorderi Apr 4, 2023
a9a917c
feat: use `StorageEngine` config during ledger init
icorderi Apr 4, 2023
93f180e
linter
icorderi Apr 4, 2023
e4cf417
fix: config tests
icorderi Apr 4, 2023
9931831
misc: remove demo comments
icorderi Apr 4, 2023
836f967
misc: add missing license
icorderi Apr 4, 2023
463ea43
fix: unsaved files
icorderi Apr 4, 2023
f7d2cb3
fix: migrations always run on startup
icorderi Apr 12, 2023
b0815bb
misc: send proto from the test to the engines
icorderi Apr 14, 2023
0859aa5
fix: `LookupOnline` not matching behaviour
icorderi Apr 14, 2023
165a2c5
fix: `LookupOnlineHistory`
icorderi Apr 14, 2023
028d2a0
test: online accounts data by address
icorderi Apr 18, 2023
9dc2b68
fix: `LookupOnlineTotalsHistory` for kv
icorderi Apr 18, 2023
c27f9bd
fix: `OnlineAccountsDelete` for KV
icorderi Apr 18, 2023
c119d49
fix: `LookupAccountRowID` for KV
icorderi Apr 18, 2023
8f7c1aa
test: `ResourceLookupByRowID`
icorderi Apr 18, 2023
89a5dfd
fix: failing test due to sqlNoRows removal
icorderi Apr 19, 2023
7790321
misc: default pebble options
icorderi Apr 19, 2023
2856449
feat: remove secondary index on accounts
icorderi Apr 19, 2023
a8d07f0
fix: `OnlineAccountsDelete` and `AccountsOnlineTop` ranges
icorderi Apr 21, 2023
a124302
fix: `LookupResourceDataByAddrID` panics on nil account
icorderi Apr 24, 2023
c22b380
feat: dual storage engines for verifying correctness
icorderi Apr 26, 2023
58aca3b
feat: testdb built with sql+kv using the new dual store
icorderi Apr 26, 2023
0dedb73
fix: missing refs
icorderi Apr 26, 2023
3f7a703
fix: nil vs empty on `OnlineAccountsAll` return
icorderi Apr 26, 2023
7eb9070
feat: add `Begin(Transaction/Batch/Snapshot)` to the store
icorderi Apr 27, 2023
06fcd2e
test: sqlite+pebble dual engine
icorderi Apr 27, 2023
cafdba8
feat: impl Testing interface on pebbledb and dual
icorderi Apr 27, 2023
4d070bd
misc: remove unncesary methods from testing interface
icorderi Apr 27, 2023
c8c89e2
refactor: first test outside trackerdb using the new testdb and dual …
icorderi Apr 27, 2023
fb187ec
feat: impl stateproofs for kv
icorderi Apr 28, 2023
b4b90e2
refactor: trackerdb `Store` interface
icorderi Apr 28, 2023
a8ea766
refactor: drivers file rename and cleanup
icorderi May 3, 2023
2f2584a
refactor: use `Open` to create dbs
icorderi May 3, 2023
a6d2f1b
refactor: remove from the interface
icorderi May 3, 2023
7d6c988
refactor: remove `SetLogger` from `Store` interface
icorderi May 3, 2023
8a512ed
refactor: reduce the number of `RunMigrations` called inside transact…
icorderi May 3, 2023
4e8a93d
feat: impl `IsSharedCacheConnection` for kv
icorderi May 3, 2023
44ce944
s: pebble import
icorderi May 15, 2023
c9f39ad
s pebble
icorderi May 16, 2023
747b439
linter
icorderi May 16, 2023
aaa9a80
fix: migration
icorderi May 16, 2023
af6e952
fix test
icorderi May 16, 2023
7b5a52c
fix: close cannot rollback if commited on sql
icorderi May 17, 2023
678497b
comment: avoid copy on for loop
icorderi May 17, 2023
5057025
misc: remove unused code
icorderi May 17, 2023
d260e2e
linter
icorderi May 17, 2023
8a48385
fix: list creatables cidx key parsing
icorderi May 17, 2023
a61ea76
fix: aidx in `LookupAllResources`
icorderi May 25, 2023
a85722b
fix: hex encoding of address in keys
icorderi May 25, 2023
373f059
misc: use geth pebble config
icorderi May 31, 2023
3d57a90
feat: add supprt for new online stake method
icorderi Jun 1, 2023
8ecac02
go.mod
icorderi Jun 1, 2023
32d556e
fix: block-generator tidy
icorderi Jun 1, 2023
52c7ca7
remove unnecesary imports
icorderi Jun 2, 2023
e53c6ca
fix: shadows
icorderi Jun 2, 2023
c01c356
refactor: extract catchpoint data into a separate db
icorderi May 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ GOLDFLAGS := $(GOLDFLAGS_BASE) \
UNIT_TEST_SOURCES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && go list ./... | grep -v /go-algorand/test/ ))
ALGOD_API_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && cd daemon/algod/api; go list ./... ))

MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/merklearray ./crypto/merklesignature ./crypto/stateproof ./data/basics ./data/transactions ./data/stateproofmsg ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./network ./node ./ledger ./ledger/ledgercore ./ledger/store/trackerdb ./ledger/encoded ./stateproof ./data/account ./daemon/algod/api/spec/v2
MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/merklearray ./crypto/merklesignature ./crypto/stateproof ./data/basics ./data/transactions ./data/stateproofmsg ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./network ./node ./ledger ./ledger/ledgercore ./ledger/store/trackerdb ./ledger/store/trackerdb/generickv ./ledger/store/catchpointdb ./ledger/encoded ./stateproof ./data/account ./daemon/algod/api/spec/v2

default: build

Expand Down
27 changes: 6 additions & 21 deletions cmd/catchpointdump/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/algorand/go-algorand/crypto/merkletrie"
"github.com/algorand/go-algorand/ledger"
"github.com/algorand/go-algorand/ledger/store/catchpointdb"
"github.com/algorand/go-algorand/ledger/store/trackerdb"
"github.com/algorand/go-algorand/ledger/store/trackerdb/sqlitedriver"
"github.com/algorand/go-algorand/util/db"
Expand Down Expand Up @@ -103,30 +104,14 @@ func printDbVersion(staging bool, version uint64, outFile *os.File) {
}

func getVersion(filename string, staging bool) (uint64, error) {
dbAccessor, err := db.MakeAccessor(filename, true, false)
if err != nil || dbAccessor.Handle == nil {
return 0, err
}
defer dbAccessor.Close()
var version uint64
err = dbAccessor.Atomic(func(ctx context.Context, tx *sql.Tx) (err error) {
if staging {
// writing the version of the catchpoint file start only on ver >= CatchpointFileVersionV7.
// in case the catchpoint version does not exists ReadCatchpointStateUint64 returns 0
cw := sqlitedriver.NewCatchpointSQLReaderWriter(tx)
version, err = cw.ReadCatchpointStateUint64(ctx, trackerdb.CatchpointStateCatchupVersion)
return err
}

versionAsInt32, err := db.GetUserVersion(ctx, tx)
version = uint64(versionAsInt32)
return err
})
if err != nil {
rdb, err := db.MakeAccessor(filename, true, false)
if err != nil || rdb.Handle == nil {
return 0, err
}
catchpointDbs := catchpointdb.MakeStore(db.Pair{Rdb: rdb, Wdb: rdb})
defer catchpointDbs.Close()

return version, nil
return catchpointDbs.GetVersion(context.Background(), staging)
}

var checkCmd = &cobra.Command{
Expand Down
8 changes: 7 additions & 1 deletion config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Local struct {
// Version tracks the current version of the defaults so we can migrate old -> new
// This is specifically important whenever we decide to change the default value
// for an existing parameter. This field tag must be updated any time we add a new version.
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27"`
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27" version[28]:"28"`

// environmental (may be overridden)
// When enabled, stores blocks indefinitely, otherwise, only the most recent blocks
Expand Down Expand Up @@ -510,6 +510,12 @@ type Local struct {
// EnableTxnEvalTracer turns on features in the BlockEvaluator which collect data on transactions, exposing them via algod APIs.
// It will store txn deltas created during block evaluation, potentially consuming much larger amounts of memory,
EnableTxnEvalTracer bool `version[27]:"false"`

// StorageEngine allows to control which type of storage to use for the ledger.
// Available options are:
// - sqlite (default)
// - pebbledb (experimental, in development)
StorageEngine string `version[28]:"sqlite"`
}

// DNSBootstrapArray returns an array of one or more DNS Bootstrap identifiers
Expand Down
3 changes: 2 additions & 1 deletion config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package config

var defaultLocal = Local{
Version: 27,
Version: 28,
AccountUpdatesStatsInterval: 5000000000,
AccountsRebuildSynchronousMode: 1,
AgreementIncomingBundlesQueueLength: 15,
Expand Down Expand Up @@ -119,6 +119,7 @@ var defaultLocal = Local{
RestReadTimeoutSeconds: 15,
RestWriteTimeoutSeconds: 120,
RunHosted: false,
StorageEngine: "sqlite",
SuggestedFeeBlockHistory: 3,
SuggestedFeeSlidingWindowSize: 50,
TLSCertFile: "",
Expand Down
27 changes: 24 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ require (
github.com/algorand/oapi-codegen v1.12.0-algorand.0
github.com/algorand/websocket v1.4.6
github.com/aws/aws-sdk-go v1.33.0
github.com/cockroachdb/pebble v0.0.0-20230123220951-b418e86f4cd4
github.com/consensys/gnark-crypto v0.7.0
github.com/davidlazar/go-crypto v0.0.0-20170701192655-dcfb0a7ac018
github.com/dchest/siphash v1.2.1
github.com/fatih/color v1.7.0
github.com/getkin/kin-openapi v0.107.0
github.com/gofrs/flock v0.7.0
github.com/golang/snappy v0.0.4
github.com/google/go-cmp v0.5.6
github.com/google/go-querystring v1.0.0
github.com/gorilla/mux v1.8.0
github.com/jmoiron/sqlx v1.2.0
Expand All @@ -30,7 +32,7 @@ require (
github.com/miekg/dns v1.1.27
github.com/olivere/elastic v6.2.14+incompatible
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v0.0.3
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.1.0
golang.org/x/sys v0.7.0
Expand All @@ -41,35 +43,54 @@ require (

require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/cpuguy83/go-md2man v1.0.8 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.19.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/invopop/yaml v0.1.0 // indirect
github.com/jmespath/go-jmespath v0.3.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.11.13 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday v1.5.2 // indirect
github.com/prometheus/client_golang v1.12.0 // indirect
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
golang.org/x/exp v0.0.0-20200513190911-00229845015e // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading