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

Add channel reserve as a constraint during order matching/expression #403

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions auctioneer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
IsSidecarChannel: castOrder.SidecarTicket != nil,
UnannouncedChannel: castOrder.UnannouncedChannel,
ZeroConfChannel: castOrder.ZeroConfChannel,
MinReserveChannel: castOrder.MinReserveChannel,
}
rpcRequest.Details = &auctioneerrpc.ServerSubmitOrderRequest_Bid{
Bid: serverBid,
Expand Down
15 changes: 14 additions & 1 deletion auctioneerrpc/auctioneer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions auctioneerrpc/auctioneer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,11 @@ message ServerBid {
Signals if this bid is interested in a zero conf channel or not.
*/
bool zero_conf_channel = 9;

/*
Signals if this bid is interested in a minimal reserve channel.
*/
bool min_reserve_channel = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that there isn't anything endogenous to a "minimum reserve" channel that distinguishes it from another channel. That the distinguishing factor need to be produced by Pool, is the bidder is in essence setting a stipulation on the asker's performance, that their node update channel balances to channel-reserve levels Pool hasn't supported before (and hence what is considered "minimum reserve" is super nebulous and could change in the future).

Let's discuss internally how to best create matches around this property

}

message ServerAsk {
Expand Down
12 changes: 12 additions & 0 deletions channel_acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ func (s *ChannelAcceptor) acceptChannel(_ context.Context,
}, nil
}

// If a minimal reserve channel is expected, ensure that the channel
// reserve is equal to the dust limit (minimum according to BOLT#2).
if expectedChanBid.MinReserveChannel {
if req.ChannelReserve != req.DustLimit {
return &lndclient.AcceptorResponse{
Accept: false,
Error: "channel reserve not set to dust limit " +
"even though minimal reserve channel expected",
}, nil
}
}

return &lndclient.AcceptorResponse{
Accept: true,
}, nil
Expand Down
16 changes: 16 additions & 0 deletions clientdb/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const (
// orderIsPublicType is the tlv type we use to store a flag value when
// it is ok to share details of this order in public markets.
orderIsPublicType tlv.Type = 11

// bidMinReserveChannelType is the tlv type we use to store a flag
// value when a bid accepts minimal reserve channels.
bidMinReserveChannelType tlv.Type = 12
)

var (
Expand Down Expand Up @@ -704,6 +708,7 @@ func deserializeOrderTlvData(r io.Reader, o order.Order) error {
askConfirmationConstraints uint8
auctionType uint8
isPublic uint8
bidMinReserveChannel uint8
)

// We'll add records for all possible additional order data fields here
Expand Down Expand Up @@ -733,6 +738,7 @@ func deserializeOrderTlvData(r io.Reader, o order.Order) error {
),
tlv.MakePrimitiveRecord(orderAuctionType, &auctionType),
tlv.MakePrimitiveRecord(orderIsPublicType, &isPublic),
tlv.MakePrimitiveRecord(bidMinReserveChannelType, &bidMinReserveChannel),
)
if err != nil {
return err
Expand Down Expand Up @@ -788,6 +794,11 @@ func deserializeOrderTlvData(r io.Reader, o order.Order) error {
if ok && t == nil && bidZeroConf == 1 {
castOrder.ZeroConfChannel = true
}

t, ok = parsedTypes[bidMinReserveChannelType]
if ok && t == nil && bidMinReserveChannel == 1 {
castOrder.MinReserveChannel = true
}
}

if t, ok := parsedTypes[orderChannelType]; ok && t == nil {
Expand Down Expand Up @@ -831,6 +842,7 @@ func serializeOrderTlvData(w io.Writer, o order.Order) error {
bidUnannouncedChannel uint8
askConfirmationConstraints uint8
bidZeroConfChannel uint8
bidMinReserveChannel uint8
)

switch castOrder := o.(type) {
Expand Down Expand Up @@ -910,6 +922,10 @@ func serializeOrderTlvData(w io.Writer, o order.Order) error {
bidZeroConfType, &bidZeroConfChannel,
))

tlvRecords = append(tlvRecords, tlv.MakePrimitiveRecord(
bidMinReserveChannelType, &bidMinReserveChannel,
))

tlvRecords = append(tlvRecords, tlv.MakePrimitiveRecord(
askChannelConfirmationConstraintsType,
&askConfirmationConstraints,
Expand Down
6 changes: 6 additions & 0 deletions cmd/pool/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ var baseBidFlags = []cli.Flag{
"the channels resulting from matching this order " +
"will be announced to the network",
},
cli.BoolFlag{
Name: "min_reserve_channel",
Usage: "flag used to signal that this bid is interested only " +
"in channels which have minimal reserves",
},
cli.BoolFlag{
Name: "zero_conf_channel",
Usage: "flag used to signal that this bid is only interested " +
Expand Down Expand Up @@ -685,6 +690,7 @@ func parseBaseBid(ctx *cli.Context) (*poolrpc.Bid, *sidecar.Ticket, error) {
MinNodeTier: nodeTier,
UnannouncedChannel: ctx.Bool("unannounced_channel"),
ZeroConfChannel: ctx.Bool("zero_conf_channel"),
MinReserveChannel: ctx.Bool("min_reserve_channel"),
}

// Let's find out if this is an order for a sidecar channel because if
Expand Down
4 changes: 4 additions & 0 deletions order/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,10 @@ type Bid struct {
// ZeroConfChannel signals if the resulting channels need to be zero
// conf or not.
ZeroConfChannel bool

// MinReserveChannel signals if the resulting channels may have minimal
// reserves or not.
MinReserveChannel bool
}

// Type returns the order type.
Expand Down
Loading