Commit graph

125 commits

Author SHA1 Message Date
positiveblue
6027ccd3d6
multi: bump btcec/v2 and btcutil to new versions 2022-03-28 15:22:41 +02:00
Oliver Gugger
23d9b8da2b
order: only extend re-created accounts 2022-01-03 16:57:02 +01:00
Oliver Gugger
e9d65b20cf
order: fix linter complaint 2022-01-03 16:57:01 +01:00
Oliver Gugger
7c2268fcbb
Merge pull request #330 from lightninglabs/default-script-chan-type
multi: remove static default channel types instead select them based on lnd's verison
2021-12-23 11:56:45 +01:00
Oliver Gugger
cd3b6b65bb
auctioneer+order: rename CurrentBatchVersion->LatestBatchVersion
To make sure the CurrentBatchVersion isn't used anywhere as the default
version anymore by accident, we explicitly rename it.
2021-12-22 09:47:45 +01:00
Oliver Gugger
e52b1ff5a6
rpcserver+order: make batch version configurable 2021-12-22 09:47:45 +01:00
Oliver Gugger
65045066af
rpcserver+order: refactor ErrVersionMismatch into struct 2021-12-22 09:47:40 +01:00
Olaoluwa Osuntokun
c83f8a56e4
order: add functional options to allow caller to pick a default chantype
In this commit, we add a new set of functional options that will allow
the caller to pick an default channel type w/o forcing the main parse
function to be aware of this logic.
2021-12-17 18:02:46 -08:00
positiveblue
2f971db8cc
order: set ExtendedAccount as default batch version 2021-12-16 13:15:41 -08:00
positiveblue
5d93deab0f
order: generate mocks for order/interfaces.go
The `mockgen` tool seems to have a bug and it is not able to parse a
valid go file. I had to change the `[sha256.Size]byte` to `[size]byte`
and define `hashSize` in the order package in the same way it is defined in
the sha256 one.
2021-12-14 20:39:55 -08:00
positiveblue
8365bfd5a8
order: add the order Manager interface 2021-12-14 20:12:40 -08:00
positiveblue
f9b444131e
order: add ExtendAccountBatchVersion support
- Add new `ExtendAccountBatchVersion` batchVersion.
- Use the right batch verification flow depending on the version.
2021-11-30 20:18:28 -08:00
Wilmer Paulino
f9c2861354
order+auctioneer: parse height hint from auctioneer's proposed batch
The auctioneer will now provide a height hint along with every proposed
batch it sends to traders. This height hint is then used by each trader
to base off their absolute lease expiration height, such that they can
agree on the same value and avoid any divergences due to block
propagation discrepancies between them.
2021-11-02 16:47:55 -07:00
Wilmer Paulino
321e3c3598
order+auctioneer: allow submission of order channel type to auctioneer 2021-11-02 16:47:53 -07:00
Wilmer Paulino
f7dce585ba
order: introduce channel type field
Previously, the channel type was being recorded by the auctioneer only,
but there was no way for a trader to set its preference. Now that we
want to support that, we move the ChannelType definition to the Pool
source code, as done in this commit.

As part of introducing this new field, a new version bump was required
to compute the proper digest of each order.

To remain backwards compatible, we define the default channel type to be
"peer dependent". This implies that the channel type will vary based on
the node features shared between the asker and bidder. We also define a
new channel type to denote that channels resulting from matched orders
must have their lease expiration enforced in the scripts of their
commitment transactions.
2021-11-02 16:47:47 -07:00
Olaoluwa Osuntokun
9c5d6a17d4
order+account: account for new dust limit w/ smaller acct in test
For the batch verify test, the dust limit is now smaller by 160
satoshis, so we reduce the main account by this amount in order to
commit a minimal diff, rather than overhaul the test to be more robust.
2021-10-20 19:37:59 -07:00
Olaoluwa Osuntokun
d5f944e3fa
build: update to pin against current lnd v0.14.0 2021-10-20 19:25:48 -07:00
Olaoluwa Osuntokun
2dcc903495
sidecar: update ticket w/ new offer field to indicate auto negotiation 2021-05-09 19:24:56 -07:00
Olaoluwa Osuntokun
c9640659cc
funding: sign offered ticket w/ trader account key
This change allows us to later use a ticket as a means to authenticate
communication between the provider and the recipient of a sidecar
channel.
2021-05-09 19:24:54 -07:00
Oliver Gugger
1a68069bc2
order: add NewQuote function
We port over the order quote calculation from the CLI to the order
package so we can also offer the same calculation over RPC.
2021-05-05 15:55:45 +02:00
Oliver Gugger
71b7f419d8
order+funding: use correct multisig key
If we're the provider of a sidecar channel then we don't actually have
the private key of the funding multisig key. Therefore we cannot
re-derive it on demand and have to use the key provided in the sidecar
ticket instead.
2021-04-06 13:41:49 +02:00
Oliver Gugger
2b46e31e6c
multi: add sidecar ticket to RPC bid order
The local database can now store a sidecar ticket with a bid order. We
now also need to accept it on the local RPC interface and forward it to
the auctioneer.
2021-04-06 13:36:30 +02:00
Oliver Gugger
2f56378898
order+clientdb: add sidecar ticket to bid order
With this commit we add the optional sidecar ticket to bid orders.
Because the node submitting the bid order doesn't necessarily need to be
the node creating the offer, we just store the ticket as is and don't
require it to be in the database already.
2021-04-02 14:18:10 +02:00
Oliver Gugger
4d6fdae004
funding+order: move DefaultBatchStepTimeout
We need to use the DefaultBatchStepTimeout variable outside of the
funding manager as well and move it to the order package to not create a
circular dependency when accessing it from the root package.
2021-03-19 16:50:32 +01:00
Oliver Gugger
0a5096ac55
order: validate self chan balance in deltas
When validating a batch we need to make sure that all three parties
(maker, taker, server) come up with the same account ending state after
matching a bid order with a push amount.
2021-03-19 16:50:32 +01:00
Oliver Gugger
2a790a1884
multi: add self chan balance to order submission RPCs
With everything prepared we now parse the self chan balance from the
client request and set it on the server request.
2021-03-19 16:50:31 +01:00
Oliver Gugger
cbacb85f45
order: add SelfChanBalance field to bid orders
With this commit we add the new SelfChanBalance to the bid order. We
also add a new version for orders that signals compatibility with that
new field. A version increase on the ask side is needed to make sure the changes in
the asker's account balance are interpreted correctly on batch
validation.
2021-03-19 16:50:31 +01:00
Oliver Gugger
5a2bc0cde9
order: store local node pubkey
The order manager already stores the local lnd node's identity public
key. We return it in an exported method so the RPC server can access it
as well without needing to query it again.
To make sure we only allow querying it after the manager is started, we
add an atomic flag for the startup state.
2021-02-02 09:57:07 +01:00
Oliver Gugger
83b458b504
multi: move auctioneer proto to auctioneerrpc package
As a preparation to extract the auctioneer proto package into its own
sub-module, we move it out of the poolrpc package.
2021-01-22 10:41:44 +01:00
Oliver Gugger
05626355ae
multi: use distinct clearing price per duration bucket 2021-01-08 14:02:14 +01:00
Oliver Gugger
919f453651
poolrpc+order: group orders and prices by duration markets 2021-01-08 14:02:13 +01:00
Oliver Gugger
a27fd7c1a0
multi: add and use new order version
We add a new order version that is allowed to submit lease durations
outside of the default/legacy 2016 block duration.
No new fields are added, so nothing changes in the serialization or the
digest. This version only signals that the client is able to process
batch requests with multiple duration buckets.
2021-01-08 14:02:11 +01:00
Oliver Gugger
83795453c7
multi: expose duration bucket state 2021-01-08 14:02:10 +01:00
Oliver Gugger
31b832ae80
multi: remove max order duration
Because the order/lease duration is now governed by the lease durations,
the maximum order duration is no longer needed.
2021-01-08 14:02:09 +01:00
Oliver Gugger
1f265865cf
order+auctioneer: rename batch versions to avoid confusion
Because the batch Versions are in the order package, the use of
order.DefaultVersion is confusing and not clear to be related to the
version of the _batch_, just from its name. We fix that by renaming the
versions of the batch.
2021-01-08 14:02:06 +01:00
Oliver Gugger
02cd3ffa28
multi: move cleanup functions to funding package
To delegate the pending batch cleanup to the funding manager, we first
need to move the cleanup functions into the funding package.
2020-12-09 09:16:42 +01:00
Oliver Gugger
2cd6381e25
order: demote scary sounding warn message to debug
Since this error caused quite some confusion among our users, we demote
it to info and change the text to further explain what's happened.
If a trader is involved in a batch and the channel funding fails in the
batch sign phase, a pending channel is never created in lnd. If the next
batch prepare message comes in, we try to clean up all pending channels
of the previous attempt. Because the channel negotiation failed and
there is no pending channel, cleaning up fails with this message.
2020-12-09 09:13:42 +01:00
Oliver Gugger
43ecf1d320
order+rpcserver: refactor AbandonCanceledChannels into function
We also need to make the channel abandonment independent of a particular
format of a pending batch, so we refactor it into a standalone function
instead of a method on the in-memory batch format.
2020-12-08 11:25:13 +01:00
Oliver Gugger
aa7f4a228f
order+rpcserver: refactor CancelPendingFundingShims into function
We want to be able to clean up after a pending batch that is replaced.
We want to do this for both in-memory pending batches but also for
persisted local snapshot batches on startup. Therefore we need to
refactor the cleanup methods into independent functions.
2020-12-08 11:25:13 +01:00
Oliver Gugger
4dd9eb8c6c
order: add DecrementingBatchIDs
To make iterating over batch IDs easier, we add a new helper function
that returns all batch IDs starting at the start key (inclusive) and
ending at the end key (inclusive) by decrementing the public keys. If
the end key cannot be reached by decrementing the start key by a maximum
of 10k times, we abort and return the first 10k items (without the end
key).
2020-11-30 23:44:27 +01:00
Olaoluwa Osuntokun
e79fcb4303
Merge pull request #158 from wpaulino/account-reserved-value-underflow
order: account for last match consuming all units left in reserved value computation
2020-11-12 15:56:54 -08:00
Wilmer Paulino
85f28057b1
order: account for last match consuming all units left in reserved value computation 2020-11-12 11:40:19 -08:00
Wilmer Paulino
3e0fd5309c
order+pool: round default min chan amt to nearest unit 2020-11-11 14:28:23 -08:00
Olaoluwa Osuntokun
7744d9d4bf
Merge pull request #104 from guggero/del-order-timestamp
Update order status to "failed" instead of deleting
2020-10-13 16:21:41 -07:00
Oliver Gugger
b0dc59a39e
order+clientdb: remove unused DelOrder method 2020-10-13 10:11:37 +02:00
Wilmer Paulino
bd39dfc78f
order: mark order with unfulfilled units below min as executed 2020-10-12 19:51:32 -07:00
Wilmer Paulino
3c92676aec
order: use min units match to compute reserved value 2020-10-12 19:51:31 -07:00
Wilmer Paulino
e9031a4885
order: enforce min units match in batch verification 2020-10-12 19:51:29 -07:00
Wilmer Paulino
f45245e8fc
order+rpc: introduce MinUnitsMatch field 2020-10-12 19:51:27 -07:00
Olaoluwa Osuntokun
a65dfb9829 order: introduce new node tier system
In this commit, we introduce a new field to only bids (for now): a min
node tier. This node tier is meant to allow buyers to express the level
of "quality" they're interested in for a given purchased channel. This
quality is determined using the current server-side rating system. The
base node tier are those considered "above the cut", this is also the
default tier: t1. The next node tier is t0, and is the buckets all other
nodes fall in. As the tiers rise, the number of nodes in each tier
shrinks, as these are meant to be the upper percentile of all nodes.

NOTE: The way this is implemented is actually a _breaking change_ from
the perspective of orders as we add a new field, which is included in
the order digest, without also bumping the version.
2020-10-07 18:03:47 -07:00