Commit Graph

2015 Commits

Author SHA1 Message Date
Greg Fitzgerald d1948b5a00 Zip earlier
And remove redundant into_iter() calls.
2018-04-10 21:18:39 -06:00
Anatoly Yakovenko c934a30f66 commandline options for client and testnode 2018-04-09 21:14:52 -07:00
Anatoly Yakovenko f330739bc7 Recycler test should verifyt that its recycling 2018-04-07 07:08:42 -07:00
Greg Fitzgerald 584c8c07b8 Better symmetry
deserialize -> process -> serialize
2018-04-06 16:34:59 -06:00
Greg Fitzgerald a93ec03d2c Move creating blobs into its own function 2018-04-06 16:22:02 -06:00
Greg Fitzgerald 7bd3a8e004 Reduce cyclomatic complexity 2018-04-06 16:12:13 -06:00
Greg Fitzgerald 912a5f951e Why is msgs cloned here? 2018-04-06 15:58:11 -06:00
Greg Fitzgerald 6869089111 Parallelize deserialize 2018-04-06 15:52:58 -06:00
Greg Fitzgerald 6fd32fe850 Cleanup constants 2018-04-06 15:43:05 -06:00
Greg Fitzgerald 81e2b36d38 Cleanup packet_verify 2018-04-06 15:24:15 -06:00
Greg Fitzgerald 7d811afab1 Parallelize CPU sig verify 2018-04-06 15:21:49 -06:00
Greg Fitzgerald 5fc81dd6c8 Fix the nightly build
Nightly uses a different (but backward compatible) version of rustfmt.
2018-04-05 22:39:29 -06:00
Greg Fitzgerald 491a530d90 Support parallelization of arbitrary transactions
Still assumes witnesses are processed serially afterward.
2018-04-05 22:30:25 -06:00
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
Anatoly Yakovenko 5ac7df17f9 Implement window service
Batch out of order blobs until we have a contigious window.
2018-04-03 13:53:19 -07: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 94eea3abec fmt 2018-04-02 21:15:21 -06:00
Greg Fitzgerald fe32159673 Add a test to ensure witness data continues to be hashed 2018-04-02 21:07:38 -06:00
Greg Fitzgerald 07aa2e1260 Add witness data to entry hash
Otherwise, witnesses can be dropped or reordered by a malicious
generator.
2018-04-02 20:47:51 -06:00
Greg Fitzgerald 6fec8fad57 Adding from to the signature is redundant 2018-04-02 20:34:18 -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 da2b4962a9 Move verify_slice() into a trait 2018-04-02 11:43:38 -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 9f256f0929 94 - snakecase mod names 2018-03-30 13:10:27 -07: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 2f1e585446 Better benchmark
Tolerates dropped UDP packets
2018-03-29 13:41:11 -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 c59c38e50e Refactor for batch verification 2018-03-29 13:09:21 -06:00
Greg Fitzgerald 232e1bb8a3 Colocate packet dependencies 2018-03-29 12:55:41 -06:00
Greg Fitzgerald 1fbb34620c Fix compiler warning 2018-03-29 12:54:10 -06:00
Greg Fitzgerald 55179101cd Add more documentation 2018-03-29 12:20:54 -06:00
Greg Fitzgerald 878ca8c5c5 Add microbenchmark for signature verification 2018-03-28 22:02:47 -06:00
Greg Fitzgerald 4bc41d81ee Fix compiler warning 2018-03-28 21:05:21 -06:00
Greg Fitzgerald 0bec360a31 Revert TCP sync of ledger
The feature was too rushed. We technically don't need it until we
implement consensus. It'll come back another day (with many more tests!)
2018-03-28 20:16:15 -06:00
Greg Fitzgerald 98c0a2af87 tx confirmed/sec ---> tx processed/sec
Before this patch, we were waiting until the full log was
sent back across the wire, parsed, and interpreted. That was giving
us a metric of "transactions confirmed per second" instead of
"transactions processed per second". Instead, we'll just send one
tiny packet back with the balance. As soon as the balance is what
we expect it to be, we end the benchmark.
2018-03-28 16:51:21 -06:00
Greg Fitzgerald 849bced602 Fix up client demo 2018-03-28 14:40:58 -06:00
Greg Fitzgerald 27f29019ef
Merge pull request #83 from garious/tcp-client
TCP subscription service
2018-03-28 13:19:38 -06:00
Greg Fitzgerald 8642a41f2b See if Travis will tolerate executing some of the test 2018-03-28 10:25:16 -06:00
Greg Fitzgerald bf902ef5bc Ignore accountant_stub test
TODO: Figure out why this test fails on TravisCI
2018-03-28 10:05:00 -06:00
Greg Fitzgerald 116166f62d Rename project: silk -> solana 2018-03-27 16:25:12 -06:00
Greg Fitzgerald 7c9681007c Drop support for random access to the ledger
No longer store the ledger locally.
2018-03-27 14:47:03 -06:00
Greg Fitzgerald 13206e4976 Let clients subscribe to the ledger over TCP
TODO: Add more tests

