Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Review: Smart contract VM 01/30/19 #908

Merged
merged 117 commits into from
Feb 7, 2019
Merged
Changes from 1 commit
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
cb03afb
very rough initial apply/eval
kantai Jan 10, 2019
ec8f6e2
some rough typing at the interpreter level
kantai Jan 10, 2019
eef1fe3
snake cases
kantai Jan 10, 2019
c456dca
just build the vm
kantai Jan 10, 2019
206fa99
rough contexts
kantai Jan 10, 2019
1be6197
user defined functions
kantai Jan 10, 2019
8ea3955
start refactoring
kantai Jan 11, 2019
bfd5374
refactor main into integration test
kantai Jan 11, 2019
9d81913
simple if statements and eq? implementation
kantai Jan 11, 2019
c0287b2
refactoring native/special function definitions out of lib.rs
kantai Jan 14, 2019
00e92f3
change s-exp representation to enum of atom, list. this is a better r…
kantai Jan 14, 2019
adcc746
implement `let` special function, add simple test
kantai Jan 14, 2019
e2f9558
add simple parsing.
kantai Jan 14, 2019
bdbd2fc
add parser tests. add tests for native arithmetic. use checked native…
kantai Jan 14, 2019
5858cee
add call stack check to prevent recursion
kantai Jan 15, 2019
a0becda
borrow checks will not like functions having pointers to their contex…
kantai Jan 15, 2019
089ed92
support (defines) in global context
kantai Jan 15, 2019
e017382
add (define) and some tests for it
kantai Jan 16, 2019
cd9ed34
experiment with kcov
kantai Jan 17, 2019
c55c7e3
change location of BitcoinNetworkType
jcnelson Jan 17, 2019
4e7f7d7
test BurnchainTxInput<BitcoinPublicKey> (de)serialization with custom…
jcnelson Jan 17, 2019
4044de0
update location of BitcoinNetworkType
jcnelson Jan 17, 2019
c659082
BitcoinNetworkType is now mod-level
jcnelson Jan 17, 2019
4974ad4
serde is broken in the rust-secp256k1 module, so implement custom (de…
jcnelson Jan 17, 2019
f81d003
BitcoinNetworkType is now a mod-level enum
jcnelson Jan 17, 2019
565ab06
use new location of BitcoinNetworkType
jcnelson Jan 17, 2019
6bfc549
denormalize the burnchain DB a little to avoid a JOIN; implement From…
jcnelson Jan 17, 2019
e2714cb
add FromRow trait to allow a uniform way of loading a particular (cus…
jcnelson Jan 17, 2019
f162465
change location of BitcoinNetworkType
jcnelson Jan 17, 2019
733e078
add a RowOrder trait that is used to force objects stored in the DB t…
jcnelson Jan 17, 2019
74a0aa9
start simple list operations
kantai Jan 22, 2019
eb70a77
upload coverage to codecov.io
kantai Jan 22, 2019
427db7a
codecov fixes
kantai Jan 22, 2019
95bf1ad
more test coverage for lists
kantai Jan 22, 2019
a14e956
use InterpreterResult instead of ValueType. this allows runtime error…
kantai Jan 25, 2019
98f819b
update tests for result types
kantai Jan 25, 2019
8b4ec5c
remove more panics
kantai Jan 25, 2019
b3e9693
add arithmetic comparisons, boolean special functions
kantai Jan 26, 2019
fd2856e
add tests for boolean functions
kantai Jan 27, 2019
928ddf4
list type enforcement
kantai Jan 27, 2019
b650eb1
clean up imports and warnings
jcnelson Jan 27, 2019
4df9a5e
flesh out pipeline traits and impls
jcnelson Jan 27, 2019
4bc68c3
move Hash160 to src/util/hash.rs
jcnelson Jan 27, 2019
45eccd3
remove unused macro
jcnelson Jan 27, 2019
a391f13
clean up imports
jcnelson Jan 27, 2019
c9fe11d
add util error types in preparation for pipeline implementations
jcnelson Jan 27, 2019
da50701
clean up imports; force UserBurnSupportOp to be parameterized by both…
jcnelson Jan 27, 2019
1733658
clean up imports; add both an address and public key type parameter s…
jcnelson Jan 27, 2019
4bc6a96
LeaderBlockCommitOp must indicate an epoch number so the parser will …
jcnelson Jan 27, 2019
5097644
add to_string() and from_string() trait impls
jcnelson Jan 27, 2019
90a2af2
clean up imports; add constructor for a burn header hash that takes a…
jcnelson Jan 27, 2019
b61781f
clean up imports; add pipeline processor trait impls to the block dow…
jcnelson Jan 27, 2019
1a462ca
WIP: fleshed out indexer implementation to check for burn chain reorg…
jcnelson Jan 27, 2019
14b79a6
clean up imports
jcnelson Jan 27, 2019
ceee097
clean up imports
jcnelson Jan 27, 2019
fe99599
rework refs to messages in the network communication so that message …
jcnelson Jan 27, 2019
2987a23
API sync with new message handler trait
jcnelson Jan 27, 2019
78ea465
extend indexer trait to deal with reorgs and to fetch headers and blocks
jcnelson Jan 27, 2019
9116f67
clean up imports; more error types
jcnelson Jan 27, 2019
b58d642
do some reorganization; adjust imports accordingly. also, add an err…
jcnelson Jan 27, 2019
53637cc
move burndb.rs to a burn-specific db dir; add code for snapshotting b…
jcnelson Jan 27, 2019
c388cb4
flesh out more impls for data we stuff into the db; move to a burn db…
jcnelson Jan 27, 2019
1a57c08
this file now contains all our burn database types
jcnelson Jan 27, 2019
88ba930
clean up trait definitions for blockstack burn operations so they all…
jcnelson Jan 27, 2019
7e18832
this directory has moved to src/chainstate/burn/operations
jcnelson Jan 27, 2019
34cbb35
this module now points to both the burn chain state and the stacks ch…
jcnelson Jan 27, 2019
d1aab43
stub for stacks blockchain state
jcnelson Jan 27, 2019
1fe0c0a
WIP: beginnings of a "main loop" that builds up the blockchain
jcnelson Jan 27, 2019
c774f1a
disable code for now
jcnelson Jan 27, 2019
2a0d980
more list test coverage
kantai Jan 28, 2019
78ff0d7
use i128 instead of u64. add native_pow (requires nightly feature for…
kantai Jan 28, 2019
3edbc17
test arithmetic errors
kantai Jan 28, 2019
a02dd15
big refactor of eval/apply so that we have a global env and a local c…
kantai Jan 28, 2019
b55c738
parsing TypeSignatures. more robust TypeSignatures
kantai Jan 29, 2019
3c77116
lots of type refactoring to support the typed tuples described in the…
kantai Jan 29, 2019
0d46334
initial implementation of tuple-typed data maps... tests incoming!
kantai Jan 29, 2019
633b2b3
first data-map test!
kantai Jan 29, 2019
9d96cb8
add (begin ...), add null-handling behavior to (get ...)
kantai Jan 29, 2019
f88e11d
revamp IPC story for block parsing and downloading -- instead of usin…
jcnelson Jan 29, 2019
7896eda
more datamap test
kantai Jan 29, 2019
111ec0d
revamp our story for dealing with multiple types of burn chains -- un…
jcnelson Jan 29, 2019
4ddb987
traits for indexing, revisited
jcnelson Jan 29, 2019
9f01462
somehow this got removed. re-add it.
jcnelson Jan 29, 2019
d571c90
revamp interface between operations and the DB -- pass a connection i…
jcnelson Jan 29, 2019
3a35edf
more error types
jcnelson Jan 29, 2019
566d855
more error types
jcnelson Jan 29, 2019
1313ae5
more error types
jcnelson Jan 29, 2019
edbfdba
have consensus hash commit to total burn so far
jcnelson Jan 29, 2019
12f9b43
thread join failure doesn't take an error cause
jcnelson Jan 29, 2019
f47f9ab
first stab at a "main loop" for indexing a burn chain
jcnelson Jan 29, 2019
7752d27
this module is defunct and will not be used
jcnelson Jan 29, 2019
1afd836
rename ValueType to Value, which is more accurate
kantai Jan 29, 2019
3de125e
remove log package; use our own log macros
jcnelson Jan 30, 2019
1c40f20
use associated types instead of type parameters to encode the type of…
jcnelson Jan 30, 2019
b4daa49
no more log::init
jcnelson Feb 3, 2019
700e004
no more log::init
jcnelson Feb 3, 2019
2e0826c
use getdata, not getblocks
jcnelson Feb 3, 2019
49f7a11
add a way to write a config file; make it so we don't always have to …
jcnelson Feb 3, 2019
df3c4b9
remove unused errors
jcnelson Feb 3, 2019
bc4322b
add send_getdata()
jcnelson Feb 3, 2019
19d5bd6
rust-ify
jcnelson Feb 3, 2019
bbf3ca1
allow writing to any location in the header file
jcnelson Feb 3, 2019
d6c4f59
indexer trait requires get_first_block_height()
jcnelson Feb 3, 2019
e21b000
update error types
jcnelson Feb 3, 2019
c1cc10d
add some more unit tests for generating consenus hashes
jcnelson Feb 3, 2019
f485ef2
remove unused errors
jcnelson Feb 3, 2019
e4698e3
no more log::init; clean up errors
jcnelson Feb 3, 2019
54e94ad
prototype working main loop
jcnelson Feb 3, 2019
6d65cea
add a way to read a block header (for debugging)
jcnelson Feb 3, 2019
c124dd7
log timestamps
jcnelson Feb 3, 2019
14df1ee
contributors document
jcnelson Feb 4, 2019
1595a2f
Merge branch 'develop-jude' into review/smart-contract-013019
kantai Feb 6, 2019
6c13560
move to main src/ dir
kantai Feb 6, 2019
965fb71
add author
kantai Feb 6, 2019
3099555
update src/vm files so that they will actually build
kantai Feb 6, 2019
78e9d6d
pin version on ed25519-dalek because the .1 version change was breaki…
kantai Feb 7, 2019
f5a019c
unpin curve version.
kantai Feb 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add a RowOrder trait that is used to force objects stored in the DB t…
…o describe the order in which their column fields should be SELECT'ed
jcnelson committed Jan 17, 2019
commit 733e0780914ba60ae88a80f2ed217e0c54a28b6c
29 changes: 24 additions & 5 deletions src/chainstate/db/burndb.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ use rusqlite::Row;
use std::fs;
use std::convert::From;

use chainstate::db::FromRow;
use chainstate::db::{FromRow, RowOrder};
use chainstate::db::VRFPublicKey_from_row;
use chainstate::db::ChainstateDB;
use chainstate::db::Error as db_error;
@@ -104,6 +104,12 @@ impl From<&UserBurnSupportOp> for HistoryRow {
}
}

impl RowOrder for LeaderKeyRegisterOp<BitcoinAddress> {
fn row_order() -> String {
"txid,vtxindex,block_height,consensus_hash,public_key,memo,address".to_string()
}
}

impl FromRow<LeaderKeyRegisterOp<BitcoinAddress>> for LeaderKeyRegisterOp<BitcoinAddress> {
fn from_row<'a>(row: &'a Row, index: usize) -> Result<LeaderKeyRegisterOp<BitcoinAddress>, db_error> {
let txid = Txid::from_row(row, 0 + index)?;
@@ -139,6 +145,12 @@ impl FromRow<LeaderKeyRegisterOp<BitcoinAddress>> for LeaderKeyRegisterOp<Bitcoi
}
}

impl RowOrder for LeaderBlockCommitOp<BitcoinPublicKey> {
fn row_order() -> String {
"txid,vtxindex,block_height,block_header_hash,new_seed,parent_block_backptr,parent_vtxindex,key_block_backptr,key_vtxindex,memo,burn_fee,input".to_string()
}
}

impl FromRow<LeaderBlockCommitOp<BitcoinPublicKey>> for LeaderBlockCommitOp<BitcoinPublicKey> {
fn from_row<'a>(row: &'a Row, index: usize) -> Result<LeaderBlockCommitOp<BitcoinPublicKey>, db_error> {
let txid = Txid::from_row(row, 0 + index)?;
@@ -190,6 +202,12 @@ impl FromRow<LeaderBlockCommitOp<BitcoinPublicKey>> for LeaderBlockCommitOp<Bitc
}
}

