Commit Graph

251 Commits

Author SHA1 Message Date
Jude Nelson
d3bcd89f64 stub out a block database and a state database for the stacks blockchain 2019-03-09 18:55:54 -05:00
Jude Nelson
f8a504631c initial codec for Stacks blocks 2019-03-09 18:55:18 -05:00
Jude Nelson
162aa317ed initial codec for the spending authorization structure in a stacks transaction 2019-03-09 18:55:01 -05:00
Jude Nelson
60bd01b723 initial codec for Stacks addresses 2019-03-09 18:54:39 -05:00
Jude Nelson
626b1eae1d add secp256k1 2019-03-09 18:54:14 -05:00
Jude Nelson
c672520e2d make it impossible to represent an invalid VRF proof 2019-03-09 18:54:02 -05:00
Jude Nelson
eeb549bb52 careful when encoding/decoding big-endian -- make sure it's a no-op on a big-endian machine 2019-03-09 18:53:32 -05:00
Jude Nelson
cca69ca928 implement a Merkle tree (but unlike a Bitcoin merkle tree, we'll be sure to _tag_ the leaf and non-leaf nodes) 2019-03-09 18:53:04 -05:00
Jude Nelson
e734f9bcb6 mod update 2019-03-09 18:52:54 -05:00
Jude Nelson
e07358e79a constants for networking 2019-03-09 18:52:45 -05:00
Jude Nelson
1ac2648384 first crack at data structures for the Stacks blockchain transactions and blocks. 2019-03-09 18:52:23 -05:00
Jude Nelson
085e54902d database-generic error structures, to be used in other places 2019-03-09 18:52:05 -05:00
Jude Nelson
4703a38c77 fix sortition algorithm to decrement burn quota only once it has been met over several blocks (#931) 2019-03-09 18:51:39 -05:00
Jude Nelson
74ed09aeda test structure update 2019-03-09 18:51:28 -05:00
Jude Nelson
0e239e5021 refactor import 2019-03-09 18:51:20 -05:00
Jude Nelson
cb5ab9b447 test structure update 2019-03-09 18:51:12 -05:00
Jude Nelson
e72bc0fb9a document possibility of including a Stacks PoW solution in a leader block commit 2019-03-09 18:50:50 -05:00
Jude Nelson
2e471a937a update block snapshot to include a running sortition burn total and include a parent block back pointer 2019-03-09 18:50:27 -05:00
Jude Nelson
6f63b3d09a copyright update 2019-03-09 18:50:07 -05:00
Jude Nelson
175109845a move db-generic code to chainstate 2019-03-09 18:49:51 -05:00
Jude Nelson
24f26d9e3b block snapshots now include a parent pointer and a running total of the number of tokens burnt for the next upcoming sortition 2019-03-09 18:49:22 -05:00
Jude Nelson
70469cb5ee burnchain blocks now include parent backpointers; include a privatekey trait 2019-03-09 18:49:03 -05:00
Jude Nelson
f1684c87a4 add a test to ensure that the burn quota increments and decrements correctly 2019-03-09 18:48:37 -05:00
Jude Nelson
d2de680604 now implemented in util::secp256k1 2019-03-09 18:48:13 -05:00
Jude Nelson
f9844325a8 burnchain blocks now store parent pointers 2019-03-09 18:47:57 -05:00
Jude Nelson
b9e06f4409 make BurnchainTxInput::to_address_bits() a member method, not a static method 2019-03-09 18:47:40 -05:00
Jude Nelson
31337a95ab add c32 encode/decode to Bitcoin addresses (for now) 2019-03-09 18:47:15 -05:00
Jude Nelson
cad5a71fb4 run c32 tests 2019-03-09 18:46:59 -05:00
Jude Nelson
c2078ad55e Merge branch 'develop' into develop-jude 2019-02-19 14:09:34 -05:00
Aaron Blankstein
29a0225531 light cleaning up of test functions 2019-02-19 11:28:30 -06:00
Aaron Blankstein
bb203956e7 rename MultiplyDefined error to VariableDefinedMultipleTimes 2019-02-19 10:40:22 -06:00
Aaron Blankstein
74e45cbcb8 implement partialeq, hash for ListData and TupleData manually: allows Value to derive. remove now uneccessary Hash traits. 2019-02-19 10:19:16 -06:00
Aaron Blankstein
f3177eece8 implement equality for Value enum 2019-02-19 09:47:23 -06:00
Jude Nelson
8a2f742694 add uint 2019-02-18 22:00:58 -05:00
Jude Nelson
aac244a5f6 burnchain::new can fail 2019-02-18 22:00:50 -05:00
Jude Nelson
ac60f8858e the check() method for operations returns a CheckResult enum now to encode specific kinds of errors (instead of a catch-all bool). Add tests for each check() method and make sure they all fail in the right way. 2019-02-18 22:00:01 -05:00
Jude Nelson
b6a6ee4fe6 implement sortition hashes -- a rolling hash over block headers from the PoW chain that gets mixed with a VRF seed 2019-02-18 21:59:30 -05:00
Jude Nelson
8eba37aab8 SortitionHash's will be stored in a BlockSnapshot, so make them insertable into rows 2019-02-18 21:58:52 -05:00
Jude Nelson
95a0d24057 flesh out unit tests; expand snapshot code to accomodate sortition results; add method to query the last successful sortition; add a few more methods needed for checking operations 2019-02-18 21:58:10 -05:00
Jude Nelson
038eba12a0 some type refactoring to better represent various burnchain configurations 2019-02-18 21:57:47 -05:00
Jude Nelson
60d36a3d3a refactor the burnchain "main loop" to only insert user burns that supported block commits in this block (and ignoring all others), and to make it easier to test cryptographic sortition. Add cryptographic sortition tests. 2019-02-18 21:57:04 -05:00
Jude Nelson
217c7f4e73 to_address_bits() should just return the 20-byte hash, not the scriptpubkey 2019-02-18 21:56:37 -05:00
Jude Nelson
e4dabe358d add macros and implementations for 256-bit and 512-bit integers (borrowed with gratitude from rust-bitcoin) 2019-02-18 21:56:11 -05:00
Jude Nelson
32883c8934 Update the BlockSnapshot code to generate a burn distribution over its blocks and select a winning block using cryptographic sortition. The burn distribution will be sampled using the hash of the PoW block header and the last successful sortition's VRF seed. 2019-02-18 21:55:20 -05:00
Jude Nelson
dde76d520c Separate out code and tests for calculating a burn distribution -- a Vec of BurnSamplePoints. This allows us to take a block's worth of block commits and user burns, and figure out the total burns behind each candidate block. This code also takes the integer range [0, 2**256 - 1) and partitions it into disjoint ranges representing sets of possible sortition hashes whose sizes are proportional to how much burn support there is behind each block. 2019-02-18 21:52:48 -05:00
Aaron Blankstein
241b3cc49f separate two kinds of contexts (local and global) into two types 2019-02-18 12:29:17 -06:00
Aaron Blankstein
8791851bbf use two types for public and private functions 2019-02-18 09:46:53 -06:00
Aaron Blankstein
476cd7f1a0 use [u8;20] array instead of vec for principal type 2019-02-18 09:28:48 -06:00
Aaron Blankstein
c62297dde7 handle the sender argument to contract execution 2019-02-18 09:18:24 -06:00
Aaron Blankstein
d062cd9859 return error from size() instead of panics on overflow. 2019-02-18 09:15:02 -06:00