Fixes #27
2018-03-27 14:46:24 -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 c64a9fb456 Give Travis a little more time to start threads 2018-03-26 22:02:05 -06:00
Greg Fitzgerald ee19b4f86e See if CI hangs because of wait_on_signature() 2018-03-26 21:53:30 -06:00
Anatoly Yakovenko 14239e584f fix writer 2018-03-26 21:36:29 -06:00
Anatoly Yakovenko c1783d77d7 fixed test 2018-03-25 16:18:27 -07:00
Anatoly Yakovenko f089abb3c5 fix bench 2018-03-25 15:37:00 -07:00
Anatoly Yakovenko 8e551f5e32 debug trait tests 2018-03-25 08:22:04 -07:00
Anatoly Yakovenko 290960c3b5 wip 2018-03-25 08:06:33 -07:00
Anatoly Yakovenko 62af09adbe wip 2018-03-25 08:05:03 -07:00
Anatoly Yakovenko e39c0b34e5 update 2018-03-25 00:06:48 -07:00
Anatoly Yakovenko 8ad90807ee responder with larger block size 2018-03-24 23:46:25 -07:00
Anatoly Yakovenko 533b3170a7 responder 2018-03-24 23:31:54 -07:00
Anatoly Yakovenko 7732f3f5fb services 2018-03-24 18:01:54 -07:00
Anatoly Yakovenko f52f02a434 services 2018-03-24 18:01:40 -07:00
Greg Fitzgerald 9a437f0d38 Revive silk-testnode 2018-03-23 21:49:28 -06:00
Greg Fitzgerald fa44be2a9d Ignore some clippy advice 2018-03-22 14:59:25 -06:00
Greg Fitzgerald 117ab0c141 Clippy review 2018-03-22 14:50:24 -06:00
Greg Fitzgerald 7488d19ae6 Clippy review 2018-03-22 14:40:28 -06:00
Greg Fitzgerald 60524ad5f2 Clippy review 2018-03-22 14:38:06 -06:00
Greg Fitzgerald fad7ff8bf0 Clippy review 2018-03-22 14:31:58 -06:00
Greg Fitzgerald 383d445ba1 Clippy review 2018-03-22 14:15:29 -06:00
Greg Fitzgerald 803dcb0800 Mutex<bool> -> AtomicBool 2018-03-22 14:05:23 -06:00
Greg Fitzgerald 8ea97141ea Update the test to replicate the ledger 2018-03-21 17:15:32 -06:00
Greg Fitzgerald 9f232bac58 Allow clients to sync the ledger
Fixes #4
2018-03-21 15:46:49 -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 bff32bf7bc Cleanup 2018-03-20 17:32:02 -06:00
Greg Fitzgerald d0e7450389 Add docs 2018-03-20 16:58:14 -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 7c7e3931a0 Better docs 2018-03-20 15:52:46 -06:00
Greg Fitzgerald 6be3d62d89 Remove Action from spending plans 2018-03-20 15:43:07 -06:00
Greg Fitzgerald 6f509a8a1e Reorder 2018-03-20 15:31:28 -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 c11a3e0fdc Move streamer benchmark out of unit tests 2018-03-19 17:10:01 -06:00
Greg Fitzgerald 8ee76bcea0 Fix benchmark build 2018-03-19 16:41:01 -06:00
Greg Fitzgerald 9238ee9572 No longer rename log crate 2018-03-19 10:18:51 -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 9f9b79f30b log -> ledger
Free up namespace for traditional runtime logs.
2018-03-19 10:09:19 -06:00
Greg Fitzgerald 265f41887f asset -> tokens 2018-03-19 10:03:41 -06:00
Greg Fitzgerald 434f321336 Add spending plan tests 2018-03-18 21:02:28 -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 367c32dabe Guard spending plans, not just payments 2018-03-17 19:56:15 -06:00
Anatoly Yakovenko e8faf6d59a trait test 2018-03-14 11:28:05 -07:00
Anatoly Yakovenko baa4ea3cd8 wfmt 2018-03-14 11:14:40 -07:00
Anatoly Yakovenko 75ef0f0329 fix test 2018-03-14 11:02:38 -07:00
Anatoly Yakovenko eb94613d7d Use streaming socket interface within accountant
Pull messages from streamer process them and forward them to the sender.
2018-03-11 23:41:09 -05:00
Greg Fitzgerald 67f4f4fb49
Merge pull request #64 from garious/dumb-contracts
Entry-level smart contracts
2018-03-11 13:23:11 -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
Anatoly Yakovenko c82b520ea8 remove unecessary returns 2018-03-11 11:45:17 -05:00
Anatoly Yakovenko 9d6e5bde4a ipv6 test with a separate flag 2018-03-11 11:22:21 -05: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
Anatoly Yakovenko 0135971769 Fast UdpSocket reader
* message needs to fit into 256 bytes
* allocator to keep track of blocks of messages
* udp socket receiver server that fills up the block as fast as possible
* udp socket sender server that sends out the block as fast as possible
2018-03-10 21:09:23 -06:00
Greg Fitzgerald 8579795c40 Ensure transactions won't get canceled after next refactor 2018-03-10 19:44:45 -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
Greg Fitzgerald a8b1980de4 Restore reorder attack test 2018-03-09 17:02:17 -07:00
Greg Fitzgerald cc9f0788aa Batch events
It's now a Tick that locks down event order. Before this change, the
event order would be locked down in the order the server sees it.

Fixes #59
Fixes #61
2018-03-09 16:16:33 -07:00
Greg Fitzgerald 957fb0667c Deterministic historian/accountant hashes
When in tick-less mode, no longer continuously hash on the
background thread. That mode is just used for testing and
genesis log generation, and those extra hashes are just noise.

Note that without the extra hashes, with lose the duration between
events. Effectively, we distinguish proof-of-order from proof-of-time.
2018-03-09 06:58:40 -07:00
Greg Fitzgerald 8d17aed785 Process timestamps as they are added 2018-03-08 15:39:03 -07:00
Greg Fitzgerald ad6665c8b6 Complete timestamp and signature transactions 2018-03-08 11:06:52 -07:00
Greg Fitzgerald 923162ae9d WIP: process timestamps 2018-03-08 10:19:54 -07:00
Greg Fitzgerald dd2bd67049 Add a barebones test for transaction conditions 2018-03-08 08:58:34 -07:00
Greg Fitzgerald d500bbff04 Add public key to mint
This turns the mint into a handy way to generate public keys
without throwing the private key away.
2018-03-08 08:33:00 -07:00
Greg Fitzgerald e759bd1a99 Add conditions to the signature to reject duplicates 2018-03-08 08:18:34 -07:00
Greg Fitzgerald 94daf4cea4 Add Cancel and Timestamp events
Fixes #31, #34, #39
2018-03-08 08:17:34 -07:00
Greg Fitzgerald 2379792e0a Add DateTime and Cancel conditions
Fixes #32, #33
2018-03-08 08:17:08 -07:00
Greg Fitzgerald 5dd567deef Rename Genesis to Mint
Genesis is a story of creation. We should only use that term to
for the event log that bootstraps the system.
2018-03-07 17:08:15 -07:00
Greg Fitzgerald b6d8f737ca Introducing, the mint
Use the mint to pair a new private key with new tokens.
2018-03-07 16:58:04 -07:00
Greg Fitzgerald 491ba9da84 Add accessors to keypairs and signatures 2018-03-07 15:32:22 -07:00
Greg Fitzgerald a420a9293f Fix demo 2018-03-07 11:37:30 -07:00
Greg Fitzgerald 9834c251d0 Boot genesis block helper
Before this change, if you wanted to use a new Transaction
feature in the genesis block, you'd need to extend its
Creator object and associated methods.  With yesterday's
addtions to Transcation, it's now so easy to work with
Transactions directly that we can get rid of the middleman.

