Commit graph

39 commits

Author SHA1 Message Date
Johan T. Halseth
0e665f592a
clientdb: store LocalBatchSnapshot on StorePendingBatch 2020-09-10 10:41:31 +02:00
Johan T. Halseth
60d7a0a48b
clientdb: add batch ID index bucket for snapshots 2020-09-10 10:41:31 +02:00
Johan T. Halseth
7c3a4d8492
clientdb: define LocalBatchSnapshot 2020-09-10 10:41:07 +02:00
Johan T. Halseth
169daf8131
clientdb: return updated order, account on modification 2020-09-10 09:51:57 +02:00
Johan T. Halseth
daf1e1a0bc
clientdb test: complete tx, don't require t for dummyOrder 2020-09-10 09:51:56 +02:00
Johan T. Halseth
4262ec71b4
clientdb/codec: add (de)serialization of LinearFeeSchedule 2020-09-10 09:51:55 +02:00
Olaoluwa Osuntokun
ffc9c60b13
multi: rename project from llm to pool 2020-09-09 19:55:10 -07:00
Wilmer Paulino
203627643b
clientdb: avoid serialization of latest tx in StateCanceledAfterRecovery
The latest transaction is also not known here, so we shouldn't serialize
it.
2020-09-04 11:36:25 -07:00
Wilmer Paulino
f71adf7b67
multi: re-purpose account close tx field to latest tx 2020-09-02 12:10:23 -07:00
Johan T. Halseth
a2abc187f3
multi: rename FundingFeeRate to MaxBatchFeeRate
The funding feerate field was previoulsy unused, so we rename it to
"max batch fee rate" in order to use it to communicate to the server the
maximum fee rate we are willing to pay to be included in a batch.

We also increase the default value to 500 sat/vbyte.
2020-08-07 16:34:07 +02:00
Oliver Gugger
6692073e89
clientdb+account: add code for migration-less new database fields
In the future we might want to have the possibility to add additional
fields to a database object (like orders or accounts) without the need
for a migration. We add the code for that already, even if it's not
being used currently.
2020-08-03 11:08:48 +02:00
Oliver Gugger
fcea7e6e97
clientdb: extract storeAccount and readAccount
As a preparation to add new account fields to a sub bucket, we extract
the read and write of an account into separate functions each.
2020-07-31 14:37:27 +02:00
Oliver Gugger
97624499a9
mod: update bbolt to fix go1.14 compat 2020-06-24 10:53:59 +02:00
Oliver Gugger
bb09760864
clientdb: fix formatting 2020-06-24 09:55:42 +02:00
Oliver Gugger
b120e5b21c
clientdb: fix order deletion 2020-06-23 15:38:53 +02:00
Olaoluwa Osuntokun
57fa63c237
multi: rename, fix modules 2020-06-21 19:37:00 -07:00
Wilmer Paulino
10efa7d582 clientdb: store global random lock ID upon database initialization 2020-06-17 18:34:49 -07:00
Olaoluwa Osuntokun
9a2268ad48 client: change order.Kit.AcctKey into raw key bytes
In this commit, we change the key stored within the internal order kit
into a raw pubkey array. Along the way we fix a bug in the verifier
tests due to using a map with pointer keys rather than the actual value
itself.
2020-05-26 19:57:54 -07:00
Wilmer Paulino
9f9e7d7cb6 clientdb: prevent test race condition by not modifying global test var 2020-05-05 14:20:49 -07:00
Wilmer Paulino
cb9c14b1b1 clientdb: add DeletePendingBatch 2020-05-05 13:54:36 -07:00
Wilmer Paulino
043a9f7d98 account: properly handle spend on pending batch not finalized
This commit aims to address a current gap within the system where trader
account states can become desynchronized if they participated in a batch
and they never received a Finalize message from the auctioneer.

From now on, if an account spend arrives while a trader has a pending
batch, then we assume they weren't able to receive its Finalize message,
and use the spend as an indication that the batch has been finalized.
This works because if a trader signs for a batch and disconnects, the
batch should have already been persisted, and if the batch was actually
finalized (i.e., broadcast without any changes), then the account should
have been spent.
2020-05-05 13:53:32 -07:00
Wilmer Paulino
d167821bee clientdb+order: store pending batch transaction
This is done as preparation to handle traders recovering from batches
which they've participated in and signed for.
2020-05-05 13:51:17 -07:00
Wilmer Paulino
15c5859239 clientdb+order: remove batch ID parameter from MarkBatchComplete
The parameter isn't necessary as traders can only maintain one pending
batch at a time, and the check is already performed by the BatchStorer.
2020-05-05 13:48:28 -07:00
Wilmer Paulino
9a2d6c4c50 clientdb: stage batch updates under distinct bucket
If trader A provides a signature for a batch, disconnects, and trader B,
who is also in the auction, bails, then the auctioneer will re-attempt
matchmaking. If trader A hasn't reconnected by and a successful batch is
made without them, then the updates would need to be rolled back.
Previously, since we would overwrite the main account and order state,
we'd lack information in order to do so. By staging the update under a
distinct bucket, we can now do so properly by simply removing the state
within it.
2020-04-27 15:51:58 -07:00
Wilmer Paulino
4b95396cdc clientdb: refactor test cases out of TestPersistBatchResult 2020-04-27 15:50:07 -07:00
Wilmer Paulino
d9738f7368 clientdb: specify src and dst buckets for updateAccountTX 2020-04-27 15:50:03 -07:00
Wilmer Paulino
210415b8b2 clientdb: specify src and dst buckets for updateOrderTX 2020-04-27 15:48:42 -07:00
Wilmer Paulino
6a64971396 clientdb+order: use 2-step commit for batch persistence
This commits serves as preparatory work for committing a pending batch
before providing signatures to the auctioneer. This is achieved by first
storing the batch as pending upon receiving a new batch and marking it
as complete upon receiving a finalize message.
2020-04-24 10:57:41 -07:00
Oliver Gugger
d2d7e7b006 clientdb: add missing types to codec 2020-04-14 15:41:22 +02:00
Oliver Gugger
30faf6188b client: add batch persistence 2020-04-03 21:53:04 +02:00
Oliver Gugger
790f05b851 clientdb: allow multiple order updates in same TX
With this commit we prepare the client order database to allow
multiple manipulations to occur in a single database transaction.
2020-03-12 15:18:19 +01:00
Oliver Gugger
fe8e4d5e79 clientdb: allow multiple account updates in same TX
With this commit we prepare the client account database to allow
multiple manipulations to occur in a single database transaction.
2020-03-12 15:17:32 +01:00
Oliver Gugger
7579b158fc client: implement stream RPC 2020-03-04 15:11:08 +01:00
Wilmer Paulino
9bf50766f7 multi: allow account closure through expiration and multi-sig paths
Traders are now able to close their accounts, whether or not they have
already expired, to arbitrary outputs or to a wallet output by default.
If an account hasn't expired, then the auctioneer's signature of the
closing transaction is required to successfully close the account.
2020-02-05 12:09:47 -08:00
Wilmer Paulino
4021b2919c multi: tweak trader key with shared secret and per-batch key
In this commit, we overhaul the keys used in the multi-sig construction
of an account to prevent script reuse and provide plausible deniability
between account outputs to third parties. This is done by tweaking the
trader's key with two new components:

1. A per-batch key, which is obtained from the auctioneer during account
creation. Every time the account is modified or participates in a
cleared batch within the system, the per-batch key is incremented by the
curve's base point, resulting in a different key used in the account
script.

2. A shared secret derived using Diffie-Hellman between the trader's and
auctioneer's base keys. By using this secret, we provide plausible
deniability to third parties with knowledge of the base keys and
per-batch key.

The resulting tweaked key for the trader is then used as the tweak for
the auctioneer's base key.
2020-01-29 13:23:15 -08:00
Wilmer Paulino
004e1cf857 multi: use btcec.PublicKey instead of [33]byte
This allows us to use utility functions that require the use of a parsed
public key without needing to parse every time.
2020-01-24 13:45:48 -08:00
Oliver Gugger
d59b603e45 client+order: store order 2020-01-17 17:41:25 +01:00
Wilmer Paulino
a1c769e703 clientdb: extend DB to implement account.Store
This aims to satisfy the account.Store dependency required by the
account.Manager. We now extend our bolt database to store information
about any pending and confirmed accounts we've opened.
2020-01-10 16:57:58 -08:00
Wilmer Paulino
6c211172fe multi: add persistent bolt storage
In this commit, we add a persistent store backed by bolt for the client
portion of CLM in which we'll store critical information required for
its proper operation.
2019-12-11 18:59:58 -08:00