iroha icon indicating copy to clipboard operation
iroha copied to clipboard

Get rid of the remaining singular queries

Open DCNick3 opened this issue 1 year ago • 0 comments

As suggested in https://github.com/hyperledger/iroha/pull/4833#issuecomment-2233249025, we should be able to remove most singular queries, making the API a bit more uniform and strictly more expressive.

There are four groups of queries here:

1. Improved predicates

Queries that can be reasonably easily removed by improving predicates for some of the types. These are FindTriggerById, FindTransactionByHash, FindBlockHeaderByHash.

Note that FindTransactionByHash is used by iroha blockchain explorer, so implementing this may result in additional code churn there.

Tracked in #5017.

2. Relational predicates

FindAccountsWithAsset that can be removed by allowing access to related entities in predicates. This is required due to transition to more shallow objects in data model (#4792). This can probably be done by passing world snapshot as context into the predicate trait implementation. There might be a more performant way to do this I am not yet aware of.

3. Projections

Queries that can be removed with implementation of projections - a mechanism to get a more narrow view of the query result. It does not have its own issue yet.

Queries from this category include all the metadata queries (FindTriggerMetadata, FindDomainMetadata, FindAssetMetadata, FindAccountMetadata, FindAssetDefinitionMetadata) and FindAssetQuantityById. FindTotalAssetQuantityByAssetDefinitionId can also be implemented with the help of #4934.

4. Data model query

Finally, there is FindExecutorDataModel which doesn't make sense to reformulate as a non-singular query. The plan is to make a separate endpoint to implement it.

DCNick3 avatar Aug 05 '24 08:08 DCNick3