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
Show file tree
Hide file tree
Changes from all commits
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
116 changes: 116 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Contributing to Blockstack Core

Blockstack Core is open-source software written in Rust. Contributions
should adhere to the following best practices.

## Simplicity of implementation

The most important consideration when accepting or rejecting a contribution is
the simplicity (i.e. ease of understanding) of its implementation.
Contributions that are "clever" or introduce functionality beyond the scope of
the immediate problem they are meant to solve will be rejected.

### Type simplicity

Simplicity of implementation includes simplicity of types. Type parameters
and associated types should only be used if there are at
least two possible implementations of those types.

Lifetime parameters should only be introduced if the compiler cannot deduce them
on its own.

## Builds with a stable Rust compiler

We use a recent, stable Rust compiler. Contributions should _not_
require nightly Rust features to build and run.

## Each file should include relevant unit tests

Each Rust file should contain a `mod test {}` definition, in which unit tests
should be supplied for the file's methods. Unit tests should cover a maximal
amount of code paths.

## Use built-in logging facilities

Blockstack Core implements logging macros in `util::log`. If your code needs to
output data, it should use these macros _exclusively_ for doing so. The only
exception is code that is explicitly user-facing, such as help documentation.

## Minimal dependencies

Adding new package dependencies is very much discouraged. Exceptions will be
granted on a case-by-case basis, and only if deemed absolutely necessary.

## Minimal global macros

Adding new global macros is discouraged. Exceptions will only be given if
absolutely necessary.

## Minimal compiler warnings

Contributions should not trigger compiler warnings if possible, and should not
mask compiler warnings with macros. Common sources of compiler warnings that
will not be accepted include, but are not limited to:

* unnecessary imports
* unused code
* variable naming conventions
* unhandled return types

## Minimal `unsafe` code

Contributions should not contain `unsafe` blocks if at all possible.

## Code block consistency

Surrounding code blocks with `{` and `}` is encouraged, even when the enclosed
block is a single statement. Blocks in the same lexical scope must use
consistent conventions. For example, consider the following:

```
match foo {
1..2 => {
// this is a single statement, but it is surrounded
// with { and } because the other blocks in the match
// statement need them.
Ok(true)
},
3..4 => {
error!("Bad value for foo");
Err(Error::BadFoo)
},
_ => {
// similarly, this block uses { }
Ok(true)
}
}

// conversely, all of the arms of this match statement
// have one-statement blocks, so { and } can be elided.
match bar {
1..2 => Some("abc"),
3..4 => Some("def"),
_ => None
}
```

## Error definitions

Each module should include an `Error` enumeration in its `mod.rs` that encodes
errors specific to the module. All error code paths in the module should return
an `Err` type with one of the module's errors.

## Whitespace

All contributions should use the same whitespacing as the rest of the project.
Moreover, Pull requests where a large number of changes only deal with whitespace will be
rejected.

## Licensing and contributor license agreement.

Blockstack Core is released under the terms of the GPL version 3. Contributions
that are not licensed under compatible terms will be rejected. Moreover,
contributions will not be accepted unless _all_ authors accept the project's
contributor license agreement.


5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "blockstack-core"
version = "0.0.1"
authors = ["Jude Nelson <jude@blockstack.com>"]
authors = ["Jude Nelson <jude@blockstack.com>", "Aaron Blankstein <aaron@blockstack.com>"]
license = "GPLv3"
homepage = "https://github.com/blockstack/blockstack-core"
repository = "https://github.com/blockstack/blockstack-core"
Expand All @@ -13,7 +13,6 @@ readme = "README.md"
bitcoin = "0.14.2"
jsonrpc = "0.10.2"
rust-ini = "0.13"
log = "0.4"
rand = "0.5"
serde = "1"
serde_derive = "1"
Expand All @@ -31,7 +30,7 @@ version = "0.16.0"
# features = ["bundled"]

[dependencies.ed25519-dalek]
version = "1.0.0-pre.0"
version = "=1.0.0-pre.0"
features = ["serde"]

[dependencies.curve25519-dalek]
Expand Down
5 changes: 3 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
working_directory: ~/blockstack
docker:
- image: circleci/rust
- image: ablankstein/circleci-rust-kcov
steps:
- checkout
- run:
Expand All @@ -13,5 +13,6 @@ jobs:
environment:
RUST_BACKTRACE: 1
BLOCKSTACK_DEBUG: 1
RUSTFLAGS: -Clink-dead-code
command: |
cargo test -- --nocapture --test-threads=1
cargo kcov && bash <(curl -s https://codecov.io/bash)
29 changes: 19 additions & 10 deletions src/burnchains/bitcoin/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
*/

use burnchains::Address;
use burnchains::Hash160;
use burnchains::bitcoin::indexer::BitcoinNetworkType;
use burnchains::bitcoin::BitcoinNetworkType;

use burnchains::bitcoin::Error as btc_error;

use bitcoin::util::base58;

use util::hash::Hash160;
use util::log;

#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
pub enum BitcoinAddressType {
PublicKeyHash,
Expand Down Expand Up @@ -173,16 +175,25 @@ impl Address for BitcoinAddress {
fn to_bytes(&self) -> Vec<u8> {
self.bytes.as_bytes().to_vec()
}

fn to_string(&self) -> String {
self.to_b58()
}

fn from_string(s: &String) -> Option<BitcoinAddress> {
match BitcoinAddress::from_b58(s) {
Ok(a) => Some(a),
Err(_e) => None
}
}
}

#[cfg(test)]
mod tests {
use super::{BitcoinAddress, BitcoinAddressType};
use burnchains::bitcoin::indexer::BitcoinNetworkType;
use burnchains::Address;
use burnchains::Hash160;
use util::log as logger;
use util::hash::hex_bytes;
use burnchains::bitcoin::BitcoinNetworkType;
use util::log;
use util::hash::{hex_bytes, Hash160};

struct AddressFixture {
addr: String,
Expand All @@ -196,8 +207,6 @@ mod tests {

#[test]
fn test_from_b58() {
logger::init();

let fixtures = vec![
AddressFixture {
addr: "mr6nrMvvh44sR5MiX929mMXP5hqgaTr6fx".to_owned(),
Expand Down Expand Up @@ -263,7 +272,7 @@ mod tests {
test_debug!("Decoded an address when we should not have");
assert!(false);
}
(Err(_e), Some(res)) => {
(Err(_e), Some(_res)) => {
test_debug!("Failed to decode when we should have: {}", fixture.addr);
assert!(false);
}
Expand Down
Loading