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

Part 2: RFQ uses fixed-points #1141

Merged
merged 12 commits into from
Oct 18, 2024
Merged

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented Oct 7, 2024

Depends on #1136.

Merge #1136 first. This PR will be in draft until then.

The high-level goal of this change is to represent asset-to-BTC conversion rates using the new fixed-point number type. This PR updates several "price" related fields that were previously typed as milli-satoshis, which were used as a workaround in the Proof of Concept (PoC).


Remaining changes after this PR has been merged:

  • Rename price oracle RPC messages (refactor only, no logic changes).
  • Add request message fields: suggestedOutAssetRate and transferType.
  • Rearrange fields in request message to correspond with BLIP (refactor only, no logic changes, TLV values should be correct after current PR is merged).

@ffranr ffranr changed the base branch from main to rfq-uses-fixed-point October 7, 2024 10:49
@ffranr ffranr force-pushed the rfq-fixed-point-part-2 branch from 9b6917f to 3433947 Compare October 7, 2024 10:53
@coveralls
Copy link

coveralls commented Oct 7, 2024

Pull Request Test Coverage Report for Build 11350535264

Details

  • 83 of 314 (26.43%) changed or added relevant lines in 13 files are covered.
  • 33 unchanged lines in 9 files lost coverage.
  • Overall coverage decreased (-0.01%) to 40.359%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rfqmsg/buy_accept.go 0 6 0.0%
rfqmsg/messages.go 22 28 78.57%
rfqmsg/sell_accept.go 0 6 0.0%
rfqmsg/buy_request.go 0 11 0.0%
rfqmsg/sell_request.go 0 11 0.0%
rfq/order.go 0 13 0.0%
rfqmsg/records.go 30 43 69.77%
tapchannel/aux_invoice_manager.go 0 14 0.0%
tapchannel/aux_traffic_shaper.go 0 14 0.0%
rpcserver.go 0 41 0.0%
Files with Coverage Reduction New Missed Lines %
tapchannel/aux_traffic_shaper.go 1 0.0%
rfqmsg/accept.go 2 29.66%
rfqmsg/sell_request.go 2 0.0%
rfqmsg/buy_request.go 2 0.0%
tapdb/addrs.go 2 79.04%
tapchannel/aux_leaf_signer.go 2 34.43%
rfqmsg/sell_accept.go 3 0.0%
tapgarden/caretaker.go 4 68.5%
universe/interface.go 15 47.09%
Totals Coverage Status
Change from base Build 11346425053: -0.01%
Covered Lines: 24306
Relevant Lines: 60225

💛 - Coveralls

@ffranr ffranr force-pushed the rfq-fixed-point-part-2 branch from 3433947 to 205adbe Compare October 7, 2024 16:21
@ffranr ffranr force-pushed the rfq-uses-fixed-point branch from aa53ed4 to c5a94c3 Compare October 11, 2024 09:52
@ffranr ffranr force-pushed the rfq-uses-fixed-point branch from c5a94c3 to 8825621 Compare October 15, 2024 12:50
@ffranr ffranr force-pushed the rfq-fixed-point-part-2 branch from 205adbe to 0142f31 Compare October 15, 2024 16:40
@ffranr
Copy link
Contributor Author

ffranr commented Oct 15, 2024

In the latest commits pushed to this PR:

RFQ wire message uses BigInt fixed-points instead of uint64 fixed-points.

@ffranr ffranr marked this pull request as ready for review October 15, 2024 16:58
@ffranr ffranr marked this pull request as draft October 15, 2024 17:03
@ffranr
Copy link
Contributor Author

ffranr commented Oct 15, 2024

@GeorgeTsagk @guggero
This PR is ready for review but not ready to be merged before #1136 is merged.

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good! Pretty much just the same comments as in part 1 (use of 0 for the scale). Once that's resolved, this should be ready quite quickly. Great work!

@ffranr ffranr force-pushed the rfq-uses-fixed-point branch 3 times, most recently from 3a37e87 to eeeb198 Compare October 16, 2024 13:05
This commit modifies the AssetPurchasePolicy struct to carry the
asset-to-BTC rate instead of a "price". It also updates the policy check
equations to use the new rate field.
Introduce `BigInt.Bytes` and `BigInt.FromBytes` methods for encoding
and decoding `BigInt` in RFQ wire messages.
This will be used for serializing fixed-points in wire messages.
@ffranr ffranr force-pushed the rfq-fixed-point-part-2 branch from 0142f31 to a6e3c35 Compare October 16, 2024 20:09
@ffranr ffranr changed the base branch from rfq-uses-fixed-point to approved-rfq-fixedpoint October 16, 2024 20:10
@ffranr ffranr marked this pull request as ready for review October 16, 2024 20:11
@ffranr
Copy link
Contributor Author

ffranr commented Oct 16, 2024

I've rebased this PR on to the merged approved part 1 PR approved-rfq-fixedpoint.

This commit updates the RFQ request wire message, renaming the
`SuggestedRateTick` field to `SuggestedAssetRate` and changing its type
to a fixed-point representation.
This commit replaces the RFQ accept wire message fields
InOutRateTick and OutInRateTick with InAssetRate and OutAssetRate.

The new fields represent the incoming asset-to-BTC rate and the
outgoing asset-to-BTC rate, respectively.
Modify TLV type integers to match the latest BLIP state.
Update the minimum supported accept wire message version to 1. Adjust
the version check logic to ensure that only version 1 is accepted, and
not any version greater than 0.
@ffranr ffranr force-pushed the rfq-fixed-point-part-2 branch from a6e3c35 to ba84cfc Compare October 17, 2024 15:39
@ffranr ffranr requested a review from guggero October 17, 2024 15:40
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress, LGTM 🎉

Update TLV type integers to align with the latest BLIP state. Some
integer values are intentionally skipped to reserve space for new
fields defined in the BLIP.
Update the minimum supported request wire message version to 1. Adjust
the version check logic to ensure that only version 1 is accepted, and
not any version greater than 0.
@ffranr ffranr force-pushed the rfq-fixed-point-part-2 branch from ba84cfc to a14d21d Compare October 18, 2024 13:57
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

LGTM 👑

// IntoBigIntFixedPoint converts the TlvFixedPoint to a BigIntFixedPoint.
func (f *TlvFixedPoint) IntoBigIntFixedPoint() rfqmath.BigIntFixedPoint {
return rfqmath.BigIntFixedPoint{
Coefficient: f.fp.Coefficient,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we explicitly copy over the Coefficient here?

@Roasbeef Roasbeef merged commit e128117 into approved-rfq-fixedpoint Oct 18, 2024
18 checks passed
@guggero guggero deleted the rfq-fixed-point-part-2 branch October 20, 2024 07:39
@dstadulis dstadulis added the rfq label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants