Skip to content

Commit bf4c269

Browse files
authored
change supported feeds to current feeds (#183)
1 parent c7800ac commit bf4c269

29 files changed

+464
-463
lines changed

benchmark/feeds_bench_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func BenchmarkSubmitSignalPricesDeliver(b *testing.B) {
7676
ba.TxConfig,
7777
GenMsgSubmitSignalPrices(
7878
val,
79-
ba.FeedsKeeper.GetSupportedFeeds(ba.Ctx).Feeds,
79+
ba.FeedsKeeper.GetCurrentFeeds(ba.Ctx).Feeds,
8080
ba.Ctx.BlockTime().Unix(),
8181
),
8282
val,
@@ -135,7 +135,7 @@ func BenchmarkFeedsEndBlock(b *testing.B) {
135135
}
136136

137137
func setupFeeds(ba *BenchmarkApp) error {
138-
numFeeds := ba.FeedsKeeper.GetParams(ba.Ctx).MaxSupportedFeeds
138+
numFeeds := ba.FeedsKeeper.GetParams(ba.Ctx).MaxCurrentFeeds
139139

140140
ba.CallBeginBlock()
141141

@@ -146,7 +146,7 @@ func setupFeeds(ba *BenchmarkApp) error {
146146
Interval: 60,
147147
})
148148
}
149-
ba.FeedsKeeper.SetSupportedFeeds(ba.Ctx, feeds)
149+
ba.FeedsKeeper.SetCurrentFeeds(ba.Ctx, feeds)
150150

151151
ba.CallEndBlock()
152152
ba.Commit()
@@ -155,7 +155,7 @@ func setupFeeds(ba *BenchmarkApp) error {
155155
}
156156

157157
func setupValidatorPriceList(ba *BenchmarkApp, vals []*Account) error {
158-
sfs := ba.FeedsKeeper.GetSupportedFeeds(ba.Ctx)
158+
sfs := ba.FeedsKeeper.GetCurrentFeeds(ba.Ctx)
159159

160160
ba.CallBeginBlock()
161161
for valIdx, val := range vals {
@@ -181,7 +181,7 @@ func setupValidatorPriceList(ba *BenchmarkApp, vals []*Account) error {
181181
}
182182

183183
func setupValidatorPrices(ba *BenchmarkApp, vals []*Account) error {
184-
sfs := ba.FeedsKeeper.GetSupportedFeeds(ba.Ctx)
184+
sfs := ba.FeedsKeeper.GetCurrentFeeds(ba.Ctx)
185185

186186
ba.CallBeginBlock()
187187
for valIdx, val := range vals {

grogu/querier/feed.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ func (q *FeedQuerier) QueryParams() (*feeds.QueryParamsResponse, error) {
7979
return getMaxBlockHeightResponse(fs, &in)
8080
}
8181

82-
func (q *FeedQuerier) QuerySupportedFeeds() (*feeds.QuerySupportedFeedsResponse, error) {
82+
func (q *FeedQuerier) QueryCurrentFeeds() (*feeds.QueryCurrentFeedsResponse, error) {
8383
fs := make(
84-
[]QueryFunction[feeds.QuerySupportedFeedsRequest, feeds.QuerySupportedFeedsResponse],
84+
[]QueryFunction[feeds.QueryCurrentFeedsRequest, feeds.QueryCurrentFeedsResponse],
8585
0,
8686
len(q.queryClients),
8787
)
8888
for _, queryClient := range q.queryClients {
89-
fs = append(fs, queryClient.SupportedFeeds)
89+
fs = append(fs, queryClient.CurrentFeeds)
9090
}
9191

92-
in := feeds.QuerySupportedFeedsRequest{}
92+
in := feeds.QueryCurrentFeedsRequest{}
9393
return getMaxBlockHeightResponse(fs, &in)
9494
}

grogu/signaller/signaller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ func (h *Signaller) updateParams() bool {
129129
}
130130

131131
func (h *Signaller) updateFeedMap() bool {
132-
resp, err := h.feedQuerier.QuerySupportedFeeds()
132+
resp, err := h.feedQuerier.QueryCurrentFeeds()
133133
if err != nil {
134134
h.logger.Error("[Signaller] failed to query supported feeds: %v", err)
135135
return false
136136
}
137137

138-
h.signalIDToFeed = sliceToMap(resp.SupportedFeeds.Feeds, func(feed types.FeedWithDeviation) string {
138+
h.signalIDToFeed = sliceToMap(resp.CurrentFeeds.Feeds, func(feed types.FeedWithDeviation) string {
139139
return feed.SignalID
140140
})
141141

proto/feeds/v1beta1/feeds.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ message FeedWithDeviation {
5959
int64 deviation_basis_point = 4;
6060
}
6161

62-
// SupportedFeeds is a structure that holds a list of currently supported feeds, and its last update time and block.
63-
message SupportedFeeds {
62+
// CurrentFeeds is a structure that holds a list of currently supported feeds, and its last update time and block.
63+
message CurrentFeeds {
6464
option (gogoproto.equal) = true;
6565

6666
// Feeds is a list of currently suppored feeds.
@@ -73,9 +73,9 @@ message SupportedFeeds {
7373
int64 last_update_block = 3;
7474
}
7575

76-
// SupportedFeedWithDeviations is a structure that holds a list of currently supported feed-with-deviations, and its
76+
// CurrentFeedWithDeviations is a structure that holds a list of currently supported feed-with-deviations, and its
7777
// last update time and block.
78-
message SupportedFeedWithDeviations {
78+
message CurrentFeedWithDeviations {
7979
option (gogoproto.equal) = true;
8080

8181
// FeedWithDeviations is a list of currently suppored feed-with-deviations.

proto/feeds/v1beta1/params.proto

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ message Params {
2626
int64 min_interval = 4;
2727

2828
// MaxInterval is the maximum limit of every feeds' interval (in seconds).
29-
// If the calculated interval of a feed is higher than this, it will not be recognized as a supported feed.
29+
// If the calculated interval of a feed is higher than this, it will not be capped at this value.
3030
int64 max_interval = 5;
3131

32-
// PowerStepThreshold is the amount of minimum power required to put feed in the supported list.
32+
// PowerStepThreshold is the amount of minimum power required to put feed in the current feeds list.
3333
int64 power_step_threshold = 6;
3434

35-
// MaxSupportedFeeds is the maximum number of feeds supported at a time.
36-
uint64 max_supported_feeds = 7;
35+
// MaxCurrentFeeds is the maximum number of feeds supported at a time.
36+
uint64 max_current_feeds = 7;
3737

3838
// CooldownTime represents the duration (in seconds) during which validators are prohibited from sending new prices.
3939
int64 cooldown_time = 8;
@@ -44,6 +44,6 @@ message Params {
4444
// MaxDeviationBasisPoint is the maximum limit of every feeds' deviation (in basis point).
4545
int64 max_deviation_basis_point = 10;
4646

47-
// SupportedFeedsUpdateInterval is the number of blocks after which the supported feeds will be re-calculated.
48-
int64 supported_feeds_update_interval = 11;
47+
// CurrentFeedsUpdateInterval is the number of blocks after which the current feeds will be re-calculated.
48+
int64 current_feeds_update_interval = 11;
4949
}

proto/feeds/v1beta1/query.proto

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ service Query {
5353
option (google.api.http).get = "/feeds/v1beta1/delegators/{delegator}/signals";
5454
}
5555

56-
// SupportedFeeds is an RPC method that returns a list of current supported feeds
57-
rpc SupportedFeeds(QuerySupportedFeedsRequest) returns (QuerySupportedFeedsResponse) {
56+
// CurrentFeeds is an RPC method that returns a list of current supported feeds
57+
rpc CurrentFeeds(QueryCurrentFeedsRequest) returns (QueryCurrentFeedsResponse) {
5858
option (google.api.http).get = "/feeds/v1beta1/supported-feeds";
5959
}
6060

@@ -169,14 +169,14 @@ message QueryDelegatorSignalsResponse {
169169
repeated Signal signals = 1 [(gogoproto.nullable) = false];
170170
}
171171

172-
// QuerySupportedFeedsRequest is the request type for the Query/SupportedFeeds RPC method
173-
message QuerySupportedFeedsRequest {}
172+
// QueryCurrentFeedsRequest is the request type for the Query/CurrentFeeds RPC method
173+
message QueryCurrentFeedsRequest {}
174174

175-
// QuerySupportedFeedsResponse is the response type for the Query/SupportedFeeds RPC method
176-
message QuerySupportedFeedsResponse {
177-
// SupportedFeeds is a list of currently supported feed-with-deviations, and its last update time and
175+
// QueryCurrentFeedsResponse is the response type for the Query/CurrentFeeds RPC method
176+
message QueryCurrentFeedsResponse {
177+
// CurrentFeeds is a list of currently supported feed-with-deviations, and its last update time and
178178
// block.
179-
SupportedFeedWithDeviations supported_feeds = 1 [(gogoproto.nullable) = false];
179+
CurrentFeedWithDeviations current_feeds = 1 [(gogoproto.nullable) = false];
180180
}
181181

182182
// QueryIsFeederRequest is request type for the Query/IsFeeder RPC method.

scripts/generate_genesis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ sed -i -e \
4343
cat <<< $(jq '.app_state.gov.params.voting_period = "60s"' ~/.band/config/genesis.json) > ~/.band/config/genesis.json
4444

4545
# update blocks per feeds update to 10 blocks for testing
46-
cat <<< $(jq '.app_state.feeds.params.supported_feeds_update_interval = "10"' ~/.band/config/genesis.json) > ~/.band/config/genesis.json
46+
cat <<< $(jq '.app_state.feeds.params.current_feeds_update_interval = "10"' ~/.band/config/genesis.json) > ~/.band/config/genesis.json

x/feeds/README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ This module is used in the BandChain.
1919
- [Feed Interval](#feed-interval)
2020
- [Feed Deviation](#feed-deviation)
2121
- [How Feed Interval and Deviation are calculated](#how-feed-interval-and-deviation-are-calculated)
22-
- [Supported Feeds](#supported-feeds)
22+
- [Current Feeds](#current-feeds)
2323
- [Validator Price](#validator-price)
2424
- [Price](#price)
2525
- [Reference Source Config](#reference-source-config)
2626
- [State](#state)
2727
- [ReferenceSourceConfig](#referencesourceconfig)
28-
- [SupportedFeeds](#supportedfeeds)
28+
- [CurrentFeeds](#currentfeeds)
2929
- [ValidatorPriceList](#validatorpricelist)
3030
- [Price](#price-1)
3131
- [DelegatorSignal](#delegatorsignal)
@@ -43,7 +43,7 @@ This module is used in the BandChain.
4343
- [Objective](#objective)
4444
- [Assumption](#assumption)
4545
- [Procedure](#procedure)
46-
- [Update supported feeds](#update-supported-feeds)
46+
- [Update current feeds](#update-current-feeds)
4747
- [Events](#events)
4848
- [EndBlocker](#endblocker)
4949
- [Handlers](#handlers)
@@ -84,9 +84,9 @@ It should be noted that while feed deviation is calculated, it is only used as a
8484

8585
You can visualize the interval/deviation as resembling the harmonic series times MaxInterval/MaxDeviationBasisPoint, with the step of PowerStepThreshold.
8686

87-
#### Supported Feeds
87+
#### Current Feeds
8888

89-
The list of currently supported feeds includes those with power exceeding the PowerStepThreshold parameter and ranking within the top `MaxSupportedFeeds`. The supported feeds will be re-calculated on every `SupportedFeedsUpdateInterval` block(s). Validators are only required to submit their prices for the supported feeds.
89+
The list of currently supported feeds includes those with power exceeding the PowerStepThreshold parameter and ranking within the top `MaxCurrentFeeds`. The current feeds will be re-calculated on every `CurrentFeedsUpdateInterval` block(s). Validators are only required to submit their prices for the current feeds.
9090

9191
### Validator Price
9292

@@ -114,11 +114,11 @@ ReferenceSourceConfig is stored in the global store `0x00` to hold Reference Sou
114114

115115
* ReferenceSourceConfig: `0x00 | []byte("ReferenceSourceConfig") -> ProtocolBuffer(ReferenceSourceConfig)`
116116

117-
### SupportedFeeds
117+
### CurrentFeeds
118118

119-
SupportedFeeds is stored in the global store `0x00` to hold the list of supported feeds.
119+
CurrentFeeds is stored in the global store `0x00` to hold the list of currently supported feeds.
120120

121-
* SupportedFeeds: `0x00 | []byte("SupportedFeeds") -> ProtocolBuffer(SupportedFeeds)`
121+
* CurrentFeeds: `0x00 | []byte("CurrentFeeds") -> ProtocolBuffer(CurrentFeeds)`
122122

123123
### ValidatorPriceList
124124

@@ -177,14 +177,14 @@ message Params {
177177
int64 min_interval = 4;
178178
179179
// MaxInterval is the maximum limit of every feeds' interval (in seconds).
180-
// If the calculated interval of a feed is higher than this, it will not be recognized as a supported feed.
180+
// If the calculated interval of a feed is higher than this, it will not be capped at this value.
181181
int64 max_interval = 5;
182182
183-
// PowerStepThreshold is the amount of minimum power required to put feed in the supported list.
183+
// PowerStepThreshold is the amount of minimum power required to put feed in the current feeds list.
184184
int64 power_step_threshold = 6;
185185
186-
// MaxSupportedFeeds is the maximum number of feeds supported at a time.
187-
int64 max_supported_feeds = 7;
186+
// MaxCurrentFeeds is the maximum number of feeds supported at a time.
187+
uint64 max_current_feeds = 7;
188188
189189
// CooldownTime represents the duration (in seconds) during which validators are prohibited from sending new prices.
190190
int64 cooldown_time = 8;
@@ -195,8 +195,8 @@ message Params {
195195
// MaxDeviationBasisPoint is the maximum limit of every feeds' deviation (in basis point).
196196
int64 max_deviation_basis_point = 10;
197197
198-
// SupportedFeedsUpdateInterval is the number of blocks after which the supported feeds will be re-calculated.
199-
uint64 supported_feeds_update_interval = 11;
198+
// CurrentFeedsUpdateInterval is the number of blocks after which the current feeds will be re-calculated.
199+
int64 current_feeds_update_interval = 11;
200200
}
201201
```
202202

@@ -233,7 +233,7 @@ This message is expected to fail if:
233233
* validator's oracle status is not active.
234234
* timestamp is too different from block time.
235235
* the price is submitted in the `CooldownTime` param.
236-
* the signals of the prices are not in the supported feeds.
236+
* the signals of the prices are not in the current feeds.
237237

238238
### MsgUpdateReferenceSourceConfig
239239

@@ -315,8 +315,8 @@ Each abci end block call, the operations to update prices.
315315

316316
### Update Prices
317317

318-
At every end block, the Validator Price of all supported feeds will be obtained and checked if it is within the acceptance period (1 interval).
319-
Any validator that does not submit a price within this period is considered to have miss-reported and will be deactivated unless the Supported feeds are in a grace period.
318+
At every end block, the Validator Price of all current feeds will be obtained and checked if it is within the acceptance period (1 interval).
319+
Any validator that does not submit a price within this period is considered to have miss-reported and will be deactivated unless the current feeds are in a grace period.
320320
Accepted Validator Prices of the same SignalID will be weighted and median based on the recency of the price and the power of the validator who submitted the price.
321321
The median price is then set as the Price. Here is the price aggregation logic:
322322

@@ -366,25 +366,25 @@ A list of PriceFeedInfo objects, each containing:
366366
- Compute the weighted median of the generated points to determine the final aggregated price.
367367
- The weighted median price is the price at which the cumulative power (sorted by increasing price) crosses half of the total weighted power.
368368

369-
### Update supported feeds
369+
### Update current feeds
370370

371-
At every `BlocksPerFeedsUpdate` block(s), the supported feeds will be re-calculated based on the parameters of the module (e.g. `MinInterval`, `MaxSupportedFeeds`).
371+
At every `BlocksPerFeedsUpdate` block(s), the current feeds will be re-calculated based on the parameters of the module (e.g. `MinInterval`, `MaxCurrentFeeds`).
372372

373373
## Events
374374

375375
The feeds module emits the following events:
376376

377377
### EndBlocker
378378

379-
| Type | Attribute Key | Attribute Value |
380-
| ----------------------- | --------------------- | --------------- |
381-
| calculate_price_failed | signal_id | {signalID} |
382-
| calculate_price_failed | error_message | {error} |
383-
| update_price | signal_id | {signalID} |
384-
| update_price | price | {price} |
385-
| update_price | timestamp | {timestamp} |
386-
| updated_supported_feeds | last_update_timestamp | {timestamp} |
387-
| updated_supported_feeds | last_update_block | {block_height} |
379+
| Type | Attribute Key | Attribute Value |
380+
| ---------------------- | --------------------- | --------------- |
381+
| calculate_price_failed | signal_id | {signalID} |
382+
| calculate_price_failed | error_message | {error} |
383+
| update_price | signal_id | {signalID} |
384+
| update_price | price | {price} |
385+
| update_price | timestamp | {timestamp} |
386+
| updated_current_feeds | last_update_timestamp | {timestamp} |
387+
| updated_current_feeds | last_update_block | {block_height} |
388388

389389
### Handlers
390390

x/feeds/abci.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
// HandleEndBlock is a handler function for the EndBlock ABCI request.
1010
func HandleEndBlock(ctx sdk.Context, k keeper.Keeper) {
1111
k.CalculatePrices(ctx)
12-
if ctx.BlockHeight()%k.GetParams(ctx).SupportedFeedsUpdateInterval == 0 {
13-
feeds := k.CalculateNewSupportedFeeds(ctx)
14-
k.SetSupportedFeeds(ctx, feeds)
12+
if ctx.BlockHeight()%k.GetParams(ctx).CurrentFeedsUpdateInterval == 0 {
13+
feeds := k.CalculateNewCurrentFeeds(ctx)
14+
k.SetCurrentFeeds(ctx, feeds)
1515
}
1616
}

x/feeds/client/cli/query.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func GetQueryCmd() *cobra.Command {
2828
GetQueryCmdSignalTotalPowers(),
2929
GetQueryCmdParams(),
3030
GetQueryCmdDelegatorSignal(),
31-
GetQueryCmdSupportedFeeds(),
31+
GetQueryCmdCurrentFeeds(),
3232
GetQueryCmdIsFeeder(),
3333
)
3434

@@ -118,17 +118,17 @@ func GetQueryCmdPrice() *cobra.Command {
118118
return cmd
119119
}
120120

121-
// GetQueryCmdSupportedFeeds implements the query supported feeds command.
122-
func GetQueryCmdSupportedFeeds() *cobra.Command {
121+
// GetQueryCmdCurrentFeeds implements the query current feeds command.
122+
func GetQueryCmdCurrentFeeds() *cobra.Command {
123123
cmd := &cobra.Command{
124-
Use: "supported-feeds",
124+
Use: "current-feeds",
125125
Short: "Shows all currently supported feeds",
126126
Args: cobra.NoArgs,
127127
RunE: func(cmd *cobra.Command, args []string) error {
128128
clientCtx := client.GetClientContextFromCmd(cmd)
129129
queryClient := types.NewQueryClient(clientCtx)
130130

131-
res, err := queryClient.SupportedFeeds(context.Background(), &types.QuerySupportedFeedsRequest{})
131+
res, err := queryClient.CurrentFeeds(context.Background(), &types.QueryCurrentFeedsRequest{})
132132
if err != nil {
133133
return err
134134
}

0 commit comments

Comments
 (0)