-
Notifications
You must be signed in to change notification settings - Fork 43
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
Convert dyn to generics in `verified_blob_content #1517
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
|
It's questionable since &dyn generates less code and generics monomorphize code for every unique T. I would really love to have a test for prover/verifier to calculate exact cycle count for a block with a fixed content inside. It will help us a lot in cases like this. Anyway, I am not against this PR. |
This would firstly affect the compile time aspect of the code & binary size. Secondly, I think that using generics would allow the compiler to better optimize the code after monomorphization takes place. |
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.
since this function will only actually take in bitcoin blob txs, we won't be generating more code with templates. only reason we went dyn or T is we are implementing a trait.
so I guess a little bit of better runtime performance is ok.
I also optimized the verified_blob_content method in this pr:
Step 2 has something unnecessary that is happenning right now. current impl of BlobWithSender is that it has its blob as CountedBufReader, which holds 1 reader, and 1 vec which is being read into, and anytime advance (or full_data) is called, it reads from the reader into the vec. the thing is, we always use another vector as the reader into this CountedBufReader, meaning that we just pass 2x the same data unnecessarily into the zk, and we have no partial reads whatsoever. we can just replace CountedBufReader with vec. but this is relatively tricky to do since BlobWithSender is part of the trait type definition of the BitcoinSpec, and versioning is going to be very uncomfortable. |
Description
Replaces dyn with generics as its slightly more efficient.
Linked Issues
Testing
Describe how these changes were tested. If you've added new features, have you added unit tests?
Docs
Describe where this code is documented. If it changes a documented interface, have the docs been updated?