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

ASN.1: Add final ILP Payment Packet format (and drafts of ILQP packets) #168

Merged
merged 4 commits into from
Mar 23, 2017

Conversation

justmoon
Copy link
Member

No description provided.

Also includes draft of ILQP formats.
AUTOMATIC TAGS ::=
BEGIN

IMPORTS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can drop all but UInt64 from IMPORTS as they are not used

@@ -2,40 +2,76 @@ InterledgerQuotingProtocol DEFINITIONS AUTOMATIC TAGS ::=
BEGIN

IMPORTS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can drop all but UInt32 and UInt128 from IMPORTS as they are not used


InterledgerProtocolPaymentMessage ::= SEQUENCE {
-- Amount which must be received at the destination
amount UInt64,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use Amount type?

BEGIN

IMPORTS
UInt64
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't import from GenericTypes. Use Amount type instead of UInt64

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about that. If there is an amount type, we should use it everywhere obviously. But if Amount is just UInt64 I think it's more readable if we just put UInt64 everywhere. For complex types, sure, define it once. But if it's just a primitive type, don't make me go to another file just to find out what it is. What do you think?

BEGIN

-- Small Integers
Int8 ::= INTEGER (-128..127)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need all of these types anymore? I appreciate the value of the comments for documenting how the design was finalized but perhaps we can put that somewhere else to keep this clean?

Copy link
Member Author

Choose a reason for hiding this comment

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

I like having a full suite of generic types, in case we need them in the future. And I like having them in the repo to avoid external dependencies. So my vote is to keep this. It's in a separate file, so I don't see how it would be distracting.

-- amounts) for the quoted route
liquidity LiquidityCurve,
-- Common prefix of all addresses for which this liquidity curve applies
-- SHOULD end with a period "." (but clients MUST NOT enforce this)
Copy link
Member

Choose a reason for hiding this comment

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

I agree but this seems like a bit of an odd thing to say so it might be worth providing more rationale or linking to the ILP addresses spec

destinationPrefix Address,
-- How long the sender should put money on hold (in milliseconds)
sourceHoldDuration UInt32
-- TODO: An exact quote expiry doesn't seem necessary...
Copy link
Member

Choose a reason for hiding this comment

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

Why not? If a connector is giving you a liquidity curve, wouldn't you want them to tell you how long you can use it for? If a sender gets a liquidity curve they might be tempted to cache it for a very long time as they send repeated streaming payments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will change to include expiry date.

-- provided in the request.
requestedAmount Amount,
sourceHoldDuration IlpHoldDuration
-- Quote with a specific source or destination amount
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment predates switching to having two different messages for quote source and quote destination

destinationAccount Address,
sourceAmount Amount,
-- How much time the receiver needs to fulfill the payment (in milliseconds)
destinationHoldDuration UInt32
Copy link
Member

Choose a reason for hiding this comment

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

What if the sender doesn't know this but does know how long they're willing to put funds on hold for? We might want to suggest some default value in case that isn't known.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we should care about that use case. You will always want to hold it for the minimum amount of time. If you don't know how long the recipient needs, you can probably make a reasonable guess or just ask them.

It just doesn't make much sense why you would choose the destination hold based on the sender's willingness to hold. It's like buying paint based on how much they have at the store instead of estimating how much you need.

| "A".."Z"
| underscore
| "a".."z"
| tilde )
Copy link
Member

Choose a reason for hiding this comment

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

Really not very important, but why are the categories ordered in this way? I would expect alphanumeric characters to come before the symbols

Copy link
Member Author

Choose a reason for hiding this comment

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

They are ordered by value, i.e. their order in the ASCII table. E.g. 'A' == 0x41, so it comes before '_' == 0x5F, which in turn comes before 'a' == 0x61


Amount ::= UInt64

-- Selection of other options considered:
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be taken out


-- --------------------------------------------------------------------------

-- Different ledgers may use different rounding parameters
Copy link
Member

Choose a reason for hiding this comment

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

Can this section be taken out?

--
-- The only amounts

LiquidityCurve ::= SEQUENCE OF SEQUENCE {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we call this a liquidity curve instead of a rate curve?

Copy link
Member Author

Choose a reason for hiding this comment

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

The rate is the slope of this curve, so the "rate curve" would be the derivative of this curve. Open to another name if anyone has ideas.

-- output amount. Each point must have larger x and y values than the previous
-- point. All coordinates must be greater than zero.
--
-- The only amounts
Copy link
Member

Choose a reason for hiding this comment

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

Oh the suspense! "The only amounts"...what?

-- Liquidity curves describe the relationship between input and output amount
-- for a given path between a given pair of ledgers.
--
-- The curve is expressed as a series of points given as <x, y> coordinates.
Copy link
Member

Choose a reason for hiding this comment

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

If x and y need to be explained in this context, what do you think about just renaming them to something like inputAmount and outputAmount?

Copy link
Collaborator

@mDuo13 mDuo13 left a comment

Choose a reason for hiding this comment

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

I can barely read ASN.1, but what I saw mostly makes sense. Agree w/ @adrianhopebailie and @emschwartz about removing more stuff that's apparently unused. Otherwise, looks fine?

Address ::= IA5String
(FROM
( hyphen
| period
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this definition include the rule that segments cannot be zero-length—that is, you cannot have .. in an ILP address?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that's possible in ASN.1, but am happy to be proven wrong by someone with better ASN.1-fu.

-- The curve is expressed as a series of points given as <x, y> coordinates.
--
-- Each x coordinate corresponds to an input amount, each y corresponds to an
-- output amount. Each point must have larger x and y values than the previous
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure both x and y have to be larger? Can you not have a "curve" that plateaus in the middle, e.g.:

   y₃ ┨         ╭┄
      ┃        ╱
      ┃       ╱
y₁,y₂ ┨  ╭╌╌╌╯
      ┃ ╱
   y₀ ┨╯
      ┗━━┳━━━┳━━┳━━
     x₀ x₁   x₂ x₃

(in this case y₁=y₂ but x₂>x₁)

Copy link
Member Author

Choose a reason for hiding this comment

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

In that case, the price is zero/infinity. My initial intuition was that that could result in some mathematical funkiness. But I haven't been able to think of a case. In crypto, you always disallow zero basically everywhere, so it's become my default habit.

The current implementation does allow equal y coordinates, but no equal x coordinates. That means that inverting a curve may give you an invalid curve. Not sure if that matters since we don't really invert curves.

I'd be ok to write what the current implementation does into the spec, but would caution us to think about this point some more.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes sense that you may have a plateau in the curve. (I haven't thought too deeply into this, but that might be meaningful for assets that have some weird external costs involved in transferring them, or some sort of transition point between transfer methods.) I'd just reword it to say that the x values must always be greater than the previous and the y values must be equal or greater.

@justmoon
Copy link
Member Author

@adrianhopebailie @emschwartz @mDuo13 Updated to address your comments.

I used UInt64 as the amount format everywhere rather than giving it an alias. It saves readers from having to look up what Amount is.

That meant taking out the explanation of why we chose UInt64 as the amount because there wasn't an obvious place to put it. (Didn't want to clutter the ILP Packet format with a long-winded, slightly off-topic explanation of the amount data type.) I think that's fine, we can explain it in the ILP RFC instead.

@@ -7,8 +7,7 @@ IMPORTS
UInt64
FROM GenericTypes

Address,
Amount
Address
FROM InterledgerTypes

MetadataEntry
Copy link
Member

Choose a reason for hiding this comment

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

MetadataEntry should be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants