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

chore: Update slinky version (backport #1768) #1781

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 2 additions & 23 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ import (
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
"go.uber.org/zap"
"google.golang.org/grpc"

// App
Expand Down Expand Up @@ -1545,15 +1544,8 @@ func (app *App) initOracle(pricesTxDecoder process.UpdateMarketPriceTxDecoder) {
compression.NewDefaultVoteExtensionCodec(),
compression.NewZLibCompressor(),
),
// We are not using the slinky PreBlocker, so there is no need to pass in PreBlocker here for
// VE handler to work properly.
// Currently the clob PreBlocker assumes that it will only be called during the normal ABCI
// PreBlocker step. Passing in the app PreBlocker here will break that assumption by causing
// the clob PreBlocker to be called unexpectedly. This to leads improperly initialized clob state
// which results in the next block being committed incorrectly.
func(_ sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) {
return nil, nil
},
// TODO we can move the UpdateMarketPrices in extend vote to this in the future.
vote_extensions.NoopPriceApplier{},
app.oracleMetrics,
)

Expand All @@ -1576,19 +1568,6 @@ func (app *App) initOracleMetrics(appOpts servertypes.AppOptions) {
if err != nil {
panic(err)
}
// run prometheus metrics
if cfg.MetricsEnabled {
promLogger, err := zap.NewProduction()
if err != nil {
panic(err)
}
app.oraclePrometheusServer, err = promserver.NewPrometheusServer(cfg.PrometheusServerAddress, promLogger)
if err != nil {
panic(err)
}
// start the prometheus server
go app.oraclePrometheusServer.Start()
}
app.oracleMetrics = oracleMetrics
}

Expand Down
1 change: 0 additions & 1 deletion protocol/app/vote_extensions/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ type PricesKeeper interface {
ctx sdk.Context,
updates []*pricestypes.MsgUpdateMarketPrices_MarketPrice,
) (err error)
GetPrevBlockCPCounter(ctx sdk.Context) (uint64, error)
}
12 changes: 12 additions & 0 deletions protocol/app/vote_extensions/extend_vote_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package vote_extensions

import (
"fmt"
slinkytypes "github.com/skip-mev/slinky/pkg/types"
"math/big"

cometabci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -19,6 +21,16 @@ type ExtendVoteHandler struct {
PricesKeeper PricesKeeper
}

type NoopPriceApplier struct{}

func (n NoopPriceApplier) ApplyPricesFromVoteExtensions(
_ sdk.Context, _ *cometabci.RequestFinalizeBlock) (map[slinkytypes.CurrencyPair]*big.Int, error) {
return nil, nil
}
func (n NoopPriceApplier) GetPricesForValidator(_ sdk.ConsAddress) map[slinkytypes.CurrencyPair]*big.Int {
return nil
}

// ExtendVoteHandler returns a sdk.ExtendVoteHandler, responsible for the following:
// 1. Decoding the x/prices MsgUpdateMarketPrices in the current block - fail on errors
// 2. Validating the proposed MsgUpdateMarketPrices in accordance with the ProcessProposal check
Expand Down
9 changes: 4 additions & 5 deletions protocol/cmd/dydxprotocold/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ func initAppConfig() (string, *DydxAppConfig) {
appConfig := DydxAppConfig{
Config: *srvCfg,
Oracle: oracleconfig.AppConfig{
Enabled: true,
OracleAddress: "localhost:8080",
ClientTimeout: time.Second * 2,
MetricsEnabled: false,
PrometheusServerAddress: "",
Enabled: true,
OracleAddress: "localhost:8080",
ClientTimeout: time.Second * 2,
MetricsEnabled: false,
},
}

Expand Down
19 changes: 4 additions & 15 deletions protocol/daemons/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ func GetDefaultDaemonFlags() DaemonFlags {
},
Slinky: SlinkyFlags{
AppConfig: oracleconfig.AppConfig{
Enabled: true,
OracleAddress: "localhost:8080",
ClientTimeout: time.Second * 2,
MetricsEnabled: true,
PrometheusServerAddress: "0.0.0.0:8001",
Enabled: true,
OracleAddress: "localhost:8080",
ClientTimeout: time.Second * 2,
MetricsEnabled: true,
},
},
}
Expand Down Expand Up @@ -218,11 +217,6 @@ func AddDaemonFlagsToCmd(
df.Slinky.AppConfig.MetricsEnabled,
"Enable the oracle metrics reporting for Slinky.",
)
cmd.Flags().String(
FlagOraclePrometheusServerAddress,
df.Slinky.AppConfig.PrometheusServerAddress,
"The address of the exposed prometheus address for Slinky metrics.",
)
}

// GetDaemonFlagValuesFromOptions gets all daemon flag values from the `AppOptions` struct.
Expand Down Expand Up @@ -316,11 +310,6 @@ func GetDaemonFlagValuesFromOptions(
result.Slinky.AppConfig.MetricsEnabled = v
}
}
if option := appOpts.Get(FlagOraclePrometheusServerAddress); option != nil {
if v, err := cast.ToStringE(option); err == nil {
result.Slinky.AppConfig.PrometheusServerAddress = v
}
}

return result
}
8 changes: 4 additions & 4 deletions protocol/daemons/types/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func (g *GrpcClientImpl) NewGrpcConnection(
ctx context.Context,
socketAddress string,
) (*grpc.ClientConn, error) {
return grpc.DialContext(
return grpc.DialContext( //nolint:staticcheck
ctx,
socketAddress,
grpc.WithTransportCredentials(insecure.NewCredentials()),
// https://github.com/grpc/grpc-go/blob/master/dialoptions.go#L264
grpc.WithBlock(),
grpc.WithBlock(), //nolint:staticcheck
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
// Create a custom `net.Dialer` in order to specify `unix` as the desired network.
var dialer net.Dialer
Expand All @@ -48,11 +48,11 @@ func (g *GrpcClientImpl) NewTcpConnection(
ctx context.Context,
endpoint string,
) (*grpc.ClientConn, error) {
return grpc.DialContext(
return grpc.DialContext( //nolint:staticcheck
ctx,
endpoint,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
grpc.WithBlock(), //nolint:staticcheck
)
}

Expand Down
Loading
Loading