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

[BUG]: Query filtering API isn't available in smart-contracts #4423

Open
Erigara opened this issue Apr 11, 2024 · 3 comments · May be fixed by #4544
Open

[BUG]: Query filtering API isn't available in smart-contracts #4423

Erigara opened this issue Apr 11, 2024 · 3 comments · May be fixed by #4544
Assignees
Labels
Bug Something isn't working iroha2-dev The re-implementation of a BFT hyperledger in RUST

Comments

@Erigara
Copy link
Contributor

Erigara commented Apr 11, 2024

Currently we have some kind of inconsistency where filtering API is available through ordinary client (http), but not available in smart-contracts.

@Erigara Erigara added Bug Something isn't working iroha2-dev The re-implementation of a BFT hyperledger in RUST labels Apr 11, 2024
@DCNick3
Copy link
Contributor

DCNick3 commented Apr 15, 2024

On http client side, query gets signed as a QueryPayload structure that has authority, query and filter parameters. The authority seems to determine what the query can access from the executor side, while I am not sure why the filter is part of the signed part. It doesn't even seem to be checked and/or passed to the executor. This signed query is then encoded into Vec<u8> and wrapped with a iroha_data_model::query::QueryWithParameters, which has sorting, pagination and fetch_size. The latter parameters are not signed.

On smart contract side, query gets wrapped into a iroha_smart_contract::QueryWithParameters structure that has sorting, pagination and fetch_size. There is no signing involved, an the QueryPayload structure is not used. Seems this is what lead to omission of the filter in smart contracts. The authority is rightfully omitted, as the executor's queries are not permissioned.

I think it would make sense to move the filter parameter to the non-signed part of the query (QueryWithParameters), both in smart contracts and in http clients

@DCNick3 DCNick3 self-assigned this Apr 15, 2024
@DCNick3
Copy link
Contributor

DCNick3 commented Apr 15, 2024

One risk with I see with that is that we might want to start passing filters to validations and sign them (see #3671 (comment))

@DCNick3
Copy link
Contributor

DCNick3 commented Apr 19, 2024

Moving the filter out of QueryPayload seems to not be that easy, as it would have to be passes as a query parameter, same as sorting, pagination and fetch_size. the filter is a predicate though, so it's not that easy to have a stable string representation for it (it's really supposed to be scale-encoded). I can either change the HTTP API and make it encode the whole QueryWithParameters struct (and then proceed with moving the filter to QueryWithParameters), or somehow desync the smart contract's QueryWithParameters and make it pass the filter along with other parameters

DCNick3 added a commit to DCNick3/iroha that referenced this issue May 2, 2024
…ry filters in wasm

Signed-off-by: Nikita Strygin <dcnick3@users.noreply.github.com>
DCNick3 added a commit to DCNick3/iroha that referenced this issue May 2, 2024
…ry filters in wasm

Signed-off-by: Nikita Strygin <dcnick3@users.noreply.github.com>
DCNick3 added a commit to DCNick3/iroha that referenced this issue May 2, 2024
…rt contract

Signed-off-by: Nikita Strygin <dcnick3@users.noreply.github.com>
@DCNick3 DCNick3 linked a pull request May 2, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants