-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
b87b08e
to
1e227a6
Compare
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
1e227a6
to
dba7c73
Compare
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) |
There was a problem hiding this comment.
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)
dba7c73
to
a4a7323
Compare
a4a7323
to
293e8d9
Compare
for release_id in concat([x[::-1] for x in release_ids]): | ||
yield release_id | ||
pointer = 0 | ||
while pointer < num_releases: |
There was a problem hiding this comment.
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.
293e8d9
to
3be068f
Compare
What was wrong?
w3.pm.get_all_packages()
andw3.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