Also added a KeyPair type alias, so that ring could be easily swapped
out with a competing library, if needed.
2018-03-07 11:10:15 -07:00
Greg Fitzgerald 54340ed4c6 Delete debugging println
Thanks @jackson-sandland!
2018-03-06 21:17:41 -07:00
Greg Fitzgerald d1b6206858 Monomorphisize Entry and Event
Transaction turned out to be the only struct worth making generic.
2018-03-06 20:29:18 -07:00
Greg Fitzgerald b725fdb093 Sha256Hash -> Hash
Because in Loom, there's just the one. Hopefully no worries that it
shares a name with std::Hash.
2018-03-06 17:40:01 -07:00
Greg Fitzgerald 1436bb1ff2 Move entry into its own module
Hmm, Logger doesn't depend on log.
2018-03-06 17:40:01 -07:00
Greg Fitzgerald 5a44c36b1f Move hash into its own module 2018-03-06 17:40:01 -07:00
Greg Fitzgerald f09952f3d7 DRY up transaction signing
Cleanup the big mess I copy-pasted myself into.
2018-03-06 16:34:25 -07:00
Greg Fitzgerald 4376032e3a data -> asset
'data' is too vague.
2018-03-06 14:50:32 -07:00
Greg Fitzgerald 624c151ca2 Add signature module
Because things other than transactions can be signed.
2018-03-06 12:48:28 -07:00
Greg Fitzgerald 5d0356f74b Move verify_entry to a method as well 2018-03-06 12:35:12 -07:00
Greg Fitzgerald b019416518 Move verify into methods
A little overly-coupled to Serialize, but makes the code a lot tighter
2018-03-06 12:27:08 -07:00
Greg Fitzgerald 4fcd9e3bd6 Give Transaction its own module 2018-03-06 12:18:17 -07:00
Greg Fitzgerald 66bf889c39 Rename Transfer to Transaction
struct names should be nouns
2018-03-06 11:54:47 -07:00
Greg Fitzgerald a2811842c8 More cleanup
Far fewer branches when we process transfers outside the context
of events.
2018-03-06 11:43:55 -07:00
Greg Fitzgerald 1929601425 Cleanup
Now that Transfer is out of the enum, we don't need to pattern
match to access its fields.
2018-03-06 11:19:59 -07:00
Greg Fitzgerald 282afee47e Use Transfer struct on the client side too
Sharing is caring.
2018-03-06 11:03:43 -07:00
Greg Fitzgerald e701ccc949 Rename Request::Transfer to Request::Transaction 2018-03-06 10:59:47 -07:00
Greg Fitzgerald 6543497c17 Move Transaction data into its own struct
This will allow us to add addition transfer types to the log.
2018-03-06 10:50:32 -07:00
Greg Fitzgerald 720c54a5bb Allow balances to be negative
* Will allow owners to loan token to others.
* Will allow for parallel verification of balances without spilling
  over 64 bits.

Fixes #43
2018-03-05 17:30:53 -07:00
Greg Fitzgerald a4336a39d6 Initialize the testnode from a log
$ cargo run --bin silk-genesis-file-demo > demo-genesis.json
$ cat demo-genesis.json | cargo run --bin silk-genesis-block > demo-genesis.log
$ cat demo-genesis.log | cargo run --bin silk-testnode
2018-03-05 15:34:44 -07:00
Greg Fitzgerald 298989c4b9 Generate log from Genesis 2018-03-05 13:03:56 -07:00
Greg Fitzgerald 48c28c2267 Transactions now require a hash of the last entry they've seen
This ensures the transaction cannot be processed on a chain
that forked before that ID. It will also provide a basis for
expiration constraints. A client may want their transaction
to expire, and the generators may want to reject transactions
that have been floating in the ether for years.
2018-03-05 12:48:14 -07:00
Greg Fitzgerald d76ecbc9c9 Don't block the server 2018-03-05 11:39:59 -07:00
Greg Fitzgerald 79fb9c00aa Boot wait_on_signature() from accountant
Instead, there should be a way to query for a page of log data,
and checking whether it has a signature should be done client-side.
2018-03-05 10:45:18 -07:00
Greg Fitzgerald c9e03f37ce Logger now only speaks when spoken to
Before this change, the logger's send channel could quickly be
flooded with Tick events. Those events should only be passed to
a writer.

Also, the log_event() function no longer sends entries. That
functionality moved to the new process_events() function. This
will allow us to initialize the with the genesis block without
flooding the send channel with events the historian won't read.
2018-03-05 10:33:12 -07:00
Greg Fitzgerald aa5f1699a7 Update the set of unique signatures when loading an existing log. 2018-03-04 22:31:12 -07:00
Greg Fitzgerald 955f76baab Finally, genesis block generation without channels 2018-03-04 14:32:30 -07:00
Greg Fitzgerald ff82fbf112 Make num_hashes mean the num_hashes since the last ID
Before this change, num_hashes meant the number of hashes since
the last ID, minus any hashing done on the event data. It made
no difference for Tick events, but logged Transaction events with
one less hash than actually occurred.
2018-03-04 09:52:36 -07:00
Greg Fitzgerald 8503a0a58f Refactor 2018-03-04 09:21:45 -07:00
Greg Fitzgerald b1e9512f44 Rename end_hash to id 2018-03-04 07:50:26 -07:00
Greg Fitzgerald 608def9c78 Consolidate imports 2018-03-04 07:28:51 -07:00
Greg Fitzgerald bcb21bc1d8 Delete dead code 2018-03-04 07:20:17 -07:00
Greg Fitzgerald 9b26892bae Add a demo app to generate the genesis file 2018-03-04 01:21:40 -07:00
Greg Fitzgerald 572475ce14 Load the genesis block 2018-03-04 00:15:17 -07:00
Greg Fitzgerald 876d7995e1 Refactor to support loading an existing ledger 2018-03-03 22:25:40 -07:00
Greg Fitzgerald b8655e30d4 Make client-demo standalone
And remove deposit() methods from the API. Those should only be
used on the server to bootstrap.
2018-03-03 21:15:51 -07:00
Greg Fitzgerald 7cf0d55546 Remove optional 'from' field 2018-03-03 20:41:07 -07:00
Greg Fitzgerald ce60b960c0 Special case sending money to self
In the genesis block, let matching 'from' and 'to' keys be used
to mint new coin.
2018-03-03 20:27:12 -07:00
Greg Fitzgerald cebcb5b92d Start genesis with a Tick, so that its hash can be used to bootstrap verification 2018-03-03 19:57:22 -07:00
Greg Fitzgerald 11a0f96f5e Add command-line tool for generating a genesis block 2018-03-03 17:35:05 -07:00
Greg Fitzgerald f7496ea6d1 Make create_logger a static method
Allows us to share the super long type signature in impl.
2018-03-03 14:26:59 -07:00
Greg Fitzgerald bebba7dc1f Give logger its own crate 2018-03-03 14:24:32 -07:00
Greg Fitzgerald afb2bf442c Use Instant instead of SystemTime for more precise ticking
And convert log_event from function to method
2018-03-03 14:08:53 -07:00
Greg Fitzgerald c7de48c982 Convert log_events from function to method 2018-03-03 14:00:37 -07:00
Greg Fitzgerald f906112c03 Move logging thread's state into a struct 2018-03-03 13:52:57 -07:00
Greg Fitzgerald 1c9b5ab53c Report performance of signature verification too 2018-03-03 11:59:34 -07:00
Greg Fitzgerald c10faae3b5 More readable metrics 2018-03-03 11:52:50 -07:00
Greg Fitzgerald 2104dd5a0a Fix benchmark
Was measuring the creation of the iterator, not running it.
2018-03-03 11:45:23 -07:00
Greg Fitzgerald d8c50b150c Move key generation and signing from transaction benchmark
Key generation, signing and verification are not the performance
bottleneck. Something is probably wrong here.
2018-03-03 11:11:46 -07:00
Greg Fitzgerald a148454376 Update readme 2018-03-02 12:07:05 -07:00
Greg Fitzgerald be518b569b Remove cyclic dependency between event and log 2018-03-02 12:03:59 -07:00
Greg Fitzgerald c998fbe2ae Sign the owner's public key
Without this, the accountant will reject transfers from different
entities if they are for the same amount and to the same entity.
2018-03-02 11:56:42 -07:00
Greg Fitzgerald 9f12cd0c09 Purge the Claim event type
It's now represented as a Transaction from an unknown party.
2018-03-02 11:48:58 -07:00
Greg Fitzgerald 0d0fee1ca1 Sign Claim's 'to' field
Otherwise, the accountant will treat deposits of the same amount as
duplicates.
2018-03-02 11:46:22 -07:00
Greg Fitzgerald a0410c4677 Pipe all Claim constructors through a function 2018-03-02 10:58:43 -07:00
Greg Fitzgerald 8fe464cfa3 Rename Claim's key field to match same field in Transaction 2018-03-02 10:47:21 -07:00
Greg Fitzgerald 3e2d6d9e8b Generalize Transaction to express a Claim
If a Transaction doesn't have an existing address, it's being used
to create new funds.
2018-03-02 10:41:15 -07:00
Greg Fitzgerald 32d677787b Reduce transactions sent by demo
We don't do retries yet, so keep tx count to something that won't
trigger any packet loss.
2018-03-02 10:35:38 -07:00
Greg Fitzgerald dfd1c4eab3 Don't process transaction if channel.send() fails.
Do all input validation first, then log (which can fail). If all
goes swimmingly, process the transaction.
2018-03-02 10:17:52 -07:00
Greg Fitzgerald 36bb1f989d More defense against a double-spend attack
Before this change, a client could spend funds before the accountant
processed a previous spend. With this change in place, the accountant
updates balances immediately, but that comes at an architectural cost.
The accountant now verifies signatures on behalf of the historian, so
that it can ensure logging will not fail.
2018-03-02 09:55:44 -07:00
Greg Fitzgerald 684f4c59e0 Delete commented out code
accountant crate shouldn't verify the log. Instead, it should
only add valid entries and leave verification to network nodes.
2018-03-02 08:51:29 -07:00
Greg Fitzgerald 1b77e8a69a Move Event into its own crate
The log crate was starting to be the catch-all for all things
related to entries, events, signatures, and hashes. This split
shows us that:

* Event depends only on signatures, not on hashes [directly]
* All event testing was done via log testing (shame on me)
* Accounting depends only on events
2018-03-02 08:43:57 -07:00
Greg Fitzgerald c935fdb12f Move signature duplicate detection into the historian 2018-03-01 17:44:10 -07:00
Greg Fitzgerald 9e16937914 Delete the Discovery event
Not useful to the accountant.
2018-03-01 17:02:41 -07:00
Greg Fitzgerald f705202381 No need to hash data that's already hashed to create the signature 2018-03-01 16:39:09 -07:00
Greg Fitzgerald 570e71f050 Check for duplicate signatures
TODO: have client add recent hash to each message
2018-03-01 14:07:39 -07:00
Greg Fitzgerald c9cc4b4369 Switch to UDP from TCP
And remove all the sleep()'ing around.
2018-03-01 13:47:53 -07:00
Greg Fitzgerald 4610de8fdd Switch to sync_channel to preserve order 2018-02-28 19:33:28 -07:00
Greg Fitzgerald 3fcc2dd944 Add testnode
Fixes #20
2018-02-28 18:05:20 -07:00
Greg Fitzgerald 8299bae2d4 Add accountant stub 2018-02-28 16:01:12 -07:00
Greg Fitzgerald 604ccf7552 Add network interface for accountant 2018-02-28 14:00:04 -07:00
Greg Fitzgerald c3bb207488 Verify event signatures before adding log entries 2018-02-28 10:23:01 -07:00
Greg Fitzgerald fa4d9e8bcb Add more tests 2018-02-27 11:28:10 -07:00
Greg Fitzgerald 34b77efc87 Sleep longer for TravisCI 2018-02-27 11:08:28 -07:00
Greg Fitzgerald 5ca0ccbcd2 Add accountant 2018-02-27 10:54:06 -07:00
Greg Fitzgerald f98e9a2ad7 Fix overuse of search-and-replace 2018-02-26 17:03:50 -07:00
Greg Fitzgerald c6134cc25b Allow the historian to track ownership of any type of data 2018-02-26 17:01:22 -07:00
Greg Fitzgerald 0443b39264 Allow event log to hold events of any serializable (hashable) type 2018-02-26 16:42:31 -07:00
Greg Fitzgerald 8b0b8efbcb Allow Entry to hold events of any kind of data 2018-02-26 15:37:33 -07:00
Greg Fitzgerald 97449cee43 Allow events to hold any kind of data 2018-02-26 15:31:01 -07:00
Greg Fitzgerald ab5252c750 Move entry verification out of Entry impl 2018-02-26 14:39:01 -07:00
Greg Fitzgerald b02eab57d2 Extend the event log with a Transaction event to transfer possession
This implementation assumes 'from' is the current owner of 'data'.
Once that's verified, the signature ensures that nobody modified
'data' (the asset being transferred) or 'to' the entity taking
ownership.

Fixes #14
2018-02-26 11:09:11 -07:00
Greg Fitzgerald b8d52cc3e4 Make the Discovery event into a struct instead of a tuple 2018-02-24 11:15:03 -07:00
Greg Fitzgerald d78082f5e4 Test bad signature 2018-02-24 10:27:51 -07:00
Greg Fitzgerald 08e501e57b Extend the event log with a Claim event to claim possession
Unlike a Discovery event, a Claim event associates a public key
with a hash. It's intended to to be used to claim ownership of
some hashable data. For example, a graphic designer could claim
copyright by hashing some image they created, signing it with
their private key, and publishing the hash-signature pair via
the historian. If someone else tries to claim it as their own,
the designer can point to the historian's log as cryptographically
secure evidence that the designer's copy existed before anyone
else's.

Note there's nothing here that verifies the first claim is the actual
content owner, only that the first claim almost certainly happened
before a second.
2018-02-24 10:09:49 -07:00
Greg Fitzgerald 29a607427d Rename UserDataKey to Discovery
From the perspective of the log, when some data's hash is added,
that data is "discovered" by the historian.  Another event
might be a "claim" that some signed data belongs to the owner of a
public key.
2018-02-24 05:25:19 -07:00
Greg Fitzgerald c1326ac3d5 Up the time to sleep so that ticks are generated 2018-02-21 12:22:23 -07:00
Greg Fitzgerald 7871b38c80 Update demo to use self-ticking logger 2018-02-21 11:52:03 -07:00
Greg Fitzgerald b34d2d7dee Allow the logger to inject Tick events on its own 2018-02-21 11:33:42 -07:00
Greg Fitzgerald fa4e232d73 Add serialization/deseriation support to event log
See bincode and serde_json for usage:
https://github.com/TyOverby/bincode

Fixes #1
2018-02-20 16:26:13 -07:00
Greg Fitzgerald 6e37f70d55 Test reorder attack 2018-02-20 14:46:36 -07:00
Greg Fitzgerald d97112d7f0 Explain proof-of-history in the readme
Also:
* Hash userdata so that verification works as the readme describes.
* Drop itertools package. Found a way to use std::iter instead.

Fixes #8
2018-02-20 14:04:49 -07:00
Greg Fitzgerald ba90e43f72 Update benchmark
* Add asm, though it doesn't make it faster. TODO: use avx instructions.
* Do 10x less hashes, since sha256 is more expensive.
2018-02-19 16:51:35 -07:00
Greg Fitzgerald 0297edaf1f Use sha256 hashes instead of Rust's builtin hasher.
Causes a 20x performance degradation. Enabling asm did not
speed things up.
2018-02-19 16:23:53 -07:00
Greg Fitzgerald bb22522e45 Remove assertions that fail in the kcov docker container 2018-02-19 12:54:01 -07:00
Greg Fitzgerald bd3fe5fac9 Sleep a little longer to ensure Travis context switches 2018-02-19 12:33:33 -07:00
Greg Fitzgerald 10a70a238b Cleanup demo 2018-02-19 12:25:57 -07:00
Greg Fitzgerald 4a7156de43 Move hash generation into stateless function 2018-02-19 12:09:58 -07:00
Greg Fitzgerald d88d1b2a09 Reset historian's hasher between events
Hasher will generate different hashes for the same input if it
had already generated a hash.

Also add a binary to ensure the example in the README works.
2018-02-19 12:03:06 -07:00
Greg Fitzgerald 5e3c7816bd Ensure verify_slice succeeds 2018-02-19 09:09:24 -07:00
Greg Fitzgerald ceb65c2669 Better function names 2018-02-18 10:05:54 -07:00
Greg Fitzgerald fd209ef1a9 Rename event crate to log 2018-02-18 09:59:33 -07:00
Greg Fitzgerald 471f036444 Better names
Event -> Entry
EventData -> Event
2018-02-18 09:53:40 -07:00
Greg Fitzgerald 4c94754661 More coverage 2018-02-17 21:13:52 -07:00
Greg Fitzgerald 831e2cbdc9 Add historian
A microservice that continuously generates hashes, only stopping to
tag messages with the latest hash.

Fixes #8
2018-02-17 20:58:23 -07:00
Greg Fitzgerald 69f70cfe72 Add separate benchmarks for seq and par versions of verify_slice 2018-02-16 09:38:12 -08:00
Greg Fitzgerald 1c2e0af69b Docs cleanup 2018-02-16 09:56:10 -07:00
Greg Fitzgerald a857ae514b Test sequential version of verify_slice with same tests 2018-02-16 09:14:42 -07:00
Greg Fitzgerald 09ccc1ee6d Use create_ticks() outside of benchmark for improved code coverage 2018-02-16 09:06:25 -07:00
Greg Fitzgerald 38485b09c7 Move tests to expose them to rustfmt and kcov 2018-02-15 17:47:54 -07:00
Greg Fitzgerald fb168fcee0 Cleanup
Make it so the parallel and sequential verification implementations
are only different in one line.

For reasons I don't understand Rayon's `all()` isn't `mut`.
2018-02-15 16:00:53 -07:00
Greg Fitzgerald b5645bc776 Rename project 2018-02-15 13:59:33 -07:00
Greg Fitzgerald 3cef50056b Consistent naming 2018-02-15 11:50:48 -07:00
Greg Fitzgerald a20e114a80 Cleanup tests 2018-02-15 11:48:18 -07:00
Greg Fitzgerald 0dc0ae506d Better names 2018-02-15 11:45:04 -07:00
Greg Fitzgerald 9723c827f5 mut hash -> end_hash 2018-02-15 11:29:09 -07:00
Greg Fitzgerald 75d091bd3c More descriptive event data 2018-02-15 10:57:32 -07:00
Greg Fitzgerald d21ad9357c More descriptive field names 2018-02-15 10:48:30 -07:00
Greg Fitzgerald a74540470a Rename Tick to Event
* Define a tick to be an event with no user data.
* Use the term "event log" for now.
** Reserve the word "entry" for hash entries, and "item" for array items.
** Reserve the word "blockchain" for when the event is a block of something.
** Reserve the word "ledger" for when the event is of a particular type,
   such as transactions.
2018-02-15 10:13:59 -07:00
Greg Fitzgerald beb4a643ad Add back a more traditional version of new() 2018-02-14 16:52:09 -07:00
Greg Fitzgerald cdf3cffcae Rename Tick::new() to Tick::run() 2018-02-14 16:45:42 -07:00
Greg Fitzgerald 8a521ba163 Make space for user data 2018-02-14 16:18:06 -07:00
Greg Fitzgerald 31d79727b6 Parallelize verification 2018-02-14 15:23:13 -07:00
Greg Fitzgerald 8ff8e90c5e Cleanup slice verification 2018-02-14 13:02:39 -07:00
Greg Fitzgerald d23fda1936 First go at Proof of History 2018-02-14 11:00:01 -07:00
Greg Fitzgerald bad95b7712 cargo init 2018-02-14 07:23:59 -07:00