Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Support multiple calls of clear_prefix with limit  #11185

Description

@bkchr

When calling clear_prefix with a limit multiple times in the same block it will always delete the same keys for the exact same input. The reason for this is that we don't check from the overlay on what we already have deleted. So, we always delete the same keys from the backend until the limit is reached. It was documented in #11182 to make this more clear to the FRAME users on how the internals are working.

@shawntabrizi and @kianenigma proposed that we make this more intuitive, aka calling it multiple times deletes always new keys and not always the same ones.

I'm personally not really convinced that we should do this, because:

  • If you want to delete more items, you can just directly pass a higher limit or just call a second time with a higher limit.
  • As the node side doesn't really know about the internals of the runtime, it would need to take into account the keys that are present in the overlay and make the implementation not count these towards the limit when we encounter them again in the backend. While this works, it also increases the complexity and may leads to a slower execution the more often clear_prefix is called.
  • We would need to introduce a new host function version for clear_prefix where only version 3 is using the new implementation. This needs to be done to ensure that we don't break any old blocks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I7-refactorCode needs refactoring.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions