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

Enforce additional best practices for iterators #592

Closed
shaspitz opened this issue Dec 13, 2022 · 1 comment · Fixed by #596
Closed

Enforce additional best practices for iterators #592

shaspitz opened this issue Dec 13, 2022 · 1 comment · Fixed by #596
Assignees
Labels
invalid This doesn't seem right

Comments

@shaspitz
Copy link
Contributor

Problem

According to communicated sdk best practices, we're using iterators in two ways that are potentially dangerous.

Closing criteria

we need to enforce two practices throughout the ICS repo:

  1. Only make operations to short-lived local variables inside an iterator callback (never write to a store queue in iterator as example, even if seemingly "out of domain")
  2. Never use embedded iterators

Problem details

Iterator contract: https://github.com/cosmos/cosmos-sdk/blob/47f46643affd7ec7978329c42bac47275ac7e1cc/store/types/store.go#L224

@shaspitz
Copy link
Contributor Author

Idea from @jtremback, to accomplish 1 we no longer expose iteration methods, and only define "GetAll" methods that return lists of records. Any writes to the store can happen with logic based on the returned list

@mpoke mpoke moved this from Todo to In Progress in Replicated Security Dec 16, 2022
@mpoke mpoke moved this from In Progress to Waiting for review in Replicated Security Dec 20, 2022
@mpoke mpoke assigned mpoke and unassigned jtremback Dec 20, 2022
Repository owner moved this from Waiting for review to Done in Replicated Security Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants