Skip to content

Query CLI & gRPC for Standard Price Reference#86

Merged
taobun merged 5 commits intomasterfrom
nathachai/query-std-price
May 31, 2021
Merged

Query CLI & gRPC for Standard Price Reference#86
taobun merged 5 commits intomasterfrom
nathachai/query-std-price

Conversation

@ntchjb
Copy link
Copy Markdown
Contributor

@ntchjb ntchjb commented May 27, 2021

Fixed: BAND-241

Implementation details

This PR implement query CLI command and gRPC to query latest prices from standard price reference's oracle script. Every time when there is a new oracle request requesting data from standard price reference oracle script, the result will be stored in a local leveldb database, so that we can query the latest price from it.

Since every ways we send query to Bandchain (gRPC, REST of gRPC-gateway, CLI), all queries will be processed at ABCI's Query(). Therefore, new hook has been created to ApplyQuery() before the baseapp's Query() to perform custom query. In this case, we perform querying from our local leveldb.

Please ensure the following requirements are met before submitting a pull request:

  • The pull request is targeted against the correct target branch
  • The pull request is linked to an issue with appropriate discussion and an accepted design OR is linked to a spec that describes the work.
  • The pull request includes a description of the implementation/work done in detail.
  • The pull request includes any and all appropriate unit/integration tests
  • You have added a relevant changelog entry to CHANGELOG_UNRELEASED.md
  • You have re-reviewed the files affected by the pull request (e.g. using the Files changed tab in the Github PR explorer)

@ntchjb ntchjb requested review from Benzbeeb, songwongtp and taobun May 27, 2021 10:33
@@ -256,14 +256,22 @@ message QueryRequestPriceRequest {
// QueryRequestPriceResponse is response type for the Query/RequestPrice RPC
// method.
message QueryRequestPriceResponse {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request must be a list of symbols?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And response must be a list of Price struct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, but response will be an object with a field, which is a list of price results.

@ntchjb ntchjb requested a review from taobun May 27, 2021 14:50
Comment thread hooks/price/types.go
Comment thread hooks/price/types.go
@taobun taobun merged commit 1ab4d73 into master May 31, 2021
@taobun taobun deleted the nathachai/query-std-price branch May 31, 2021 09:15
taobun added a commit that referenced this pull request May 31, 2021
Query CLI & gRPC for Standard Price Reference
RogerKSI added a commit that referenced this pull request Nov 11, 2024
* first version

* update follow by spec

* fix typo

* add deactivate logic

* fix issues

* update name

* fix mistype

* adjust logic

* update config

* add more path

* add pagination logic

* update name and comment

* update comment

* update query path

* apply median

* refactor median

* update script

* update name

* add query path

* filter price vals

* add index in sorting

* remove comment

* Msg signal symbol (#63)

* make MsgSignalSymbols

* add signal related query, fix remove old signal bug

* add more params

* clean old symbol logic

* change signal msg to use new store

* implement interval calculation and update timestamp

* implement symbol index by power

* change hardcoded supportedSymbol num to param

* cleanup code & add comments

* rank by name for equal power

* add hook + fix typo

* delete print

* change endblock to only supported symbol, change delegation sum func

* accept price at interval minus transition time

* add transition time for changing interval

* fix from comments

* change set delegator signal type

---------

Co-authored-by: Warittorn Cheevachaipimol <warittorn@bandprotocol.com>

* fix path

* [!chore] Fix Lint (#72)

* checkpoint

* fix

* fix invincible before price exist

* fix from comments

* make signal cli be able to remove singal

* msg signalSymbols emit events

* implement new message functions for every messages

* fix chore

* fix

* fix name

* fix name

* refactor params & msg server

* fix from comments

* [feat][feeds] add submit price types (#93)

* add submit price types

* update comment

* update func filters

* update ValidateBasic

* add todo

---------

Co-authored-by: satawatnack <satawat@bandprotocol.com>

* fix from comments

* add comment to the proto file

* change symbol name to signal id, symbol to feed

* store only string in feed by power index

* validate signal of MsgSubmitSignals

* add feechecker test

* median return error, endblock emit event when failed

* fix from comments

* genesis export signals

* fix from comments

* separate cooldown time from transition time

* change ways to check is top validator

* implement deviation

* add block height to price validator

* change block height to last block hash

* remove last block hash from price validator

* fix bug no price option

* delete feed when power is zero, emit event when removing signal

* fix from comments

* add README.md

* fix from comments

* change internal error to not found

* implement new logic for msg submitsignals

* fix go.mod after merge confilct

* fix feechecker_test

* add function comments

* add hook for delegation remove

* fix readme and auto replace feed by power index

* fix setFeed bug

* fix from comments

* [Feeds] Fix merkle tree (#136)

* fix tree

* fix abi

* fix test

* [feeds] Module - Unit test (#86)

* add draft

* fix test

* final unit test first version

* adjust

* fix test

* fix test

* fix test

* fix from comment

* fix lint

* fix

* fix conflict

* fix test

* prevent dup

* fix keeper_test

* remove not used GetDelegation mock

* fix test

---------

Co-authored-by: colmazia <ongart.pisan@gmail.com>

* change file name and move constant

---------

Co-authored-by: Kitipong Sirirueangsakul <kitipong.sirir@gmail.com>
Co-authored-by: Warittorn Cheevachaipimol <warittorn@bandprotocol.com>
Co-authored-by: warittornc <69615455+warittornc@users.noreply.github.com>
Co-authored-by: satawat thitisupakul <s.nack1919@gmail.com>
Co-authored-by: satawatnack <satawat@bandprotocol.com>
RogerKSI added a commit that referenced this pull request Nov 11, 2024
* first version

* update follow by spec

* fix typo

* add deactivate logic

* fix issues

* update name

* fix mistype

* adjust logic

* update config

* add more path

* add pagination logic

* update name and comment

* update comment

* update query path

* initialize grogu

* change to new feeds module

* add adjusted gas

* connect to off chain price, query chain for symbols

* add checkSymbol function

* delete not used file, implement check symbols logic

* implement querySymbols, add retry in submitPrices, clean

* apply median

* refactor median

* cleanup

* fix from comments

* update script

* Combine prices & symbols

* update name

* update script

* change executor to price-service

* add query path

* filter price vals

* add index in sorting

* remove comment

* refactor code

* check validator validity

* add request timeout for rest price service

* fix case out of gas when broadcast but no error

* make MsgSignalSymbols

* add signal related query, fix remove old signal bug

* add more params

* clean old symbol logic

* change signal msg to use new store

* implement interval calculation and update timestamp

* implement symbol index by power

* change hardcoded supportedSymbol num to param

* cleanup code & add comments

* rank by name for equal power

* add hook + fix typo

* delete print

* change endblock to only supported symbol, change delegation sum func

* accept price at interval minus transition time

* support new signaled symbols

* add transition time for changing interval

* fix from comments

* change set delegator signal type

* Msg signal symbol (#63)

* make MsgSignalSymbols

* add signal related query, fix remove old signal bug

* add more params

* clean old symbol logic

* change signal msg to use new store

* implement interval calculation and update timestamp

* implement symbol index by power

* change hardcoded supportedSymbol num to param

* cleanup code & add comments

* rank by name for equal power

* add hook + fix typo

* delete print

* change endblock to only supported symbol, change delegation sum func

* accept price at interval minus transition time

* add transition time for changing interval

* fix from comments

* change set delegator signal type

---------

Co-authored-by: Warittorn Cheevachaipimol <warittorn@bandprotocol.com>

* fix path

* [!chore] Fix Lint (#72)

* checkpoint

* fix

* fix lint

* add from for estimate gas

* fix invincible before price exist

* fix from comments

* make signal cli be able to remove singal

* msg signalSymbols emit events

* implement new message functions for every messages

* fix chore

* fix

* fix name

* fix name

* fix from comments, restructure code

* refactor params & msg server

* fix from comments

* fix

* fix name

* fix name

* refactor params & msg server

* using queryClient in abci query

* [feat][feeds] add submit price types (#93)

* add submit price types

* update comment

* update func filters

* update ValidateBasic

* add todo

---------

Co-authored-by: satawatnack <satawat@bandprotocol.com>

* implement grpc priceservice

* support price option, fix rest priceservice

* implement unit test for function QuerySymbols

* fix from comments

* add comment to the proto file

* change grogucontext to context

* fix grpc url parsing, test symbol, script symbol

* change symbol name to signal id, symbol to feed

* store only string in feed by power index

* validate signal of MsgSubmitSignals

* add feechecker test

* median return error, endblock emit event when failed

* fix from comments

* genesis export signals

* update grogu to match new feeds types

* fix from comments

* fix from comments

* separate cooldown time from transition time

* change ways to check is top validator

* implement deviation

* add block height to price validator

* change block height to last block hash

* remove last block hash from price validator

* implement distribution feature

* fix bug no price option

* implement deviation check

* refactor check service

* put distribution flag in run cmd

* delete feed when power is zero, emit event when removing signal

* fix from comments

* add README.md

* fix from comments

* change internal error to not found

* implement new logic for msg submitsignals

* fix go.mod after merge confilct

* fix feechecker_test

* add function comments

* add hook for delegation remove

* fix readme and auto replace feed by power index

* fix setFeed bug

* fix from comments

* [Feeds] Fix merkle tree (#136)

* fix tree

* fix abi

* fix test

* [feeds] Module - Unit test (#86)

* add draft

* fix test

* final unit test first version

* adjust

* fix test

* fix test

* fix test

* fix from comment

* fix lint

* fix

* fix conflict

* fix test

* prevent dup

* fix keeper_test

* remove not used GetDelegation mock

* fix test

---------

Co-authored-by: colmazia <ongart.pisan@gmail.com>

* use public bothan

* change file name and move constant

* fix from comments

---------

Co-authored-by: Kitipong Sirirueangsakul <kitipong.sirir@gmail.com>
Co-authored-by: Warittorn Cheevachaipimol <warittorn@bandprotocol.com>
Co-authored-by: warittornc <69615455+warittornc@users.noreply.github.com>
Co-authored-by: satawat thitisupakul <s.nack1919@gmail.com>
Co-authored-by: satawatnack <satawat@bandprotocol.com>
RogerKSI added a commit that referenced this pull request Nov 11, 2024
* add draft

* fix test

* final unit test first version

* adjust

* fix test

* fix test

* fix test

* fix from comment

* fix lint

* fix

* fix conflict

* fix test

* prevent dup

* fix keeper_test

* remove not used GetDelegation mock

* fix test

---------

Co-authored-by: colmazia <ongart.pisan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants