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

[feature] Fidelity Bonds #90

Merged
merged 12 commits into from
Feb 18, 2024
Merged

[feature] Fidelity Bonds #90

merged 12 commits into from
Feb 18, 2024

Conversation

rajarshimaitra
Copy link

This PR adds the Fidelity Bond API, protocol, and tests.

The previous fidelity bond codes are mostly removed.

The Wallet now has a new fidelity-related API.

The Makers by default attempt to create a fidelity bond and startup with default config options. If failed, then the server stops with a hard error.

Takers now validate fidelity bonds at the offer downloading time. If an invalid bond is present, that offer is rejected.

Unit and functional tests were added to test fidelity bond behavior.

Reviewer's note:
Commits are broken into modular chunks. Check out each commit message to get the change summary.

This commits does some preparatory and unrelated changes. They are mostly
code improvements and removal of redundant stuffs.

utill: use slice instead of a vec.
teleport/bin: remove fidelity bond generattion command. Fidelity bonds
should be created via the new wallet api from now on.
contract + messages + swapcoin: Use bitcoin's Signature whenever possible. This removes ambiguity over
Signature types.
scripts/wallet: remove fidelity related scripts. not needed anymore.
fidelity: Defines the new fidelity API of the Wallet. Give it a fresh look.
Comparing it with the previous version won't be useful.

storage: Stores the fidelity bonds in wallet storage. Also removes the redundant FileData
interface. wallet storage is now directly encoded into the wallet file.

direct_send: Add anti-feesnipping locktime and disaalow fidelity bond related operation
via direct send.

error: Add a bunch of internal error type + new fidelity error type.

rpc: Update the scan logic for relevant fidelity parts. Using the new fidelity
structures in the wallet store.

api: Minor changes in previous wallet apis due to fidelity addition.
Updates the Existing FidelityProof struct with better infos.
Include FidelityProof in Offer data.
Update the Maker to
 - attempt to create a fidelity bond from available balance at startup. If not enough
 balance give hard error.

 - provide fidelity proof in the offer data.

 - add fidelity bond related config params. Define defaults.
Updates the Taker to handle fidelity bond validation at offer download.

The `sync_offerbook()` is taken out of the offerbook api and into the Taker api, where
its a more natural fit. Taker rejects offer if fidelity bond verification failed.
Add a new fidelity bond related test. Doc is included the describe whats being
tested.
Update all the existing tests to allow fidelity creation. From now on every future tests
for coinswap will require valid fidelity bond generation by the makers.
Remove redundant dep naive-datetime.

Update Readme roadmap.
Copy link

codecov bot commented Feb 10, 2024

Codecov Report

Attention: 108 lines in your changes are missing coverage. Please review.

Comparison is base (dda5c2d) 68.83% compared to head (050c105) 72.16%.

Files Patch % Lines
src/wallet/fidelity.rs 83.77% 49 Missing ⚠️
src/maker/api.rs 7.69% 12 Missing ⚠️
src/wallet/error.rs 25.00% 12 Missing ⚠️
src/wallet/api.rs 36.36% 7 Missing ⚠️
src/maker/mod.rs 75.00% 6 Missing ⚠️
src/wallet/rpc.rs 75.00% 6 Missing ⚠️
src/wallet/swapcoin.rs 53.84% 6 Missing ⚠️
src/wallet/direct_send.rs 0.00% 5 Missing ⚠️
src/scripts/wallet.rs 0.00% 2 Missing ⚠️
src/taker/api.rs 91.66% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #90      +/-   ##
==========================================
+ Coverage   68.83%   72.16%   +3.32%     
==========================================
  Files          28       28              
  Lines        5773     5910     +137     
==========================================
+ Hits         3974     4265     +291     
+ Misses       1799     1645     -154     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/protocol/contract.rs Show resolved Hide resolved
src/protocol/contract.rs Show resolved Hide resolved
src/protocol/contract.rs Outdated Show resolved Hide resolved
src/protocol/contract.rs Outdated Show resolved Hide resolved
src/protocol/contract.rs Show resolved Hide resolved
@rajarshimaitra
Copy link
Author

@Shourya742 removed secp signatures entirely.. No reason we needed both..

@rajarshimaitra rajarshimaitra linked an issue Feb 11, 2024 that may be closed by this pull request
@rajarshimaitra rajarshimaitra linked an issue Feb 11, 2024 that may be closed by this pull request
src/wallet/fidelity.rs Show resolved Hide resolved
src/wallet/fidelity.rs Outdated Show resolved Hide resolved
tests/malice2.rs Show resolved Hide resolved
tests/malice1.rs Show resolved Hide resolved
src/maker/config.rs Outdated Show resolved Hide resolved
@rajarshimaitra rajarshimaitra self-assigned this Feb 17, 2024
@rajarshimaitra rajarshimaitra linked an issue Feb 17, 2024 that may be closed by this pull request
@rajarshimaitra rajarshimaitra merged commit c30c108 into master Feb 18, 2024
8 checks passed
@rajarshimaitra rajarshimaitra added this to the v0.1.0 milestone Feb 18, 2024
@rajarshimaitra rajarshimaitra deleted the fidelity branch February 22, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

test: Unit tests for wallet/fidelity.rs feature: Fidelity Bonds RnD: Reduce dependnecy.
3 participants