-
Notifications
You must be signed in to change notification settings - Fork 98
Last unwraps #290
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
Last unwraps #290
Conversation
Shourya742
left a comment
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.
Ack. What are your thoughts on adding a NotFound error variant for all instances where we're currently using get with expect?
I am not entirely opposed. It feels equivalent to me. And more code to add variants just to denote a If Using It can still panic, but that only means two things: Both are valid cases for just panics.
|
KnowWhoami
left a comment
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.
Ack few nits and small improvements, then it's good to go.
src/utill.rs
Outdated
| WitnessVersion::V0, | ||
| &redeemscript.wscript_hash().to_byte_array(), | ||
| ) | ||
| .unwrap(); |
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.
categroize this error in Wallet::Protocol -> we will get an error only when there's something wrong with our redeemscript which is directly related to coinswap protocol.
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.
Damn, this opened up an entire can of worms. This is such a low-level util that changing its signature affects everything. But this needed to be handled or it can be quite problematic. A rouge maker can trigger this unwrap by sending non-segwit reedemscripts.
Stay tuned for another round of refactoring commits.
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 also cannot be added to the wallet error as this function is used in the contract module, which is the core module. Adding this to the ProtocolError because that already encapsulates contract error so we can propagate easily.
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 is such a low-level util that changing its signature affects everything. But this needed to be handled or it can be quite problematic.
yeah , this error needs to be propagated and should be properly handled by high level api's .
A rouge maker can trigger this unwrap by sending non-segwit reedemscripts.
Since this api is been used for both maker and taker components so the unwrap here can be a threat to both of them.
For eg: this api is used to get the scriptpubkey from mutliscript_redeemscript of funding tx in order to verify the proof of funding.
so for:
-
Makercreates a seperate thread for handling the clients so having unwrap in this low level api will ultimately create unwrap inside the thread. So it will not cause much damage to it sinceMaker Serverwould still run but it would'nt be able to figure out the reason behind it and couldn't take any proper actions. -
Taker: Since it works in blocking mode -> thus havingunwrapcan panic the whole coinswap process and it wouldn't be able to figure out the exact reason behind this.
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.
Stay tuned for another round of refactoring commits.
If it requires lot of refactorings -> then let's just have a followup PR for this issue otherwise it would create this PR a bit mess.
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.
its gonna be a mess later too trying to fix it. Pushed the changes. lets bite the bullet here.
|
Not sure what you mean, but only Taker didn't had propagation. Added that. Maker is fine.
There are many unwraps in funding module functions that are not being used. No point in spending time solving these unwraps. The only routine used currently is |
|
There are weird overlaps between |
0c98aba to
85258ab
Compare
|
Addressed comments and other refactors from 7de0fba |
85258ab to
0c4dbfb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #290 +/- ##
==========================================
- Coverage 78.01% 74.83% -3.18%
==========================================
Files 32 32
Lines 4835 3998 -837
==========================================
- Hits 3772 2992 -780
+ Misses 1063 1006 -57 ☔ View full report in Codecov by Sentry. |
0c4dbfb to
bbb56b0
Compare
bbb56b0 to
8497c0a
Compare
Yeah ,that will make things a bit simpler. |
|
Contracts are part of the protocol. I don't see any reason why we need a separate error for just contracts. And if we are going by definition, then that should only include script errors, and nothing else. That's what a "contract" is. Its redundant nomenclature. Better to get rid of it. |
8497c0a to
feec410
Compare
feec410 to
64fd3ec
Compare
Shourya742
left a comment
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.
ACK
Resolves #253, #237
Removes unwraps from
utill.rsandtakermodules.Note:
setup_loggerunwraps are kept intact. As this is only used once in cli apps, where unwraps atmain.rsit doesn't have any effect. We will later refator this anyway for custom logger. Wasn't worth to add one more error variants just for this.Added a few more unwraps removal from maker and market.