Skip to content

Commit 1d9a6a5

Browse files
authored
Merge pull request #97 from Gearbox-protocol/Optimize
Optimize
2 parents f0a3052 + ce0a2fe commit 1d9a6a5

File tree

34 files changed

+400
-206
lines changed

34 files changed

+400
-206
lines changed

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func StartServer(lc fx.Lifecycle, engine ds.EngineI, cfg *config.Config, client
4343
// In production, we'd want to separate the Listen and Serve phases for
4444
// better error-handling.
4545
go func() {
46-
engine.UseThreads()
46+
// engine.UseThreads()
4747
engine.SyncHandler()
4848
}()
4949
return nil

debts/module.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ import (
44
"go.uber.org/fx"
55
)
66

7-
var Module = fx.Option(
8-
fx.Provide(NewDebtEngine))
7+
var Module = fx.Provide(NewDebtEngine)

ds/adapter_kit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ func (kit *AdapterKit) init() {
1616
// REVERT_POOL_WRAPPER
1717
kit.AddLevel([]string{PoolWrapper, AccountManager, CompositeChainlinkPF})
1818
// another level created bcz of poolKeeper.
19-
kit.AddLevel([]string{PoolQuotaWrapper, ChainlinkPriceFeed})
19+
kit.AddLevel([]string{PoolQuotaWrapper, ChainlinkWrapper}) // ChainlinkPriceFeed
2020
// REVERT_CM_WRAPPER
21-
kit.AddLevel([]string{CMWrapper, AggregatedQueryFeedWrapper, LMRewardsv2,LMRewardsv3 })
21+
kit.AddLevel([]string{CMWrapper, AggregatedQueryFeedWrapper, LMRewardsv2, LMRewardsv3})
2222
// REVERT_CF_WRAPPER
2323
kit.AddLevel([]string{CFWrapper, CreditConfigurator, Treasury})
2424
// - we are dropping the uni check, so the dependency is reversed.

ds/adapter_name.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const (
2525
RebaseToken = "RebaseToken"
2626
// Wrapper
2727
AggregatedQueryFeedWrapper = "AggregatedQueryFeedWrapper"
28+
ChainlinkWrapper = "ChainlinkWrapper"
2829
AdminWrapper = "AdminWrapper"
2930
CFWrapper = "CFWrapper"
3031
CMWrapper = "CMWrapper"
@@ -56,7 +57,7 @@ const (
5657

5758
const (
5859
FacadeMulticallCall = "FacadeMulticall"
59-
FacadeBotMulticallCall = "FacadeBotMulticall"
60+
FacadeBotMulticallCall = "FacadeBotMulticall"
6061
FacadeOpenMulticallCall = "FacadeOpenMulticall"
6162
FacadeLiquidateCall = "FacadeLiquidate"
6263
FacadeLiquidateExpiredCall = "FacadeLiquidateExpired"

ds/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type RepositoryI interface {
6464
// price feed/oracle funcs
6565
GetTokenOracles() map[schemas.PFVersion]map[string]*schemas.TokenOracle
6666
DirectlyAddTokenOracle(tokenOracle *schemas.TokenOracle)
67-
AddNewPriceOracleEvent(tokenOracle *schemas.TokenOracle, bounded bool, forChainlinkNewFeed ...bool)
67+
AddNewPriceOracleEvent(tokenOracle *schemas.TokenOracle, forChainlinkNewFeed ...bool)
6868
//
6969
GetPrice(token string) *big.Int
7070
AddPriceFeed(pf *schemas.PriceFeed)

ds/repo_dummy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (DummyRepo) GetRetryFeedForDebts() []QueryPriceFeedI {
222222
}
223223

224224
// has mutex lock
225-
func (DummyRepo) AddNewPriceOracleEvent(tokenOracle *schemas.TokenOracle, bounded bool, forChainlinkNewFeed ...bool) {
225+
func (DummyRepo) AddNewPriceOracleEvent(tokenOracle *schemas.TokenOracle, forChainlinkNewFeed ...bool) {
226226
}
227227

228228
func (DummyRepo) LoadLastDebtSync() schemas.LastSync {

engine/index.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/Gearbox-protocol/third-eye/repository"
2020
"github.com/ethereum/go-ethereum/common"
2121
"github.com/ethereum/go-ethereum/core/types"
22+
"github.com/prometheus/client_golang/prometheus"
2223
)
2324

2425
type Engine struct {
@@ -28,6 +29,7 @@ type Engine struct {
2829
debtEng ds.DebtEngineI
2930
syncedBlock atomic.Value
3031
batchSizeForHistory int64
32+
reg *prometheus.Registry
3133
UsingThreads bool
3234
}
3335

@@ -36,12 +38,14 @@ type Engine struct {
3638
func NewEngine(config *config.Config,
3739
ec core.ClientI,
3840
debtEng ds.DebtEngineI,
41+
reg *prometheus.Registry,
3942
repo ds.RepositoryI) ds.EngineI {
4043
eng := &Engine{
4144
debtEng: debtEng,
4245
config: config,
4346
repo: repo.(*repository.Repository),
4447
batchSizeForHistory: config.BatchSizeForHistory,
48+
reg: reg,
4549
Node: &pkg.Node{
4650
Client: ec,
4751
},
@@ -162,6 +166,9 @@ func (e *Engine) LastSyncedBlock() (int64, uint64) {
162166
func (e *Engine) Sync(syncTill int64) {
163167
kit := e.repo.GetKit()
164168
log.Info("Sync till", syncTill)
169+
if e.reg != nil {
170+
e.Client.(interface{ PromInit(*prometheus.Registry) }).PromInit(e.reg)
171+
}
165172
// log.Info("No of calls before syncing: ", e.Client.(*ethclient.Client).GetNoOfCalls())
166173
for lvlIndex := 0; lvlIndex < kit.Len(); lvlIndex++ {
167174
wg := &sync.WaitGroup{}

engine/module.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ import (
1111
)
1212

1313
var Module = fx.Option(
14-
fx.Provide(NewEngine))
14+
fx.Provide(NewEngine, getRegistry))

engine/reg.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package engine
2+
3+
import "github.com/prometheus/client_golang/prometheus"
4+
5+
func getRegistry() *prometheus.Registry {
6+
return prometheus.NewRegistry()
7+
}

go.mod

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
module github.com/Gearbox-protocol/third-eye
22

3-
go 1.20
3+
go 1.21
4+
5+
toolchain go1.23.2
46

57
require (
6-
github.com/Gearbox-protocol/sdk-go v0.0.0-20250323030017-295df9237f0c
8+
github.com/Gearbox-protocol/sdk-go v0.0.0-20250324154851-854e9960e69d
79
github.com/ethereum/go-ethereum v1.13.14
810
github.com/go-playground/validator/v10 v10.4.1
9-
github.com/google/go-cmp v0.5.9
11+
github.com/google/go-cmp v0.6.0
1012
github.com/heroku/x v0.0.42
1113
github.com/joho/godotenv v1.3.0
12-
github.com/prometheus/client_golang v1.14.0
13-
github.com/stretchr/testify v1.8.4
14+
github.com/prometheus/client_golang v1.21.1
15+
github.com/stretchr/testify v1.10.0
1416
go.uber.org/fx v1.13.1
1517
gorm.io/gorm v1.25.11
1618
)
@@ -21,7 +23,7 @@ require (
2123
github.com/beorn7/perks v1.0.1 // indirect
2224
github.com/bits-and-blooms/bitset v1.10.0 // indirect
2325
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
24-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
26+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2527
github.com/consensys/bavard v0.1.13 // indirect
2628
github.com/consensys/gnark-crypto v0.12.1 // indirect
2729
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
@@ -35,7 +37,6 @@ require (
3537
github.com/go-playground/locales v0.13.0 // indirect
3638
github.com/go-playground/universal-translator v0.17.0 // indirect
3739
github.com/go-stack/stack v1.8.1 // indirect
38-
github.com/golang/protobuf v1.5.3 // indirect
3940
github.com/google/go-jsonnet v0.18.0 // indirect
4041
github.com/google/uuid v1.3.0 // indirect
4142
github.com/gorilla/websocket v1.4.2 // indirect
@@ -47,15 +48,16 @@ require (
4748
github.com/jackc/puddle/v2 v2.2.1 // indirect
4849
github.com/jinzhu/inflection v1.0.0 // indirect
4950
github.com/jinzhu/now v1.1.5 // indirect
51+
github.com/klauspost/compress v1.17.11 // indirect
5052
github.com/leodido/go-urn v1.2.0 // indirect
51-
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
5253
github.com/metachris/flashbotsrpc v0.5.0 // indirect
5354
github.com/mmcloughlin/addchain v0.4.0 // indirect
55+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5456
github.com/pkg/errors v0.9.1 // indirect
5557
github.com/pmezard/go-difflib v1.0.0 // indirect
56-
github.com/prometheus/client_model v0.3.0 // indirect
57-
github.com/prometheus/common v0.39.0 // indirect
58-
github.com/prometheus/procfs v0.9.0 // indirect
58+
github.com/prometheus/client_model v0.6.1 // indirect
59+
github.com/prometheus/common v0.62.0 // indirect
60+
github.com/prometheus/procfs v0.15.1 // indirect
5961
github.com/rabbitmq/amqp091-go v1.2.0 // indirect
6062
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
6163
github.com/supranational/blst v0.3.11 // indirect
@@ -66,13 +68,13 @@ require (
6668
go.uber.org/multierr v1.5.0 // indirect
6769
golang.org/x/crypto v0.17.0 // indirect
6870
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
69-
golang.org/x/mod v0.14.0 // indirect
70-
golang.org/x/sync v0.5.0 // indirect
71-
golang.org/x/sys v0.16.0 // indirect
71+
golang.org/x/mod v0.17.0 // indirect
72+
golang.org/x/sync v0.10.0 // indirect
73+
golang.org/x/sys v0.28.0 // indirect
7274
golang.org/x/term v0.15.0 // indirect
73-
golang.org/x/text v0.14.0 // indirect
74-
golang.org/x/tools v0.15.0 // indirect
75-
google.golang.org/protobuf v1.28.1 // indirect
75+
golang.org/x/text v0.21.0 // indirect
76+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
77+
google.golang.org/protobuf v1.36.1 // indirect
7678
gopkg.in/yaml.v2 v2.4.0 // indirect
7779
gopkg.in/yaml.v3 v3.0.1 // indirect
7880
gorm.io/driver/postgres v1.5.9 // indirect
@@ -82,6 +84,6 @@ require (
8284

8385
replace github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.22.1
8486

85-
replace github.com/Gearbox-protocol/sdk-go v0.0.0-20250202041008-5cd987002fd9 => ../sdk-go
87+
replace github.com/Gearbox-protocol/sdk-go v0.0.0-20250324142421-7899229e67ef => ../sdk-go
8688

8789
replace github.com/ethereum/go-ethereum v1.13.14 => github.com/OffchainLabs/go-ethereum v1.13.4-0.20240313010929-e5d8587e7227

0 commit comments

Comments
 (0)