refactor(verification): externalize verification dependencies [part 2/2]#904
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## refactor/verification-dependencies #904 +/- ##
=====================================================================
Coverage ? 85.38%
=====================================================================
Files ? 290
Lines ? 22508
Branches ? 3385
=====================================================================
Hits ? 19219
Misses ? 2618
Partials ? 671 ☔ View full report in Codecov by Sentry. |
0c9121f to
8b2e539
Compare
fc1e6c0 to
1a93e95
Compare
| try: | ||
| spent_output = spent_tx.outputs[tx_input.index] | ||
| except IndexError: | ||
| raise InexistentInput( |
There was a problem hiding this comment.
Have you had this exception raised? I mean, this condition would be impossible if the transaction has been validated.
No problem with this change. Just checking if this condition occurred with you.
There was a problem hiding this comment.
It's just that before, this method was only called during verification. Now, it's called before verification (when retrieving the verification dependencies). So, if the tx is invalid, it will raise this exception during that retrieval.
hathor/transaction/transaction.py
Outdated
| token_dict[token_uid] = TokenInfo(sum_tokens, token_info.can_mint, token_info.can_melt) | ||
|
|
||
| def iter_spent_rewards(self) -> Iterator[Block]: | ||
| def iter_spent_rewards(self, storage: Optional['SimpleMemoryStorage'] = None) -> Iterator[Block]: |
There was a problem hiding this comment.
It seems like we are juggling to make the new memory storage work alongside the current code. I think we can spawn an ephemeral verifier that carries a storage and use it to run the verification. It can be either set to tx.storage or to any other storage. What do you think?
There was a problem hiding this comment.
Indeed, this was not a good solution. I have solved this using a StorageProtocol, so both TransacionStorage and SimpleMemoryStorage have an unified interface that can be received by those methods. It was implemented in #922, and after it's merged to master I'll rebase this PR so this is updated.
8b2e539 to
937fc81
Compare
1a93e95 to
02bdf05
Compare
555be09 to
7e42779
Compare
02bdf05 to
ddfa87a
Compare
44842b7 to
c8261f4
Compare
ddfa87a to
33f50f3
Compare
c8261f4 to
021a595
Compare
33f50f3 to
28be92e
Compare
1618015 to
2a6d4d0
Compare
28be92e to
2bdaa2a
Compare
2a6d4d0 to
02efe61
Compare
2bdaa2a to
eb46aab
Compare
02efe61 to
6397eb3
Compare
eb46aab to
9c3e425
Compare
91f19c2 to
9e7caf3
Compare
adaaa85 to
792e630
Compare
f156d96 to
6b0c206
Compare
792e630 to
9e2e668
Compare
6b0c206 to
6578961
Compare
9e2e668 to
74b1849
Compare
Depends on #859
Motivation
Finish the refactor started in #859 (read its description for more info). After this PR, all verification dependencies are externalized and pre-calculated.
Acceptance Criteria
SimpleMemoryStorage.VerificationServiceaccordingly.Transactionmethods related to token info to receive an optionalSimpleMemoryStorage, which may be used to retrieve data.Checklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged