Commit Graph

106 Commits

Author SHA1 Message Date
Greg Fitzgerald c12da50f9b Fix race condition
Without this patch, it was possible for two transactions with the same
'from' address to drive its balance below zero. With the patch, we'll
hold a write lock from just before we verify sufficient funds until
after those funds are deducted from the account.
2018-04-05 22:30:25 -06:00
Greg Fitzgerald 41e8500fc5 Break up process_verified_transaction() 2018-04-05 22:29:13 -06:00
Stephen Akridge f4466c8c0a Change for cuda verify integration 2018-04-05 20:00:44 -07:00
Greg Fitzgerald 01326936e6 Expire all transactions after some amount of time
Reject old transactions so that we can calculate an upper bound
for memory usage, and therefore ensure the server won't slow
down over time to crash due to memory exhaustion.
2018-04-05 10:26:45 -06:00
Greg Fitzgerald c960e8d351 Reject transactions with a `last_id` that isn't from this ledger
Before this patch, a client could put any value into `last_id` and
was primarily there to ensure the transaction had a globally unique
signature. With this patch, the server can use `last_id` as an
indicator of how long its been since the transaction was created.
The server may choose to reject sufficiently old transactions so
that it can forget about old signatures.
2018-04-05 09:54:03 -06:00
Greg Fitzgerald 8d425e127b Update benchmark to avoid write locks in sig duplicate detection 2018-04-04 17:29:22 -06:00
Greg Fitzgerald 3cfb07ea38 Sort signatures by last_id
This will allow for additional concurrency as well as give the server
a means of garbage-collecting old signatures.
2018-04-04 17:06:31 -06:00
Greg Fitzgerald 76679ffb92 Per-cell locking
This allows us to use read-locks for balances most of the time. We
only lock the full table if we need to add one.
2018-04-04 16:31:13 -06:00
Greg Fitzgerald dc2ec925d7 Better test 2018-04-04 16:01:43 -06:00
Greg Fitzgerald 014bdaa355 Add benchmark for parallel transaction processing 2018-04-04 12:43:27 -06:00
Greg Fitzgerald 0c60fdd2ce Make accountant thread-safe
Before this change, parallel transaction processing required locking
the full accountant. Since we only call one method,
process_verified_transaction, the global lock equates to doing no
parallelization at all.  With this change, we only lock the data that's
being written to.
2018-04-04 12:33:03 -06:00
Greg Fitzgerald c323bd3c87 Fix clippy warnings 2018-04-03 09:55:33 -06:00
Greg Fitzgerald 2f80747dc7 Move tests
After we restructured for parallel verification, the tests here
were unreferenced by the accountant, but still meaningful to
transaction verification.
2018-04-02 21:45:21 -06:00
Greg Fitzgerald 49708e92d3 Use last_id instead of seed
It doesn't really matter, but was confusing since the seed points
to an entry before the mint's deposit.
2018-04-02 15:06:42 -06:00
Greg Fitzgerald daadae7987 Move replaying ledger out of accountant 2018-04-02 14:51:55 -06:00
Greg Fitzgerald 2b788d06b7 Move the historian up to accountant_skel 2018-04-02 14:41:07 -06:00
Greg Fitzgerald 90cd9bd533 Move balance check so that log_* methods are only used to add logging 2018-04-02 14:14:49 -06:00
Greg Fitzgerald d63506f98c No longer allow deposits outside the constructor 2018-04-02 14:00:42 -06:00
Greg Fitzgerald 17de6876bb Add simpler accountant constructor 2018-04-02 13:51:44 -06:00
Greg Fitzgerald 3abe305a21 Move reserve_signatures into accountant
Reasons Transaction signatures need to be unique:

