Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyaoy committed Oct 4, 2024
1 parent 15ec28a commit 72905a8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
14 changes: 14 additions & 0 deletions protocol/daemons/slinky/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -82,6 +83,7 @@ func (c *Client) start(
defer c.wg.Done()
c.RunMarketPairFetcher(c.ctx, appFlags, grpcClient)
}()

// 2. Start the PriceFetcher
c.priceFetcher = NewPriceFetcher(
c.marketPairFetcher,
Expand All @@ -94,6 +96,17 @@ func (c *Client) start(
defer c.wg.Done()
c.RunPriceFetcher(c.ctx)
}()

// 3. Start the SidecarVersionChecker
c.sidecarVersionChecker = NewSidecarVersionChecker(
slinky,
c.logger,
)
c.wg.Add(1)
go func() {
defer c.wg.Done()
c.RunSidecarVersionChecker(c.ctx)
}()
return nil
}

Expand Down Expand Up @@ -160,6 +173,7 @@ func (c *Client) RunMarketPairFetcher(ctx context.Context, appFlags appflags.Fla
// RunSidecarVersionChecker periodically calls the sidecarVersionChecker to check if the running sidecar version
// is at least a minimum acceptable version
func (c *Client) RunSidecarVersionChecker(ctx context.Context) {
fmt.Println("Running SidecarVersionChecker")
err := c.sidecarVersionChecker.Start(ctx)
if err != nil {
c.logger.Error("Error initializing sidecarVersionChecker in slinky daemon: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion protocol/daemons/slinky/client/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var (
// SlinkyMarketParamFetchDelay is the frequency at which we query the x/price module to refresh mappings from
// currency pair to x/price ID.
SlinkyMarketParamFetchDelay = time.Millisecond * 1900
SlinkySidecarCheckDelay = time.Minute * 10
SlinkySidecarCheckDelay = time.Second * 10
)

const (
Expand Down
11 changes: 6 additions & 5 deletions protocol/daemons/slinky/client/sidecar_version_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
MinSidecarVersion = "v1.0.12"
MinSidecarVersion = "v2.1.0"
)

// SidecarVersionChecker is a lightweight process run in a goroutine by the slinky client.
Expand All @@ -26,14 +26,14 @@ type SidecarVersionChecker interface {

// SidecarVersionCheckerImpl implements the SidecarVersionChecker interface.
type SidecarVersionCheckerImpl struct {
Logger log.Logger
slinky oracleclient.OracleClient
logger log.Logger
}

func NewSidecarVersionChecker(logger log.Logger, slinky oracleclient.OracleClient) SidecarVersionChecker {
func NewSidecarVersionChecker(slinky oracleclient.OracleClient, logger log.Logger) SidecarVersionChecker {
return &SidecarVersionCheckerImpl{
Logger: logger,
slinky: slinky,
logger: logger,
}
}

Expand All @@ -55,6 +55,7 @@ func (p *SidecarVersionCheckerImpl) CheckSidecarVersion(ctx context.Context) err
return err
}
current, err := version.NewVersion(slinkyResponse.Version)
fmt.Println("Sidecar version", current)
if err != nil {
return fmt.Errorf("failed to parse current version: %w", err)
}
Expand All @@ -70,7 +71,7 @@ func (p *SidecarVersionCheckerImpl) CheckSidecarVersion(ctx context.Context) err
}

// Version is acceptable
p.Logger.Info("Sidecar version check passed", "version", current)
p.logger.Info("Sidecar version check passed", "version", current)
return nil

}
2 changes: 1 addition & 1 deletion protocol/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ services:
volumes:
- ./localnet/dydxprotocol3:/dydxprotocol/chain/.dave/data
connect0:
image: ghcr.io/skip-mev/connect-sidecar:v2.1.0
image: ghcr.io/skip-mev/connect-sidecar:v2.0.1
entrypoint: >
sh -c "connect --marketmap-provider dydx_migration_api --oracle-config /etc/connect/oracle.json --log-std-out-level error"
environment:
Expand Down

0 comments on commit 72905a8

Please sign in to comment.