From 868a63158895e0e4f8dcd3edef6b0a0e38003574 Mon Sep 17 00:00:00 2001 From: Jiayu Ye Date: Thu, 26 Dec 2019 19:10:36 +0800 Subject: [PATCH] =?UTF-8?q?[=E1=9A=ACframework]=20Rebase=20master=20(#73)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: metrics logger (#43) * add logger config * add logger.metrics example * Revert "add logger.metrics example" This reverts commit 7c04ff3e906ab5e155c8258b63195740f9d1f0f5. * add logger module instruction * chore: add newline to the end of text file * refactor: change serde to json crate to manipulate json * chore: remove patch version in Cargo.toml depencencies * chore: tips for running `make ci` before create PR (#54) * feat: support consensus tracing (#53) * feat: support consensus trace * feat: avoid unsafe unwrap * feat: check is_err when init_tracer to ensure tracer init correctly * feat: panic when init tracer failed * chore: cargo fmt * feat: return ProtocolResult for standard when init tracer * feat: update tracer sdk * refactor: remove unnecessary code * chore: upgrade bytes to 0.5 (#57) Also upgrade prost to pinned git commit, ophelia to 0.2. All of these are required to upgrade bytes. * reafctor(consensus): redesign the consensus architecture (#45) * refactor rpc * refactor: muta consensus * fix CI * chore(ci): reduce travis cache size (#62) * chore(ci): use sccache and limit its cache size to 2G (#63) * chore(ci): use sccache and limit its cache size to 2G Try fix cahce timeout * fix(ci): disable sccache to install it * chore(ci): enable sccache * chore(ci): remove cargo sweep from script.sh * chore(ci): disable sccache on master (#66) * fix(consensus): empty block receipts root (#61) * fix: empty block receipts root * upgrade rust toolchain version * chore(ci): enable sccache (#67) * fix(ci): fail to install sccache after new rust-toolchain (#68) * feat(consensus): develop aggregate crypto with overlord (#60) * update ophelia * feat: aggregated signature * refactor(protocol): Adjust the data structure of transactions and receipts. * feat(protocol/types): Add cycles_price for raw_transaction. (#46) * feat(protocol/traits): Add traits of binding. (#47) * feat(core/binding): Implementation of service state. (#48) * feat(core/binding-macro): Add `read` and `write` proc-macro. (#49) * feat(core/binding-macro): Add cycles proc-marco. (#52) * [ᚬframework] feat(core/binding): add default StoreBool, StoreUint64, StoreString (#51) * feat(core/binding): add DefaultStoreBool, DefaultStoreUint64, DefaultStoreString * feat(core/binding): adjust tests path * feat(core/binding): adjust code * feat(core/binding): fix fmt * feat(core/binding): change BigEndian to LittleEndian * [ᚬframework] feat(core/binding): add StoreMap, StoreArray (#55) * feat(core/binding): add StoreMap * feat(core/binding): add StoreArray * feat(core/binding): fix some issues * feat(core/binding): add TODO comment * [ᚬframework] feat(core/binding): add service_sdk, chain_querier, request_context (#58) * feat(core/binding): finish alloc type and chain querier of sdk * feat(core/binding): add sdk test * feat(core/binding): add service sdk and request context * fix style * [ᚬframework] feat(core/binding-macro): Add #[service] to automatically implement the service trait. (#56) * feat(core/binding-macro): Add #[service] to automatically implement the service trait. * Documents do not run tests. * split for impl * fix read/write result * update cargo.lock * [ᚬframework] feat(core/binding-macro): Add #[init] attribute. (#64) * feat(core/binding-macro): Add #[init] attribute. * fix typo * fix binding trait * chore: Add framework dir. (#65) * feat(core/binding-macro): Support for returning a struct. (#70) * feat(build-in-services): Add asset service. * feat(framework): Service executor. * exec hook * fix stash * fix typo * fix typo * fix overflow * fix typo * rebase master * . * [ᚬframework] feat(framework/binding): add Iterator and impl FixedCodec for rust primitive type (#72) Co-authored-by: Wenchao Hu Co-authored-by: yonghui Co-authored-by: zeroqn Co-authored-by: Eason Gao Co-authored-by: zhounan <33241113+mkxbl@users.noreply.github.com> --- Cargo.lock | 433 +++--------------- Cargo.toml | 8 +- binding-macro/Cargo.toml | 2 +- binding-macro/tests/mod.rs | 12 +- built-in-services/asset/Cargo.toml | 2 +- built-in-services/asset/src/lib.rs | 12 +- built-in-services/asset/src/tests/mod.rs | 8 +- core/api/src/lib.rs | 354 -------------- core/consensus/Cargo.toml | 1 + core/consensus/src/adapter.rs | 81 +++- core/consensus/src/engine.rs | 15 +- core/consensus/src/fixed_types.rs | 41 +- core/consensus/src/synchronization.rs | 7 +- core/consensus/src/util.rs | 2 + core/mempool/Cargo.toml | 2 +- core/mempool/src/adapter/mod.rs | 6 +- core/mempool/src/tests/mod.rs | 44 +- core/mempool/src/tx_cache.rs | 44 +- core/network/src/connection/control.rs | 4 +- core/network/src/error.rs | 4 +- core/network/src/event.rs | 6 +- core/network/src/outbound/gossip.rs | 6 +- core/network/src/peer_manager/mod.rs | 10 +- core/network/src/peer_manager/peer.rs | 10 +- core/network/src/service.rs | 4 +- core/network/src/traits.rs | 4 +- core/storage/src/tests/mod.rs | 52 +-- devtools/chain/README.md | 12 +- devtools/chain/config.toml | 2 +- devtools/chain/genesis.json | 48 -- devtools/chain/genesis.toml | 8 + devtools/keypair/src/main.rs | 4 +- framework/Cargo.toml | 6 +- framework/src/binding/sdk/mod.rs | 8 +- framework/src/binding/store/primitive.rs | 9 +- framework/src/binding/tests/sdk.rs | 23 +- framework/src/executor/factory.rs | 22 + framework/src/executor/mod.rs | 14 +- .../src/executor/tests/genesis_services.toml | 8 + .../src/executor/tests/genesis_services.yaml | 4 - framework/src/executor/tests/mod.rs | 28 +- framework/src/tests/mod.rs | 2 +- protocol/Cargo.toml | 5 +- protocol/src/codec/primitive.rs | 39 +- protocol/src/fixed_codec/epoch.rs | 2 +- protocol/src/fixed_codec/macro.rs | 4 +- protocol/src/fixed_codec/mod.rs | 1 - protocol/src/fixed_codec/primitive.rs | 35 +- protocol/src/fixed_codec/receipt.rs | 4 +- protocol/src/fixed_codec/tests/fixed_codec.rs | 2 - protocol/src/fixed_codec/tests/mod.rs | 48 +- protocol/src/fixed_codec/transaction.rs | 8 +- protocol/src/traits/consensus.rs | 10 +- protocol/src/traits/executor.rs | 11 + protocol/src/traits/mod.rs | 4 +- protocol/src/types/epoch.rs | 2 +- protocol/src/types/genesis.rs | 57 +-- protocol/src/types/mod.rs | 6 +- protocol/src/types/primitive.rs | 16 +- src/main.rs | 93 ++-- 60 files changed, 423 insertions(+), 1296 deletions(-) delete mode 100644 devtools/chain/genesis.json create mode 100644 devtools/chain/genesis.toml create mode 100644 framework/src/executor/factory.rs create mode 100644 framework/src/executor/tests/genesis_services.toml delete mode 100644 framework/src/executor/tests/genesis_services.yaml diff --git a/Cargo.lock b/Cargo.lock index 6e6e2dede..9eca706e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,17 +92,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "asset" version = "0.1.0" dependencies = [ - "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "binding-macro 0.1.0", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "cita_trie 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "framework 0.1.0", "protocol 0.1.0", - "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -212,15 +212,15 @@ dependencies = [ name = "binding-macro" version = "0.1.0" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "framework 0.1.0", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "protocol 0.1.0", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -295,15 +295,6 @@ name = "bs58" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "buf_redux" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bumpalo" version = "2.6.0" @@ -504,27 +495,13 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "core-api" -version = "0.1.0" -dependencies = [ - "async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "common-crypto 0.1.0", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "juniper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "juniper_codegen 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", - "protocol 0.1.0", - "tide 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - [[package]] name = "core-consensus" version = "0.1.0" dependencies = [ "async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cita_trie 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "common-crypto 0.1.0", "common-logger 0.1.0", "common-merkle 0.1.0", @@ -568,7 +545,7 @@ name = "core-mempool" version = "0.1.0" dependencies = [ "async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "chashmap 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "common-crypto 0.1.0", "core-network 0.1.0", @@ -835,7 +812,6 @@ name = "error-chain" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -925,7 +901,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -981,9 +957,9 @@ name = "framework" version = "0.1.0" dependencies = [ "asset 0.1.0", - "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "cita_trie 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -992,10 +968,10 @@ dependencies = [ "json 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "protocol 0.1.0", - "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1325,27 +1301,6 @@ dependencies = [ "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "http-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "http-service-hyper" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "http-service 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "httparse" version = "1.3.4" @@ -1453,7 +1408,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1501,33 +1455,6 @@ dependencies = [ "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "juniper" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "juniper_codegen 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "juniper_codegen" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "keccak" version = "0.1.0" @@ -1604,14 +1531,6 @@ dependencies = [ "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "log" version = "0.4.8" @@ -1673,30 +1592,11 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mime" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mime" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "mime_guess" -version = "1.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mime_guess" version = "2.0.1" @@ -1776,40 +1676,23 @@ dependencies = [ "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "multipart" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "buf_redux 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "twoway 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "muta-chain" version = "0.1.0" dependencies = [ "binding-macro 0.1.0", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "common-config-parser 0.1.0", "common-crypto 0.1.0", "common-logger 0.1.0", - "core-api 0.1.0", "core-consensus 0.1.0", "core-mempool 0.1.0", "core-network 0.1.0", "core-storage 0.1.0", "framework 0.1.0", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "protocol 0.1.0", @@ -1818,7 +1701,7 @@ dependencies = [ "runtime-tokio 0.3.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2155,41 +2038,6 @@ name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_shared" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pin-project" version = "0.4.6" @@ -2279,27 +2127,27 @@ dependencies = [ name = "protocol" version = "0.1.0" dependencies = [ - "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "cita_trie 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "creep 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethbloom 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hasher 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "json 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.5.0 (git+https://github.com/danburkert/prost?rev=dfe51e9)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2661,11 +2509,6 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "route-recognizer" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "runtime" version = "0.3.0-alpha.8" @@ -2749,11 +2592,6 @@ name = "ryu" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "schannel" version = "0.1.16" @@ -2874,17 +2712,6 @@ dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "serde_qs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "serde_urlencoded" version = "0.5.5" @@ -2896,17 +2723,6 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "serde_urlencoded" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "serde_yaml" version = "0.8.11" @@ -2914,7 +2730,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2957,11 +2773,6 @@ name = "shlex" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "slab" version = "0.4.2" @@ -3258,112 +3069,6 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tide" -version = "0.2.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "http-service 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http-service-hyper 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "route-recognizer 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tide-cookies 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", - "tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", - "tide-cors 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", - "tide-forms 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)", - "tide-headers 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)", - "tide-log 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)", - "tide-querystring 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - -[[package]] -name = "tide-cookies" -version = "0.2.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "http-service 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - -[[package]] -name = "tide-core" -version = "0.2.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "http-service 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "route-recognizer 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tide-cors" -version = "0.2.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "http-service 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - -[[package]] -name = "tide-forms" -version = "0.1.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "http-service 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "multipart 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - -[[package]] -name = "tide-headers" -version = "0.1.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - -[[package]] -name = "tide-log" -version = "0.1.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - -[[package]] -name = "tide-querystring" -version = "0.1.0" -source = "git+https://github.com/rustasync/tide?rev=af0b900#af0b900bc447eb4410874752c9a7a35b9be79561" -dependencies = [ - "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_qs 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)", -] - [[package]] name = "time" version = "0.1.42" @@ -3581,6 +3286,14 @@ dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "toml" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "traitobject" version = "0.1.0" @@ -3609,14 +3322,6 @@ dependencies = [ "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "twoway" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "typemap" version = "0.3.3" @@ -3641,14 +3346,6 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "unicase" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicase" version = "2.6.0" @@ -3966,6 +3663,25 @@ dependencies = [ "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "zeroize" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zeroize_derive" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" @@ -3998,7 +3714,6 @@ dependencies = [ "checksum bls_amcl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d50b3e0a442966e947a596516385d0e3611f271644b9d8881b7348588e13cf2e" "checksum bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c95ee6bba9d950218b6cc910cf62bc9e0a171d0f4537e3627b0f54d08549b188" "checksum bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" -"checksum buf_redux 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" "checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -4096,8 +3811,6 @@ dependencies = [ "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" "checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -"checksum http-service 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25c8f5ec0cd178a4f7f1750ef816be157b50c943c6570ec5c16e847844e88de7" -"checksum http-service-hyper 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e1448396b4b59718d3d4ea7c2cdcc267df1587d88485b168020e1e8a8c4b8c87" "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" @@ -4114,18 +3827,15 @@ dependencies = [ "checksum js-sys 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "367647c532db6f1555d7151e619540ec5f713328235b8c062c6b4f63e84adfe3" "checksum json 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3ca41abbeb7615d56322a984e63be5e5d0a117dfaca86c14393e32a762ccac1" "checksum juliex 0.3.0-alpha.8 (registry+https://github.com/rust-lang/crates.io-index)" = "22dcfd5923ddd3e945884e66c89f92e7ce370e8fcabc593f6af1ce76e21099bc" -"checksum juniper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b570603cc5ea362590965be2d201f24c5e39f2675953d46813ea4c5f7a34e75c" -"checksum juniper_codegen 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "230e99ba589c473bb53d33bf4bd9aedcb7069c50b336bb76dcff9f69a1b19418" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum librocksdb-sys 6.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b93b02499a16b46dfa35536a54b54ca14cc27275dd766aba4f4e267c97572994" +"checksum librocksdb-sys 6.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0785e816e1e11e7599388a492c61ef80ddc2afc91e313e61662cce537809be" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" "checksum log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "100052474df98158c0738a7d3f4249c99978490178b5f9f68cd835ac57adbd1b" @@ -4133,9 +3843,7 @@ dependencies = [ "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" -"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" -"checksum mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0d977de9ee851a0b16e932979515c0f3da82403183879811bc97d50bd9cc50f7" "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" @@ -4144,7 +3852,6 @@ dependencies = [ "checksum miracl_amcl 3.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "89d10a1ea3ffe41d318ccd9f21a1f2366c8103b95e1deaa9449793f4b10cefe8" "checksum moodyblues-sdk 0.1.1 (git+https://github.com/homura/moodyblues-client-rust)" = "" "checksum moodyblues-sdk 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f94a8f39dfdc0674efc42c7e8b118bcb4588ae62f69ecc0b80fff538f34c9a0b" -"checksum multipart 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "136eed74cadb9edd2651ffba732b19a450316b680e4f48d6c79e905799e19d01" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" @@ -4177,10 +3884,6 @@ dependencies = [ "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "94b90146c7216e4cb534069fb91366de4ea0ea353105ee45ed297e2d1619e469" "checksum pin-project-internal 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "44ca92f893f0656d3cba8158dd0f2b99b94de256a4a54e870bd6922fcc6c8355" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" @@ -4227,7 +3930,6 @@ dependencies = [ "checksum rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3a44d5ae8afcb238af8b75640907edc6c931efcfab2c854e81ed35fa080f84cd" "checksum rocksdb 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d65bee9fe606c76fd90d6cc33b86bdafde0981b8a6b2d190ec1267e0d065baf8" "checksum romio 0.3.0-alpha.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba32440c5c69de3768e8ba2af3c1469fbab67c52429d0ba0d5ec873dbeb3d2b" -"checksum route-recognizer 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ea509065eb0b3c446acdd0102f0d46567dc30902dc0be91d6552035d92b0f4f8" "checksum runtime 0.3.0-alpha.8 (registry+https://github.com/rust-lang/crates.io-index)" = "837d0b4ebb8ef26295c63f03672635de6d94e06bdaa7bb1784bc594bb5145211" "checksum runtime-attributes 0.3.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "56d89e2690a05350788bcd6bb07209ebbf674fb91d7cec993e552e1e2fd6c922" "checksum runtime-native 0.3.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6867a446c9bf954d7d08e72a0c4c54ddb4e277a9ddd5007aac79643e98b9ccc0" @@ -4237,7 +3939,6 @@ dependencies = [ "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" -"checksum safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" "checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum secp256k1 0.15.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4d311229f403d64002e9eed9964dfa5a0a0c1ac443344f7546bf48e916c6053a" @@ -4252,15 +3953,12 @@ dependencies = [ "checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" -"checksum serde_qs 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d43eef44996bbe16e99ac720e1577eefa16f7b76b5172165c98ced20ae9903e1" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" -"checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" "checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" -"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" @@ -4292,14 +3990,6 @@ dependencies = [ "checksum thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" "checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum tide 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" -"checksum tide-cookies 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" -"checksum tide-core 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" -"checksum tide-cors 0.2.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" -"checksum tide-forms 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" -"checksum tide-headers 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" -"checksum tide-log 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" -"checksum tide-querystring 0.1.0 (git+https://github.com/rustasync/tide?rev=af0b900)" = "" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" "checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" @@ -4318,15 +4008,14 @@ dependencies = [ "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum tokio-yamux 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "723c77f5e71061a1363d8402418ac87be5570fe548a638a4eb231fa01d6124b6" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +"checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -"checksum twoway 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1" "checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "754ba11732b9161b94c41798e5197e5e75388d012f760c42adb5000353e98646" -"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" @@ -4368,3 +4057,5 @@ dependencies = [ "checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" "checksum xmltree 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8eaee9d17062850f1e6163b509947969242990ee59a35801af437abe041e70" "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" +"checksum zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" +"checksum zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "080616bd0e31f36095288bb0acdf1f78ef02c2fa15527d7e993f2a6c7591643e" diff --git a/Cargo.toml b/Cargo.toml index f51b925b4..3b0e21c65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ common-logger = { path = "./common/logger" } common-config-parser = { path = "./common/config-parser" } common-crypto = { path = "./common/crypto" } protocol = { path = "./protocol" } -core-api = { path = "./core/api" } +# core-api = { path = "./core/api" } core-storage = { path = "./core/storage" } core-mempool = { path = "./core/mempool" } core-network = { path = "./core/network" } @@ -24,12 +24,12 @@ runtime = "0.3.0-alpha.7" runtime-tokio = "0.3.0-alpha.6" serde = "1.0" serde_derive = "1.0" -serde_json = "1.0" log = "0.4" clap = "2.33" -bytes = "0.4" +bytes = "0.5" hex = "0.4" rlp = "0.4" +toml = "0.5" [workspace] members = [ @@ -43,7 +43,7 @@ members = [ "common/metrics", "common/pubsub", - "core/api", + # "core/api", "core/consensus", "core/mempool", "core/network", diff --git a/binding-macro/Cargo.toml b/binding-macro/Cargo.toml index c730ccaa1..9cbac2264 100644 --- a/binding-macro/Cargo.toml +++ b/binding-macro/Cargo.toml @@ -21,5 +21,5 @@ serde_json = "1.0" [dev-dependencies] framework = { path = "../framework" } -bytes = "0.4" +bytes = "0.5" serde = { version = "1.0", features = ["derive"] } diff --git a/binding-macro/tests/mod.rs b/binding-macro/tests/mod.rs index b38b94be7..05c03aab9 100644 --- a/binding-macro/tests/mod.rs +++ b/binding-macro/tests/mod.rs @@ -236,11 +236,15 @@ impl RequestContext for MockRequestContext { &self.method } + fn get_timestamp(&self) -> u64 { + 0 + } + fn get_payload(&self) -> &str { &self.payload } - fn emit_event(&mut self, _message: String) -> ProtocolResult<()> { + fn emit_event(&self, _message: String) -> ProtocolResult<()> { unimplemented!() } } @@ -248,8 +252,6 @@ impl RequestContext for MockRequestContext { struct MockServiceSDK; impl ServiceSDK for MockServiceSDK { - type ContextItem = MockRequestContext; - // Alloc or recover a `Map` by` var_name` fn alloc_or_recover_map( &mut self, @@ -339,10 +341,6 @@ impl ServiceSDK for MockServiceSDK { unimplemented!() } - fn get_request_context(&self) -> ProtocolResult { - unimplemented!() - } - // Call other read-only methods of `service` and return the results // synchronously NOTE: You can use recursive calls, but the maximum call // stack is 1024 diff --git a/built-in-services/asset/Cargo.toml b/built-in-services/asset/Cargo.toml index 4053d0eb7..290457fc8 100644 --- a/built-in-services/asset/Cargo.toml +++ b/built-in-services/asset/Cargo.toml @@ -13,7 +13,7 @@ protocol = { path = "../../protocol" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" rlp = "0.4" -bytes = "0.4" +bytes = "0.5" derive_more = "0.15" byteorder = "1.3" diff --git a/built-in-services/asset/src/lib.rs b/built-in-services/asset/src/lib.rs index 2daa3868b..e55f49451 100644 --- a/built-in-services/asset/src/lib.rs +++ b/built-in-services/asset/src/lib.rs @@ -5,7 +5,7 @@ pub mod types; use bytes::Bytes; use derive_more::{Display, From}; -use binding_macro::{cycles, init, read, service, write}; +use binding_macro::{cycles, init, service, write}; use protocol::traits::{RequestContext, ReturnEmpty, ServiceSDK, StoreMap, RETURN_EMPTY}; use protocol::types::Hash; use protocol::{ProtocolError, ProtocolErrorKind, ProtocolResult}; @@ -65,8 +65,7 @@ impl AssetService { payload: CreateAssetPayload, ) -> ProtocolResult { let caller = ctx.get_caller(); - let payload_str = - serde_json::to_string(&payload).map_err(|e| ServiceError::JsonParse(e))?; + let payload_str = serde_json::to_string(&payload).map_err(ServiceError::JsonParse)?; let id = Hash::digest(Bytes::from(payload_str + &caller.as_hex())); @@ -82,8 +81,7 @@ impl AssetService { }; self.assets.insert(id.clone(), asset.clone())?; - self.sdk - .set_account_value(&caller, id.clone(), payload.supply)?; + self.sdk.set_account_value(&caller, id, payload.supply)?; Ok(asset) } @@ -98,7 +96,7 @@ impl AssetService { let caller = ctx.get_caller(); let asset_id = payload.asset_id.clone(); let value = payload.value; - let to = payload.to.clone(); + let to = payload.to; if !self.assets.contains(&asset_id)? { return Err(ServiceError::NotFoundAsset { id: asset_id }.into()); @@ -125,7 +123,7 @@ impl AssetService { if overflow { return Err(ServiceError::U64Overflow.into()); } - self.sdk.set_account_value(&caller, asset_id.clone(), v)?; + self.sdk.set_account_value(&caller, asset_id, v)?; Ok(RETURN_EMPTY) } diff --git a/built-in-services/asset/src/tests/mod.rs b/built-in-services/asset/src/tests/mod.rs index 4a25002f0..43e307f59 100644 --- a/built-in-services/asset/src/tests/mod.rs +++ b/built-in-services/asset/src/tests/mod.rs @@ -41,7 +41,7 @@ fn test_create_asset() { assert_eq!(asset, new_asset); let balance_res = service - .get_balance(context.clone(), GetBalancePayload { + .get_balance(context, GetBalancePayload { asset_id: asset.id.clone(), }) .unwrap(); @@ -53,7 +53,7 @@ fn test_create_asset() { fn test_transfer() { let cycles_limit = 1024 * 1024 * 1024; // 1073741824 let caller = Address::from_hex("0x755cdba6ae4f479f7164792b318b2a06c759833b").unwrap(); - let context = mock_context(cycles_limit, caller.clone()); + let context = mock_context(cycles_limit, caller); let mut service = new_asset_service(); @@ -85,9 +85,7 @@ fn test_transfer() { let context = mock_context(cycles_limit, to_address); let balance_res = service - .get_balance(context, GetBalancePayload { - asset_id: asset.id.clone(), - }) + .get_balance(context, GetBalancePayload { asset_id: asset.id }) .unwrap(); assert_eq!(balance_res.balance, 1024); } diff --git a/core/api/src/lib.rs b/core/api/src/lib.rs index 19987c2e9..8b1378917 100644 --- a/core/api/src/lib.rs +++ b/core/api/src/lib.rs @@ -1,355 +1 @@ -#[macro_use] -extern crate juniper_codegen; -pub mod adapter; -pub mod config; -mod schema; - -use std::convert::TryFrom; -use std::sync::Arc; -use std::u64; - -use futures::executor::block_on; -use juniper::graphiql::graphiql_source; -use juniper::{FieldError, FieldResult}; -use tide::{error::ResultExt, response, App, EndpointResult}; - -use common_crypto::{ - HashValue, PrivateKey, PublicKey, Secp256k1PrivateKey, Signature, ToPublicKey, -}; -use protocol::fixed_codec::ProtocolFixedCodec; -use protocol::traits::{APIAdapter, Context}; - -use crate::config::GraphQLConfig; -use crate::schema::{ - Address, AssetID, Balance, Bytes, ContractType, Epoch, Hash, InputDeployAction, - InputRawTransaction, InputTransactionEncryption, InputTransferAction, Uint64, -}; -use http::header::HeaderValue; -use tide::middleware::{CorsMiddleware, CorsOrigin}; - -pub async fn start_graphql(cfg: GraphQLConfig, adapter: Adapter) { - let state = State { - adapter: Arc::new(Box::new(adapter)), - }; - - let mut app = App::with_state(Arc::new(state)); - // allow CORS - app.middleware( - CorsMiddleware::new() - .allow_origin(CorsOrigin::from("*")) - .allow_methods(HeaderValue::from_static("GET, POST, OPTIONS")), - ); - - app.at(&cfg.graphql_uri).post(handle_graphql); - app.at(&cfg.graphiql_uri).get(handle_graphiql); - app.serve(cfg.listening_address).await.unwrap(); -} - -// This is accessible as state in Tide, and as executor context in Juniper. -#[derive(Clone)] -struct State { - adapter: Arc>, -} - -impl juniper::Context for State {} - -// We define `Query` unit struct here. GraphQL queries will refer to this -// struct. The struct itself doesn't have any associated state (and there's no -// need to do so), but instead it exposes the accumulator state from the -// context. -struct Query; -// Switch to async/await fn https://github.com/graphql-rust/juniper/issues/2 -#[juniper::object(Context = State)] -impl Query { - #[graphql(name = "getLatestEpoch", description = "Get the latest epoch")] - fn get_latest_epoch(state_ctx: &State, epoch_id: Option) -> FieldResult { - let epoch_id = opt_hex_to_u64(epoch_id.map(|id| id.as_hex()))?; - - let epoch = block_on(state_ctx.adapter.get_epoch_by_id(Context::new(), epoch_id)) - .map_err(FieldError::from)?; - Ok(Epoch::from(epoch)) - } - - #[graphql( - name = "getBalance", - description = "Get the asset balance of an account", - arguments(id(description = "The asset id. Asset is the first-class in Muta, \ - this means that your assets can be more than one in Muta, \ - and the UDT(User Defined Token) will be supported in the future")) - )] - fn get_balance( - state_ctx: &State, - address: Address, - id: AssetID, - epoch_id: Option, - ) -> FieldResult { - let epoch_id = opt_hex_to_u64(epoch_id.map(|id| id.as_hex()))?; - let address = protocol::types::Address::from_hex(&address.as_hex())?; - let id = protocol::types::AssetID::from_hex(&id.as_hex())?; - - let result = block_on(state_ctx.adapter.get_balance( - Context::new(), - &address, - &id, - epoch_id, - )); - - match result { - Ok(balance) => Ok(Balance::from(balance)), - Err(_) => Ok(Balance::from(protocol::types::Balance::from_bytes_be(b""))), - } - } -} - -struct Mutation; -// Switch to async/await fn https://github.com/graphql-rust/juniper/issues/2 -#[juniper::object(Context = State)] -impl Mutation { - #[graphql( - name = "sendTransferTransaction", - description = "Send a transfer transaction to the blockchain." - )] - fn send_transfer_transaction( - state_ctx: &State, - input_raw: InputRawTransaction, - input_action: InputTransferAction, - input_encryption: InputTransactionEncryption, - ) -> FieldResult { - let action = cover_transfer_action(&input_action)?; - let signed_tx = cover_to_signed_tx(&action, &input_raw, &input_encryption)?; - block_on( - state_ctx - .adapter - .insert_signed_txs(Context::new(), signed_tx), - ) - .map_err(FieldError::from)?; - - Ok(input_encryption.tx_hash) - } - - #[graphql( - name = "sendDeployTransaction", - description = "Send deployment contract transaction to the blockchain." - )] - fn send_deploy_transaction( - state_ctx: &State, - input_raw: InputRawTransaction, - input_action: InputDeployAction, - input_encryption: InputTransactionEncryption, - ) -> FieldResult { - let action = cover_deploy_action(&input_action)?; - let signed_tx = cover_to_signed_tx(&action, &input_raw, &input_encryption)?; - block_on( - state_ctx - .adapter - .insert_signed_txs(Context::new(), signed_tx), - ) - .map_err(FieldError::from)?; - - Ok(input_encryption.tx_hash) - } - - #[graphql( - name = "sendUnsafeTransferTransaction", - deprecated = "DON'T use it in production! This is just for development." - )] - fn send_unsafe_transfer_transaction( - state_ctx: &State, - input_raw: InputRawTransaction, - input_action: InputTransferAction, - input_privkey: Bytes, - ) -> FieldResult { - let action = cover_transfer_action(&input_action)?; - let raw_tx = cover_to_raw_tx(&action, &input_raw)?; - let tx_hash = protocol::types::Hash::digest(raw_tx.encode_fixed()?); - let tx_hash = Hash::from(tx_hash); - - let input_encryption = gen_input_tx_encryption(input_privkey, tx_hash.clone())?; - let signed_tx = cover_to_signed_tx(&action, &input_raw, &input_encryption)?; - block_on( - state_ctx - .adapter - .insert_signed_txs(Context::new(), signed_tx), - ) - .map_err(FieldError::from)?; - - Ok(tx_hash) - } - - #[graphql( - name = "sendUnsafeDeployTransaction", - deprecated = "DON'T use it in production! This is just for development." - )] - fn send_unsafe_deploy_transaction( - state_ctx: &State, - input_raw: InputRawTransaction, - input_action: InputDeployAction, - input_privkey: Bytes, - ) -> FieldResult { - let action = cover_deploy_action(&input_action)?; - let raw_tx = cover_to_raw_tx(&action, &input_raw)?; - let tx_hash = protocol::types::Hash::digest(raw_tx.encode_fixed()?); - let tx_hash = Hash::from(tx_hash); - - let input_encryption = gen_input_tx_encryption(input_privkey, tx_hash.clone())?; - let signed_tx = cover_to_signed_tx(&action, &input_raw, &input_encryption)?; - block_on( - state_ctx - .adapter - .insert_signed_txs(Context::new(), signed_tx), - ) - .map_err(FieldError::from)?; - - Ok(tx_hash) - } -} - -// Adding `Query` and `Mutation` together we get `Schema`, which describes, -// well, the whole GraphQL schema. -type Schema = juniper::RootNode<'static, Query, Mutation>; - -// Finally, we'll bridge between Tide and Juniper. `GraphQLRequest` from Juniper -// implements `Deserialize`, so we use `Json` extractor to deserialize the -// request body. -async fn handle_graphql(mut ctx: tide::Context>) -> EndpointResult { - let query: juniper::http::GraphQLRequest = ctx.body_json().await.client_err()?; - let schema = Schema::new(Query, Mutation); - let response = query.execute(&schema, ctx.state()); - let status = if response.is_ok() { - http::status::StatusCode::OK - } else { - http::status::StatusCode::BAD_REQUEST - }; - let mut resp = response::json(response); - *resp.status_mut() = status; - Ok(resp) -} - -async fn handle_graphiql( - _ctx: tide::Context>, -) -> EndpointResult> { - let html = graphiql_source("/graphql"); - - Ok(tide::http::Response::builder() - .status(http::status::StatusCode::OK) - .header("Content-Type", "text/html") - .body(html) - .unwrap()) -} - -fn hex_to_vec_u8(s: &str) -> FieldResult> { - hex::decode(s).map_err(FieldError::from) -} - -fn hex_to_u64(s: &str) -> FieldResult { - let n = u64::from_str_radix(s, 16).map_err(FieldError::from)?; - Ok(n) -} - -fn opt_hex_to_u64(s: Option) -> FieldResult> { - match s { - Some(s) => match hex_to_u64(&s) { - Ok(num) => Ok(Some(num)), - Err(e) => Err(e), - }, - None => Ok(None), - } -} - -fn gen_input_tx_encryption( - input_privkey: Bytes, - tx_hash: Hash, -) -> FieldResult { - let privkey = Secp256k1PrivateKey::try_from(hex_to_vec_u8(&input_privkey.as_hex())?.as_ref()) - .map_err(FieldError::from)?; - let pubkey = privkey.pub_key(); - let hash_value = HashValue::try_from(hex_to_vec_u8(&tx_hash.as_hex())?.as_ref()) - .map_err(FieldError::from)?; - let signature = privkey.sign_message(&hash_value); - - let input_encryption = InputTransactionEncryption { - tx_hash, - pubkey: Bytes::from(pubkey.to_bytes()), - signature: Bytes::from(signature.to_bytes()), - }; - Ok(input_encryption) -} - -// ##################### -// Convert from graphql type to protocol type -// ##################### - -fn cover_to_raw_tx( - action: &protocol::types::TransactionAction, - input_raw: &InputRawTransaction, -) -> FieldResult { - let raw = protocol::types::RawTransaction { - chain_id: protocol::types::Hash::from_hex(&input_raw.chain_id.as_hex()) - .map_err(FieldError::from)?, - nonce: protocol::types::Hash::from_hex(&input_raw.nonce.as_hex()) - .map_err(FieldError::from)?, - timeout: hex_to_u64(&input_raw.timeout.as_hex())?, - fee: protocol::types::Fee { - asset_id: protocol::types::AssetID::from_hex(&input_raw.fee_asset_id.as_hex()) - .map_err(FieldError::from)?, - cycle: hex_to_u64(&input_raw.fee_cycle.as_hex())?, - }, - action: action.clone(), - }; - - Ok(raw) -} - -fn cover_to_signed_tx( - action: &protocol::types::TransactionAction, - input_raw: &InputRawTransaction, - input_encryption: &InputTransactionEncryption, -) -> FieldResult { - let raw = cover_to_raw_tx(action, input_raw)?; - - let signed_tx = protocol::types::SignedTransaction { - raw, - tx_hash: protocol::types::Hash::from_hex(&input_encryption.tx_hash.as_hex()) - .map_err(FieldError::from)?, - pubkey: protocol::Bytes::from(hex_to_vec_u8(&input_encryption.pubkey.as_hex())?), - signature: protocol::Bytes::from(hex_to_vec_u8(&input_encryption.signature.as_hex())?), - }; - - Ok(signed_tx) -} - -fn cover_transfer_action( - input_action: &InputTransferAction, -) -> FieldResult { - let action = protocol::types::TransactionAction::Transfer { - receiver: protocol::types::UserAddress::from_hex(&input_action.receiver.as_hex()) - .map_err(FieldError::from)?, - carrying_asset: protocol::types::CarryingAsset { - asset_id: protocol::types::AssetID::from_hex(&input_action.carrying_asset_id.as_hex()) - .map_err(FieldError::from)?, - amount: protocol::types::Balance::from_bytes_be( - hex_to_vec_u8(&input_action.carrying_amount.as_hex())?.as_ref(), - ), - }, - }; - - Ok(action) -} - -fn cover_deploy_action( - input_action: &InputDeployAction, -) -> FieldResult { - let contract_type = match input_action.contract_type { - ContractType::Asset => protocol::types::ContractType::Asset, - ContractType::App => protocol::types::ContractType::App, - ContractType::Library => protocol::types::ContractType::Library, - }; - - let action = protocol::types::TransactionAction::Deploy { - code: protocol::Bytes::from(hex_to_vec_u8(&input_action.code.as_hex())?), - contract_type, - }; - - Ok(action) -} diff --git a/core/consensus/Cargo.toml b/core/consensus/Cargo.toml index 1aa256536..6b8f4ab85 100644 --- a/core/consensus/Cargo.toml +++ b/core/consensus/Cargo.toml @@ -21,6 +21,7 @@ parking_lot = "0.10" rlp = "0.4" serde = {version = "1.0", features = ["derive"]} serde_json = "1.0" +cita_trie = "2.0" common-crypto = { path = "../../common/crypto"} common-logger = { path = "../../common/logger" } diff --git a/core/consensus/src/adapter.rs b/core/consensus/src/adapter.rs index 5abce0ad4..6b1a9a0d8 100644 --- a/core/consensus/src/adapter.rs +++ b/core/consensus/src/adapter.rs @@ -8,15 +8,14 @@ use futures::stream::StreamExt; use log::{debug, error}; use common_merkle::Merkle; -use protocol::traits::executor::{ExecutorExecResp, ExecutorFactory, TrieDB}; use protocol::traits::{ - ConsensusAdapter, Context, Gossip, MemPool, MessageTarget, MixedTxHashes, NodeInfo, Priority, - Rpc, Storage, + ConsensusAdapter, Context, ExecutorFactory, ExecutorParams, ExecutorResp, Gossip, MemPool, + MessageTarget, MixedTxHashes, NodeInfo, Priority, Rpc, Storage, }; use protocol::types::{ Address, Epoch, Hash, MerkleRoot, Proof, Receipt, SignedTransaction, Validator, }; -use protocol::{fixed_codec::ProtocolFixedCodec, ProtocolResult}; +use protocol::{fixed_codec::FixedCodec, ProtocolResult}; use crate::fixed_types::{FixedEpoch, FixedEpochID, FixedSignedTxs, PullTxsRequest}; use crate::status::{CurrentStatusAgent, UpdateInfo}; @@ -26,12 +25,12 @@ use crate::ConsensusError; const OVERLORD_GAP: usize = 10; pub struct OverlordConsensusAdapter< - EF: ExecutorFactory, + EF: ExecutorFactory, G: Gossip, M: MemPool, R: Rpc, S: Storage, - DB: TrieDB, + DB: cita_trie::DB, > { rpc: Arc, network: Arc, @@ -45,12 +44,12 @@ pub struct OverlordConsensusAdapter< #[async_trait] impl ConsensusAdapter for OverlordConsensusAdapter where - EF: ExecutorFactory, + EF: ExecutorFactory, G: Gossip + Sync + Send, R: Rpc + Sync + Send, M: MemPool, S: Storage, - DB: TrieDB, + DB: cita_trie::DB, { async fn get_txs_from_mempool( &self, @@ -107,6 +106,8 @@ where cycles_price: u64, coinbase: Address, signed_txs: Vec, + cycles_limit: u64, + timestamp: u64, ) -> ProtocolResult<()> { let chain_id = node_info.chain_id; let exec_info = ExecuteInfo { @@ -116,6 +117,8 @@ where signed_txs, order_root, coinbase, + cycles_limit, + timestamp, }; let mut tx = self.exec_queue.clone(); @@ -193,12 +196,12 @@ where impl OverlordConsensusAdapter where - EF: ExecutorFactory, + EF: ExecutorFactory, G: Gossip + Sync + Send, R: Rpc + Sync + Send, M: MemPool, S: Storage, - DB: TrieDB, + DB: cita_trie::DB, { pub fn new( rpc: Arc, @@ -248,8 +251,8 @@ pub struct ExecDemons { impl ExecDemons where S: Storage, - DB: TrieDB, - EF: ExecutorFactory, + DB: cita_trie::DB, + EF: ExecutorFactory, { fn new( storage: Arc, @@ -266,6 +269,37 @@ where pin_ef: PhantomData, status: status_agent, } + Ok(()) + } + + async fn save_receipts(&self, receipts: Vec) -> ProtocolResult<()> { + self.storage.insert_receipts(receipts).await + } +} + +fn gen_update_info( + exec_resp: ExecutorExecResp, + epoch_id: u64, + order_root: MerkleRoot, +) -> UpdateInfo { + let cycles = exec_resp.all_cycles_used.iter().map(|fee| fee.cycle).sum(); + let receipt = Merkle::from_hashes( + exec_resp + .receipts + .iter() + .map(|r| Hash::digest(r.to_owned().encode_fixed().unwrap())) + .collect::>(), + ) + .get_root_hash() + .unwrap_or_else(Hash::from_empty); + + UpdateInfo { + exec_epoch_id: epoch_id, + cycles_used: cycles, + receipt_root: receipt, + confirm_root: order_root, + state_root: exec_resp.state_root.clone(), + logs_bloom: exec_resp.logs_bloom, } pub async fn run(mut self) { @@ -284,15 +318,17 @@ where error!("muta-consensus: execute {} epoch", epoch_id); let mut executor = EF::from_root( - info.chain_id.clone(), self.state_root.clone(), Arc::clone(&self.trie_db), - info.epoch_id, - info.cycles_price, - info.coinbase, + Arc::clone(&self.storage), )?; - - let resp = executor.exec(txs)?; + let exec_params = ExecutorParams { + state_root: self.state_root.clone(), + epoch_id, + timestamp: info.timestamp, + cycels_limit: info.cycles_limit, + }; + let resp = executor.exec(&exec_params, &txs)?; self.state_root = resp.state_root.clone(); self.save_receipts(resp.receipts.clone()).await?; self.status @@ -308,12 +344,9 @@ where } } -fn gen_update_info( - exec_resp: ExecutorExecResp, - epoch_id: u64, - order_root: MerkleRoot, -) -> UpdateInfo { - let cycles = exec_resp.all_cycles_used.iter().map(|fee| fee.cycle).sum(); +fn gen_update_info(exec_resp: ExecutorResp, epoch_id: u64, order_root: MerkleRoot) -> UpdateInfo { + let cycles = exec_resp.all_cycles_used; + let receipt = Merkle::from_hashes( exec_resp .receipts diff --git a/core/consensus/src/engine.rs b/core/consensus/src/engine.rs index 575c4dfc0..fe2d50b55 100644 --- a/core/consensus/src/engine.rs +++ b/core/consensus/src/engine.rs @@ -13,11 +13,10 @@ use parking_lot::RwLock; use rlp::Encodable; use common_merkle::Merkle; -use protocol::fixed_codec::ProtocolFixedCodec; +use protocol::fixed_codec::FixedCodec; use protocol::traits::{ConsensusAdapter, Context, MessageTarget, NodeInfo}; use protocol::types::{ - Address, Epoch, EpochHeader, Hash, MerkleRoot, Pill, Proof, SignedTransaction, UserAddress, - Validator, + Address, Epoch, EpochHeader, Hash, MerkleRoot, Pill, Proof, SignedTransaction, Validator, }; use protocol::{Bytes, BytesMut, ProtocolError, ProtocolResult}; @@ -181,7 +180,8 @@ impl Engine self.exec( pill.epoch.header.order_root.clone(), epoch_id, - Address::User(pill.epoch.header.proposer.clone()), + pill.epoch.header.proposer.clone(), + pill.epoch.header.timestamp, full_txs.clone(), ) .await?; @@ -257,7 +257,7 @@ impl Engine ctx, msg, END_GOSSIP_SIGNED_VOTE, - MessageTarget::Specified(UserAddress::from_bytes(addr)?), + MessageTarget::Specified(Address::from_bytes(addr)?), ) .await?; } @@ -268,7 +268,7 @@ impl Engine ctx, msg, END_GOSSIP_AGGREGATED_VOTE, - MessageTarget::Specified(UserAddress::from_bytes(addr)?), + MessageTarget::Specified(Address::from_bytes(addr)?), ) .await?; } @@ -342,6 +342,7 @@ impl ConsensusEngine { order_root: MerkleRoot, epoch_id: u64, address: Address, + timestamp: u64, txs: Vec, ) -> ProtocolResult<()> { let status = { self.current_consensus_status.read().clone() }; @@ -354,6 +355,8 @@ impl ConsensusEngine { status.cycles_price, address, txs, + status.cycles_limit, + timestamp, ) .await } diff --git a/core/consensus/src/fixed_types.rs b/core/consensus/src/fixed_types.rs index c1ec0dfa4..e921063f5 100644 --- a/core/consensus/src/fixed_types.rs +++ b/core/consensus/src/fixed_types.rs @@ -5,7 +5,7 @@ use bincode::{deserialize, serialize}; use overlord::Codec; use protocol::codec::{Deserialize, ProtocolCodecSync, Serialize}; -use protocol::fixed_codec::ProtocolFixedCodec; +use protocol::fixed_codec::FixedCodec; use protocol::types::{Epoch, Hash, Pill, SignedTransaction}; use protocol::{traits::MessageCodec, Bytes, BytesMut, ProtocolResult}; @@ -52,7 +52,7 @@ impl MessageCodec for ConsensusRpcResponse { match flag.as_ref() { b"a" => { - let res: Epoch = ProtocolFixedCodec::decode_fixed(bytes)?; + let res: Epoch = FixedCodec::decode_fixed(bytes)?; Ok(ConsensusRpcResponse::PullEpochs(Box::new(res))) } @@ -78,7 +78,7 @@ impl Codec for FixedPill { } fn decode(data: Bytes) -> Result> { - let inner: Pill = ProtocolFixedCodec::decode_fixed(data)?; + let inner: Pill = FixedCodec::decode_fixed(data)?; Ok(FixedPill { inner }) } } @@ -169,12 +169,11 @@ mod test { use std::convert::From; use futures::executor; - use num_traits::FromPrimitive; use rand::random; use protocol::types::{ - CarryingAsset, Epoch, EpochHeader, Fee, Hash, Proof, RawTransaction, SignedTransaction, - TransactionAction, UserAddress, + Address, Epoch, EpochHeader, Hash, Proof, RawTransaction, SignedTransaction, + TransactionRequest, }; use protocol::Bytes; @@ -182,7 +181,7 @@ mod test { fn gen_epoch(epoch_id: u64, epoch_hash: Hash) -> Epoch { let nonce = Hash::digest(Bytes::from("XXXX")); - let addr_str = "10CAB8EEA4799C21379C20EF5BAA2CC8AF1BEC475B"; + let addr_str = "CAB8EEA4799C21379C20EF5BAA2CC8AF1BEC475B"; let header = EpochHeader { chain_id: nonce.clone(), epoch_id, @@ -194,7 +193,7 @@ mod test { state_root: nonce, receipt_root: Vec::new(), cycles_used: vec![999_999], - proposer: UserAddress::from_hex(addr_str).unwrap(), + proposer: Address::from_hex(addr_str).unwrap(), proof: mock_proof(epoch_hash), validator_version: 1, validators: Vec::new(), @@ -220,33 +219,23 @@ mod test { (0..len).map(|_| random::()).collect::>() } - fn gen_user_address() -> UserAddress { - let inner = "0x107899EE7319601cbC2684709e0eC3A4807bb0Fd74"; - UserAddress::from_hex(inner).unwrap() - } - fn gen_signed_tx() -> SignedTransaction { use protocol::codec::ProtocolCodec; - let address = gen_user_address(); let nonce = Hash::digest(Bytes::from(gen_random_bytes(10))); - let fee = Fee { - asset_id: nonce.clone(), - cycle: random::(), - }; - let action = TransactionAction::Transfer { - receiver: address, - carrying_asset: CarryingAsset { - asset_id: nonce.clone(), - amount: FromPrimitive::from_i32(42).unwrap(), - }, + + let request = TransactionRequest { + service_name: "test".to_owned(), + method: "test".to_owned(), + payload: "test".to_owned(), }; let mut raw = RawTransaction { chain_id: nonce.clone(), nonce, timeout: random::(), - fee, - action, + cycles_price: 1, + cycles_limit: random::(), + request, }; let raw_bytes = executor::block_on(async { raw.encode().await.unwrap() }); diff --git a/core/consensus/src/synchronization.rs b/core/consensus/src/synchronization.rs index f21cd65c6..e7af6f16c 100644 --- a/core/consensus/src/synchronization.rs +++ b/core/consensus/src/synchronization.rs @@ -9,9 +9,9 @@ use log::{error, warn}; use overlord::types::{OverlordMsg, Status}; use overlord::OverlordHandler; -use protocol::fixed_codec::ProtocolFixedCodec; +use protocol::fixed_codec::FixedCodec; use protocol::traits::ConsensusAdapter; -use protocol::types::{Address, Hash, Proof}; +use protocol::types::{Hash, Proof}; use protocol::ProtocolResult; use crate::engine::ConsensusEngine; @@ -103,7 +103,8 @@ where .exec( epoch.header.order_root.clone(), epoch.header.epoch_id, - Address::User(epoch.header.proposer.clone()), + epoch.header.proposer.clone(), + epoch.header.timestamp, txs.clone(), ) .await?; diff --git a/core/consensus/src/util.rs b/core/consensus/src/util.rs index 4f62de9bf..629958589 100644 --- a/core/consensus/src/util.rs +++ b/core/consensus/src/util.rs @@ -134,6 +134,8 @@ pub struct ExecuteInfo { pub order_root: MerkleRoot, pub cycles_price: u64, pub coinbase: Address, + pub timestamp: u64, + pub cycles_limit: u64, } #[cfg(test)] diff --git a/core/mempool/Cargo.toml b/core/mempool/Cargo.toml index cafa8dafb..18c9829a9 100644 --- a/core/mempool/Cargo.toml +++ b/core/mempool/Cargo.toml @@ -19,7 +19,7 @@ derive_more = "0.15" async-trait = "0.1" parking_lot = "0.8" num-traits = "0.2" -bytes = "0.4" +bytes = "0.5" rayon = "1.0" rand = "0.7" hex = "0.3" diff --git a/core/mempool/src/adapter/mod.rs b/core/mempool/src/adapter/mod.rs index 3f8222ede..c5b5ee9de 100644 --- a/core/mempool/src/adapter/mod.rs +++ b/core/mempool/src/adapter/mod.rs @@ -23,7 +23,7 @@ use log::{debug, error}; use common_crypto::Crypto; use protocol::{ - fixed_codec::ProtocolFixedCodec, + fixed_codec::FixedCodec, traits::{Context, Gossip, MemPoolAdapter, Priority, Rpc, Storage}, types::{Hash, SignedTransaction}, ProtocolError, ProtocolErrorKind, ProtocolResult, @@ -336,7 +336,7 @@ mod tests { use protocol::{ traits::{Context, Gossip, MessageCodec, Priority}, - types::UserAddress, + types::Address, Bytes, ProtocolResult, }; @@ -394,7 +394,7 @@ mod tests { &self, _: Context, _: &str, - _: Vec, + _: Vec
, _: M, _: Priority, ) -> ProtocolResult<()> diff --git a/core/mempool/src/tests/mod.rs b/core/mempool/src/tests/mod.rs index 401a11c77..7ae3db691 100644 --- a/core/mempool/src/tests/mod.rs +++ b/core/mempool/src/tests/mod.rs @@ -8,7 +8,6 @@ use std::sync::Arc; use async_trait::async_trait; use chashmap::CHashMap; use futures::executor; -use num_traits::FromPrimitive; use rand::random; use rand::rngs::OsRng; use rayon::iter::IntoParallelRefIterator; @@ -20,15 +19,11 @@ use common_crypto::{ }; use protocol::codec::ProtocolCodec; use protocol::traits::{Context, MemPool, MemPoolAdapter, MixedTxHashes}; -use protocol::types::{ - CarryingAsset, Fee, Hash, RawTransaction, SignedTransaction, TransactionAction, - UserAddress as Address, -}; +use protocol::types::{Hash, RawTransaction, SignedTransaction, TransactionRequest}; use protocol::{Bytes, ProtocolResult}; use crate::{HashMemPool, MemPoolError}; -const AMOUNT: i32 = 42; const CYCLE_LIMIT: u64 = 10_000; const CURRENT_EPOCH_ID: u64 = 999; const POOL_SIZE: usize = 100_000; @@ -95,15 +90,8 @@ fn mock_txs(valid_size: usize, invalid_size: usize, timeout: u64) -> Vec HashMemPool ProtocolResult
{ - let mut pub_key_str = Hash::digest(pub_key.to_bytes()).as_hex(); - pub_key_str.truncate(40); - pub_key_str.insert_str(0, "10"); - Address::from_bytes(Bytes::from(hex::decode(pub_key_str).unwrap())) -} - async fn check_hash(tx: SignedTransaction) -> ProtocolResult<()> { let mut raw = tx.raw; let raw_bytes = raw.encode().await?; @@ -223,28 +204,23 @@ fn exec_get_full_txs( fn mock_signed_tx( priv_key: &Secp256k1PrivateKey, pub_key: &Secp256k1PublicKey, - address: &Address, timeout: u64, valid: bool, ) -> SignedTransaction { let nonce = Hash::digest(Bytes::from(get_random_bytes(10))); - let fee = Fee { - asset_id: nonce.clone(), - cycle: TX_CYCLE, - }; - let action = TransactionAction::Transfer { - receiver: address.clone(), - carrying_asset: CarryingAsset { - asset_id: nonce.clone(), - amount: FromPrimitive::from_i32(AMOUNT).unwrap(), - }, + + let request = TransactionRequest { + service_name: "test".to_owned(), + method: "test".to_owned(), + payload: "test".to_owned(), }; let mut raw = RawTransaction { chain_id: nonce.clone(), nonce, timeout, - fee, - action, + cycles_limit: TX_CYCLE, + cycles_price: 1, + request, }; let raw_bytes = executor::block_on(async { raw.encode().await.unwrap() }); diff --git a/core/mempool/src/tx_cache.rs b/core/mempool/src/tx_cache.rs index e9db8de6b..7f3d497ba 100644 --- a/core/mempool/src/tx_cache.rs +++ b/core/mempool/src/tx_cache.rs @@ -20,11 +20,11 @@ use crate::MemPoolError; /// transaction hashes for consensus. pub struct TxWrapper { /// Content. - tx: SignedTransaction, + tx: SignedTransaction, /// While map removes a `shared_tx` during flush, it will mark `removed` /// true. Afterwards, queue removes the transaction which marks /// `removed` true during package. - removed: AtomicBool, + removed: AtomicBool, /// The response transactions in propose-syncing will insert into `TxCache` /// marking `proposed` true. /// While collecting propose_tx_hashes during package, @@ -114,14 +114,14 @@ struct QueueRole<'a> { /// out, `queue_1` switch to insertion queue. pub struct TxCache { /// One queue. - queue_0: ArrayQueue, + queue_0: ArrayQueue, /// Another queue. - queue_1: ArrayQueue, + queue_1: ArrayQueue, /// A map for randomly search and removal. - map: Map, + map: Map, /// This is used to pick a queue for insertion, /// If true selects `queue_0`, else `queue_1`. - is_zero: AtomicBool, + is_zero: AtomicBool, /// This is an atomic state to solve concurrent insertion problem during /// package. While switching insertion queues, some transactions may /// still insert into the old queue. We use this state to make sure @@ -217,10 +217,10 @@ impl TxCache { } // Accumulate cycles. The order_tx_hashes and the propose_tx_hashes both collect // transactions under cycle limit. - cycle_count += shared_tx.tx.raw.fee.cycle; + cycle_count += shared_tx.tx.raw.cycles_limit; if cycle_count > cycle_limit { stage = stage.next(); - cycle_count = shared_tx.tx.raw.fee.cycle; + cycle_count = shared_tx.tx.raw.cycles_limit; } match stage { @@ -353,15 +353,12 @@ mod tests { use std::sync::Arc; use std::thread; - use num_traits::FromPrimitive; use rand::random; use rayon::iter::IntoParallelRefIterator; use rayon::prelude::*; use test::Bencher; - use protocol::types::{ - CarryingAsset, Fee, Hash, RawTransaction, SignedTransaction, TransactionAction, UserAddress, - }; + use protocol::types::{Hash, RawTransaction, SignedTransaction, TransactionRequest}; use protocol::Bytes; use crate::map::Map; @@ -391,29 +388,24 @@ mod tests { fn mock_signed_tx(bytes: Vec) -> SignedTransaction { let rand_hash = Hash::digest(Bytes::from(bytes)); let chain_id = rand_hash.clone(); - let asset_id = rand_hash.clone(); let nonce = rand_hash.clone(); let tx_hash = rand_hash; let add_str = "10CAB8EEA4799C21379C20EF5BAA2CC8AF1BEC475B"; let bytes = Bytes::from(hex::decode(add_str).unwrap()); - let address = UserAddress::from_bytes(bytes.clone()).unwrap(); - let fee = Fee { - asset_id: asset_id.clone(), - cycle: TX_CYCLE, - }; - let action = TransactionAction::Transfer { - receiver: address, - carrying_asset: CarryingAsset { - asset_id, - amount: FromPrimitive::from_i32(10_000).unwrap(), - }, + + let request = TransactionRequest { + service_name: "test".to_owned(), + method: "test".to_owned(), + payload: "test".to_owned(), }; + let raw = RawTransaction { chain_id, nonce, timeout: TIMEOUT, - fee, - action, + cycles_limit: TX_CYCLE, + cycles_price: 1, + request, }; SignedTransaction { raw, diff --git a/core/network/src/connection/control.rs b/core/network/src/connection/control.rs index a88ba81a8..9556e2699 100644 --- a/core/network/src/connection/control.rs +++ b/core/network/src/connection/control.rs @@ -3,7 +3,7 @@ use std::{io, marker::PhantomData}; use async_trait::async_trait; use futures::channel::{mpsc::UnboundedSender, oneshot}; use log::debug; -use protocol::{traits::Priority, types::UserAddress, Bytes}; +use protocol::{traits::Priority, types::Address, Bytes}; use tentacle::{ error::Error as TentacleError, service::{ServiceControl, TargetSession}, @@ -70,7 +70,7 @@ impl MessageSender for ConnectionServiceControl

{ async fn users_send( &self, - user_addrs: Vec, + user_addrs: Vec

, msg: Bytes, pri: Priority, ) -> Result<(), NetworkError> { diff --git a/core/network/src/error.rs b/core/network/src/error.rs index cbaf2ea8e..d9f802ebd 100644 --- a/core/network/src/error.rs +++ b/core/network/src/error.rs @@ -3,7 +3,7 @@ use std::{error::Error, num::ParseIntError}; use derive_more::{Display, From}; use tentacle::{ProtocolId, SessionId}; -use protocol::{types::UserAddress, ProtocolError, ProtocolErrorKind}; +use protocol::{types::Address, ProtocolError, ProtocolErrorKind}; #[derive(Debug, Display, From)] pub enum ErrorKind { @@ -82,7 +82,7 @@ pub enum NetworkError { NotEndpoint, #[display(fmt = "{:?} account addrs aren't connecting, try connect them", miss)] - PartialRouteMessage { miss: Vec }, + PartialRouteMessage { miss: Vec
}, #[display(fmt = "internal error: {}", _0)] Internal(Box), diff --git a/core/network/src/event.rs b/core/network/src/event.rs index f203e6d49..e95d55d70 100644 --- a/core/network/src/event.rs +++ b/core/network/src/event.rs @@ -2,7 +2,7 @@ use std::error::Error; use derive_more::{Display, From}; use futures::channel::oneshot::Sender; -use protocol::{traits::Priority, types::UserAddress, Bytes}; +use protocol::{traits::Priority, types::Address, Bytes}; use tentacle::{ multiaddr::Multiaddr, secio::{PeerId, PublicKey}, @@ -79,7 +79,7 @@ pub enum RemoveKind { #[derive(Debug, Display)] #[display(fmt = "multi users message, addrs: {:?}", user_addrs)] pub struct MultiUsersMessage { - pub user_addrs: Vec, + pub user_addrs: Vec
, pub msg: Bytes, pub pri: Priority, } @@ -165,6 +165,6 @@ pub enum PeerManagerEvent { #[display(fmt = "try route multi accounts message: {}", users_msg)] RouteMultiUsersMessage { users_msg: MultiUsersMessage, - miss_tx: Sender>, + miss_tx: Sender>, }, } diff --git a/core/network/src/outbound/gossip.rs b/core/network/src/outbound/gossip.rs index 82bbea9e5..5ef8740d6 100644 --- a/core/network/src/outbound/gossip.rs +++ b/core/network/src/outbound/gossip.rs @@ -1,7 +1,7 @@ use async_trait::async_trait; use protocol::{ traits::{Context, Gossip, MessageCodec, Priority}, - types::UserAddress, + types::Address, Bytes, ProtocolResult, }; use tentacle::service::TargetSession; @@ -61,7 +61,7 @@ where async fn users_send( &self, _ctx: Context, - users: Vec, + users: Vec
, msg: Bytes, pri: Priority, ) -> Result<(), NetworkError> { @@ -89,7 +89,7 @@ where &self, cx: Context, end: &str, - users: Vec, + users: Vec
, msg: M, p: Priority, ) -> ProtocolResult<()> diff --git a/core/network/src/peer_manager/mod.rs b/core/network/src/peer_manager/mod.rs index deae63bda..48ab9c939 100644 --- a/core/network/src/peer_manager/mod.rs +++ b/core/network/src/peer_manager/mod.rs @@ -35,7 +35,7 @@ use futures::{ }; use log::{debug, error, info, warn}; use parking_lot::RwLock; -use protocol::types::UserAddress; +use protocol::types::Address; use rand::seq::IteratorRandom; use tentacle::{ multiaddr::{Multiaddr, Protocol}, @@ -121,7 +121,7 @@ struct Inner { connected: RwLock>, addr_pid: RwLock>, - user_pid: RwLock>, + user_pid: RwLock>, pool: RwLock>, // Self PeerId @@ -169,14 +169,14 @@ impl Inner { self.listen.read().clone() } - pub fn user_peer(&self, user: &UserAddress) -> Option { + pub fn user_peer(&self, user: &Address) -> Option { let user_pid = self.user_pid.read(); let pool = self.pool.read(); user_pid.get(user).and_then(|pid| pool.get(pid).cloned()) } - pub fn pid_user_addr(&self, pid: &PeerId) -> Option { + pub fn pid_user_addr(&self, pid: &PeerId) -> Option
{ let pool = self.pool.read(); pool.get(pid).map(|peer| peer.user_addr().clone()) @@ -802,7 +802,7 @@ impl PeerManager { fn route_multi_users_message( &mut self, users_msg: MultiUsersMessage, - miss_tx: oneshot::Sender>, + miss_tx: oneshot::Sender>, ) { let mut no_peers = vec![]; let mut connected = vec![]; diff --git a/core/network/src/peer_manager/peer.rs b/core/network/src/peer_manager/peer.rs index 1581e956f..d3ef74430 100644 --- a/core/network/src/peer_manager/peer.rs +++ b/core/network/src/peer_manager/peer.rs @@ -7,7 +7,7 @@ use std::{ }; use derive_more::Display; -use protocol::{types::UserAddress, Bytes}; +use protocol::{types::Address, Bytes}; use serde_derive::{Deserialize, Serialize}; use tentacle::{ multiaddr::Multiaddr, @@ -62,7 +62,7 @@ pub(super) struct PeerState { )] pub struct Peer { id: Arc, - user_addr: Arc, + user_addr: Arc
, pubkey: Arc, state: PeerState, } @@ -129,7 +129,7 @@ impl Peer { self.state.connection_ip } - pub fn user_addr(&self) -> &UserAddress { + pub fn user_addr(&self) -> &Address { &self.user_addr } @@ -212,10 +212,10 @@ impl Peer { } // # Panic - pub(super) fn pubkey_to_addr(pubkey: &PublicKey) -> UserAddress { + pub(super) fn pubkey_to_addr(pubkey: &PublicKey) -> Address { let pubkey_bytes = Bytes::from(pubkey.inner_ref().clone()); - UserAddress::from_pubkey_bytes(pubkey_bytes) + Address::from_pubkey_bytes(pubkey_bytes) .expect("convert from secp256k1 public key should always success") } } diff --git a/core/network/src/service.rs b/core/network/src/service.rs index e2572638e..f3b8a9fb0 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -16,7 +16,7 @@ use futures::{ use log::{debug, error, info}; use protocol::{ traits::{Context, Gossip, MessageCodec, MessageHandler, Priority, Rpc}, - types::UserAddress, + types::Address, ProtocolResult, }; @@ -57,7 +57,7 @@ impl Gossip for NetworkServiceHandle { &self, cx: Context, end: &str, - users: Vec, + users: Vec
, msg: M, p: Priority, ) -> ProtocolResult<()> diff --git a/core/network/src/traits.rs b/core/network/src/traits.rs index 27e08fbd9..bda3dcc4c 100644 --- a/core/network/src/traits.rs +++ b/core/network/src/traits.rs @@ -1,7 +1,7 @@ use async_trait::async_trait; use protocol::{ traits::{Cloneable, Context, Priority}, - types::UserAddress, + types::Address, Bytes, }; use tentacle::{ @@ -27,7 +27,7 @@ pub trait NetworkProtocol { #[async_trait] pub trait MessageSender { fn send(&self, tar: TargetSession, msg: Bytes, pri: Priority) -> Result<(), NetworkError>; - async fn users_send(&self, users: Vec, msg: Bytes, pri: Priority) -> Result<(), NetworkError>; + async fn users_send(&self, users: Vec
, msg: Bytes, pri: Priority) -> Result<(), NetworkError>; } pub trait Compression { diff --git a/core/storage/src/tests/mod.rs b/core/storage/src/tests/mod.rs index 53a7c4122..10187b069 100644 --- a/core/storage/src/tests/mod.rs +++ b/core/storage/src/tests/mod.rs @@ -9,36 +9,30 @@ macro_rules! exec { mod adapter; mod storage; -use num_traits::FromPrimitive; use rand::random; use protocol::types::{ - CarryingAsset, Epoch, EpochHeader, Fee, Hash, Proof, RawTransaction, Receipt, ReceiptResult, - SignedTransaction, TransactionAction, UserAddress, + Address, Epoch, EpochHeader, Hash, Proof, RawTransaction, Receipt, ReceiptResponse, + SignedTransaction, TransactionRequest, }; use protocol::Bytes; fn mock_signed_tx(tx_hash: Hash) -> SignedTransaction { let nonce = Hash::digest(Bytes::from("XXXX")); - let fee = Fee { - asset_id: nonce.clone(), - cycle: 10, - }; - let addr_str = "10CAB8EEA4799C21379C20EF5BAA2CC8AF1BEC475B"; - let action = TransactionAction::Transfer { - receiver: UserAddress::from_hex(addr_str).unwrap(), - carrying_asset: CarryingAsset { - asset_id: nonce.clone(), - amount: FromPrimitive::from_i32(10).unwrap(), - }, + let request = TransactionRequest { + service_name: "test".to_owned(), + method: "test".to_owned(), + payload: "test".to_owned(), }; + let raw = RawTransaction { chain_id: nonce.clone(), nonce, timeout: 10, - fee, - action, + cycles_limit: 10, + cycles_price: 1, + request, }; SignedTransaction { @@ -51,30 +45,26 @@ fn mock_signed_tx(tx_hash: Hash) -> SignedTransaction { fn mock_receipt(tx_hash: Hash) -> Receipt { let nonce = Hash::digest(Bytes::from("XXXX")); - let cycles_used = Fee { - asset_id: nonce.clone(), - cycle: 10, - }; - let addr_str = "10CAB8EEA4799C21379C20EF5BAA2CC8AF1BEC475B"; - let result = ReceiptResult::Transfer { - receiver: UserAddress::from_hex(addr_str).unwrap(), - asset_id: nonce.clone(), - before_amount: FromPrimitive::from_i32(10).unwrap(), - after_amount: FromPrimitive::from_i32(20).unwrap(), - }; + let response = ReceiptResponse { + service_name: "test".to_owned(), + method: "test".to_owned(), + ret: "test".to_owned(), + is_error: false, + }; Receipt { state_root: nonce, epoch_id: 10, tx_hash, - cycles_used, - result, + cycles_used: 10, + events: vec![], + response, } } fn mock_epoch(epoch_id: u64, epoch_hash: Hash) -> Epoch { let nonce = Hash::digest(Bytes::from("XXXX")); - let addr_str = "10CAB8EEA4799C21379C20EF5BAA2CC8AF1BEC475B"; + let addr_str = "CAB8EEA4799C21379C20EF5BAA2CC8AF1BEC475B"; let header = EpochHeader { chain_id: nonce.clone(), epoch_id, @@ -86,7 +76,7 @@ fn mock_epoch(epoch_id: u64, epoch_hash: Hash) -> Epoch { state_root: nonce, receipt_root: Vec::new(), cycles_used: vec![999_999], - proposer: UserAddress::from_hex(addr_str).unwrap(), + proposer: Address::from_hex(addr_str).unwrap(), proof: mock_proof(epoch_hash), validator_version: 1, validators: Vec::new(), diff --git a/devtools/chain/README.md b/devtools/chain/README.md index 93eb670c3..ed73bf482 100644 --- a/devtools/chain/README.md +++ b/devtools/chain/README.md @@ -2,9 +2,9 @@ Address in genesis: -| Address | Asset(MTT) | PrivKey | Pubkey | -| ---------------------------------------------- | ------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------- | -| `0x10f8389d774afdad8755ef8e629e5a154fddc6325a` | `0x100000000` | `0x45c56be699dca666191ad3446897e0f480da234da896270202514a0e1a587c3f` | `0x031288a6788678c25952eba8693b2f278f66e2187004b64ac09416d07f83f96d5b` | -| `0x103e9b982b443592ffc3d4c2a484c220fb3e29e2e4` | `0x100000000` | `0x1ab5dfb50a38643ad8bbcbb27145825ddba65e67c72ec9bb643b72e190a27509` | `0x02926fd77bf9d00988cb34a16f9dbd35d46afcd63ee912fd1857e32f8f88c81059` | -| `0x10b052e7314afdaf74eff1da982c07c4784d70d3eb` | `0x100000000` | `0xf03cbf4206c877b3c9883eac9cdd1d822efba271e1d2b49cea027e85485efd3e` | `0x02020863e0b699c1d6a6d100b2333e1a8ec734d71abff676671218a5d39161519c` | -| `0x107d8bdc384fdeb95b61d7757a4ab0df9f10829d14` | `0x100000000` | `0xc5c404b811a9396052ec0a8a6e8f682aa16a96e65fcc48a12aab2e234d63e7bc` | `0x03848371a3891fc534f576eb99d9d3c3dc0a6a15546f60661ce642c6c34f16be98` | +| Address | Asset(MTT) | PrivKey | Pubkey | +| -------------------------------------------- | ------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `0xf8389d774afdad8755ef8e629e5a154fddc6325a` | `0x100000000` | `0x45c56be699dca666191ad3446897e0f480da234da896270202514a0e1a587c3f` | `0x031288a6788678c25952eba8693b2f278f66e2187004b64ac09416d07f83f96d5b` | +| `0x3e9b982b443592ffc3d4c2a484c220fb3e29e2e4` | `0x100000000` | `0x1ab5dfb50a38643ad8bbcbb27145825ddba65e67c72ec9bb643b72e190a27509` | `0x02926fd77bf9d00988cb34a16f9dbd35d46afcd63ee912fd1857e32f8f88c81059` | +| `0xb052e7314afdaf74eff1da982c07c4784d70d3eb` | `0x100000000` | `0xf03cbf4206c877b3c9883eac9cdd1d822efba271e1d2b49cea027e85485efd3e` | `0x02020863e0b699c1d6a6d100b2333e1a8ec734d71abff676671218a5d39161519c` | +| `0x7d8bdc384fdeb95b61d7757a4ab0df9f10829d14` | `0x100000000` | `0xc5c404b811a9396052ec0a8a6e8f682aa16a96e65fcc48a12aab2e234d63e7bc` | `0x03848371a3891fc534f576eb99d9d3c3dc0a6a15546f60661ce642c6c34f16be98` | diff --git a/devtools/chain/config.toml b/devtools/chain/config.toml index 9bdc9d6bd..7b0be9c48 100644 --- a/devtools/chain/config.toml +++ b/devtools/chain/config.toml @@ -29,7 +29,7 @@ broadcast_txs_interval = 200 cycles_limit = 99999999 cycles_price = 1 interval = 3000 -verifier_list = [ "10f8389d774afdad8755ef8e629e5a154fddc6325a" ] +verifier_list = [ "f8389d774afdad8755ef8e629e5a154fddc6325a" ] private_key = "0000000000000000000000000000000030269d47fcf602b889243722b666881bf953f1213228363d34cf04ddcd51dfd2" public_keys = [ "040093d0344b912ea2052626714b03917dc1143323b0a4ee64fd038b872360a2c0638cffbc6a057eb2c9b06791517048db0fa29a4cc0817cc484ca30ca89972ed0fc15c0ca6ee02a7a1243e63e3af92b3af0abe7f39b4aa4166b7a39496b24fa6d" ] common_ref = "6d757461" diff --git a/devtools/chain/genesis.json b/devtools/chain/genesis.json deleted file mode 100644 index 81a9c6c5f..000000000 --- a/devtools/chain/genesis.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "timestamp": 0, - "prevhash": "44915be5b6c20b0678cf05fcddbbaa832e25d7e6ac538784cd5c24de00d47472", - "system_token": { - "code": "", - "name": "Muta system token", - "symbol": "MST", - "supply": 18446744073709551615 - }, - "state_alloc": [ - { - "address": "10f8389d774afdad8755ef8e629e5a154fddc6325a", - "assets": [ - { - "asset_id": "fee0decb4f6a76d402f200b5642a9236ba455c22aa80ef82d69fc70ea5ba20b5", - "balance": "1000000000" - } - ] - }, - { - "address": "103e9b982b443592ffc3d4c2a484c220fb3e29e2e4", - "assets": [ - { - "asset_id": "fee0decb4f6a76d402f200b5642a9236ba455c22aa80ef82d69fc70ea5ba20b5", - "balance": "1000000000" - } - ] - }, - { - "address": "10b052e7314afdaf74eff1da982c07c4784d70d3eb", - "assets": [ - { - "asset_id": "fee0decb4f6a76d402f200b5642a9236ba455c22aa80ef82d69fc70ea5ba20b5", - "balance": "1000000000" - } - ] - }, - { - "address": "107d8bdc384fdeb95b61d7757a4ab0df9f10829d14", - "assets": [ - { - "asset_id": "fee0decb4f6a76d402f200b5642a9236ba455c22aa80ef82d69fc70ea5ba20b5", - "balance": "1000000000" - } - ] - } - ] -} diff --git a/devtools/chain/genesis.toml b/devtools/chain/genesis.toml new file mode 100644 index 000000000..1d2ffd212 --- /dev/null +++ b/devtools/chain/genesis.toml @@ -0,0 +1,8 @@ +timestamp = 0 +prevhash = "44915be5b6c20b0678cf05fcddbbaa832e25d7e6ac538784cd5c24de00d47472" + +[[services]] +caller = "f8389d774afdad8755ef8e629e5a154fddc6325a" +service = "asset" +method = "create_asset" +payload = '{ "name": "MutaToken", "symbol": "MT", "supply": 320000011 }' diff --git a/devtools/keypair/src/main.rs b/devtools/keypair/src/main.rs index 4af1ed068..f0945bad3 100644 --- a/devtools/keypair/src/main.rs +++ b/devtools/keypair/src/main.rs @@ -2,7 +2,7 @@ use rand::{rngs::OsRng, thread_rng, RngCore}; use tentacle_secio::SecioKeyPair; use common_crypto::{BlsPrivateKey, PrivateKey, PublicKey, ToBlsPublicKey}; -use protocol::types::{Hash, UserAddress}; +use protocol::types::{Address, Hash}; use protocol::BytesMut; pub fn main() { @@ -12,7 +12,7 @@ pub fn main() { let seckey = Hash::digest(BytesMut::from(seed.as_ref()).freeze()); let keypair = SecioKeyPair::secp256k1_raw_key(seckey.as_bytes()).expect("secp256k1 keypair"); let pubkey = keypair.to_public_key().inner(); - let user_addr = UserAddress::from_pubkey_bytes(pubkey.into()).expect("user addr"); + let user_addr = Address::from_pubkey_bytes(pubkey.into()).expect("user addr"); println!("seckey hex: {:?}", seckey.as_hex()); println!( diff --git a/framework/Cargo.toml b/framework/Cargo.toml index 826d44c1e..b542373f5 100644 --- a/framework/Cargo.toml +++ b/framework/Cargo.toml @@ -12,7 +12,7 @@ asset = { path = "../built-in-services/asset"} hasher = { version = "0.1", features = ['hash-keccak'] } cita_trie = "2.0" -bytes = "0.4" +bytes = "0.5" derive_more = "0.15" rocksdb = "0.12" lazy_static = "1.4" @@ -20,9 +20,9 @@ byteorder = "1.3" rlp = "0.4" futures = "0.3" json = "0.12" -serde_json = "1.0" hex = "0.4" +serde_json = "1.0" [dev-dependencies] async-trait = "0.1" -serde_yaml = "0.8" +toml = "0.5" diff --git a/framework/src/binding/sdk/mod.rs b/framework/src/binding/sdk/mod.rs index e22db129e..2947f3f28 100644 --- a/framework/src/binding/sdk/mod.rs +++ b/framework/src/binding/sdk/mod.rs @@ -7,8 +7,8 @@ use std::rc::Rc; use protocol::fixed_codec::FixedCodec; use protocol::traits::{ - ChainQuerier, RequestContext, ServiceSDK, ServiceState, StoreArray, StoreBool, StoreMap, - StoreString, StoreUint64, + ChainQuerier, ServiceSDK, ServiceState, StoreArray, StoreBool, StoreMap, StoreString, + StoreUint64, }; use protocol::types::{Address, Epoch, Hash, Receipt, SignedTransaction}; use protocol::ProtocolResult; @@ -136,13 +136,13 @@ impl ServiceSDK for DefalutServiceSD // Call other read-only methods of `service` and return the results // synchronously NOTE: You can use recursive calls, but the maximum call // stack is 1024 - fn read(&self, service: &str, method: &str, payload: &str) -> ProtocolResult<&str> { + fn read(&self, _service: &str, _method: &str, _payload: &str) -> ProtocolResult<&str> { unimplemented!(); } // Call other writable methods of `service` and return the results synchronously // NOTE: You can use recursive calls, but the maximum call stack is 1024 - fn write(&mut self, service: &str, method: &str, payload: &str) -> ProtocolResult<&str> { + fn write(&mut self, _service: &str, _method: &str, _payload: &str) -> ProtocolResult<&str> { unimplemented!(); } } diff --git a/framework/src/binding/store/primitive.rs b/framework/src/binding/store/primitive.rs index a358661d3..0123e264a 100644 --- a/framework/src/binding/store/primitive.rs +++ b/framework/src/binding/store/primitive.rs @@ -1,9 +1,6 @@ use std::cell::RefCell; -use std::io::Cursor; -use std::mem; use std::rc::Rc; -use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use bytes::Bytes; use protocol::traits::{ServiceState, StoreBool, StoreString, StoreUint64}; @@ -30,7 +27,7 @@ impl StoreBool for DefaultStoreBool { fn get(&self) -> ProtocolResult { let b: Option = self.state.borrow().get(&self.key)?; - b.ok_or(StoreError::GetNone.into()) + b.ok_or_else(|| StoreError::GetNone.into()) } fn set(&mut self, b: bool) -> ProtocolResult<()> { @@ -57,7 +54,7 @@ impl StoreUint64 for DefaultStoreUint64 { fn get(&self) -> ProtocolResult { let u: Option = self.state.borrow().get(&self.key)?; - u.ok_or(StoreError::GetNone.into()) + u.ok_or_else(|| StoreError::GetNone.into()) } fn set(&mut self, val: u64) -> ProtocolResult<()> { @@ -160,7 +157,7 @@ impl StoreString for DefaultStoreString { fn get(&self) -> ProtocolResult { let s: Option = self.state.borrow().get(&self.key)?; - s.ok_or(StoreError::GetNone.into()) + s.ok_or_else(|| StoreError::GetNone.into()) } fn len(&self) -> ProtocolResult { diff --git a/framework/src/binding/tests/sdk.rs b/framework/src/binding/tests/sdk.rs index 5e7b92426..54d5c7517 100644 --- a/framework/src/binding/tests/sdk.rs +++ b/framework/src/binding/tests/sdk.rs @@ -16,7 +16,6 @@ use protocol::ProtocolResult; use crate::binding::sdk::{DefalutServiceSDK, DefaultChainQuerier}; use crate::binding::store::StoreError; use crate::binding::tests::state::new_state; -use crate::{ContextParams, DefaultRequestContext}; #[test] fn test_service_sdk() { @@ -276,7 +275,7 @@ pub fn mock_epoch_header() -> EpochHeader { confirm_root: vec![mock_hash(), mock_hash()], state_root: mock_merkle_root(), receipt_root: vec![mock_hash(), mock_hash()], - cycles_used: 999_999, + cycles_used: vec![999_999], proposer: mock_address(), proof: mock_proof(), validator_version: 1, @@ -295,23 +294,3 @@ pub fn mock_epoch(order_size: usize) -> Epoch { ordered_tx_hashes: (0..order_size).map(|_| mock_hash()).collect(), } } - -// ##################### -// Mock RequestContext -// ##################### - -pub fn mock_request_context() -> DefaultRequestContext { - let parrams = ContextParams { - cycles_limit: 100, - cycles_price: 8, - cycles_used: Rc::new(RefCell::new(10)), - caller: Address::from_hash(Hash::from_empty()).unwrap(), - epoch_id: 1, - timestamp: 0, - service_name: "service_name".to_owned(), - service_method: "service_method".to_owned(), - service_payload: "service_payload".to_owned(), - events: Rc::new(RefCell::new(vec![])), - }; - DefaultRequestContext::new(parrams) -} diff --git a/framework/src/executor/factory.rs b/framework/src/executor/factory.rs new file mode 100644 index 000000000..29e9bc80c --- /dev/null +++ b/framework/src/executor/factory.rs @@ -0,0 +1,22 @@ +use std::sync::Arc; + +use protocol::traits::{Executor, ExecutorFactory, Storage}; +use protocol::types::MerkleRoot; +use protocol::ProtocolResult; + +use crate::executor::ServiceExecutor; + +pub struct ServiceExecutorFactory; + +impl ExecutorFactory + for ServiceExecutorFactory +{ + fn from_root( + root: MerkleRoot, + db: Arc, + storage: Arc, + ) -> ProtocolResult> { + let executor = ServiceExecutor::with_root(root, db, storage)?; + Ok(Box::new(executor)) + } +} diff --git a/framework/src/executor/mod.rs b/framework/src/executor/mod.rs index 1fb39900e..41251b8d8 100644 --- a/framework/src/executor/mod.rs +++ b/framework/src/executor/mod.rs @@ -1,6 +1,9 @@ +mod factory; #[cfg(test)] mod tests; +pub use factory::ServiceExecutorFactory; + use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; @@ -10,7 +13,7 @@ use cita_trie::DB as TrieDB; use derive_more::{Display, From}; use asset::AssetService; -use bytes::Bytes; +use bytes::BytesMut; use protocol::traits::{ ExecResp, Executor, ExecutorParams, ExecutorResp, RequestContext, Service, ServiceState, Storage, @@ -99,7 +102,7 @@ impl ServiceExecutor { } pub fn with_root(root: MerkleRoot, trie_db: Arc, storage: Arc) -> ProtocolResult { - let trie = MPTTrie::from(root.clone(), Arc::clone(&trie_db))?; + let trie = MPTTrie::from(root, Arc::clone(&trie_db))?; let root_state = GeneralServiceState::new(trie); let asset_root = @@ -228,9 +231,9 @@ impl ServiceExecutor { }; let result = if readonly { - service.read_(context.clone()) + service.read_(context) } else { - service.write_(context.clone()) + service.write_(context) }; let (ret, is_error) = match result { @@ -245,7 +248,8 @@ impl ServiceExecutor { let mut bloom = Bloom::default(); for receipt in receipts { for event in receipt.events.iter() { - let bytes = Bytes::from((event.service.clone() + &event.data).as_bytes()); + let bytes = + BytesMut::from((event.service.clone() + &event.data).as_bytes()).freeze(); let hash = Hash::digest(bytes).as_bytes(); let input = BloomInput::Raw(hash.as_ref()); diff --git a/framework/src/executor/tests/genesis_services.toml b/framework/src/executor/tests/genesis_services.toml new file mode 100644 index 000000000..1d2ffd212 --- /dev/null +++ b/framework/src/executor/tests/genesis_services.toml @@ -0,0 +1,8 @@ +timestamp = 0 +prevhash = "44915be5b6c20b0678cf05fcddbbaa832e25d7e6ac538784cd5c24de00d47472" + +[[services]] +caller = "f8389d774afdad8755ef8e629e5a154fddc6325a" +service = "asset" +method = "create_asset" +payload = '{ "name": "MutaToken", "symbol": "MT", "supply": 320000011 }' diff --git a/framework/src/executor/tests/genesis_services.yaml b/framework/src/executor/tests/genesis_services.yaml deleted file mode 100644 index 0567eb8ba..000000000 --- a/framework/src/executor/tests/genesis_services.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- caller: f8389d774afdad8755ef8e629e5a154fddc6325a # id f56924db538e77bb5951eb5ff0d02b88983c49c45eea30e8ae3e7234b311436c - service: asset - method: create_asset - payload: '{ "name": "MutaToken", "symbol": "MT", "supply": 320000011 }' diff --git a/framework/src/executor/tests/mod.rs b/framework/src/executor/tests/mod.rs index ebb2badc2..e4958dbd5 100644 --- a/framework/src/executor/tests/mod.rs +++ b/framework/src/executor/tests/mod.rs @@ -1,13 +1,13 @@ use std::sync::Arc; use async_trait::async_trait; -use bytes::Bytes; +use bytes::{Bytes, BytesMut}; use cita_trie::MemoryDB; use asset::types::{Asset, GetBalanceResponse}; use protocol::traits::{Executor, ExecutorParams, Storage}; use protocol::types::{ - Address, Epoch, GenesisService, Hash, Proof, RawTransaction, Receipt, SignedTransaction, + Address, Epoch, Genesis, Hash, Proof, RawTransaction, Receipt, SignedTransaction, TransactionRequest, }; use protocol::ProtocolResult; @@ -16,12 +16,13 @@ use crate::executor::ServiceExecutor; #[test] fn test_create_genesis() { - let yaml = include_str!("./genesis_services.yaml"); - let genesis_services: Vec = serde_yaml::from_str(yaml).unwrap(); + let toml_str = include_str!("./genesis_services.toml"); + let genesis: Genesis = toml::from_str(toml_str).unwrap(); + let db = Arc::new(MemoryDB::new(false)); let root = ServiceExecutor::create_genesis( - genesis_services, + genesis.services, Arc::clone(&db), Arc::new(MockStorage {}), ) @@ -31,7 +32,7 @@ fn test_create_genesis() { ServiceExecutor::with_root(root.clone(), Arc::clone(&db), Arc::new(MockStorage {})) .unwrap(); let params = ExecutorParams { - state_root: root.clone(), + state_root: root, epoch_id: 1, timestamp: 0, cycels_limit: std::u64::MAX, @@ -47,17 +48,18 @@ fn test_create_genesis() { let res = executor.read(¶ms, &caller, 1, &request).unwrap(); let resp: GetBalanceResponse = serde_json::from_str(&res.ret).unwrap(); - assert_eq!(resp.balance, 320000011); + assert_eq!(resp.balance, 320_000_011); } #[test] fn test_exec() { - let yaml = include_str!("./genesis_services.yaml"); - let genesis_services: Vec = serde_yaml::from_str(yaml).unwrap(); + let toml_str = include_str!("./genesis_services.toml"); + let genesis: Genesis = toml::from_str(toml_str).unwrap(); + let db = Arc::new(MemoryDB::new(false)); let root = ServiceExecutor::create_genesis( - genesis_services, + genesis.services, Arc::clone(&db), Arc::new(MockStorage {}), ) @@ -68,7 +70,7 @@ fn test_exec() { .unwrap(); let params = ExecutorParams { - state_root: root.clone(), + state_root: root, epoch_id: 1, timestamp: 0, cycels_limit: std::u64::MAX, @@ -94,7 +96,7 @@ fn test_exec() { hex::decode("031288a6788678c25952eba8693b2f278f66e2187004b64ac09416d07f83f96d5b") .unwrap(), ), - signature: Bytes::from("".as_bytes()), + signature: BytesMut::from("").freeze(), }; let txs = vec![stx]; let executor_resp = executor.exec(¶ms, &txs).unwrap(); @@ -104,7 +106,7 @@ fn test_exec() { let asset: Asset = serde_json::from_str(&receipt.response.ret).unwrap(); assert_eq!(asset.name, "MutaToken2"); assert_eq!(asset.symbol, "MT2"); - assert_eq!(asset.supply, 320000011); + assert_eq!(asset.supply, 320_000_011); } struct MockStorage; diff --git a/framework/src/tests/mod.rs b/framework/src/tests/mod.rs index a3b75ab7d..2ea4ae358 100644 --- a/framework/src/tests/mod.rs +++ b/framework/src/tests/mod.rs @@ -20,7 +20,7 @@ fn test_request_context() { service_payload: "service_payload".to_owned(), events: Rc::new(RefCell::new(vec![])), }; - let mut ctx = DefaultRequestContext::new(params); + let ctx = DefaultRequestContext::new(params); ctx.sub_cycles(8).unwrap(); assert_eq!(ctx.get_cycles_used(), 18); diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index a82b2c8ca..887c08834 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -13,9 +13,10 @@ async-trait = "0.1" lazy_static = "1.4" num-bigint = "0.2" ethbloom = "0.8" -bytes = "0.4" +bytes = "0.5" hex = "0.3" -prost = "0.5" +# For bytes 0.5 +prost = { git = "https://github.com/danburkert/prost", rev = "dfe51e9" } hasher = { version = "0.1", features = ['hash-keccak'] } creep = "0.1" bincode = "1.2" diff --git a/protocol/src/codec/primitive.rs b/protocol/src/codec/primitive.rs index 472e527f7..5f4367916 100644 --- a/protocol/src/codec/primitive.rs +++ b/protocol/src/codec/primitive.rs @@ -40,15 +40,6 @@ pub struct Address { pub value: Vec, } -#[derive(Clone, Message)] -pub struct Fee { - #[prost(message, tag = "1")] - pub asset_id: Option, - - #[prost(uint64, tag = "2")] - pub cycle: u64, -} - // ##################### // Conversion // ##################### @@ -131,40 +122,12 @@ impl TryFrom for protocol_primitive::MerkleRoot { } } -// Fee - -impl From for Fee { - fn from(fee: protocol_primitive::Fee) -> Fee { - let asset_id = Hash::from(fee.asset_id); - - Fee { - asset_id: Some(asset_id), - cycle: fee.cycle, - } - } -} - -impl TryFrom for protocol_primitive::Fee { - type Error = ProtocolError; - - fn try_from(fee: Fee) -> Result { - let asset_id = field!(fee.asset_id, "Fee", "asset_id")?; - - let fee = protocol_primitive::Fee { - asset_id: protocol_primitive::Hash::try_from(asset_id)?, - cycle: fee.cycle, - }; - - Ok(fee) - } -} - // ##################### // Codec // ##################### // MerkleRoot and AssetID are just Hash aliases -impl_default_bytes_codec_for!(primitive, [Balance, Hash, Fee]); +impl_default_bytes_codec_for!(primitive, [Balance, Hash]); // ##################### // Util diff --git a/protocol/src/fixed_codec/epoch.rs b/protocol/src/fixed_codec/epoch.rs index 342ca7ba2..3481ea36f 100644 --- a/protocol/src/fixed_codec/epoch.rs +++ b/protocol/src/fixed_codec/epoch.rs @@ -6,7 +6,7 @@ use crate::types::primitive::Hash; use crate::types::Bloom; use crate::{impl_default_fixed_codec_for, ProtocolResult}; -// Impl ProtocolFixedCodec trait for types +// Impl FixedCodec trait for types impl_default_fixed_codec_for!(epoch, [Proof, Validator, Epoch, EpochHeader, Pill, EpochId]); impl rlp::Encodable for Proof { diff --git a/protocol/src/fixed_codec/macro.rs b/protocol/src/fixed_codec/macro.rs index 0bd51abcc..15f868e1e 100644 --- a/protocol/src/fixed_codec/macro.rs +++ b/protocol/src/fixed_codec/macro.rs @@ -5,8 +5,8 @@ macro_rules! impl_default_fixed_codec_for { $( impl FixedCodec for $category::$type { - fn encode_fixed(&self) -> ProtocolResult { - Ok(Bytes::from(rlp::encode(self))) + fn encode_fixed(&self) -> ProtocolResult { + Ok(bytes::Bytes::from(rlp::encode(self))) } fn decode_fixed(bytes: bytes::Bytes) -> ProtocolResult { diff --git a/protocol/src/fixed_codec/mod.rs b/protocol/src/fixed_codec/mod.rs index 2ede734d3..61103240b 100644 --- a/protocol/src/fixed_codec/mod.rs +++ b/protocol/src/fixed_codec/mod.rs @@ -1,7 +1,6 @@ #[macro_use] mod r#macro; pub mod epoch; -pub mod genesis; pub mod primitive; pub mod receipt; #[cfg(test)] diff --git a/protocol/src/fixed_codec/primitive.rs b/protocol/src/fixed_codec/primitive.rs index 85a1f5c1a..d0d6ee92c 100644 --- a/protocol/src/fixed_codec/primitive.rs +++ b/protocol/src/fixed_codec/primitive.rs @@ -1,14 +1,14 @@ use std::mem; use byteorder::{ByteOrder, LittleEndian}; -use bytes::Bytes; +use bytes::{Bytes, BytesMut}; use crate::fixed_codec::{FixedCodec, FixedCodecError}; -use crate::types::{Account, Address, Fee, Hash}; +use crate::types::{Account, Address, Hash}; use crate::{impl_default_fixed_codec_for, ProtocolResult}; -// Impl ProtocolFixedCodec trait for types -impl_default_fixed_codec_for!(primitive, [Hash, Fee, Address, Account]); +// Impl FixedCodec trait for types +impl_default_fixed_codec_for!(primitive, [Hash, Address, Account]); impl FixedCodec for bool { fn encode_fixed(&self) -> ProtocolResult { @@ -18,7 +18,7 @@ impl FixedCodec for bool { [0u8; mem::size_of::()] }; - Ok(Bytes::from(bs.as_ref())) + Ok(BytesMut::from(bs.as_ref()).freeze()) } fn decode_fixed(bytes: Bytes) -> ProtocolResult { @@ -34,7 +34,7 @@ impl FixedCodec for bool { impl FixedCodec for u8 { fn encode_fixed(&self) -> ProtocolResult { - Ok(Bytes::from([*self].as_ref())) + Ok(BytesMut::from([*self].as_ref()).freeze()) } fn decode_fixed(bytes: Bytes) -> ProtocolResult { @@ -49,7 +49,7 @@ impl FixedCodec for u32 { let mut buf = [0u8; mem::size_of::()]; LittleEndian::write_u32(&mut buf, *self); - Ok(Bytes::from(buf.as_ref())) + Ok(BytesMut::from(buf.as_ref()).freeze()) } fn decode_fixed(bytes: Bytes) -> ProtocolResult { @@ -62,7 +62,7 @@ impl FixedCodec for u64 { let mut buf = [0u8; mem::size_of::()]; LittleEndian::write_u64(&mut buf, *self); - Ok(Bytes::from(buf.as_ref())) + Ok(BytesMut::from(buf.as_ref()).freeze()) } fn decode_fixed(bytes: Bytes) -> ProtocolResult { @@ -105,25 +105,6 @@ impl rlp::Decodable for Hash { } } -impl rlp::Encodable for Fee { - fn rlp_append(&self, s: &mut rlp::RlpStream) { - s.begin_list(2).append(&self.asset_id).append(&self.cycle); - } -} - -impl rlp::Decodable for Fee { - fn decode(r: &rlp::Rlp) -> Result { - if !r.is_list() && r.size() != 2 { - return Err(rlp::DecoderError::RlpIncorrectListLen); - } - - let asset_id: Hash = rlp::decode(r.at(0)?.as_raw())?; - let cycle = r.at(1)?.as_val()?; - - Ok(Fee { asset_id, cycle }) - } -} - impl rlp::Encodable for Address { fn rlp_append(&self, s: &mut rlp::RlpStream) { s.begin_list(1).append(&self.as_bytes().to_vec()); diff --git a/protocol/src/fixed_codec/receipt.rs b/protocol/src/fixed_codec/receipt.rs index bac9290f9..c8b7b2676 100644 --- a/protocol/src/fixed_codec/receipt.rs +++ b/protocol/src/fixed_codec/receipt.rs @@ -1,10 +1,8 @@ -use bytes::BytesMut; - use crate::fixed_codec::{FixedCodec, FixedCodecError}; use crate::types::receipt::{Event, Receipt, ReceiptResponse}; use crate::{impl_default_fixed_codec_for, ProtocolResult}; -// Impl ProtocolFixedCodec trait for types +// Impl FixedCodec trait for types impl_default_fixed_codec_for!(receipt, [Receipt, ReceiptResponse]); impl rlp::Encodable for Receipt { diff --git a/protocol/src/fixed_codec/tests/fixed_codec.rs b/protocol/src/fixed_codec/tests/fixed_codec.rs index caaf7c5e2..9e6c40b8b 100644 --- a/protocol/src/fixed_codec/tests/fixed_codec.rs +++ b/protocol/src/fixed_codec/tests/fixed_codec.rs @@ -62,8 +62,6 @@ fn test_fixed_codec() { test_eq!(receipt, Receipt, mock_receipt); test_eq!(receipt, Receipt, mock_receipt); test_eq!(receipt, Receipt, mock_receipt); - - test_eq!(genesis, Genesis, mock_genesis); } #[test] diff --git a/protocol/src/fixed_codec/tests/mod.rs b/protocol/src/fixed_codec/tests/mod.rs index 40f1b325e..97ab03b5c 100644 --- a/protocol/src/fixed_codec/tests/mod.rs +++ b/protocol/src/fixed_codec/tests/mod.rs @@ -5,7 +5,6 @@ use num_traits::FromPrimitive; use rand::random; use crate::types::epoch::{Epoch, EpochHeader, EpochId, Pill, Proof, Validator}; -use crate::types::genesis::{Genesis, GenesisStateAlloc, GenesisStateAsset, GenesisSystemToken}; use crate::types::primitive::{Address, Balance, Hash, MerkleRoot}; use crate::types::receipt::{Event, Receipt, ReceiptResponse}; use crate::types::transaction::{RawTransaction, SignedTransaction, TransactionRequest}; @@ -131,7 +130,7 @@ pub fn mock_epoch_header() -> EpochHeader { confirm_root: vec![mock_hash(), mock_hash()], state_root: mock_merkle_root(), receipt_root: vec![mock_hash(), mock_hash()], - cycles_used: 999_999, + cycles_used: vec![999_999], proposer: mock_address(), proof: mock_proof(), validator_version: 1, @@ -158,51 +157,6 @@ pub fn mock_pill(order_size: usize, propose_size: usize) -> Pill { } } -// ##################### -// Mock Genesis -// ##################### - -pub fn mock_genesis() -> Genesis { - Genesis { - timestamp: 99, - prevhash: "prevhashtest".to_string(), - system_token: GenesisSystemToken { - code: "codetest".to_string(), - name: "nametest".to_string(), - symbol: "symbol".to_string(), - supply: 7, - }, - state_alloc: vec![ - GenesisStateAlloc { - address: "test".to_string(), - assets: vec![ - GenesisStateAsset { - asset_id: "test".to_string(), - balance: "test".to_string(), - }, - GenesisStateAsset { - asset_id: "test".to_string(), - balance: "test".to_string(), - }, - ], - }, - GenesisStateAlloc { - address: "test".to_string(), - assets: vec![ - GenesisStateAsset { - asset_id: "test".to_string(), - balance: "test".to_string(), - }, - GenesisStateAsset { - asset_id: "test".to_string(), - balance: "test".to_string(), - }, - ], - }, - ], - } -} - pub fn get_random_bytes(len: usize) -> Bytes { let vec: Vec = (0..len).map(|_| random::()).collect(); Bytes::from(vec) diff --git a/protocol/src/fixed_codec/transaction.rs b/protocol/src/fixed_codec/transaction.rs index c6e899a55..bc7513cdc 100644 --- a/protocol/src/fixed_codec/transaction.rs +++ b/protocol/src/fixed_codec/transaction.rs @@ -1,11 +1,11 @@ -use bytes::{Bytes, BytesMut}; +use bytes::BytesMut; use crate::fixed_codec::{FixedCodec, FixedCodecError}; use crate::types::primitive::Hash; use crate::types::transaction::{RawTransaction, SignedTransaction, TransactionRequest}; use crate::{impl_default_fixed_codec_for, ProtocolResult}; -// Impl ProtocolFixedCodec trait for types +// Impl FixedCodec trait for types impl_default_fixed_codec_for!(transaction, [RawTransaction, SignedTransaction]); impl rlp::Encodable for RawTransaction { @@ -24,13 +24,13 @@ impl rlp::Encodable for RawTransaction { impl rlp::Decodable for RawTransaction { fn decode(r: &rlp::Rlp) -> Result { - let chain_id = Hash::from_bytes(Bytes::from(r.at(0)?.data()?)) + let chain_id = Hash::from_bytes(BytesMut::from(r.at(0)?.data()?).freeze()) .map_err(|_| rlp::DecoderError::RlpInvalidLength)?; let cycles_limit: u64 = r.at(1)?.as_val()?; let cycles_price: u64 = r.at(2)?.as_val()?; - let nonce = Hash::from_bytes(Bytes::from(r.at(3)?.data()?)) + let nonce = Hash::from_bytes(BytesMut::from(r.at(3)?.data()?).freeze()) .map_err(|_| rlp::DecoderError::RlpInvalidLength)?; let request = TransactionRequest { diff --git a/protocol/src/traits/consensus.rs b/protocol/src/traits/consensus.rs index 28486027f..ca7c005d4 100644 --- a/protocol/src/traits/consensus.rs +++ b/protocol/src/traits/consensus.rs @@ -1,10 +1,8 @@ use async_trait::async_trait; use creep::Context; -use crate::types::{ - Address, Bloom, Epoch, Hash, MerkleRoot, Proof, Receipt, SignedTransaction, Validator, -}; -use crate::{traits::mempool::MixedTxHashes, traits::ExecutorResp, ProtocolResult}; +use crate::types::{Address, Epoch, Hash, MerkleRoot, Proof, SignedTransaction, Validator}; +use crate::{traits::mempool::MixedTxHashes, ProtocolResult}; #[derive(Clone, Debug, PartialEq, Eq)] pub enum MessageTarget { @@ -77,7 +75,9 @@ pub trait ConsensusAdapter: Send + Sync { cycles_price: u64, coinbase: Address, signed_txs: Vec, - ) -> ProtocolResult; + cycles_limit: u64, + timestamp: u64, + ) -> ProtocolResult<()>; /// Flush the given transactions in the mempool. async fn flush_mempool(&self, ctx: Context, txs: Vec) -> ProtocolResult<()>; diff --git a/protocol/src/traits/executor.rs b/protocol/src/traits/executor.rs index 4c22a0b13..0b270a4b8 100644 --- a/protocol/src/traits/executor.rs +++ b/protocol/src/traits/executor.rs @@ -1,3 +1,6 @@ +use std::sync::Arc; + +use crate::traits::Storage; use crate::types::{Address, Bloom, MerkleRoot, Receipt, SignedTransaction, TransactionRequest}; use crate::ProtocolResult; @@ -23,6 +26,14 @@ pub struct ExecResp { pub is_error: bool, } +pub trait ExecutorFactory: Send + Sync { + fn from_root( + root: MerkleRoot, + db: Arc, + storage: Arc, + ) -> ProtocolResult>; +} + pub trait Executor { fn exec( &mut self, diff --git a/protocol/src/traits/mod.rs b/protocol/src/traits/mod.rs index 47f47fc7a..c2efcae15 100644 --- a/protocol/src/traits/mod.rs +++ b/protocol/src/traits/mod.rs @@ -12,8 +12,8 @@ pub use binding::{ ServiceSDK, ServiceState, StoreArray, StoreBool, StoreMap, StoreString, StoreUint64, RETURN_EMPTY, }; -pub use consensus::{Consensus, ConsensusAdapter, CurrentConsensusStatus, MessageTarget, NodeInfo}; -pub use executor::{ExecResp, Executor, ExecutorParams, ExecutorResp}; +pub use consensus::{Consensus, ConsensusAdapter, MessageTarget, NodeInfo}; +pub use executor::{ExecResp, Executor, ExecutorFactory, ExecutorParams, ExecutorResp}; pub use mempool::{MemPool, MemPoolAdapter, MixedTxHashes}; pub use network::{Gossip, MessageCodec, MessageHandler, Priority, Rpc}; pub use storage::{Storage, StorageAdapter, StorageBatchModify, StorageCategory, StorageSchema}; diff --git a/protocol/src/types/epoch.rs b/protocol/src/types/epoch.rs index 40ceb9972..99c4fea04 100644 --- a/protocol/src/types/epoch.rs +++ b/protocol/src/types/epoch.rs @@ -19,7 +19,7 @@ pub struct EpochHeader { pub confirm_root: Vec, pub state_root: MerkleRoot, pub receipt_root: Vec, - pub cycles_used: u64, + pub cycles_used: Vec, pub proposer: Address, pub proof: Proof, pub validator_version: u64, diff --git a/protocol/src/types/genesis.rs b/protocol/src/types/genesis.rs index 524428205..80d38edd3 100644 --- a/protocol/src/types/genesis.rs +++ b/protocol/src/types/genesis.rs @@ -2,30 +2,9 @@ use serde::Deserialize; #[derive(Clone, Debug, Deserialize, PartialEq, Eq)] pub struct Genesis { - pub timestamp: u64, - pub prevhash: String, - pub system_token: GenesisSystemToken, - pub state_alloc: Vec, -} - -#[derive(Clone, Debug, Deserialize, PartialEq, Eq)] -pub struct GenesisStateAlloc { - pub address: String, - pub assets: Vec, -} - -#[derive(Clone, Debug, Deserialize, PartialEq, Eq)] -pub struct GenesisStateAsset { - pub asset_id: String, - pub balance: String, -} - -#[derive(Clone, Debug, Deserialize, PartialEq, Eq)] -pub struct GenesisSystemToken { - pub code: String, - pub name: String, - pub symbol: String, - pub supply: u64, + pub timestamp: u64, + pub prevhash: String, + pub services: Vec, } #[derive(Clone, Debug, Deserialize, PartialEq, Eq)] @@ -35,33 +14,3 @@ pub struct GenesisService { pub method: String, pub payload: String, } - -#[cfg(test)] -mod tests { - use super::Genesis; - - #[test] - fn test_name() { - let genesis_string = r#"{ - "timestamp": 100000, - "prevhash": "0x0000000000", - "system_token": { - "code": "", - "name": "Muta system token", - "symbol": "MST", - "supply": 21000000000 - }, - "state_alloc": [ - { - "address": "0xfffff", - "assets": [{ - "asset_id": "0xff", - "balance": "0xfff" - }] - } - ] - }"#; - - let _: Genesis = serde_json::from_str(genesis_string).unwrap(); - } -} diff --git a/protocol/src/types/mod.rs b/protocol/src/types/mod.rs index f0cf6cc69..f87ba62e7 100644 --- a/protocol/src/types/mod.rs +++ b/protocol/src/types/mod.rs @@ -12,10 +12,8 @@ use crate::{ProtocolError, ProtocolErrorKind}; pub use epoch::{Epoch, EpochHeader, EpochId, Pill, Proof, Validator}; pub use ethbloom::{Bloom, BloomRef, Input as BloomInput}; -pub use genesis::{Genesis, GenesisService, GenesisStateAlloc, GenesisStateAsset}; -pub use primitive::{ - Account, Address, Balance, Fee, Hash, JsonString, MerkleRoot, GENESIS_EPOCH_ID, -}; +pub use genesis::{Genesis, GenesisService}; +pub use primitive::{Account, Address, Balance, Hash, JsonString, MerkleRoot, GENESIS_EPOCH_ID}; pub use receipt::{Event, Receipt, ReceiptResponse}; pub use transaction::{RawTransaction, SignedTransaction, TransactionRequest}; diff --git a/protocol/src/types/primitive.rs b/protocol/src/types/primitive.rs index 774aad1e2..03c872745 100644 --- a/protocol/src/types/primitive.rs +++ b/protocol/src/types/primitive.rs @@ -132,7 +132,7 @@ impl fmt::Debug for Hash { /// Address length. const ADDRESS_LEN: usize = 20; -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Address([u8; ADDRESS_LEN]); impl Serialize for Address { @@ -208,7 +208,7 @@ impl Address { } pub fn as_bytes(&self) -> Bytes { - Bytes::from(self.0.as_ref()) + BytesMut::from(self.0.as_ref()).freeze() } pub fn as_hex(&self) -> String { @@ -216,17 +216,17 @@ impl Address { } } +impl fmt::Debug for Address { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.as_hex()) + } +} + #[derive(Clone, Debug, PartialEq, Eq)] pub struct Account { pub storage_root: MerkleRoot, } -#[derive(Clone, Debug, Hash, PartialEq, Eq)] -pub struct Fee { - pub asset_id: Hash, - pub cycle: u64, -} - fn clean_0x(s: &str) -> &str { if s.starts_with("0x") { &s[2..] diff --git a/src/main.rs b/src/main.rs index c29beb188..fd74acbc5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,17 +4,20 @@ mod config; use std::collections::HashMap; use std::convert::TryFrom; -use std::fs::File; +use std::fs; use std::path::Path; use std::str::from_utf8; use std::sync::Arc; +use futures::executor::block_on; +use parking_lot::RwLock; + use common_crypto::{ BlsCommonReference, BlsPrivateKey, BlsPublicKey, PublicKey, Secp256k1, Secp256k1PrivateKey, ToPublicKey, }; -use core_api::adapter::DefaultAPIAdapter; -use core_api::config::GraphQLConfig; +// use core_api::adapter::DefaultAPIAdapter; +// use core_api::config::GraphQLConfig; use core_consensus::fixed_types::{FixedEpoch, FixedSignedTxs}; use core_consensus::message::{ ProposalMessageHandler, PullEpochRpcHandler, PullTxsRpcHandler, QCMessageHandler, @@ -25,23 +28,17 @@ use core_consensus::message::{ use core_consensus::status::{CurrentConsensusStatus, StatusPivot}; use core_consensus::trace::init_tracer; use core_consensus::{OverlordConsensus, OverlordConsensusAdapter}; -use core_executor::trie::RocksTrieDB; -use core_executor::TransactionExecutorFactory; use core_mempool::{ DefaultMemPoolAdapter, HashMemPool, MsgPushTxs, NewTxsHandler, PullTxsHandler, END_GOSSIP_NEW_TXS, RPC_PULL_TXS, RPC_RESP_PULL_TXS, }; use core_network::{NetworkConfig, NetworkService}; use core_storage::{adapter::rocks::RocksAdapter, ImplStorage}; -use futures::executor::block_on; -use parking_lot::RwLock; - -use protocol::traits::executor::ExecutorFactory; +use framework::binding::state::RocksTrieDB; +use framework::executor::{ServiceExecutor, ServiceExecutorFactory}; use protocol::traits::{NodeInfo, Storage}; -use protocol::types::{ - Address, Bloom, Epoch, EpochHeader, Genesis, Hash, MerkleRoot, Proof, UserAddress, Validator, -}; -use protocol::{fixed_codec::ProtocolFixedCodec, Bytes, ProtocolResult}; +use protocol::types::{Address, Bloom, Epoch, EpochHeader, Genesis, Hash, Proof, Validator}; +use protocol::{fixed_codec::FixedCodec, Bytes, ProtocolResult}; use crate::config::Config; @@ -55,8 +52,8 @@ async fn main() { .default_value("./devtools/chain/config.toml"), ) .arg( - clap::Arg::from_usage("-g --genesis=[FILE] 'a required file for the genesis json'") - .default_value("./devtools/chain/genesis.json"), + clap::Arg::from_usage("-g --genesis=[FILE] 'a required file for the genesis toml'") + .default_value("./devtools/chain/genesis.toml"), ) .get_matches(); let args_config = matches.value_of("config").unwrap(); @@ -82,15 +79,9 @@ async fn main() { async fn handle_init(cfg: &Config, genesis_path: impl AsRef) -> ProtocolResult<()> { let chain_id = Hash::from_hex(&cfg.chain_id).unwrap(); - // self private key - let my_privkey = - Secp256k1PrivateKey::try_from(hex::decode(cfg.privkey.clone()).unwrap().as_ref()).unwrap(); - let my_pubkey = my_privkey.pub_key(); - let my_address = UserAddress::from_pubkey_bytes(my_pubkey.to_bytes()).unwrap(); - // Read genesis. - let mut r = File::open(genesis_path).unwrap(); - let genesis: Genesis = serde_json::from_reader(&mut r).unwrap(); + let genesis_toml = fs::read_to_string(genesis_path).unwrap(); + let genesis: Genesis = toml::from_str(&genesis_toml).unwrap(); log::info!("Genesis data: {:?}", genesis); // Init Block db @@ -116,18 +107,11 @@ async fn handle_init(cfg: &Config, genesis_path: impl AsRef) -> ProtocolRe let trie_db = Arc::new(RocksTrieDB::new(path_state, cfg.executor.light).unwrap()); // Init genesis - let genesis_state_root = { - let mut executor = TransactionExecutorFactory::from_root( - chain_id.clone(), - MerkleRoot::from_empty(), - Arc::clone(&trie_db), - 0, - cfg.consensus.cycles_price, - Address::User(my_address), - )?; - - executor.create_genesis(&genesis)? - }; + let genesis_state_root = ServiceExecutor::create_genesis( + genesis.services, + Arc::clone(&trie_db), + Arc::clone(&storage), + )?; // Build genesis block. let genesis_epoch_header = EpochHeader { @@ -141,8 +125,7 @@ async fn handle_init(cfg: &Config, genesis_path: impl AsRef) -> ProtocolRe state_root: genesis_state_root, receipt_root: vec![Hash::from_empty()], cycles_used: vec![0], - proposer: UserAddress::from_hex("100000000000000000000000000000000000000000") - .unwrap(), + proposer: Address::from_hex("0000000000000000000000000000000000000000").unwrap(), proof: Proof { epoch_id: 0, round: 0, @@ -172,7 +155,7 @@ async fn start(cfg: Config) -> ProtocolResult<()> { let my_privkey = Secp256k1PrivateKey::try_from(hex::decode(cfg.privkey.clone()).unwrap().as_ref()).unwrap(); let my_pubkey = my_privkey.pub_key(); - let my_address = UserAddress::from_pubkey_bytes(my_pubkey.to_bytes()).unwrap(); + let my_address = Address::from_pubkey_bytes(my_pubkey.to_bytes()).unwrap(); // Init Block db let path_block = cfg.data_path_for_block(); @@ -267,7 +250,7 @@ async fn start(cfg: Config) -> ProtocolResult<()> { .verifier_list .iter() .map(|v| Validator { - address: UserAddress::from_hex(v).unwrap(), + address: Address::from_hex(v).unwrap(), propose_weight: 1, vote_weight: 1, }) @@ -283,7 +266,7 @@ async fn start(cfg: Config) -> ProtocolResult<()> { .iter() .zip(cfg.consensus.public_keys.iter()) { - let address = UserAddress::from_hex(addr).unwrap().as_bytes(); + let address = Address::from_hex(addr).unwrap().as_bytes(); let pub_key = BlsPublicKey::try_from(hex::decode(bls_pub_key).unwrap().as_ref()).unwrap(); bls_pub_keys.insert(address, pub_key); } @@ -307,7 +290,7 @@ async fn start(cfg: Config) -> ProtocolResult<()> { let (status_pivot, agent) = StatusPivot::new(Arc::clone(¤t_consensus_status)); let mut consensus_adapter = - OverlordConsensusAdapter::::new( + OverlordConsensusAdapter::::new( Arc::new(network_service.handle()), Arc::new(network_service.handle()), Arc::clone(&mempool), @@ -387,18 +370,24 @@ async fn start(cfg: Config) -> ProtocolResult<()> { runtime::spawn(network_service); // Init graphql - let api_adapter = DefaultAPIAdapter::::new( - Arc::clone(&mempool), - Arc::clone(&storage), - Arc::clone(&trie_db), - ); - let mut graphql_config = GraphQLConfig::default(); - graphql_config.listening_address = cfg.graphql.listening_address; - graphql_config.graphql_uri = cfg.graphql.graphql_uri.clone(); - graphql_config.graphiql_uri = cfg.graphql.graphiql_uri.clone(); + // let api_adapter = DefaultAPIAdapter::::new( Arc::clone(&mempool), + // Arc::clone(&storage), + // Arc::clone(&trie_db), + // ); + // let mut graphql_config = GraphQLConfig::default(); + // graphql_config.listening_address = cfg.graphql.listening_address; + // graphql_config.graphql_uri = cfg.graphql.graphql_uri.clone(); + // graphql_config.graphiql_uri = cfg.graphql.graphiql_uri.clone(); + // + // // Run GraphQL server + // runtime::spawn(core_api::start_graphql(graphql_config, api_adapter)); + + // Run sychronization process + runtime::spawn(synchronization.run()); - // Run GraphQL server - runtime::spawn(core_api::start_graphql(graphql_config, api_adapter)); + // Run status cache pivot + runtime::spawn(status_pivot.run()); // Run sychronization process runtime::spawn(synchronization.run());