Skip to content

Commit

Permalink
bump slinky to latest and apply latest client updates
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Jul 31, 2024
1 parent 70a4d77 commit 600a594
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
43 changes: 38 additions & 5 deletions app/oracle/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
"cosmossdk.io/log"

"github.com/skip-mev/slinky/oracle/config"
slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"
oracleclient "github.com/skip-mev/slinky/service/clients/oracle"
"github.com/skip-mev/slinky/service/metrics"
oracleservertypes "github.com/skip-mev/slinky/service/servers/oracle/types"

"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials/insecure"

l2slinky "github.com/initia-labs/OPinit/x/opchild/l2slinky"
Expand Down Expand Up @@ -172,10 +174,6 @@ func (c *GRPCClient) createConnection(ctx context.Context) error {
grpc.WithTransportCredentials(insecure.NewCredentials()),
}

if c.blockingDial {
opts = append(opts, grpc.WithBlock())
}

// dial the client, but defer to context closure, if necessary
var (
conn *grpc.ClientConn
Expand All @@ -184,7 +182,17 @@ func (c *GRPCClient) createConnection(ctx context.Context) error {
)
go func() {
defer close(done)
conn, err = grpc.DialContext(ctx, c.addr, opts...)
conn, err = slinkygrpc.NewClient(c.addr, opts...)

// attempt to connect + wait for change in connection state
if c.blockingDial {
// connect
conn.Connect()

if err == nil {
conn.WaitForStateChange(ctx, connectivity.Ready)
}

Check warning on line 194 in app/oracle/client.go

View check run for this annotation

Codecov / codecov/patch

app/oracle/client.go#L185-L194

Added lines #L185 - L194 were not covered by tests
}
}()

// wait for either the context to close or the dial to complete
Expand All @@ -198,8 +206,10 @@ func (c *GRPCClient) createConnection(ctx context.Context) error {
return fmt.Errorf("failed to dial oracle gRPC server: %w", err)
}

c.mutex.Lock()

Check warning on line 209 in app/oracle/client.go

View check run for this annotation

Codecov / codecov/patch

app/oracle/client.go#L209

Added line #L209 was not covered by tests
c.client = oracleservertypes.NewOracleClient(conn)
c.conn = conn
c.mutex.Unlock()

Check warning on line 212 in app/oracle/client.go

View check run for this annotation

Codecov / codecov/patch

app/oracle/client.go#L212

Added line #L212 was not covered by tests

c.logger.Info("oracle client started")

Expand Down Expand Up @@ -231,3 +241,26 @@ func (c *GRPCClient) MarketMap(

return c.client.MarketMap(ctx, req, grpc.WaitForReady(true))

Check warning on line 242 in app/oracle/client.go

View check run for this annotation

Codecov / codecov/patch

app/oracle/client.go#L242

Added line #L242 was not covered by tests
}

// Version returns the version of the oracle service.
func (c *GRPCClient) Version(ctx context.Context, req *oracleservertypes.QueryVersionRequest, _ ...grpc.CallOption) (res *oracleservertypes.QueryVersionResponse, err error) {
c.mutex.Lock()
defer c.mutex.Unlock()

start := time.Now()
defer func() {
// Observe the duration of the call as well as the error.
c.metrics.ObserveOracleResponseLatency(time.Since(start))
c.metrics.AddOracleResponse(metrics.StatusFromError(err))
}()

Check warning on line 255 in app/oracle/client.go

View check run for this annotation

Codecov / codecov/patch

app/oracle/client.go#L246-L255

Added lines #L246 - L255 were not covered by tests

// set deadline on the context
ctx, cancel := context.WithTimeout(ctx, c.timeout)
defer cancel()

if c.client == nil {
return nil, fmt.Errorf("oracle client not started")
}

Check warning on line 263 in app/oracle/client.go

View check run for this annotation

Codecov / codecov/patch

app/oracle/client.go#L258-L263

Added lines #L258 - L263 were not covered by tests

return c.client.Version(ctx, req, grpc.WaitForReady(true))

Check warning on line 265 in app/oracle/client.go

View check run for this annotation

Codecov / codecov/patch

app/oracle/client.go#L265

Added line #L265 was not covered by tests
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
cosmossdk.io/client/v2 v2.0.0-beta.1.0.20240124105859-5ad1805d0e79
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.11.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/depinject v1.0.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.3.1
cosmossdk.io/math v1.3.0
Expand All @@ -23,7 +23,7 @@ require (
github.com/IGLOU-EU/go-wildcard v1.0.3
github.com/aptos-labs/serde-reflection/serde-generate/runtime/golang v0.0.0-20231213012317-73b6bbf74833
github.com/bits-and-blooms/bitset v1.13.0
github.com/cometbft/cometbft v0.38.9
github.com/cometbft/cometbft v0.38.10
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.8
Expand All @@ -47,7 +47,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/skip-mev/block-sdk/v2 v2.1.2
github.com/skip-mev/slinky v1.0.4
github.com/skip-mev/slinky v1.0.5
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
Expand Down Expand Up @@ -208,7 +208,7 @@ require (
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.171.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo=
cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w=
cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc=
cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI=
Expand Down Expand Up @@ -988,8 +988,8 @@ github.com/skip-mev/block-sdk/v2 v2.1.2 h1:fNKbrb+PVVzuU0JiSuWgBV4Afj5zZ1VeHQJp8
github.com/skip-mev/block-sdk/v2 v2.1.2/go.mod h1:kIq7SMva0/eHKTCiG/oI5XGxD4HNVK0t71TrUZqHcvA=
github.com/skip-mev/chaintestutil v0.0.0-20240116134208-3e49bf514803 h1:VRRVYN3wsOIOqVT3e3nDh3vyUl6RvF9QwdK4BvgPP9c=
github.com/skip-mev/chaintestutil v0.0.0-20240116134208-3e49bf514803/go.mod h1:LF2koCTmygQnz11yjSfHvNP8axdyZ2lTEw0EwI+dnno=
github.com/skip-mev/slinky v1.0.4 h1:T4Y46IzbV+w1sSaVze9k3Nt0pDvsn3qdtW+uh+9fB5Q=
github.com/skip-mev/slinky v1.0.4/go.mod h1:+PP4u5CivZforSB2r/EwhQRuZZwqdcoRFA0J3NsZNDA=
github.com/skip-mev/slinky v1.0.5 h1:fQm486VeAbNL8EBcvb9f9OmDLB8zEU17iifmaOmmVOM=
github.com/skip-mev/slinky v1.0.5/go.mod h1:I47xFOLQZ5d0f9cH7k9RtKoakIPLfbT0sJhinOvASBM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down Expand Up @@ -1658,8 +1658,8 @@ google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUE
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
Expand Down

0 comments on commit 600a594

Please sign in to comment.