From 297b5922a0b4d7611fd4f12553bb8257458af196 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 4 Mar 2024 14:22:06 -0800 Subject: [PATCH] Merge --- protocol/app/app.go | 189 ++++++++++++++---- protocol/cmd/dydxprotocold/cmd/config.go | 5 - .../slinky/client/market_pair_fetcher.go | 2 +- .../slinky/client/market_pair_fetcher_test.go | 2 +- .../daemons/slinky/client/price_fetcher.go | 2 +- protocol/lib/slinky/utils.go | 2 +- protocol/lib/slinky/utils_test.go | 2 +- protocol/mocks/MarketPairFetcher.go | 4 +- protocol/testing/genesis.sh | 40 +--- protocol/testing/testnet-local/local.sh | 2 +- 10 files changed, 161 insertions(+), 89 deletions(-) diff --git a/protocol/app/app.go b/protocol/app/app.go index f6d041f02da..e65f94bc08d 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -89,10 +89,10 @@ import ( "github.com/cosmos/ibc-go/modules/capability" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/dydxprotocol/v4-chain/protocol/daemons/configs" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" "github.com/spf13/cast" + "go.uber.org/zap" "google.golang.org/grpc" // App @@ -100,9 +100,10 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/app/flags" "github.com/dydxprotocol/v4-chain/protocol/app/middleware" "github.com/dydxprotocol/v4-chain/protocol/app/prepare" - "github.com/dydxprotocol/v4-chain/protocol/app/prepare/prices" "github.com/dydxprotocol/v4-chain/protocol/app/process" + priceUpdateGenerator "github.com/dydxprotocol/v4-chain/protocol/app/prepare/prices" + "github.com/dydxprotocol/v4-chain/protocol/app/vote_extensions" "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" timelib "github.com/dydxprotocol/v4-chain/protocol/lib/time" @@ -113,6 +114,7 @@ import ( // Daemons bridgeclient "github.com/dydxprotocol/v4-chain/protocol/daemons/bridge/client" + "github.com/dydxprotocol/v4-chain/protocol/daemons/configs" daemonflags "github.com/dydxprotocol/v4-chain/protocol/daemons/flags" liquidationclient "github.com/dydxprotocol/v4-chain/protocol/daemons/liquidation/client" metricsclient "github.com/dydxprotocol/v4-chain/protocol/daemons/metrics/client" @@ -206,9 +208,16 @@ import ( streamingtypes "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc/types" // Slinky + slinkyproposals "github.com/skip-mev/slinky/abci/proposals" + "github.com/skip-mev/slinky/abci/strategies/aggregator" + compression "github.com/skip-mev/slinky/abci/strategies/codec" + "github.com/skip-mev/slinky/abci/strategies/currencypair" + "github.com/skip-mev/slinky/abci/ve" oracleconfig "github.com/skip-mev/slinky/oracle/config" + "github.com/skip-mev/slinky/pkg/math/voteweighted" oracleclient "github.com/skip-mev/slinky/service/clients/oracle" servicemetrics "github.com/skip-mev/slinky/service/metrics" + promserver "github.com/skip-mev/slinky/service/servers/prometheus" ) var ( @@ -322,11 +331,13 @@ type App struct { PriceFeedClient *pricefeedclient.Client LiquidationsClient *liquidationclient.Client BridgeClient *bridgeclient.Client + SlinkyClient *slinkyclient.Client DaemonHealthMonitor *daemonservertypes.HealthMonitor // Slinky - SlinkyClient *slinkyclient.Client + oraclePrometheusServer *promserver.PrometheusServer + oracleMetrics servicemetrics.Metrics } // assertAppPreconditions assert invariants required for an application to start. @@ -1332,52 +1343,103 @@ func New( app.SetPrecommiter(app.Precommitter) app.SetPrepareCheckStater(app.PrepareCheckStater) + strategy := currencypair.NewDefaultCurrencyPairStrategy(app.PricesKeeper) + veCodec := compression.NewCompressionVoteExtensionCodec( + compression.NewDefaultVoteExtensionCodec(), + compression.NewZLibCompressor(), + ) + extCommitCodec := compression.NewCompressionExtendedCommitCodec( + compression.NewDefaultExtendedCommitCodec(), + compression.NewZLibCompressor(), + ) + priceUpdateGenerator := priceUpdateGenerator.NewSlinkyPriceUpdateGenerator( + aggregator.NewDefaultVoteAggregator( + logger, + voteweighted.MedianFromContext( + logger, + app.StakingKeeper, + voteweighted.DefaultPowerThreshold, + ), + strategy, + ), + extCommitCodec, + veCodec, + strategy, + ) + + var dydxPrepareProposalHandler sdk.PrepareProposalHandler // PrepareProposal setup. - priceUpdateGenerator := prices.NewDefaultPriceUpdateGenerator(app.PricesKeeper) if appFlags.NonValidatingFullNode { - app.SetPrepareProposal(prepare.FullNodePrepareProposalHandler()) + dydxPrepareProposalHandler = prepare.FullNodePrepareProposalHandler() } else { - app.SetPrepareProposal( - prepare.PrepareProposalHandler( - txConfig, - app.BridgeKeeper, - app.ClobKeeper, - app.PerpetualsKeeper, - priceUpdateGenerator, - ), + // setup slinky prepare-proposal handler + dydxPrepareProposalHandler = prepare.PrepareProposalHandler( + txConfig, + app.BridgeKeeper, + app.ClobKeeper, + app.PerpetualsKeeper, + priceUpdateGenerator, ) } + priceUpdateDecoder := process.NewSlinkyMarketPriceDecoder( + process.NewDefaultUpdateMarketPriceTxDecoder(app.PricesKeeper, app.txConfig.TxDecoder()), + priceUpdateGenerator, + ) + + // if the node is a NonValidatingFullNode, we don't need to run any of the oracle code + if !appFlags.NonValidatingFullNode { + if app.oracleMetrics == nil { + app.oracleMetrics = app.initOracleMetrics(appOpts) + } + app.initOracle(priceUpdateDecoder) + } + + if app.oracleMetrics == nil { + app.oracleMetrics = servicemetrics.NewNopMetrics() + } + // ProcessProposal setup. - priceUpdateDecoder := process.NewDefaultUpdateMarketPriceTxDecoder(app.PricesKeeper, app.txConfig.TxDecoder()) + var dydxProcessProposalHandler sdk.ProcessProposalHandler if appFlags.NonValidatingFullNode { // Note: If the command-line flag `--non-validating-full-node` is enabled, this node will use // an implementation of `ProcessProposal` which always returns `abci.ResponseProcessProposal_ACCEPT`. // Full-nodes do not participate in consensus, and therefore should not participate in voting / `ProcessProposal`. - app.SetProcessProposal( - process.FullNodeProcessProposalHandler( - txConfig, - app.BridgeKeeper, - app.ClobKeeper, - app.StakingKeeper, - app.PerpetualsKeeper, - priceUpdateDecoder, - ), + dydxProcessProposalHandler = process.FullNodeProcessProposalHandler( + txConfig, + app.BridgeKeeper, + app.ClobKeeper, + app.StakingKeeper, + app.PerpetualsKeeper, + priceUpdateDecoder, ) } else { - app.SetProcessProposal( - process.ProcessProposalHandler( - txConfig, - app.BridgeKeeper, - app.ClobKeeper, - app.StakingKeeper, - app.PerpetualsKeeper, - app.PricesKeeper, - priceUpdateDecoder, - ), + dydxProcessProposalHandler = process.ProcessProposalHandler( + txConfig, + app.BridgeKeeper, + app.ClobKeeper, + app.StakingKeeper, + app.PerpetualsKeeper, + app.PricesKeeper, + priceUpdateDecoder, ) } + proposalHandler := slinkyproposals.NewProposalHandler( + logger, + dydxPrepareProposalHandler, + dydxProcessProposalHandler, + ve.NewDefaultValidateVoteExtensionsFn(app.ChainID(), app.StakingKeeper), + veCodec, + extCommitCodec, + strategy, + app.oracleMetrics, + slinkyproposals.RetainOracleDataInWrappedProposalHandler(), + ) + + app.SetPrepareProposal(proposalHandler.PrepareProposalHandler()) + app.SetProcessProposal(proposalHandler.ProcessProposalHandler()) + // Note that panics from out of gas errors won't get logged, since the `OutOfGasMiddleware` is added in front of this, // so error will get handled by that middleware and subsequent middlewares won't get executed. // Also note that `AddRunTxRecoveryHandler` adds the handler in reverse order, meaning that handlers that appear @@ -1426,8 +1488,7 @@ func New( return app } -func (app *App) initSlinkySidecarClient(appOpts servertypes.AppOptions) oracleclient.OracleClient { - // Slinky setup +func (app *App) initOracleMetrics(appOpts servertypes.AppOptions) servicemetrics.Metrics { cfg, err := oracleconfig.ReadConfigFromAppOpts(appOpts) if err != nil { panic(err) @@ -1436,11 +1497,35 @@ func (app *App) initSlinkySidecarClient(appOpts servertypes.AppOptions) oraclecl 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() + } + return oracleMetrics +} + +func (app *App) initSlinkySidecarClient(appOpts servertypes.AppOptions) oracleclient.OracleClient { // Create the oracle service. + if app.oracleMetrics == nil { + app.oracleMetrics = app.initOracleMetrics(appOpts) + } + cfg, err := oracleconfig.ReadConfigFromAppOpts(appOpts) + if err != nil { + panic(err) + } slinkyClient, err := oracleclient.NewClientFromConfig( cfg, app.Logger().With("client", "oracle"), - oracleMetrics, + app.oracleMetrics, ) if err != nil { panic(err) @@ -1448,6 +1533,31 @@ func (app *App) initSlinkySidecarClient(appOpts servertypes.AppOptions) oraclecl return slinkyClient } +func (app *App) initOracle(pricesTxDecoder process.UpdateMarketPriceTxDecoder) { + // Vote Extension setup. + slinkyVoteExtensionsHandler := ve.NewVoteExtensionHandler( + app.Logger(), + vote_extensions.NewOracleClient(app.PricesKeeper), + time.Second, + currencypair.NewDefaultCurrencyPairStrategy(app.PricesKeeper), + compression.NewCompressionVoteExtensionCodec( + compression.NewDefaultVoteExtensionCodec(), + compression.NewZLibCompressor(), + ), + app.PreBlocker, + app.oracleMetrics, + ) + + dydxExtendVoteHandler := vote_extensions.ExtendVoteHandler{ + SlinkyExtendVoteHandler: slinkyVoteExtensionsHandler.ExtendVoteHandler(), + PricesTxDecoder: pricesTxDecoder, + PricesKeeper: app.PricesKeeper, + } + + app.SetExtendVoteHandler(dydxExtendVoteHandler.ExtendVoteHandler()) + app.SetVerifyVoteExtensionHandler(slinkyVoteExtensionsHandler.VerifyVoteExtensionHandler()) +} + // RegisterDaemonWithHealthMonitor registers a daemon service with the update monitor, which will commence monitoring // the health of the daemon. If the daemon does not register, the method will panic. func (app *App) RegisterDaemonWithHealthMonitor( @@ -1699,9 +1809,7 @@ func (app *App) buildAnteHandler(txConfig client.TxConfig) sdk.AnteHandler { FeegrantKeeper: app.FeeGrantKeeper, SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - ClobKeeper: app.ClobKeeper, - Codec: app.appCodec, - AuthStoreKey: app.keys[authtypes.StoreKey], + ClobKeeper: app.ClobKeeper, }, ) if err != nil { @@ -1722,6 +1830,9 @@ func (app *App) setAnteHandler(txConfig client.TxConfig) { // Close invokes an ordered shutdown of routines. func (app *App) Close() error { app.BaseApp.Close() + if app.oraclePrometheusServer != nil { + app.oraclePrometheusServer.Close() + } return app.closeOnce() } diff --git a/protocol/cmd/dydxprotocold/cmd/config.go b/protocol/cmd/dydxprotocold/cmd/config.go index 422b37a9c6b..173c8e3995e 100644 --- a/protocol/cmd/dydxprotocold/cmd/config.go +++ b/protocol/cmd/dydxprotocold/cmd/config.go @@ -90,11 +90,6 @@ func initTendermintConfig() *tmcfg.Config { // Expose the Tendermint RPC. cfg.RPC.ListenAddress = "tcp://0.0.0.0:26657" cfg.RPC.CORSAllowedOrigins = []string{"*"} - // goroutine profiling showed that we were using exactly 900 threads (the default) which was throttling - // the maximum amount of load that the process could take. As of the last load test, at max QPS we were - // seeing ~1700 threads being used. - cfg.RPC.MaxOpenConnections = 4000 - cfg.RPC.GRPCMaxOpenConnections = 4000 // Mempool config. // We specifically are using a number greater than max QPS (currently set at 5000) * ShortBlockWindow to prevent diff --git a/protocol/daemons/slinky/client/market_pair_fetcher.go b/protocol/daemons/slinky/client/market_pair_fetcher.go index c80169304a5..9014d4c64ec 100644 --- a/protocol/daemons/slinky/client/market_pair_fetcher.go +++ b/protocol/daemons/slinky/client/market_pair_fetcher.go @@ -8,7 +8,7 @@ import ( "cosmossdk.io/log" "google.golang.org/grpc" - oracletypes "github.com/skip-mev/slinky/x/oracle/types" + oracletypes "github.com/skip-mev/slinky/pkg/types" appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" daemontypes "github.com/dydxprotocol/v4-chain/protocol/daemons/types" diff --git a/protocol/daemons/slinky/client/market_pair_fetcher_test.go b/protocol/daemons/slinky/client/market_pair_fetcher_test.go index 18c511ec829..34cacb3967d 100644 --- a/protocol/daemons/slinky/client/market_pair_fetcher_test.go +++ b/protocol/daemons/slinky/client/market_pair_fetcher_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - slinkytypes "github.com/skip-mev/slinky/x/oracle/types" + slinkytypes "github.com/skip-mev/slinky/pkg/types" "github.com/dydxprotocol/v4-chain/protocol/daemons/slinky/client" "github.com/dydxprotocol/v4-chain/protocol/mocks" diff --git a/protocol/daemons/slinky/client/price_fetcher.go b/protocol/daemons/slinky/client/price_fetcher.go index 752bbe04a7e..fb75d7ba98d 100644 --- a/protocol/daemons/slinky/client/price_fetcher.go +++ b/protocol/daemons/slinky/client/price_fetcher.go @@ -8,9 +8,9 @@ import ( "cosmossdk.io/log" "google.golang.org/grpc" + oracletypes "github.com/skip-mev/slinky/pkg/types" oracleclient "github.com/skip-mev/slinky/service/clients/oracle" "github.com/skip-mev/slinky/service/servers/oracle/types" - oracletypes "github.com/skip-mev/slinky/x/oracle/types" "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/api" daemontypes "github.com/dydxprotocol/v4-chain/protocol/daemons/types" diff --git a/protocol/lib/slinky/utils.go b/protocol/lib/slinky/utils.go index 5b5c6a5eff0..1a3417a9ccb 100644 --- a/protocol/lib/slinky/utils.go +++ b/protocol/lib/slinky/utils.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/skip-mev/slinky/x/oracle/types" + "github.com/skip-mev/slinky/pkg/types" ) /* diff --git a/protocol/lib/slinky/utils_test.go b/protocol/lib/slinky/utils_test.go index 7756cacc395..a2ee405e4bd 100644 --- a/protocol/lib/slinky/utils_test.go +++ b/protocol/lib/slinky/utils_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/skip-mev/slinky/x/oracle/types" + "github.com/skip-mev/slinky/pkg/types" "github.com/stretchr/testify/require" "github.com/dydxprotocol/v4-chain/protocol/lib/slinky" diff --git a/protocol/mocks/MarketPairFetcher.go b/protocol/mocks/MarketPairFetcher.go index 9e1a43ce2d5..eada02f661e 100644 --- a/protocol/mocks/MarketPairFetcher.go +++ b/protocol/mocks/MarketPairFetcher.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. +// Code generated by mockery v2.42.0. DO NOT EDIT. package mocks @@ -10,7 +10,7 @@ import ( mock "github.com/stretchr/testify/mock" - types "github.com/skip-mev/slinky/x/oracle/types" + types "github.com/skip-mev/slinky/pkg/types" ) // MarketPairFetcher is an autogenerated mock type for the MarketPairFetcher type diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index 7d8175b088b..6c49f6cc415 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -77,8 +77,9 @@ function edit_genesis() { dasel put -t string -f "$GENESIS" '.genesis_time' -v "$GENESIS_TIME" # Consensus params - dasel put -t string -f "$GENESIS" '.consensus_params.block.max_bytes' -v '4194304' - dasel put -t string -f "$GENESIS" '.consensus_params.block.max_gas' -v '-1' + dasel put -t string -f "$GENESIS" '.consensus.params.block.max_bytes' -v '4194304' + dasel put -t string -f "$GENESIS" '.consensus.params.block.max_gas' -v '-1' + dasel put -t string -f "$GENESIS" '.consensus.params.abci.vote_extensions_enable_height' -v '1' # Update crisis module. dasel put -t string -f "$GENESIS" '.app_state.crisis.constant_fee.denom' -v "$NATIVE_TOKEN" @@ -178,7 +179,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[0].params.atomic_resolution' -v '-10' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[0].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[0].params.liquidity_tier' -v '0' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[0].params.market_type' -v '1' # Perpetual: ETH-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -188,7 +188,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[1].params.atomic_resolution' -v '-9' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[1].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[1].params.liquidity_tier' -v '0' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[1].params.market_type' -v '1' # Perpetual: LINK-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -198,7 +197,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[2].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[2].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[2].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[2].params.market_type' -v '1' # Perpetual: MATIC-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -208,7 +206,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[3].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[3].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[3].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[3].params.market_type' -v '1' # Perpetual: CRV-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -218,7 +215,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[4].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[4].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[4].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[4].params.market_type' -v '1' # Perpetual: SOL-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -228,7 +224,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[5].params.atomic_resolution' -v '-7' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[5].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[5].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[5].params.market_type' -v '1' # Perpetual: ADA-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -238,7 +233,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[6].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[6].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[6].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[6].params.market_type' -v '1' # Perpetual: AVAX-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -248,7 +242,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[7].params.atomic_resolution' -v '-7' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[7].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[7].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[7].params.market_type' -v '1' # Perpetual: FIL-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -258,7 +251,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[8].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[8].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[8].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[8].params.market_type' -v '1' # Perpetual: LTC-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -268,7 +260,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[9].params.atomic_resolution' -v '-7' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[9].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[9].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[9].params.market_type' -v '1' # Perpetual: DOGE-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -278,7 +269,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[10].params.atomic_resolution' -v '-4' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[10].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[10].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[10].params.market_type' -v '1' # Perpetual: ATOM-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -288,7 +278,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[11].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[11].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[11].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[11].params.market_type' -v '1' # Perpetual: DOT-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -298,7 +287,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[12].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[12].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[12].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[12].params.market_type' -v '1' # Perpetual: UNI-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -308,7 +296,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[13].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[13].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[13].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[13].params.market_type' -v '1' # Perpetual: BCH-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -318,7 +305,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[14].params.atomic_resolution' -v '-8' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[14].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[14].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[14].params.market_type' -v '1' # Perpetual: TRX-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -328,7 +314,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[15].params.atomic_resolution' -v '-4' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[15].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[15].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[15].params.market_type' -v '1' # Perpetual: NEAR-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -338,7 +323,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[16].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[16].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[16].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[16].params.market_type' -v '1' # Perpetual: MKR-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -348,7 +332,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[17].params.atomic_resolution' -v '-9' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[17].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[17].params.liquidity_tier' -v '2' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[17].params.market_type' -v '1' # Perpetual: XLM-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -358,7 +341,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[18].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[18].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[18].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[18].params.market_type' -v '1' # Perpetual: ETC-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -368,7 +350,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[19].params.atomic_resolution' -v '-7' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[19].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[19].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[19].params.market_type' -v '1' # Perpetual: COMP-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -378,7 +359,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[20].params.atomic_resolution' -v '-7' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[20].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[20].params.liquidity_tier' -v '2' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[20].params.market_type' -v '1' # Perpetual: WLD-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -388,7 +368,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[21].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[21].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[21].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[21].params.market_type' -v '1' # Perpetual: APE-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -398,7 +377,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[22].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[22].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[22].params.liquidity_tier' -v '2' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[22].params.market_type' -v '1' # Perpetual: APT-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -408,7 +386,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[23].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[23].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[23].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[23].params.market_type' -v '1' # Perpetual: ARB-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -418,7 +395,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[24].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[24].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[24].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[24].params.market_type' -v '1' # Perpetual: BLUR-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -428,7 +404,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[25].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[25].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[25].params.liquidity_tier' -v '2' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[25].params.market_type' -v '1' # Perpetual: LDO-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -438,7 +413,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[26].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[26].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[26].params.liquidity_tier' -v '2' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[26].params.market_type' -v '1' # Perpetual: OP-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -448,7 +422,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[27].params.atomic_resolution' -v '-6' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[27].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[27].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[27].params.market_type' -v '1' # Perpetual: PEPE-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -458,7 +431,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[28].params.atomic_resolution' -v '1' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[28].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[28].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[28].params.market_type' -v '1' # Perpetual: SEI-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -468,7 +440,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[29].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[29].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[29].params.liquidity_tier' -v '2' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[29].params.market_type' -v '1' # Perpetual: SHIB-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -478,7 +449,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[30].params.atomic_resolution' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[30].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[30].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[30].params.market_type' -v '1' # Perpetual: SUI-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -488,7 +458,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[31].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[31].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[31].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[31].params.market_type' -v '1' # Perpetual: XRP-USD dasel put -t json -f "$GENESIS" '.app_state.perpetuals.perpetuals.[]' -v "{}" @@ -498,7 +467,6 @@ function edit_genesis() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[32].params.atomic_resolution' -v '-5' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[32].params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[32].params.liquidity_tier' -v '1' - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.[32].params.market_type' -v '1' # Update prices module. # Market: BTC-USD @@ -1604,8 +1572,6 @@ function update_genesis_use_test_volatile_market() { dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.last().params.atomic_resolution' -v '-10' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.last().params.default_funding_ppm' -v '0' dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.last().params.liquidity_tier' -v "${NUM_LIQUIDITY_TIERS}" - dasel put -t int -f "$GENESIS" '.app_state.perpetuals.perpetuals.last().params.market_type' -v '1' - # Clob: TEST-USD NUM_CLOB_PAIRS=$(jq -c '.app_state.clob.clob_pairs | length' < ${GENESIS}) diff --git a/protocol/testing/testnet-local/local.sh b/protocol/testing/testnet-local/local.sh index 68986821184..1dc5dfc1341 100755 --- a/protocol/testing/testnet-local/local.sh +++ b/protocol/testing/testnet-local/local.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -eo pipefail +set -exo pipefail # This file initializes muliple validators for local and CI testing purposes. # This file should be run as part of `docker-compose.yml`.