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

Re-design datastore key queries (ABIs AS and WASMV1) #4828

Open
damip opened this issue Jan 17, 2025 · 0 comments
Open

Re-design datastore key queries (ABIs AS and WASMV1) #4828

damip opened this issue Jan 17, 2025 · 0 comments

Comments

@damip
Copy link
Member

damip commented Jan 17, 2025

Goal

As a followup to #4721 let's allow the ABIs in the AS and WASMV1 runtimes to list datastore keys (both for the current and for other addresses) similarly to the APIs with the following extra optional arguments:

  • start_key
  • inclusive_start_key
  • end_key
  • inclusive_end_key
  • count

Existing TODOs to solve

Complete the code TODOs introduced by #4809 in:

  • interface_impl: get_keys
  • interface_impl: get_keys_for
  • interface_impl: get_ds_keys_wasmv1
  • impl ExecutionContext: get_keys

Determinism

The behavior must be deterministic. Therefore, contrary to the API case in which the user can choose stuff like the max count, in the case of the ABIs, all limits must come from protocol constants.

Impact minimization

In the AS runtime try to make the current datastore key listing ABI retro-compatible if possible (eg. by appending optional arguments) so that we don't add extra ABIs and ensure that previous projects work. If it appears impossible, we need to resort to creating a new ABI.

For WASMV1, protobuf is used, therefore it should not be an issue to add extra numbered proto fields of the existing ABIs while maintaining retro-compatibility.

One breaking thing however is the choice of the max count constant. As a starter, it should be chosen to be the smallest possible such that if a smart contract would have requested that number of items, it would have ran out of at least one of those (and hence failed anyway):

  • VM RAM
  • slot gas
  • return values max size
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

No branches or pull requests

1 participant