Skip to content

Commit

Permalink
[CORE-658] Remove telemetry from x/prices/EndBlocker and rename ind…
Browse files Browse the repository at this point in the history
…exer event method (#569)

* rename, cleanup

* nit
  • Loading branch information
ttl33 authored Oct 11, 2023
1 parent 774cab3 commit 05da3b2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion protocol/testutil/keeper/prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func AssertPriceUpdateEventsInIndexerBlock(
updatedMarketPrices []types.MarketPrice,
) {
marketEvents := getMarketEventsFromIndexerBlock(ctx, k)
expectedEvents := keeper.GenerateMarketPriceUpdateEvents(updatedMarketPrices)
expectedEvents := keeper.GenerateMarketPriceUpdateIndexerEvents(updatedMarketPrices)
for _, expectedEvent := range expectedEvents {
require.Contains(t, marketEvents, expectedEvent)
}
Expand Down
10 changes: 5 additions & 5 deletions protocol/x/prices/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/dydxprotocol/v4-chain/protocol/x/prices/types"
)

// InitGenesis initializes the capability module's state from a provided genesis
// InitGenesis initializes the x/prices module's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
k.InitializeForGenesis(ctx)
Expand All @@ -18,14 +18,14 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
}

// Set all the market params and prices.
for i, elem := range genState.MarketParams {
if _, err := k.CreateMarket(ctx, elem, genState.MarketPrices[i]); err != nil {
for i, param := range genState.MarketParams {
if _, err := k.CreateMarket(ctx, param, genState.MarketPrices[i]); err != nil {
panic(err)
}
}

marketPriceUpdates := keeper.GenerateMarketPriceUpdateEvents(genState.MarketPrices)
for _, update := range marketPriceUpdates {
priceUpdateIndexerEvents := keeper.GenerateMarketPriceUpdateIndexerEvents(genState.MarketPrices)
for _, update := range priceUpdateIndexerEvents {
k.GetIndexerEventManager().AddTxnEvent(
ctx,
indexerevents.SubtypeMarket,
Expand Down
7 changes: 5 additions & 2 deletions protocol/x/prices/keeper/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import (
"github.com/dydxprotocol/v4-chain/protocol/x/prices/types"
)

// GenerateMarketPriceUpdateEvents takes in a slice of market prices and returns a slice of price updates.
func GenerateMarketPriceUpdateEvents(markets []types.MarketPrice) []*indexerevents.MarketEventV1 {
// GenerateMarketPriceUpdateIndexerEvents takes in a slice of market prices
// and returns a slice of price updates.
func GenerateMarketPriceUpdateIndexerEvents(
markets []types.MarketPrice,
) []*indexerevents.MarketEventV1 {
events := make([]*indexerevents.MarketEventV1, 0, len(markets))
for _, market := range markets {
events = append(
Expand Down
4 changes: 2 additions & 2 deletions protocol/x/prices/keeper/market_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func (k Keeper) UpdateMarketPrices(
)
}

marketPriceUpdates := GenerateMarketPriceUpdateEvents(updatedMarketPrices)
for _, update := range marketPriceUpdates {
priceUpdateIndexerEvents := GenerateMarketPriceUpdateIndexerEvents(updatedMarketPrices)
for _, update := range priceUpdateIndexerEvents {
k.GetIndexerEventManager().AddTxnEvent(
ctx,
indexerevents.SubtypeMarket,
Expand Down
8 changes: 2 additions & 6 deletions protocol/x/prices/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand All @@ -15,7 +14,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/dydxprotocol/v4-chain/protocol/x/prices/client/cli"
Expand Down Expand Up @@ -158,12 +156,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
// ConsensusVersion implements ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

// BeginBlock executes all ABCI BeginBlock logic respective to the prices module.
// BeginBlock is no-op.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}

// EndBlock executes all ABCI EndBlock logic respective to the prices module. It
// returns no validator updates.
// EndBlock is no-op.It returns no validator updates.
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
defer telemetry.ModuleMeasureSince(am.Name(), time.Now(), telemetry.MetricKeyEndBlocker)
return []abci.ValidatorUpdate{}
}

0 comments on commit 05da3b2

Please sign in to comment.