1. guard against duplicates
2. accountant uses them as IDs to link Witness signatures to transactions via the
`pending` hash map
2018-04-02 09:38:36 -06:00
Greg Fitzgerald 46e8c09bd8 Revoke API access to first_id 2018-04-02 09:30:10 -06:00
Jackson Sandland ef169a6652 94: source doc review 2018-03-30 10:43:38 -07:00
Greg Fitzgerald b8cf5f9427 Fix transaction logging 2018-03-29 13:50:32 -06:00
Greg Fitzgerald 22f5985f1b Do request verification in parallel, and then process the verified requests 2018-03-29 13:18:08 -06:00
Greg Fitzgerald 55179101cd Add more documentation 2018-03-29 12:20:54 -06:00
Greg Fitzgerald ddb21d151d Nightly rustfmt
Format code with the nightly version of rustfmt, which sorts imports.
2018-03-26 22:03:28 -06:00
Greg Fitzgerald 117ab0c141 Clippy review 2018-03-22 14:50:24 -06:00
Greg Fitzgerald 60524ad5f2 Clippy review 2018-03-22 14:38:06 -06:00
Greg Fitzgerald 383d445ba1 Clippy review 2018-03-22 14:15:29 -06:00
Greg Fitzgerald 8295cc11c0 Move JSON printing up the stack 2018-03-20 23:15:44 -06:00
Greg Fitzgerald 9a7cac1e07 Use the Entry API to remove the double lookup 2018-03-20 18:07:54 -06:00
Greg Fitzgerald c584a25ec9 Move complete_transaction from method to function
So that we can hold separate mutable references to the pending queue
and the map of balances.
2018-03-20 17:47:57 -06:00
Greg Fitzgerald 4da89ac8a9 Cleanup naming 2018-03-20 16:53:41 -06:00
Greg Fitzgerald f7032f7d9a Cleanup: replace bool retval with is_complete() method 2018-03-20 16:52:47 -06:00
Greg Fitzgerald 6be3d62d89 Remove Action from spending plans 2018-03-20 15:43:07 -06:00
Greg Fitzgerald 4379fabf16 PlanEvent -> Witness
The term used by the Simplicity smart contract language
2018-03-20 15:25:50 -06:00
Greg Fitzgerald 64af37e0cd logger -> recorder
Free up namespace for a traditional runtime logger.
2018-03-19 10:16:21 -06:00
Greg Fitzgerald 265f41887f asset -> tokens 2018-03-19 10:03:41 -06:00
Greg Fitzgerald f4e0d1be58 Make conditions explicit in races
And boot recursive spending plans. That path required heap allocations.
Since we don't have a need for this generality right now, reduce the
language to the smallest one that can pass our test suite.
2018-03-17 20:43:05 -06:00
Greg Fitzgerald e5bae0604b Specialize transaction assets to i64
Proof-of-history is generic, but now that we're using it entirely
for tokens, we can specialize the type and start doing more interesting
things than just Eq and Serialize operations.
2018-03-17 19:56:15 -06:00
Greg Fitzgerald e7da083c31 Move spending plans to their own crate 2018-03-17 19:56:15 -06:00
Greg Fitzgerald 45765b625a Don't let users accidentally burn their funds either 2018-03-11 12:04:49 -06:00
Greg Fitzgerald aa0a184ebe Ensure the server isn't passed a Plan that spends more than is bonded 2018-03-11 11:53:45 -06:00
Greg Fitzgerald 0eb3669fbf cleanup timestamp processing 2018-03-11 00:30:01 -07:00
Greg Fitzgerald 30449b6054 cleanup sig processing 2018-03-11 00:11:08 -07:00
Greg Fitzgerald f5f71a19b8 First go at smart contracts
Needs lots of cleanup.
2018-03-10 22:00:48 -07:00
Greg Fitzgerald 9d77fd7eec Store only spending plans, not full transactions 2018-03-10 18:35:10 -07:00
Greg Fitzgerald 8c40d1bd72 Move spending endpoints into expressions 2018-03-10 17:41:18 -07:00
Greg Fitzgerald 7a0bc7d888 Move smart contract fields into their own struct 2018-03-10 16:55:39 -07:00
Greg Fitzgerald 49281b24e5 Move Tick out of Event
Every Entry is now a Tick and the entries contain events.
2018-03-09 17:22:17 -07:00