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

Support querying for blocks and transactions #2103

Closed
0x009922 opened this issue Apr 14, 2022 · 5 comments
Closed

Support querying for blocks and transactions #2103

0x009922 opened this issue Apr 14, 2022 · 5 comments
Assignees
Labels
Enhancement New feature or request good first issue Good for newcomers iroha2-dev The re-implementation of a BFT hyperledger in RUST

Comments

@0x009922
Copy link
Contributor

In Iroha Block Explorer, we need to show up to a user the list of latest blocks and transactions. Also it would be useful to query for some specific block/transaction by its id, height and hash relatively.

Thus, it would be nice to extend Query API with the following:

  • FindAllBlocks, that returns a list of blocks. With pagination, of course. Ordered by height desc.

    There are several life stages of a block:

    1. pending
    2. chained
    3. valid
    4. committed

    AFAIK in explorer we only need pending and committed blocks, and we need to distinguish them from each other.

  • FindBlockByHeight, that returns a single block if it has been found. I think we need to know the block status here as well.

  • FindAllTransactions, that returns a list of latest transactions, ordered by timestamp desc. The most debatable query.

    I am not sure that this query is a good idea, because actually transactions are always contained within blocks, and its enough to query for blocks only to get transactions as well. But if we want to show the list of transactions decoupled from their blocks, how to paginate this data independently from blocks? Maybe we should drop the idea of "transactions list" decoupled from blocks.

  • FindTransactionByHash, that returns a single transaction if it has been found. This is not as debatable as FindAllTransactions is, but I think it might be really hard to query for it in an efficient way. Am I right?

@0x009922 0x009922 added Enhancement New feature or request iroha2-dev The re-implementation of a BFT hyperledger in RUST labels Apr 14, 2022
@appetrosyan
Copy link
Contributor

  • FindTransactionByHash is there since GaroRobe/issue1485 #1517.
  • FindAllTransactions has some overlap with FindAllBlocks. Still, because of the difference in pagination and how it would be a nightmare to implement FindAllTransactions given only a paginated FindAllBlocks I think we should implement both.
  • FindBlockByHeight is redundant. Pagination has a lower and upper bound. FindAllBlocks can be used to get blocks of height n to n+1 and it would have the same effect.

@appetrosyan appetrosyan added the good first issue Good for newcomers label May 4, 2022
@appetrosyan
Copy link
Contributor

@QuentinI If you're looking for something new to implement, seems like a good place to start

@QuentinI QuentinI self-assigned this May 4, 2022
@s8sato
Copy link
Contributor

s8sato commented May 6, 2022

Does block stream not work for it?

@QuentinI
Copy link
Contributor

QuentinI commented May 8, 2022

Regarding FindAllBlocks: structures describing blocks are in defined in iroha_core, which depends on iroha_data_model where the queries need to be defined.
As far as I understand, iroha_data_model doesn't concern itself with blocks at all at the moment. Do we actually want to change that, or is /block/stream API endpoint @s8sato mentioned sufficient here? My take would be that /block/stream should suffice if we need this information only for Block Explorer.

@appetrosyan
Copy link
Contributor

@0x009922 You're probably the best person to explain what's missing in the block streaming API.

QuentinI added a commit that referenced this issue May 20, 2022
* [feature] add FindAllTransactions query

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>

* [feature] add FindAllBlocks query

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>

* split valid and rejected txns in BlockValue

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>

* fix suggestions

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
pesterev pushed a commit to pesterev/iroha that referenced this issue May 25, 2022
…ons (hyperledger#2210)

* [feature] add FindAllTransactions query

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>

* [feature] add FindAllBlocks query

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>

* split valid and rejected txns in BlockValue

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>

* fix suggestions

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request good first issue Good for newcomers iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

No branches or pull requests

5 participants