impl RowOrder for UserBurnSupportOp {
fn row_order() -> String {
"txid,vtxindex,block_height,consensus_hash,public_key,block_header_hash_160,memo,burn_fee".to_string()
}
}

impl FromRow<UserBurnSupportOp> for UserBurnSupportOp {
fn from_row<'a>(row: &'a Row, index: usize) -> Result<UserBurnSupportOp, db_error> {
let txid = Txid::from_row(row, 0 + index)?;
@@ -459,7 +477,8 @@ impl BurnDB {
where
P: IntoIterator,
P::Item: ToSql,
T: FromRow<T>
T: FromRow<T>,
T: RowOrder
{
let mut stmt = self.conn.prepare(sql_query)
.map_err(|e| db_error::SqliteError(e))?;
@@ -491,7 +510,7 @@ impl BurnDB {
}

// NOTE: we must select the fields *in this order*
let qry = "SELECT txid,vtxindex,block_height,consensus_hash,public_key,memo,address FROM leader_keys WHERE block_height = ?1 ORDER BY vtxindex ASC";
let qry = format!("SELECT {} FROM leader_keys WHERE block_height = ?1 ORDER BY vtxindex ASC", LeaderKeyRegisterOp::row_order());
let args = [&(block_height as i64) as &ToSql];
self.query_rows::<LeaderKeyRegisterOp<BitcoinAddress>, _>(&qry.to_string(), &args)
}
@@ -503,7 +522,7 @@ impl BurnDB {
}

// NOTE: we must select the fields *in this order*
let qry = "SELECT txid,vtxindex,block_height,block_header_hash,new_seed,parent_block_backptr,parent_vtxindex,key_block_backptr,key_vtxindex,memo,burn_fee,input FROM block_commits WHERE block_height = ?1 ORDER BY vtxindex ASC";
let qry = format!("SELECT {} FROM block_commits WHERE block_height = ?1 ORDER BY vtxindex ASC", LeaderBlockCommitOp::row_order());
let args = [&(block_height as i64) as &ToSql];
self.query_rows::<LeaderBlockCommitOp<BitcoinPublicKey>, _>(&qry.to_string(), &args)
}
@@ -515,7 +534,7 @@ impl BurnDB {
}

// NOTE: we must select the fields *in this order*
let qry = "SELECT txid,vtxindex,block_height,consensus_hash,public_key,block_header_hash_160,memo,burn_fee FROM user_burn_support WHERE block_height = ?1 ORDER BY vtxindex ASC";
let qry = format!("SELECT {} FROM user_burn_support WHERE block_height = ?1 ORDER BY vtxindex ASC", UserBurnSupportOp::row_order());
let args = [&(block_height as i64) as &ToSql];
self.query_rows::<UserBurnSupportOp, _>(&qry.to_string(), &args)
}
4 changes: 4 additions & 0 deletions src/chainstate/db/mod.rs
Original file line number Diff line number Diff line change
@@ -124,6 +124,10 @@ pub trait ChainstateDB {
fn backup(backup_path: &String) -> Result<(), Error>;
}

pub trait RowOrder {
fn row_order() -> String;
}

pub trait FromRow<T> {
fn from_row<'a>(row: &'a Row, index: usize) -> Result<T, db_error>;
}