diff --git a/.github/actions/bitcoin-int-tests/Dockerfile.atlas-test b/.github/actions/bitcoin-int-tests/Dockerfile.atlas-test index 0a5f48cb1..fc3403fbd 100644 --- a/.github/actions/bitcoin-int-tests/Dockerfile.atlas-test +++ b/.github/actions/bitcoin-int-tests/Dockerfile.atlas-test @@ -1,4 +1,4 @@ -FROM rust:buster +FROM rust:bullseye WORKDIR /src diff --git a/.github/actions/bitcoin-int-tests/Dockerfile.bitcoin-tests b/.github/actions/bitcoin-int-tests/Dockerfile.bitcoin-tests index 0a29e968e..312555a4e 100644 --- a/.github/actions/bitcoin-int-tests/Dockerfile.bitcoin-tests +++ b/.github/actions/bitcoin-int-tests/Dockerfile.bitcoin-tests @@ -1,4 +1,4 @@ -FROM rust:buster +FROM rust:bullseye WORKDIR /src/ diff --git a/.github/actions/bitcoin-int-tests/Dockerfile.large-genesis b/.github/actions/bitcoin-int-tests/Dockerfile.large-genesis index b9adabe36..9d80d041c 100644 --- a/.github/actions/bitcoin-int-tests/Dockerfile.large-genesis +++ b/.github/actions/bitcoin-int-tests/Dockerfile.large-genesis @@ -1,4 +1,4 @@ -FROM rust:buster +FROM rust:bullseye WORKDIR /src diff --git a/.github/actions/bitcoin-int-tests/Dockerfile.net-tests b/.github/actions/bitcoin-int-tests/Dockerfile.net-tests index 2b007e38f..e7e3f8eaa 100644 --- a/.github/actions/bitcoin-int-tests/Dockerfile.net-tests +++ b/.github/actions/bitcoin-int-tests/Dockerfile.net-tests @@ -1,4 +1,4 @@ -FROM rust:buster +FROM rust:bullseye WORKDIR /src diff --git a/.github/actions/bitcoin-int-tests/Dockerfile.rustfmt b/.github/actions/bitcoin-int-tests/Dockerfile.rustfmt index 240f99f5a..793d8e466 100644 --- a/.github/actions/bitcoin-int-tests/Dockerfile.rustfmt +++ b/.github/actions/bitcoin-int-tests/Dockerfile.rustfmt @@ -1,4 +1,4 @@ -FROM rust:buster +FROM rust:bullseye WORKDIR /src diff --git a/Cargo.lock b/Cargo.lock index b90545fd5..be21f05be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -359,6 +359,44 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "clarity" +version = "0.0.1" +dependencies = [ + "assert-json-diff", + "chrono", + "curve25519-dalek", + "ed25519-dalek", + "integer-sqrt", + "lazy_static", + "libc", + "mio", + "percent-encoding", + "prometheus", + "rand 0.7.2", + "rand_chacha 0.2.2", + "regex", + "ripemd160", + "rstest", + "rstest_reuse", + "rusqlite", + "secp256k1", + "serde", + "serde_derive", + "serde_json", + "serde_stacker", + "sha2 0.8.2", + "sha2-asm", + "sha3", + "slog", + "slog-json", + "slog-term", + "stx-genesis", + "time 0.2.23", + "tini", + "url", +] + [[package]] name = "clear_on_drop" version = "0.2.4" @@ -2524,6 +2562,12 @@ dependencies = [ "syn", ] +[[package]] +name = "tini" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11eeaa68267376df2aacbaaed9b0092544ebbc897cd59f61e81a1105fbaf102e" + [[package]] name = "tinyvec" version = "0.3.3" diff --git a/Cargo.toml b/Cargo.toml index d985be1b2..86bf34569 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,7 +112,8 @@ sha2-asm = "0.5.3" [workspace] members = [ - ".", + ".", + "clarity", "stx-genesis", "testnet/stacks-node", "testnet/puppet-chain"] diff --git a/circle.yml b/circle.yml index 968ff8d5a..6c8a68878 100644 --- a/circle.yml +++ b/circle.yml @@ -48,7 +48,7 @@ jobs: - run: no_output_timeout: 200m command: | - cargo test -j 1 --workspace + cargo test -j 1 --workspace --exclude clarity all_tests: docker: - image: rust:1.40-stretch diff --git a/clarity/Cargo.toml b/clarity/Cargo.toml new file mode 100644 index 000000000..4605610d3 --- /dev/null +++ b/clarity/Cargo.toml @@ -0,0 +1,88 @@ +[package] +name = "clarity" +version = "0.0.1" +authors = [ "Jude Nelson ", + "Aaron Blankstein ", + "Ludo Galabru " ] +license = "GPLv3" +homepage = "https://github.com/blockstack/stacks-blockchain" +repository = "https://github.com/blockstack/stacks-blockchain" +description = "Reference implementation of the Stacks 2.0 Blockchain" +keywords = [ "stacks", "stx", "bitcoin", "crypto", "blockstack", "decentralized", "dapps", "blockchain" ] +readme = "README.md" + +[profile.release] +debug = true + +[lib] +name = "clarity" +path = "../src/libclarity.rs" + +[dependencies] +tini = "0.2" +rand = "=0.7.2" +rand_chacha = "=0.2.2" +serde = "1" +serde_derive = "1" +serde_stacker = "0.1" +sha3 = "0.8.2" +ripemd160 = "0.8.0" +regex = "1" +mio = "0.6" +lazy_static = "1.4.0" +url = "2.1.0" +percent-encoding = "2.1.0" +sha2 = "0.8.0" +prometheus = { version = "0.9", optional = true } +integer-sqrt = "0.1.3" +slog = { version = "2.5.2", features = [ "max_level_trace" ] } +slog-term = "2.6.0" +slog-json = { version = "2.3.0", optional = true } +chrono = "0.4.19" +libc = "0.2.82" + +[dependencies.serde_json] +version = "1.0" +features = ["arbitrary_precision", "unbounded_depth"] + +[dependencies.secp256k1] +version = "0.19.0" +features = ["serde", "recovery"] + +[dependencies.rusqlite] +version = "=0.24.2" +features = ["blob", "serde_json", "i128_blob", "bundled", "trace"] + +[dependencies.ed25519-dalek] +version = "=1.0.0-pre.3" +features = ["serde"] + +[dependencies.curve25519-dalek] +version = "=2.0.0" +features = ["serde"] + +[dependencies.time] +version = "0.2.23" +features = ["std"] + +[dev-dependencies] +rstest = "0.11.0" +rstest_reuse = "0.1.3" +assert-json-diff = "1.0.0" +# a nightly rustc regression (35dbef235 2021-03-02) prevents criterion from compiling +# but it isn't necessary for tests: only benchmarks. therefore, commenting out for now. +# criterion = "0.3" +stx_genesis = { package = "stx-genesis", path = "../stx-genesis/."} + +[features] +default = ["developer-mode"] +developer-mode = [] +monitoring_prom = ["prometheus"] +slog_json = ["slog-json"] + + +[profile.dev.package.regex] +opt-level = 2 + +[target.'cfg(all(target_arch = "x86_64", not(target_env = "msvc")))'.dependencies] +sha2-asm = "0.5.3" diff --git a/migration-verification/Dockerfile b/migration-verification/Dockerfile index 03490f053..ce2e6aba6 100644 --- a/migration-verification/Dockerfile +++ b/migration-verification/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:buster +FROM rust:bullseye ### Install Node.js RUN apt-get update diff --git a/src/libclarity.rs b/src/libclarity.rs new file mode 100644 index 000000000..2e917adde --- /dev/null +++ b/src/libclarity.rs @@ -0,0 +1,133 @@ +// Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation +// Copyright (C) 2020 Stacks Open Internet Foundation +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#![allow(unused_imports)] +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![cfg_attr(test, allow(unused_variables, unused_assignments))] + +extern crate curve25519_dalek; +extern crate ed25519_dalek; +extern crate rand; +extern crate rand_chacha; +extern crate rusqlite; +extern crate secp256k1; +extern crate serde; +extern crate tini; +#[macro_use] +extern crate lazy_static; +extern crate integer_sqrt; +extern crate mio; +extern crate percent_encoding; +extern crate regex; +extern crate ripemd160; +extern crate sha2; +extern crate sha3; +extern crate time; +extern crate url; + +#[macro_use(o, slog_log, slog_trace, slog_debug, slog_info, slog_warn, slog_error)] +extern crate slog; +extern crate chrono; +#[cfg(feature = "slog_json")] +extern crate slog_json; +extern crate slog_term; + +#[cfg(unix)] +extern crate libc; + +#[macro_use] +extern crate serde_derive; +#[macro_use] +extern crate serde_json; + +#[cfg(test)] +#[macro_use] +extern crate assert_json_diff; + +#[cfg(test)] +#[macro_use] +extern crate rstest; + +#[cfg(test)] +#[macro_use] +extern crate rstest_reuse; + +#[cfg(feature = "monitoring_prom")] +#[macro_use] +pub extern crate prometheus; + +#[macro_use] +pub mod codec; + +#[macro_use] +pub mod util; + +#[macro_use] +pub mod net; + +#[macro_use] +/// The Clarity virtual machine +pub mod vm; + +#[macro_use] +pub mod chainstate; + +#[cfg(test)] +extern crate stx_genesis; + +pub mod address; +pub mod burnchains; + +/// A high level library for interacting with the Clarity vm +pub mod clarity_vm; +pub mod core; +pub mod deps; + +pub mod clarity; + +pub mod monitoring; +pub mod types; + +// set via _compile-time_ envars +const GIT_BRANCH: Option<&'static str> = option_env!("GIT_BRANCH"); +const GIT_COMMIT: Option<&'static str> = option_env!("GIT_COMMIT"); +const GIT_TREE_CLEAN: Option<&'static str> = option_env!("GIT_TREE_CLEAN"); + +#[cfg(debug_assertions)] +const BUILD_TYPE: &'static str = "debug"; +#[cfg(not(debug_assertions))] +const BUILD_TYPE: &'static str = "release"; + +pub fn version_string(pkg_name: &str, pkg_version: &str) -> String { + let git_branch = GIT_BRANCH.unwrap_or(""); + let git_commit = GIT_COMMIT.unwrap_or(""); + let git_tree_clean = GIT_TREE_CLEAN.unwrap_or(""); + + format!( + "{} {} ({}:{}{}, {} build, {} [{}])", + pkg_name, + pkg_version, + &git_branch, + git_commit, + git_tree_clean, + BUILD_TYPE, + std::env::consts::OS, + std::env::consts::ARCH + ) +} diff --git a/src/vm/docs/mod.rs b/src/vm/docs/mod.rs index 91fbe7a37..007f5581f 100644 --- a/src/vm/docs/mod.rs +++ b/src/vm/docs/mod.rs @@ -1677,7 +1677,8 @@ const TOKEN_TRANSFER: SpecialAPI = SpecialAPI { output_type: "(response bool uint)", signature: "(ft-transfer? token-name amount sender recipient)", description: "`ft-transfer?` is used to increase the token balance for the `recipient` principal for a token -type defined using `define-fungible-token` by debiting the `sender` principal. +type defined using `define-fungible-token` by debiting the `sender` principal. In contrast to `stx-transfer?`, +any user can transfer the assets. When used, relevant guards need to be added. This function returns (ok true) if the transfer is successful. In the event of an unsuccessful transfer it returns one of the following error codes: @@ -1700,7 +1701,8 @@ const ASSET_TRANSFER: SpecialAPI = SpecialAPI { signature: "(nft-transfer? asset-class asset-identifier sender recipient)", description: "`nft-transfer?` is used to change the owner of an asset identified by `asset-identifier` from `sender` to `recipient`. The `asset-class` must have been defined by `define-non-fungible-token` and `asset-identifier` -must be of the type specified in that definition. +must be of the type specified in that definition. In contrast to `stx-transfer?`, any user can transfer the asset. +When used, relevant guards need to be added. This function returns (ok true) if the transfer is successful. In the event of an unsuccessful transfer it returns one of the following error codes: