Skip to content

Commit

Permalink
Merge pull request #1747 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
support exposing Pebble stats too, beside Leveldb
  • Loading branch information
ucwong authored Oct 1, 2023
2 parents 2edccde + 94d1f5b commit 11dd506
Show file tree
Hide file tree
Showing 28 changed files with 499 additions and 810 deletions.
6 changes: 6 additions & 0 deletions ctxcdb/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package leveldb

import (
"fmt"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -245,6 +246,11 @@ func (db *Database) NewSnapshot() (ctxcdb.Snapshot, error) {

// Stat returns a particular internal stat of the database.
func (db *Database) Stat(property string) (string, error) {
if property == "" {
property = "leveldb.stats"
} else if !strings.HasPrefix(property, "leveldb.") {
property = "leveldb." + property
}
return db.db.GetProperty(property)
}

Expand Down
2 changes: 1 addition & 1 deletion ctxcdb/pebble/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func upperBound(prefix []byte) (limit []byte) {

// Stat returns a particular internal stat of the database.
func (d *Database) Stat(property string) (string, error) {
return "", nil
return d.db.Metrics().String(), nil
}

// Compact flattens the underlying data store for the given key range. In essence,
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1
github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8
github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
github.com/CortexFoundation/torrentfs v1.0.55-0.20230928134616-cf4f35fd8ad8
github.com/CortexFoundation/torrentfs v1.0.55-0.20230929073517-3a6a99844e80
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/arsham/figurine v1.3.0
github.com/aws/aws-sdk-go-v2 v1.21.0
Expand All @@ -17,7 +17,7 @@ require (
github.com/cespare/cp v1.1.1
github.com/charmbracelet/bubbletea v0.24.2
github.com/cloudflare/cloudflare-go v0.57.1
github.com/cockroachdb/pebble v0.0.0-20230927205513-725ebe297867
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
github.com/consensys/gnark-crypto v0.12.0
github.com/crate-crypto/go-kzg-4844 v0.3.0
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
Expand Down Expand Up @@ -100,8 +100,8 @@ require (
github.com/anacrolix/mmsg v1.0.0 // indirect
github.com/anacrolix/multiless v0.3.1-0.20221221005021-2d12701f83f7 // indirect
github.com/anacrolix/stm v0.5.0 // indirect
github.com/anacrolix/sync v0.4.0 // indirect
github.com/anacrolix/torrent v1.52.6-0.20230926122046-f009e1d583cb // indirect
github.com/anacrolix/sync v0.4.1-0.20230926072150-b8cd7cfb92d0 // indirect
github.com/anacrolix/torrent v1.52.6-0.20230929044811-45c91b322ad1 // indirect
github.com/anacrolix/upnp v0.1.3-0.20220123035249-922794e51c96 // indirect
github.com/anacrolix/utp v0.2.0 // indirect
github.com/antlabs/stl v0.0.1 // indirect
Expand Down Expand Up @@ -143,8 +143,8 @@ require (
github.com/elliotchance/orderedmap v1.5.0 // indirect
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
github.com/getsentry/sentry-go v0.22.0 // indirect
github.com/go-llsqlite/adapter v0.0.0-20230912124304-94ed0e573c23 // indirect
github.com/go-llsqlite/crawshaw v0.0.0-20230910110433-7e901377eb6c // indirect
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916 // indirect
github.com/go-llsqlite/crawshaw v0.4.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand Down Expand Up @@ -218,7 +218,7 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/ucwong/filecache v1.0.6-0.20230405163841-810d53ced4bd // indirect
github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb // indirect
github.com/ucwong/golang-kv v1.0.23-0.20230928100657-72a7bea7f86f // indirect
github.com/ucwong/golang-kv v1.0.23-0.20230928202756-429f2d3b732c // indirect
github.com/ucwong/shard v1.0.1-0.20230924231639-2ac2d8ab288c // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/xujiajun/mmap-go v1.0.1 // indirect
Expand Down
29 changes: 14 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
contrib.go.opencensus.io/exporter/ocagent v0.6.0/go.mod h1:zmKjrJcdo0aYcVS7bmEeSEBLPA9YJp5bjrofdU3pIXs=
crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797 h1:yDf7ARQc637HoxDho7xjqdvO5ZA2Yb+xzv/fOnnvZzw=
crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797/go.mod h1:sXBiorCo8c46JlQV3oXPKINnZ8mcqnye1EkVkqsectk=
crawshaw.io/sqlite v0.3.2/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4=
dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU=
Expand Down Expand Up @@ -67,8 +66,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1:
github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q=
github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk=
github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA=
github.com/CortexFoundation/torrentfs v1.0.55-0.20230928134616-cf4f35fd8ad8 h1:QDYy+5OBCzu3R4NXhfvtShWPiWBeJ3cKwgqPbeo6Qso=
github.com/CortexFoundation/torrentfs v1.0.55-0.20230928134616-cf4f35fd8ad8/go.mod h1:TtxTSsJ+MIZOviVV1ecz9hNYC20dxg/gDJR3l90gNpo=
github.com/CortexFoundation/torrentfs v1.0.55-0.20230929073517-3a6a99844e80 h1:4t1w0OzhztU7MZSVhxMqQWDMpY3Eecoul6BoJ0nqirY=
github.com/CortexFoundation/torrentfs v1.0.55-0.20230929073517-3a6a99844e80/go.mod h1:w3KRObyytJWRF1tzP3ZdTTLMcGVnucQn8jJkzKZtOmo=
github.com/CortexFoundation/wormhole v0.0.2-0.20230922082251-f97b53242e48 h1:EDrk6U+GjSJ1FdbTrtRDe3LA/Ot6E3xu/HpXAio99B4=
github.com/CortexFoundation/wormhole v0.0.2-0.20230922082251-f97b53242e48/go.mod h1:a2ynt5IqAlGTWLQY0pILqkxYe4AzHLNd+bPmK/r03oE=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
Expand Down Expand Up @@ -194,8 +193,8 @@ github.com/anacrolix/sync v0.0.0-20180611022320-3c4cb11f5a01/go.mod h1:+u91KiUuf
github.com/anacrolix/sync v0.0.0-20180808010631-44578de4e778/go.mod h1:s735Etp3joe/voe2sdaXLcqDdJSay1O0OPnM0ystjqk=
github.com/anacrolix/sync v0.2.0/go.mod h1:BbecHL6jDSExojhNtgTFSBcdGerzNc64tz3DCOj/I0g=
github.com/anacrolix/sync v0.3.0/go.mod h1:BbecHL6jDSExojhNtgTFSBcdGerzNc64tz3DCOj/I0g=
github.com/anacrolix/sync v0.4.0 h1:T+MdO/u87ir/ijWsTFsPYw5jVm0SMm4kVpg8t4KF38o=
github.com/anacrolix/sync v0.4.0/go.mod h1:BbecHL6jDSExojhNtgTFSBcdGerzNc64tz3DCOj/I0g=
github.com/anacrolix/sync v0.4.1-0.20230926072150-b8cd7cfb92d0 h1:M2HtYrYz6CVwo88TfVrGNlc+mSe59KXCBe3gFuEsEto=
github.com/anacrolix/sync v0.4.1-0.20230926072150-b8cd7cfb92d0/go.mod h1:BbecHL6jDSExojhNtgTFSBcdGerzNc64tz3DCOj/I0g=
github.com/anacrolix/tagflag v0.0.0-20180109131632-2146c8d41bf0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw=
github.com/anacrolix/tagflag v0.0.0-20180605133421-f477c8c2f14c/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw=
github.com/anacrolix/tagflag v0.0.0-20180803105420-3a8ff5428f76/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw=
Expand All @@ -211,8 +210,8 @@ github.com/anacrolix/torrent v1.15.0/go.mod h1:MFc6KcbpAyfwGqOyRkdarUK9QnKA/FkVg
github.com/anacrolix/torrent v1.15.1-0.20200504230043-cc5d2abe18e5/go.mod h1:QlOfgrCz5kbvhOz8M58dUwHY5SfZ9VbIvReZ0z0MdIk=
github.com/anacrolix/torrent v1.15.1-0.20200619022403-dd51e99b88cc/go.mod h1:wuopQPC5+/M+zHYvhcA2vp5UCTm9rUc+VqjyBa882Q8=
github.com/anacrolix/torrent v1.15.1-0.20200715061614-dd906f8fa72e/go.mod h1:XWo/fJN1oKgcjgxM+pUZpvalHfqHDs27BY5mBZjIQWo=
github.com/anacrolix/torrent v1.52.6-0.20230926122046-f009e1d583cb h1:VpGwTQi/NUbXf1syyfxdhW3CBXnWT2vawLtYA1pYe84=
github.com/anacrolix/torrent v1.52.6-0.20230926122046-f009e1d583cb/go.mod h1:Ma/WtLey9lU97u2i55LUJ8AnXaL2GfEK6pWh7/9v1hI=
github.com/anacrolix/torrent v1.52.6-0.20230929044811-45c91b322ad1 h1:KzIKTajeqBXWeLjHv2KHjlwigyR19TkdvU5uLGPGQAI=
github.com/anacrolix/torrent v1.52.6-0.20230929044811-45c91b322ad1/go.mod h1:q4utKicrzW80odcXiy3J8sObJELsGGFI1FxhFt/2qA0=
github.com/anacrolix/upnp v0.1.1/go.mod h1:LXsbsp5h+WGN7YR+0A7iVXm5BL1LYryDev1zuJMWYQo=
github.com/anacrolix/upnp v0.1.2-0.20200416075019-5e9378ed1425/go.mod h1:Pz94W3kl8rf+wxH3IbCa9Sq+DTJr8OSbV2Q3/y51vYs=
github.com/anacrolix/upnp v0.1.3-0.20220123035249-922794e51c96 h1:QAVZ3pN/J4/UziniAhJR2OZ9Ox5kOY2053tBbbqUPYA=
Expand Down Expand Up @@ -348,8 +347,8 @@ github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+
github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
github.com/cockroachdb/pebble v0.0.0-20230927205513-725ebe297867 h1:O/fBxpVLLedWnVw+kRDe2rcybSGFLiLXnnHgyrT/Pr0=
github.com/cockroachdb/pebble v0.0.0-20230927205513-725ebe297867/go.mod h1:nindLFinxeDPjP4qI9LtVHAwDef57/0s5KMfWgdktQc=
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A=
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo=
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
Expand Down Expand Up @@ -504,10 +503,10 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
github.com/go-llsqlite/adapter v0.0.0-20230912124304-94ed0e573c23 h1:7krbnPREaxbmEaAkZovTNCMjmiZXEy/Gz9isFbqFK0I=
github.com/go-llsqlite/adapter v0.0.0-20230912124304-94ed0e573c23/go.mod h1:DADrR88ONKPPeSGjFp5iEN55Arx3fi2qXZeKCYDpbmU=
github.com/go-llsqlite/crawshaw v0.0.0-20230910110433-7e901377eb6c h1:pm7z8uwA2q3s8fAsJmKuGckNohqIrw2PRtv6yJ6z0Ro=
github.com/go-llsqlite/crawshaw v0.0.0-20230910110433-7e901377eb6c/go.mod h1:UdTSzmN3nr5dJNuZCsbPLfhSQB76u16rWh8pn+WFx9Q=
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916 h1:OyQmpAN302wAopDgwVjgs2HkFawP9ahIEqkUYz7V7CA=
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916/go.mod h1:DADrR88ONKPPeSGjFp5iEN55Arx3fi2qXZeKCYDpbmU=
github.com/go-llsqlite/crawshaw v0.4.0 h1:L02s2jZBBJj80xm1VkkdyB/JlQ/Fi0kLbNHfXA8yrec=
github.com/go-llsqlite/crawshaw v0.4.0/go.mod h1:/YJdV7uBQaYDE0fwe4z3wwJIZBJxdYzd38ICggWqtaE=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
Expand Down Expand Up @@ -1252,8 +1251,8 @@ github.com/ucwong/filecache v1.0.6-0.20230405163841-810d53ced4bd h1:gBtlvLAsgLk+
github.com/ucwong/filecache v1.0.6-0.20230405163841-810d53ced4bd/go.mod h1:ddwX+NCjMZPdpzcGh1fcEbNTUTCtKgt2hC2rqvmLKgA=
github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb h1:dVZH3AH9f7zB3VBmsjn25B7lfcAyMP4QxdFYTrfj7tg=
github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb/go.mod h1:3yswsBsVuwsOjDvFfC5Na9XSEf4HC7mj3W3g6jvSY/s=
github.com/ucwong/golang-kv v1.0.23-0.20230928100657-72a7bea7f86f h1:Qdn58gT8RlwtDC4bMnwwTDSRTw+qeXr5d+glvVZBXp8=
github.com/ucwong/golang-kv v1.0.23-0.20230928100657-72a7bea7f86f/go.mod h1:VDnYcNcJ7OiGcEGe4gMrysnDMi+up8uUQXEQTKnr+j8=
github.com/ucwong/golang-kv v1.0.23-0.20230928202756-429f2d3b732c h1:xeD21N/IEHb+vc1u+vbLMgGDd58Gnrr2bGHMGNmrG3w=
github.com/ucwong/golang-kv v1.0.23-0.20230928202756-429f2d3b732c/go.mod h1:T7eMjpfCOE820LvrLHv0Oy2DU48rydi4wi5+dH0CSps=
github.com/ucwong/golang-set v1.8.1-0.20200419153428-d7b0b1ac2d43/go.mod h1:xu0FaiQFGbBcFZj2o7udZ5rbA8jRTsv47hkPoG5qQNM=
github.com/ucwong/goleveldb v1.0.3-0.20200508074755-578cba616f37/go.mod h1:dgJUTtDxq/ne6/JzZhHzF24OL/uqILz9IWk8HmT4V2g=
github.com/ucwong/goleveldb v1.0.3-0.20200618184106-f1c6bc3a428b/go.mod h1:7Sq6w7AfEZuB/a6mrlvHCSXCSkqojCMMrM3Ei12QAT0=
Expand Down
6 changes: 0 additions & 6 deletions internal/ctxcapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"math/big"
"strings"
"time"

"github.com/CortexFoundation/CortexTheseus/accounts"
Expand Down Expand Up @@ -1714,11 +1713,6 @@ func NewPrivateDebugAPI(b Backend) *PrivateDebugAPI {

// ChaindbProperty returns leveldb properties of the key-value database.
func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) {
if property == "" {
property = "leveldb.stats"
} else if !strings.HasPrefix(property, "leveldb.") {
property = "leveldb." + property
}
return api.b.ChainDb().Stat(property)
}

Expand Down
Loading

0 comments on commit 11dd506

Please sign in to comment.