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

[ethPM] Fix bug in package id and release id fetching strategy #1427

Merged
merged 1 commit into from
Aug 21, 2019

Conversation

njgheorghita
Copy link
Contributor

What was wrong?

w3.pm.get_all_packages() and w3.pm.get_all_release_ids() were wonky when dealing with large amounts of packages / releases. This can be seen here and here.

The tests only covered cases with ~6 releases which worked fine.

Cute Animal Picture

image

web3/pm.py Outdated
package_ids = []
while pointer < num_packages:
new_ids, pointer = self.registry.functions.getAllPackageIds(pointer, (pointer + BATCH_SIZE)).call()
package_ids.append(new_ids)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pipermerriam Not sure how you feel about this - feels a bit mutate-y to me, but also the easiest way to implement it. The BATCH_SIZE is also arbitrary, but I tested it locally with values of 1, 2, 4, 10, and 100 and it works fine. I didn't update the tests in this case b/c releasing 100+ packages just to test this case seems a bit overkill.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be able to be converted to a non-mutative solution reasonably easy. IIUC this correctly you need to reverse each of the individual chunks and return in order which I think would be equivalent to just replacing this statement with yield from reversed(new_ids)

web3/pm.py Outdated
package_ids = []
while pointer < num_packages:
new_ids, pointer = self.registry.functions.getAllPackageIds(pointer, (pointer + BATCH_SIZE)).call()
package_ids.append(new_ids)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be able to be converted to a non-mutative solution reasonably easy. IIUC this correctly you need to reverse each of the individual chunks and return in order which I think would be equivalent to just replacing this statement with yield from reversed(new_ids)

@njgheorghita njgheorghita changed the title Bump version: 5.0.0 → 5.0.1 [ethPM] Fix bug in package id and release id fetching strategy Aug 21, 2019
for release_id in concat([x[::-1] for x in release_ids]):
yield release_id
pointer = 0
while pointer < num_releases:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing. This is probably fine, however, you could save yourself a headache by enforcing that pointer always increases on each loop iteration to ensure you cannot end up in an infinite loop.

@njgheorghita njgheorghita merged commit 5890846 into ethereum:master Aug 21, 2019
@njgheorghita njgheorghita deleted the ethpm-bugfix branch August 21, 2019 20:47
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

Successfully merging this pull request may close these issues.

3 participants